Celeritas 0.6.0-rc.2.10+develop.de0a3a05
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 SPParams = std::shared_ptr< CoreParams >
 
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.
 
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
SPParams constParams ()
 Access Celeritas data.
 
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 SPGeantSd = std::shared_ptr< GeantSd >
 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 SPTimeOutput = std::shared_ptr< TimeOutput >
 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.
 
using BBox = BoundingBox< double >
 Initialization status and integration mode.
 
Mode mode () const
 Initialization status and integration mode.
 
SPGeantSd 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.
 
SPTimeOutput consttimer () const
 Access the timer.
 
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.
 
BBox constbbox () const
 Initialization status and integration mode.
 

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/2]

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/2]

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.

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.

◆ geant_geo_params()

auto celeritas::SharedParams::geant_geo_params ( ) const

Lazily created Geant geometry parameters.

Todo:
Remove this for 0.7; it's only used in GeantSimpleCalo and that should be converted to use make_logical_vol_labels from GeantGeoUtils. Also it can cause segfaults (Geant4 allocators as usual) if called during cleanup.

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

◆ num_streams()

unsigned int celeritas::SharedParams::num_streams ( ) const

Lazily obtained number of streams.

Todo:
This is currently needed due to some wackiness with the celer-g4 GeantDiagnostics and initialization sequence. We should remove this: for user applications it should strictly be determined by the run manager/input, and celer-g4 should set it up accordingly.

◆ Params() [1/2]

auto celeritas::SharedParams::Params ( )
inline

Access Celeritas data.

This can only be called after Initialize.

◆ Params() [2/2]

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: