Celeritas  0.5.0-86+4a8eea4
Public Member Functions | List of all members
celeritas::StreamStore< P, S > Class Template Reference

Helper class for storing parameters and multiple stream-dependent states. More...

#include <StreamStore.hh>

Public Types

Type aliases
using ParamsHostVal = P< Ownership::value, MemSpace::host >
 

Public Member Functions

 StreamStore (ParamsHostVal &&host, StreamId::size_type num_streams)
 Construct with parameters and the number of streams. More...
 
 operator bool () const
 Whether the instance is ready for storing data.
 
StreamId::size_type num_streams () const
 Number of streams being stored.
 
template<MemSpace M>
P< Ownership::const_reference, M > const & params () const
 Get a reference to the params data.
 
template<MemSpace M>
S< Ownership::reference, M > & state (StreamId stream_id, size_type size)
 Get a reference to the state data, allocating if necessary.
 
template<MemSpace M>
S< Ownership::reference, M > const * state (StreamId stream_id) const
 Get a pointer to the state data, null if not allocated.
 
template<MemSpace M>
S< Ownership::reference, M > * state (StreamId stream_id)
 Get a mutable pointer to the state data, null if not allocated.
 

Detailed Description

template<template< Ownership, MemSpace > class P, template< Ownership, MemSpace > class S>
class celeritas::StreamStore< P, S >

Helper class for storing parameters and multiple stream-dependent states.

This requires a templated ParamsData and StateData. Hopefully this frankenstein of a class will be replaced by a std::any-like data container owned by each (possibly thread-local) State.

Usage:

StreamStore<FooParams, FooState> store{host_val, num_streams};
assert(store);
execute_kernel(store.params(), store.state<Memspace::host>(StreamId{0},
state_size))
if (auto* state = store.state<Memspace::device>(StreamId{1}))
{
cout << "Have device data for stream 1" << endl;
}
S< Ownership::reference, M > & state(StreamId stream_id, size_type size)
Get a reference to the state data, allocating if necessary.
Definition: StreamStore.hh:196
StreamId::size_type num_streams() const
Number of streams being stored.
Definition: StreamStore.hh:72

There is some additional complexity in the "state" accessors to allow for const correctness.

Constructor & Destructor Documentation

◆ StreamStore()

template<template< Ownership, MemSpace > class P, template< Ownership, MemSpace > class S>
celeritas::StreamStore< P, S >::StreamStore ( ParamsHostVal &&  host,
StreamId::size_type  num_streams 
)
inline

Construct with parameters and the number of streams.

The constructor is not thread safe and should be called during params setup, not at run time.


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