cuda::experimental::stf::stream_pool

Defined in include/cuda/experimental/__stf/internal/async_resources_handle.cuh

struct stream_pool

A stream_pool object stores a set of streams associated to a specific CUDA context (device, green context, …)

Stream pools are populated lazily.

Public Types

using iterator = ::std::vector<decorated_stream>::iterator

Public Functions

stream_pool() = default
~stream_pool() = default
inline stream_pool(size_t n, int dev_id, CUcontext cuctx = nullptr)

stream_pool constructor taking a number of slots, an optional CUDA context and a device id.

Streams are initialized lazily when calling next().

inline stream_pool(stream_pool &&rhs)
inline decorated_stream next()

Get the next stream in the pool.

The stream is wrapped into a decorated_stream class to embed information such as its position in the pool, or the device id.

inline iterator begin()
inline iterator end()
inline size_t size() const

Number of streams in the pool.

CUDA streams are initialized lazily, so this gives the number of slots available in the pool, not the number of streams initialized.

Public Members

mutable ::std::mutex mtx
::std::vector<decorated_stream> payload
size_t index = 0
int dev_id = 1
CUcontext primary_ctx = nullptr