Celeritas  0.5.0-86+4a8eea4
List of all members
celeritas::SharedParams Class Reference

Shared (one instance for all threads) Celeritas problem data. More...

#include <SharedParams.hh>

Public Types

Type aliases
using SPConstParams = std::shared_ptr< CoreParams const >
 
using VecG4ParticleDef = std::vector< G4ParticleDefinition const * >
 

Public Member Functions

Accessors
SPConstParams Params () const
 Access Celeritas data. More...
 
VecG4ParticleDef const & OffloadParticles () const
 Get a vector of particles supported by Celeritas offloading.
 
 operator bool () const
 Whether Celeritas core params have been created.
 

Internal use only

using SPHitManager = std::shared_ptr< detail::HitManager >
 Hit manager, to be used only by LocalTransporter. More...
 
using SPOffloadWriter = std::shared_ptr< detail::OffloadWriter >
 Hit manager, to be used only by LocalTransporter. More...
 
using SPOutputRegistry = std::shared_ptr< OutputRegistry >
 Hit manager, to be used only by LocalTransporter. More...
 
using SPState = std::shared_ptr< CoreStateInterface >
 Hit manager, to be used only by LocalTransporter. More...
 
using SPConstGeantGeoParams = std::shared_ptr< GeantGeoParams const >
 Hit manager, to be used only by LocalTransporter. More...
 
SPHitManager const & hit_manager () const
 Hit manager, to be used only by LocalTransporter. More...
 
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.
 

Construction

static bool CeleritasDisabled ()
 On worker threads, set up data with thread storage duration. More...
 
static bool KillOffloadTracks ()
 On worker threads, set up data with thread storage duration. More...
 
static void InitializeWorker (SetupOptions const &options)
 On worker threads, set up data with thread storage duration. More...
 
 SharedParams ()=default
 On worker threads, set up data with thread storage duration. More...
 
 SharedParams (SetupOptions const &options)
 Set up Celeritas using Geant4 data. More...
 
 SharedParams (std::string output_filename)
 Set up Celeritas components for a Geant4-only run. More...
 
void Initialize (SetupOptions const &options)
 Helper for making initialization more obvious from user code.
 
void Initialize (std::string output_filename)
 Helper for making initialization more obvious from user code.
 
void Finalize ()
 Clear shared data after writing out diagnostics. More...
 

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.

Member Typedef Documentation

◆ SPConstGeantGeoParams

Hit manager, to be used only by LocalTransporter.

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

◆ SPHitManager

using celeritas::SharedParams::SPHitManager = std::shared_ptr<detail::HitManager>

Hit manager, to be used only by LocalTransporter.

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

◆ SPOffloadWriter

using celeritas::SharedParams::SPOffloadWriter = std::shared_ptr<detail::OffloadWriter>

Hit manager, to be used only by LocalTransporter.

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

◆ SPOutputRegistry

Hit manager, to be used only by LocalTransporter.

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

◆ SPState

Hit manager, to be used only by LocalTransporter.

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

Constructor & Destructor Documentation

◆ SharedParams() [1/3]

celeritas::SharedParams::SharedParams ( )
default

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.

◆ 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 components for a Geant4-only run.

This is for doing standalone Geant4 calculations without offloading from Celeritas, but still using components such as the simple calorimeter.

Member Function Documentation

◆ CeleritasDisabled()

bool celeritas::SharedParams::CeleritasDisabled ( )
static

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.

◆ 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.

◆ 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)
static

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

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.

◆ 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: