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

Store all state data for a single thread. More...

#include <CoreState.hh>

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

Public Types

Type aliases
template<template< Ownership, MemSpace > class S>
using StateRef = S< Ownership::reference, M >
 
using SPAuxStateVec = std::shared_ptr< AuxStateVec >
 
using Ref = StateRef< CoreStateData >
 
using Ptr = ObserverPtr< Ref, M >
 
- Public Types inherited from celeritas::CoreStateInterface
using size_type = TrackSlotId::size_type
 

Public Member Functions

 CoreState (CoreParams const &params, StreamId stream_id)
 Construct from CoreParams.
 
 CoreState (CoreParams const &params, StreamId stream_id, size_type num_track_slots)
 Construct with manual slot count.
 
 ~CoreState () final
 Print diagnostic when core state is being deleted.
 
 CoreState (CoreState const &)=delete
 
CoreState & operator= (CoreState const &)=delete
 
 CoreState (CoreState &&)=delete
 
CoreState & operator= (CoreState &&)=delete
 
StreamId stream_id () const final
 Thread/stream ID.
 
size_type size () const final
 Number of track slots.
 
void warming_up (bool)
 Whether the state should be transported with no active particles.
 
bool warming_up () const
 Whether the state is being transported with no active particles.
 
Ref & ref ()
 Get a reference to the mutable state data.
 
Ref const & ref () const
 Get a reference to the mutable state data.
 
Ptr ptr ()
 Get a native-memspace pointer to the mutable state data.
 
void reset ()
 Reset the state data.
 
size_type initializer_capacity () const
 Current capacity of the track initializer buffer.
 
void reserve_initializers (size_type min_capacity)
 Grow the track initializer buffer to hold at least this many.
 
CoreStateCounters sync_get_counters () const final
 Synchronize and copy track initialization counters from device to host.
 
void sync_put_counters (CoreStateCounters const &) final
 Synchronize and copy track initialization counters from host to device For host-only code, this copies the local CoreStateCounters back to the class, since sync_get_counters() doesn't return a reference.
 
void initialize_counters (size_type num_pending)
 Reset counters that are accumulated during a step.
 
void async_copy_counters ()
 Copy the current counters to host-accessible storage without synchronizing.
 
AsyncSnapshot< CoreStateCounters > const & host_counters () const
 Access the host counters, which are copied asynchronously.
 
AuxStateVec const & aux () const final
 Access auxiliary state data.
 
AuxStateVec & aux () final
 Access auxiliary state data (mutable)
 
SPAuxStateVec & aux_ptr ()
 Access auxiliary state data (mutable)
 
template<template< Ownership, MemSpace > class S>
StateRef< S > & aux_data (AuxId auxid)
 
bool has_action_range () const
 Return whether tracks can be sorted by action.
 
Range< ThreadId > get_action_range (ActionId action_id) const
 Get a range of sorted track slots about to undergo a given action.
 
auto & action_thread_offsets ()
 Access the range of actions to apply for all track IDs.
 
auto const & action_thread_offsets () const
 Access the range of actions to apply for all track IDs.
 
auto & native_action_thread_offsets ()
 Access action offsets for computation (native memory space).
 
template<template< Ownership, MemSpace > class S>
auto aux_data (AuxId auxid) -> StateRef< S > &
 Convenience function to access auxiliary "collection group" data.
 
- Public Member Functions inherited from celeritas::CoreStateInterface
virtual ~CoreStateInterface ()
 Support polymorphic deletion.
 

Static Public Attributes

static constexpr MemSpace memspace = M
 Memory space.
 

Additional Inherited Members

- Protected Member Functions inherited from celeritas::CoreStateInterface
 CoreStateInterface (CoreStateInterface const &)=default
 
CoreStateInterface & operator= (CoreStateInterface const &)=default
 
 CoreStateInterface (CoreStateInterface &&)=default
 
CoreStateInterface & operator= (CoreStateInterface &&)=default
 

Detailed Description

