A variant of DeviceGuard that is specialized for CUDA. More...
#include <CUDAGuard.h>
Public Member Functions | |
CUDAGuard ()=delete | |
No default constructor; see Note [Omitted default constructor from RAII]. | |
CUDAGuard (DeviceIndex device_index) | |
Set the current CUDA device to the passed device index. | |
CUDAGuard (Device device) | |
Sets the current CUDA device to the passed device. More... | |
CUDAGuard (const CUDAGuard &)=delete | |
CUDAGuard & | operator= (const CUDAGuard &)=delete |
CUDAGuard (CUDAGuard &&other)=delete | |
CUDAGuard & | operator= (CUDAGuard &&other)=delete |
void | set_device (Device device) |
Sets the CUDA device to the given device. More... | |
void | reset_device (Device device) |
Sets the CUDA device to the given device. More... | |
void | set_index (DeviceIndex device_index) |
Sets the CUDA device to the given device index. | |
Device | original_device () const |
Returns the device that was set upon construction of the guard. | |
Device | current_device () const |
Returns the last device that was set via set_device , if any, otherwise the device passed during construction. More... | |
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.
Definition at line 20 of file CUDAGuard.h.
|
inlineexplicit |
Sets the current CUDA device to the passed device.
Errors if the passed device is not a CUDA device.
Definition at line 29 of file CUDAGuard.h.
|
inline |
Returns the last device that was set via set_device
, if any, otherwise the device passed during construction.
Definition at line 56 of file CUDAGuard.h.
|
inline |
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).
Definition at line 46 of file CUDAGuard.h.
|
inline |
Sets the CUDA device to the given device.
Errors if the given device is not a CUDA device.
Definition at line 41 of file CUDAGuard.h.