Task-based Geant4 prototype

R&D task number: G4RD1

Geant4 Task-based Parallelism

Currently, the multithreading is handled by the G4MTRunManager which handles the batching of events to an internal pool of threads, e.g. if 100 events are requested along with 4 threads, G4MTRunManager will create a pool of 4 threads and divide these 100 events among the 4 threads in batches up to 25 events per-thread (subject to user-configuration). Each thread processes the given batch of events and then queries G4MTRunManager if there is another batch of events which need to be processed. A “task” is essentially just a function call which is structured in the code to permit execution by another entity, e.g. another thread, and the processing of the subset of events is effectively a “task” given to the threads created by G4MTRunManager. However, the current system in Geant4 does not provide an interface for specifying different types of the tasks other than the processing of Geant4 events. This restricts the multithreading system in Geant4 from load-balancing work with finer granularity than one G4Event and can be problematic when frameworks within user-applications implement their own pool of threads: N threads from Geant4 might each implement N threads in the user-level code (or vice-versa) resulting in N2 threads.

The new tasking interface for Geant4 will generalize the dispatching of work to the pool of threads used by G4MTRunManager to lift the granularity restriction and provide an interface through which user-applications can configure Geant4 to share the pool of threads. In particular, this will enable Geant4 to be compatible with existing frameworks such as Intel Thread Building Blocks (TBB).

  • Lead: Jonathan R. Madsen