A variant of OptionalStreamGuard that is specialized for CUDA. More...
#include <CUDAGuard.h>
Public Member Functions | |
OptionalCUDAStreamGuard () | |
Create an uninitialized guard. | |
OptionalCUDAStreamGuard (Stream stream) | |
Set the current CUDA device to the device associated with the passed stream, and set the current CUDA stream on that device to the passed stream. More... | |
OptionalCUDAStreamGuard (optional< Stream > stream_opt) | |
Set the current device to the device associated with the passed stream, and set the current stream on that device to the passed stream, if the passed stream is not nullopt. More... | |
OptionalCUDAStreamGuard (const OptionalCUDAStreamGuard &)=delete | |
Copy is disallowed. | |
OptionalCUDAStreamGuard & | operator= (const OptionalCUDAStreamGuard &)=delete |
OptionalCUDAStreamGuard (OptionalCUDAStreamGuard &&other)=delete | |
OptionalCUDAStreamGuard & | operator= (OptionalCUDAStreamGuard &&other)=delete |
void | reset_stream (Stream stream) |
Resets the currently set CUDA stream to the original stream and the currently set device to the original device. More... | |
optional< CUDAStream > | original_stream () const |
Returns the CUDA stream that was set at the time the guard was most recently initialized, or nullopt if the guard is uninitialized. More... | |
optional< CUDAStream > | current_stream () const |
Returns the most recent CUDA stream that was set using this stream guard, either from construction, or via reset_stream, if the guard is initialized, or nullopt if the guard is uninitialized. More... | |
void | reset () |
Restore the original CUDA device and stream, resetting this guard to uninitialized state. | |
A variant of OptionalStreamGuard that is specialized for CUDA.
See CUDAGuard for when you can use this.
Definition at line 174 of file CUDAGuard.h.
|
inlineexplicit |
Set the current CUDA device to the device associated with the passed stream, and set the current CUDA stream on that device to the passed stream.
Errors if the Stream is not a CUDA stream.
Definition at line 181 of file CUDAGuard.h.
|
inlineexplicit |
Set the current device to the device associated with the passed stream, and set the current stream on that device to the passed stream, if the passed stream is not nullopt.
Definition at line 186 of file CUDAGuard.h.
|
inline |
Returns the most recent CUDA stream that was set using this stream guard, either from construction, or via reset_stream, if the guard is initialized, or nullopt if the guard is uninitialized.
Definition at line 219 of file CUDAGuard.h.
|
inline |
Returns the CUDA stream that was set at the time the guard was most recently initialized, or nullopt if the guard is uninitialized.
Definition at line 207 of file CUDAGuard.h.
|
inline |
Resets the currently set CUDA stream to the original stream and the currently set device to the original device.
Then, set the current device to the device associated with the passed stream, and set the current stream on that device to the passed stream. Initializes the guard if it was not previously initialized.
Definition at line 203 of file CUDAGuard.h.