Celeritas 0.7-develop+ddcb429
Loading...
Searching...
No Matches
Public Member Functions | List of all members
celeritas::optical::GeneratorCounterState< M > Class Template Reference

Generator counters that are updated in the state's memory space. More...

#include <GeneratorCounterState.hh>

Inheritance diagram for celeritas::optical::GeneratorCounterState< M >:
Inheritance graph
[legend]

Public Types

Type aliases
using CountersT = GeneratorCounters< size_type >
 
using DevicePtr = ObserverPtr< GeneratorStateCounters, M >
 
- Public Types inherited from celeritas::AuxStateInterface
using SPState = std::shared_ptr< AuxStateInterface >
 Default destructor.
 

Public Member Functions

 GeneratorCounterState (StreamId stream)
 Construct with the stream used to update the counters.
 
StreamId stream_id () const
 Stream used to update the counters.
 
DevicePtr device_counters ()
 Counters in the state's memory space.
 
void assign (CountersT const &value)
 Set the current counters.
 
size_type buffer_bound ()
 Get a conservative upper bound on the current buffer size.
 
void grow_bound (size_type count)
 Increase the buffer bound by the maximum number of items added.
 
void copy_async ()
 Enqueue a copy of the counters used to tighten the buffer bound.
 
void sync_counters () override
 Synchronize and update the host counters and statistics.
 
void clear_generated () override
 Clear the generated count at the start of a transport loop.
 
void reset_counters () override
 Discard the current counters after the loop aborted early.
 
- Public Member Functions inherited from celeritas::AuxStateInterface
virtual ~AuxStateInterface ()
 Default destructor.
 

Additional Inherited Members

- Public Attributes inherited from celeritas::GeneratorStateBase
GeneratorCounters< size_type > counters
 Counts since the start of the optical loop (host copy)
 
GeneratorCounters< std::size_t > accum
 Counts accumulated over the event for diagnostics.
 
- Protected Member Functions inherited from celeritas::AuxStateInterface
 AuxStateInterface ()=default
 
 AuxStateInterface (AuxStateInterface const &)=default
 Default destructor.
 
AuxStateInterface & operator= (AuxStateInterface const &)=default
 Default destructor.
 
 AuxStateInterface (AuxStateInterface &&)=default
 Default destructor.
 
AuxStateInterface & operator= (AuxStateInterface &&)=default
 Default destructor.
 

Detailed Description

template<MemSpace M>
class celeritas::optical::GeneratorCounterState< M >

Generator counters that are updated in the state's memory space.

The counters are modified by kernels during stepping so that the host never has to wait on the device to update them. The host copy in GeneratorStateBase::counters is only refreshed by sync_counters , which is called by the optical transporter once the loop has completed and by OpticalCollector before reporting the buffer sizes or statistics.

For buffers that are filled during stepping, this class also tracks a conservative upper bound on the buffer size so that capacity can be validated and fixed-size device algorithms can be launched without synchronizing. The bound is grown by the maximum number of items that may be added in each step, and it is tightened whenever an asynchronous copy of the counters, enqueued with copy_async, has completed.

Distributions and photons are counted in the accumulated statistics when they are queued, and photons again when they are generated. Since these counts are also updated by kernels, the increments are kept in the state's memory and added to GeneratorStateBase::accum by sync_counters .

Constructor & Destructor Documentation

◆ GeneratorCounterState()

template<MemSpace M>
celeritas::optical::GeneratorCounterState< M >::GeneratorCounterState ( StreamId  stream)
explicit

Construct with the stream used to update the counters.

Like the snapshot of the counters, this must be constructed after the device is activated.

Member Function Documentation

◆ assign()

Set the current counters.

This updates the host copy immediately and enqueues the update of the state's copy, followed by a copy of the updated counters so that the bound is only tightened from the assigned value. The buffer bound is set to the new buffer size.

◆ buffer_bound()

Get a conservative upper bound on the current buffer size.

If the most recent copy of the counters has completed, the bound is tightened using the copied buffer size and the growth since the copy was enqueued.

◆ clear_generated()

template<MemSpace M>
void celeritas::optical::GeneratorCounterState< M >::clear_generated ( )
overridevirtual

Clear the generated count at the start of a transport loop.

Implements celeritas::GeneratorStateBase.

◆ copy_async()

template<MemSpace M>
void celeritas::optical::GeneratorCounterState< M >::copy_async ( )

Enqueue a copy of the counters used to tighten the buffer bound.

This should be called after all the kernels that modify the buffer size in a step have been enqueued. A new copy is not enqueued while a previous one is still pending, since the host could not use it any earlier.

◆ reset_counters()

template<MemSpace M>
void celeritas::optical::GeneratorCounterState< M >::reset_counters ( )
overridevirtual

Discard the current counters after the loop aborted early.

The accumulated increments are kept.

Implements celeritas::GeneratorStateBase.

Reimplemented in celeritas::optical::WlsGeneratorState< M >.

◆ sync_counters()

template<MemSpace M>
void celeritas::optical::GeneratorCounterState< M >::sync_counters ( )
overridevirtual

Synchronize and update the host counters and statistics.

The increments accumulated in the state's memory space are added to the accumulated statistics and cleared. This waits for the counters to be copied from the device, so it should not be called while stepping except for diagnostics.

Implements celeritas::GeneratorStateBase.


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