Struct OptionalCUDAStreamGuard
Defined in File CUDAGuard.h
Page Contents
Struct Documentation
-
struct OptionalCUDAStreamGuard
A variant of OptionalStreamGuard that is specialized for CUDA.
See CUDAGuard for when you can use this.
Public Functions
-
inline explicit 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.
Errors if the Stream is not a CUDA stream.
-
inline explicit OptionalCUDAStreamGuard(std::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.
-
OptionalCUDAStreamGuard(const OptionalCUDAStreamGuard&) = delete
Copy is disallowed.
-
OptionalCUDAStreamGuard &operator=(const OptionalCUDAStreamGuard&) = delete
-
OptionalCUDAStreamGuard(OptionalCUDAStreamGuard &&other) = delete
-
OptionalCUDAStreamGuard &operator=(OptionalCUDAStreamGuard &&other) = delete
-
inline void reset_stream(Stream stream)
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.
-
inline std::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.
-
inline std::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.
-
inline explicit OptionalCUDAStreamGuard(Stream stream)