template<MemSpace M>
class celeritas::CoreState< M >

Store all state data for a single thread.

When the state lives on the device, we maintain a separate copy of the device "ref" in device memory: otherwise we'd have to copy the entire state in launch arguments and access it through constant memory.

Constructor & Destructor Documentation

◆ CoreState()

template<MemSpace M>
celeritas::CoreState< M >::CoreState ( CoreParams const &  params,
StreamId  stream_id,
size_type  num_track_slots 
)

Construct with manual slot count.

This is currently used for unit tests, and temporarily used by the Stepper constructor.

Member Function Documentation

◆ async_copy_counters()

template<MemSpace M>
void celeritas::CoreState< M >::async_copy_counters ( )

Copy the current counters to host-accessible storage without synchronizing.

For a device state, the copy is enqueued on the state's stream and completes asynchronously: the host_counters snapshot tracks its completion. Completion of the copy also implies completion of all work enqueued on the stream before this call.

◆ aux() [1/2]

template<MemSpace M>
AuxStateVec const & celeritas::CoreState< M >::aux ( ) const
inlinefinalvirtual

Access auxiliary state data.

Implements celeritas::CoreStateInterface.

◆ aux() [2/2]

template<MemSpace M>
AuxStateVec & celeritas::CoreState< M >::aux ( )
inlinefinalvirtual

Access auxiliary state data (mutable)

Implements celeritas::CoreStateInterface.

◆ get_action_range()

template<MemSpace M>
Range< ThreadId > celeritas::CoreState< M >::get_action_range ( ActionId  action_id) const

Get a range of sorted track slots about to undergo a given action.

The result delimits the [start, end) of the track partition assigned action_id in track_slots.

◆ reserve_initializers()

template<MemSpace M>
void celeritas::CoreState< M >::reserve_initializers ( size_type  min_capacity)

Grow the track initializer buffer to hold at least this many.

If the buffer is too small, it is reallocated with at least twice its current capacity and the queued initializers are copied into it. This must be called between steps, after the host counters have been updated, since the number of queued initializers is taken from them.

◆ reset()

template<MemSpace M>
void celeritas::CoreState< M >::reset ( )

Reset the state data.

This clears the state counters and initializes the necessary state data so the state can be reused for a new event. This should be necessary only if the previous event aborted early.

◆ size()

template<MemSpace M>
size_type celeritas::CoreState< M >::size ( ) const
inlinefinalvirtual

Number of track slots.

Implements celeritas::CoreStateInterface.

◆ stream_id()

template<MemSpace M>
StreamId celeritas::CoreState< M >::stream_id ( ) const
inlinefinalvirtual

Thread/stream ID.

Implements celeritas::CoreStateInterface.

◆ sync_get_counters()

template<MemSpace M>
CoreStateCounters celeritas::CoreState< M >::sync_get_counters ( ) const
finalvirtual

Synchronize and copy track initialization counters from device to host.

Copy the core state counters from the device to the host.

For host-only code, the counters reside on the host, so this just returns a CoreStateCounters object. Note that it does not return a reference, so sync_put_counters() must be used if any counters change.

Implements celeritas::CoreStateInterface.

◆ sync_put_counters()

template<MemSpace M>
void celeritas::CoreState< M >::sync_put_counters ( CoreStateCounters const &  host_counters)
finalvirtual

Synchronize and copy track initialization counters from host to device For host-only code, this copies the local CoreStateCounters back to the class, since sync_get_counters() doesn't return a reference.

Copy the core state counters from the host to the device.

For host-only code, this function copies a CoreStateCounter object into the CoreState object, which is needed when any of the counters change, because sync_get_counters() doesn't return a reference.

Implements celeritas::CoreStateInterface.

◆ warming_up()

template<MemSpace M>
void celeritas::CoreState< M >::warming_up ( bool  new_state)

Whether the state should be transported with no active particles.

This can only be called when there are no active tracks. It should be immediately cleared after a step.

See also
Stepper::warm_up

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