140 likes | 262 Views
IEEE Nuclear Science Symposium and Medical Imaging Conference Short Course The Geant4 Simulation Toolkit. Sunanda Banerjee ( Saha Inst. Nucl . Phys., Kolkata, India) Min Cheol Han ( Hanyang Univ., Seoul, Korea) Steffen Hauf (XFEL, Hamburg, Germany)
E N D
IEEE Nuclear Science Symposium and Medical Imaging ConferenceShort CourseThe Geant4 Simulation Toolkit Sunanda Banerjee (Saha Inst. Nucl. Phys., Kolkata, India) Min Cheol Han (Hanyang Univ., Seoul, Korea) Steffen Hauf(XFEL, Hamburg, Germany) Maria Grazia Pia (INFN Genova, Italy) MariaGrazia.Pia@ge.infn.it Seoul, 27 October 2013 http://www.ge.infn.it/geant4/events/nss2013/geant4course.html This course encompasses training material developed by several Geant4 members: thanks to all of them!
Evolution of Computer Technology • Increase in CPU power used to be done by increasing frequency. This has reached a plateau because of power needs. So expectation in future trend in computer technology: • No major increase in single core performance • Many cores in a processor (double/2 year?) • Less memory per core • Need new software models to take these into account → increase parallelism • In Geant4 events are supposed to be independent. • Each event can be simulated separately • To keep backward compatibility with user code, multi-threading at event level is a natural choice for parallelism Geant4 Multithreading
What is a thread? Sequential application Start N copies of application in the cores if they fit in memory Introduce shared objects to reduce overall memory consumption MT Application: master controls workers that do simulation Geant4 Multithreading
Geant4 MT Model • Steps to be taken • Isolate static data structure from the dynamic one • Protect dynamic part of memory which can be shared among the working threads • A Geant4 (with MT) application can be seen as simple finite state machine • Threads do not exist before /run/beamOn. Master writes shared memory. When threads start they cannot change the shared memory No locking Geant4 Multithreading
Geant4 MT Model Seeds pre-prepared per event in a “queue” Threads compete for next event to be processed Command line scoring and G4tools merge results from threads Geant4 Multithreading
User Application in Sequential Model Geant4 Multithreading
User Application in MT Mode Geant4 Multithreading
Migration to MT (1) • Move user action class from main() to a new ActionInitialization class Geant4 Multithreading
Migration to MT (2) Geant4 Multithreading
Migration to MT (3) • Instantiate G4MTRunManager and replace the code moved in ActionInitialization with use of this class • If sensitive detectors are present separate their creation in a new function CreateSDandField() • A new utility function can be used: G4VUserDetectorConstruction::SetSensitiveDetector • If magnetic field is present, move it toCreateSDandField() Geant4 Multithreading
Migration to MT (4) • Typically G4Allocator us used in Hit, Trajectory and TrajectoryPoint classes • Change static declarations to static G4ThreadLocal Geant4 Multithreading
Computing Performance Deviation from linearity less than 6% Memory saving is better than 40% Geant4 Multithreading
Physics Performance ATLAS TileCal MT reproduces sequential results faithfully Geant4 Multithreading