Taskflow  3.2.0-Master-Branch
Loading...
Searching...
No Matches
tf::cudaStream Class Reference

‍** More...

#include <cuda_stream.hpp>

Public Member Functions

 cudaStream (cudaStream_t stream)
 constructs an RAII-styled object from the given CUDA stream
 
 cudaStream ()
 constructs an RAII-styled object for a new CUDA stream
 
 cudaStream (const cudaStream &)=delete
 disabled copy constructor
 
 cudaStream (cudaStream &&rhs)
 move constructor
 
 ~cudaStream ()
 destructs the CUDA stream
 
cudaStreamoperator= (const cudaStream &)=delete
 disabled copy assignment
 
cudaStreamoperator= (cudaStream &&rhs)
 move assignment
 
void reset (cudaStream_t stream=nullptr)
 replaces the managed stream
 
 operator cudaStream_t () const
 implicit conversion to the native CUDA stream (cudaStream_t)
 
void synchronize () const
 synchronizes the associated stream
 
void begin_capture (cudaStreamCaptureMode m=cudaStreamCaptureModeGlobal) const
 begins graph capturing on the stream
 
cudaGraph_t end_capture () const
 ends graph capturing on the stream
 
void record (cudaEvent_t event) const
 records an event on the stream
 
void wait (cudaEvent_t event) const
 waits on an event
 

Detailed Description

‍**

‍** ‍**

class to create a CUDA stream in an RAII-styled wrapper

A cudaStream object is an RAII-styled wrapper over a native CUDA stream (cudaStream_t). A cudaStream object is move-only.

Constructor & Destructor Documentation

◆ cudaStream() [1/2]

tf::cudaStream::cudaStream ( cudaStream_t  stream)
inlineexplicit

constructs an RAII-styled object from the given CUDA stream

Constructs a cudaStream object which owns stream.

◆ cudaStream() [2/2]

tf::cudaStream::cudaStream ( )
inline

constructs an RAII-styled object for a new CUDA stream

Equivalently calling cudaStreamCreate to create a stream.

Member Function Documentation

◆ begin_capture()

void tf::cudaStream::begin_capture ( cudaStreamCaptureMode  m = cudaStreamCaptureModeGlobal) const
inline

begins graph capturing on the stream

When a stream is in capture mode, all operations pushed into the stream will not be executed, but will instead be captured into a graph, which will be returned via cudaStream::end_capture.

A thread's mode can be one of the following:

  • cudaStreamCaptureModeGlobal: This is the default mode. If the local thread has an ongoing capture sequence that was not initiated with cudaStreamCaptureModeRelaxed at cuStreamBeginCapture, or if any other thread has a concurrent capture sequence initiated with cudaStreamCaptureModeGlobal, this thread is prohibited from potentially unsafe API calls.
  • cudaStreamCaptureModeThreadLocal: If the local thread has an ongoing capture sequence not initiated with cudaStreamCaptureModeRelaxed, it is prohibited from potentially unsafe API calls. Concurrent capture sequences in other threads are ignored.
  • cudaStreamCaptureModeRelaxed: The local thread is not prohibited from potentially unsafe API calls. Note that the thread is still prohibited from API calls which necessarily conflict with stream capture, for example, attempting cudaEventQuery on an event that was last recorded inside a capture sequence.

◆ end_capture()

cudaGraph_t tf::cudaStream::end_capture ( ) const
inline

ends graph capturing on the stream

Equivalently calling cudaStreamEndCapture to end capture on stream and returning the captured graph. Capture must have been initiated on stream via a call to cudaStream::begin_capture. If capture was invalidated, due to a violation of the rules of stream capture, then a NULL graph will be returned.

◆ operator cudaStream_t()

tf::cudaStream::operator cudaStream_t ( ) const
inline

implicit conversion to the native CUDA stream (cudaStream_t)

Returns the underlying stream of type cudaStream_t.

◆ record()

void tf::cudaStream::record ( cudaEvent_t  event) const
inline

records an event on the stream

Equivalently calling cudaEventRecord to record an event on this stream, both of which must be on the same CUDA context.

◆ reset()

void tf::cudaStream::reset ( cudaStream_t  stream = nullptr)
inline

replaces the managed stream

Destructs the managed stream and resets it to the given stream.

◆ synchronize()

void tf::cudaStream::synchronize ( ) const
inline

synchronizes the associated stream

Equivalently calling cudaStreamSynchronize to block until this stream has completed all operations.

◆ wait()

void tf::cudaStream::wait ( cudaEvent_t  event) const
inline

waits on an event

Equivalently calling cudaStreamWaitEvent to make all future work submitted to stream wait for all work captured in event.


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