Home

Multi-core and multi-threading: Tips on how to write “thread

image

Contents

1. 4MT Transformation automatic S e Follow the change list e Transform the original Geant4 to be thread safe e Fxample for a static variable that is not a class member BEFORE static G4FieldTrack endTrack 0 AFTER Static _ thread G4FieldTrack endTrack NEW PTR 0 if endTrack NEW _PTR_ endTrack NEW PTR_ new G4FieldTrack 0 G4FieldTrack amp endTrack endTrack_ NEW PTR WZ Northeastern N Ai X Automatically transform Geant4 cont e Example for a static class member BEFORE static G4String dirName AFTER static _thread G4String dirName_NEW_PTR_ BEFORE G4String G4NuclearLevelStore dirName AFTER _ thread G4String G4NuclearLevelStore dirName NEW PTR_ 0 G4NuclearLevelStore G4NuclearLevelStore GetInstance if dirName NEW PTR_ dirName_NEW_PTR_ new G4String G4String amp dirName dirName_NEW_PTR_ oe Sws Northeastern AN Sharable Class Transformation by user Redefine the references for read write data members class G4PV Replica public G4VPhysical Volume int g4PVReplicaObjectOrder static G4PVReplicaPrivateObjectManager g4PVReplicaPrivateObjectManager G4int fcopyNoG4PV Replica define fcopyNoG4PVReplica g4PReplicaPrivateObjectManager offset g4PV ReplicaObjectOrder fcopyNo Sharable Class Transformation continued Implement the array for all thread private data members class ReplicaPrivateObj
2. Multi core and multi threading Tips on how to write thread safe code in Geant4 Gene Cooperman and Xin Dong High Performance Computing Lab College of Computer and Information Science Northeastern University Boston Massachusetts 02115 gene xindong ccs neu edu WZ Northeastern Early 2010 First Version of Geant4MT Geant4MT Geant4 MultiThreaded This takes advantage of multi core architectures now commonly available A multithreaded version of Geant4 using multiple threads and also copy on write is more computationally efficient than running 1 multiple independent Geant4 processes or ii multiple forked child Geant4 processes using UNIX copy on write semantics A first version for use by developers is planned for early 2010 Northeastern Goals of initial Geant4MT release e Goal allow developers to become aware of the new technology e Delivered Geant4MT source code a modified version of the Geant4 source code e Delivered Manual e Jools Tool for transforming Geant4 code into Geant4MT code Most Geant4 kernel developers will not need to use this tool awu gt zw lt Northeastern AN How is Geant4MT Created from Geant4 1 Most of the Geant4MT modifications are created automatically by the source code transformation tool About 10 000 lines of code are automatically modified 2 The default is for Geant4 classes to be thread private Each thread has its own private copy of
3. a Geant4 object 3 Certain Geant4 classes are modified in Geant4MT to create shared objects objects shared by the threads Two primary ways to modify Geant4 source code a C stylized comments hints for Geant4MT b C preprocessor conditionalizations define 4 Geant4MT source code transformation tool based on modified g parser generates database of symbols in Geant4 source code requiring modifications in their use then applies modifications WZ Northeastern Uu X How does this Affect the Geant4 Kernel Developer 1 If the Geant4MT source code transformation tool recognizes your coding style and if your Geant4 classes should be thread private each thread has a private copy of its objects then you don t need to do anything 2 The manual documents a coding style that is recognized by the source code transformation tool More than 99 of the current Geant4 source code already conforms to this coding style We call this code Geant4MT ready 3 In some cases kernel developer code may not be Geant4MT ready In such cases there are two options a Rewrite the code to conform to conform to a style recognized by the tool b Use C conditionalizations define and or C stylized comments hints for the source code transformation tool 4 In most cases the Geant4MT source code transformation tool will detect and report code that is not Geant4MT ready The Geant4MT team will be running the tool for this first
4. ect public G4int fcopyNo ie class G4PVReplicaPrivateObjectManager public ReplicaPrivateObject privateDataArray int MasterAddNew void WorkerInitialization void WorkerFree Northeastern Northeastern Questions
5. version to promote developer awareness Kernel developers do not need to run the tool themselves What categories of code need to be verified as Geant4MT ready 1 Static initialization of global variables static data members of classes that are initialized 2 Classes that are intended to be shared which contain data members with read write access Read only data members are fine The Geant4MT Experience na A Ww WN WZ Northeastern Manual with detailed examples for correct versus incorrect Geant4MT ready kernel code Manual will explain issues of thread private versus thread shared objects If the code appears Geant4MT ready don t change it You re done If the code appears not Geant4MT ready change the coding style to conform if possible Otherwise use C preprocessor conditionalizations and stylized comments hints Cross your fingers and hope it works Then wait for the next run of the Geant4MT source code transformation tool and see if it worked In unusual cases you may have to work with the Geant4MT developers The source code transformation tool can be extended to recognize additional coding styles Northeastern Later Versions of Geant4MT 1 Geant4MT version 2 Incorporates extended coding styles learned from first version 2 Geant4MT version 3 User manual to allow for creation of Geant4MT ready Geant4 user applications AN Northeastern Geant4 Geant

Download Pdf Manuals

image

Related Search

Related Contents

Telecargar  2big dual Datasheet  RDR-GX210  2007年度版 - 東京海上日動  Herzlichen Glückwunsch  141 - VARMEC  HK 416C HK 416 CQB HK 417  Barclay Products 7913-BN Installation Guide  Samsung PL100 Lietotāja rokasgrāmata  Franklin KJB-640 User's Manual  

Copyright © All rights reserved.
Failed to retrieve file