Struct CUDAGuard¶
Defined in File CUDAGuard.h
Page Contents
Struct Documentation¶
-
struct CUDAGuard¶
A variant of DeviceGuard that is specialized for CUDA.
It accepts integer indices (interpreting them as CUDA devices) and is a little more efficient than DeviceGuard (it compiles to straight line cudaSetDevice/cudaGetDevice calls); however, it can only be used from code that links against CUDA directly.
Public Functions
-
explicit CUDAGuard() = delete¶
No default constructor; see Note [Omitted default constructor from RAII].
-
inline explicit CUDAGuard(DeviceIndex device_index)¶
Set the current CUDA device to the passed device index.
-
inline explicit CUDAGuard(Device device)¶
Sets the current CUDA device to the passed device.
Errors if the passed device is not a CUDA device.
-
~CUDAGuard() = default¶
-
inline void set_device(Device device)¶
Sets the CUDA device to the given device.
Errors if the given device is not a CUDA device.
-
inline void reset_device(Device device)¶
Sets the CUDA device to the given device.
Errors if the given device is not a CUDA device. (This method is provided for uniformity with DeviceGuard).
-
inline void set_index(DeviceIndex device_index)¶
Sets the CUDA device to the given device index.
-
explicit CUDAGuard() = delete¶