Celeritas 0.6.0-dev.115+3b60a5fd
|
Shared (one instance for all threads) Celeritas problem data. More...
#include <SharedParams.hh>
Public Types | |
enum class | Mode { uninitialized , disabled , kill_offload , enabled , size_ } |
Setup for Celeritas usage. | |
Type aliases | |
using | SPConstParams = std::shared_ptr< CoreParams const > |
using | VecG4ParticleDef = std::vector< G4ParticleDefinition * > |
Public Member Functions | |
Construction | |
SharedParams ()=default | |
Set up Celeritas using Geant4 data. | |
SharedParams (SetupOptions const &options) | |
Set up Celeritas using Geant4 data. | |
SharedParams (std::string output_filename) | |
Set up Celeritas using Geant4 data. | |
void | Initialize (SetupOptions const &options) |
Helper for making initialization more obvious from user code. | |
void | InitializeWorker (SetupOptions const &options) |
On worker threads, set up data with thread storage duration. | |
void | Finalize () |
Clear shared data after writing out diagnostics. | |
Accessors | |
SPConstParams | Params () const |
Access Celeritas data. | |
VecG4ParticleDef const & | OffloadParticles () const |
Get a vector of particles supported by Celeritas offloading. | |
operator bool () const | |
Whether the class has been constructed. | |
Static Public Member Functions | |
Status | |
static Mode | GetMode () |
Whether celeritas is disabled, set to kill, or to be enabled. | |
static bool | CeleritasDisabled () |
Whether celeritas is disabled, set to kill, or to be enabled. | |
static bool | KillOffloadTracks () |
Whether celeritas is disabled, set to kill, or to be enabled. | |
Internal use only | |
using | SPHitManager = std::shared_ptr< detail::HitManager > |
Initialization status and integration mode. | |
using | SPOffloadWriter = std::shared_ptr< detail::OffloadWriter > |
Initialization status and integration mode. | |
using | SPOutputRegistry = std::shared_ptr< OutputRegistry > |
Initialization status and integration mode. | |
using | SPState = std::shared_ptr< CoreStateInterface > |
Initialization status and integration mode. | |
using | SPConstGeantGeoParams = std::shared_ptr< GeantGeoParams const > |
Initialization status and integration mode. | |
Mode | mode () const |
Initialization status and integration mode. | |
SPHitManager const & | hit_manager () const |
Hit manager, to be used only by LocalTransporter. | |
SPOffloadWriter const & | offload_writer () const |
Optional offload writer, only for use by LocalTransporter. | |
SPOutputRegistry const & | output_reg () const |
Output registry for writing data at end of run. | |
void | set_state (unsigned int stream_id, SPState &&) |
Let LocalTransporter register the thread's state. | |
unsigned int | num_streams () const |
Lazily obtained number of streams. | |
SPConstGeantGeoParams const & | geant_geo_params () const |
Lazily created Geant geometry parameters. | |
Shared (one instance for all threads) Celeritas problem data.
The CeleritasDisabled
accessor queries the CELER_DISABLE
environment variable as a global option for disabling Celeritas offloading. This is implemented by SimpleOffload
This should be instantiated on the master thread during problem setup, preferably as a shared pointer. The shared pointer should be passed to a thread-local LocalTransporter
instance. At the beginning of the run, after Geant4 has initialized physics data, the Initialize
method must be called first on the "master" thread to populate the Celeritas data structures (geometry, physics). InitializeWorker
must subsequently be invoked on all worker threads to set up thread-local data (specifically, CUDA device initialization).
Some low-level objects, such as the output diagnostics and Geant4 geometry wrapper, can be created independently of Celeritas being enabled.
|
default |
Set up Celeritas using Geant4 data.
This is a separate step from construction because it has to happen at the beginning of the run, not when user classes are created. It should be called from the "master" thread (for MT mode) or from the main thread (for Serial), and it must complete before any worker thread tries to access the shared data.
|
explicit |
Set up Celeritas using Geant4 data.
This is a separate step from construction because it has to happen at the beginning of the run, not when user classes are created. It should be called from the "master" thread (for MT mode) or from the main thread (for Serial), and it must complete before any worker thread tries to access the shared data.
|
explicit |
Set up Celeritas using Geant4 data.
This is a separate step from construction because it has to happen at the beginning of the run, not when user classes are created. It should be called from the "master" thread (for MT mode) or from the main thread (for Serial), and it must complete before any worker thread tries to access the shared data.
|
static |
Whether celeritas is disabled, set to kill, or to be enabled.
This gets the value from environment variables and
celeritas::inp
object and determine values rather than from the environment . void celeritas::SharedParams::Finalize | ( | ) |
Clear shared data after writing out diagnostics.
This should be executed exactly once across all threads and at the end of the run.
|
static |
Whether celeritas is disabled, set to kill, or to be enabled.
This gets the value from environment variables and
celeritas::inp
object and determine values rather than from the environment .
|
inline |
Hit manager, to be used only by LocalTransporter.
If sensitive detector callback is disabled, the hit manager will be null.
void celeritas::SharedParams::InitializeWorker | ( | SetupOptions const & | options | ) |
On worker threads, set up data with thread storage duration.
Some data that has "static" storage duration (such as CUDA device properties) in single-thread mode has "thread" storage in a multithreaded application. It must be initialized on all threads.
|
static |
Whether celeritas is disabled, set to kill, or to be enabled.
This gets the value from environment variables and
celeritas::inp
object and determine values rather than from the environment .
|
inline |
Access Celeritas data.
This can only be called after Initialize
.