Celeritas 0.6.0-dev.115+3b60a5fd
Loading...
Searching...
No Matches
Public Types | List of all members
celeritas::SharedParams Class Reference

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 constOffloadParticles () 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 consthit_manager () const
 Hit manager, to be used only by LocalTransporter.
 
SPOffloadWriter constoffload_writer () const
 Optional offload writer, only for use by LocalTransporter.
 
SPOutputRegistry constoutput_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 constgeant_geo_params () const
 Lazily created Geant geometry parameters.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SharedParams() [1/3]

celeritas::SharedParams::SharedParams ( )
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.

◆ SharedParams() [2/3]

celeritas::SharedParams::SharedParams ( SetupOptions const options)
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.

◆ SharedParams() [3/3]

celeritas::SharedParams::SharedParams ( std::string  output_filename)
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.

Member Function Documentation

◆ CeleritasDisabled()

bool celeritas::SharedParams::CeleritasDisabled ( )
static

Whether celeritas is disabled, set to kill, or to be enabled.

This gets the value from environment variables and

Todo:
This will be refactored for 0.6 to take a celeritas::inp object and determine values rather than from the environment .

◆ Finalize()

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.

◆ GetMode()

auto celeritas::SharedParams::GetMode ( )
static

Whether celeritas is disabled, set to kill, or to be enabled.

This gets the value from environment variables and

Todo:
This will be refactored for 0.6 to take a celeritas::inp object and determine values rather than from the environment .

◆ hit_manager()

auto celeritas::SharedParams::hit_manager ( ) const
inline

Hit manager, to be used only by LocalTransporter.

If sensitive detector callback is disabled, the hit manager will be null.

◆ InitializeWorker()

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.

◆ KillOffloadTracks()

bool celeritas::SharedParams::KillOffloadTracks ( )
static

Whether celeritas is disabled, set to kill, or to be enabled.

This gets the value from environment variables and

Todo:
This will be refactored for 0.6 to take a celeritas::inp object and determine values rather than from the environment .

◆ Params()

auto celeritas::SharedParams::Params ( ) const
inline

Access Celeritas data.

This can only be called after Initialize.


The documentation for this class was generated from the following files: