CUDA Utils#
-
class CudaDeviceGuard#
Temporarily switch the active CUDA device for the current thread.
Use this instead of a raw cudaSetDevice when scoped initialization must run on a target device without leaking that thread-local device change back to the caller. Construction throws through CUDA_CHECK when the current or requested device cannot be selected; destruction is noexcept and intentionally ignores restore failures.
Public Functions
-
inline explicit CudaDeviceGuard(int32_t device)#
-
inline ~CudaDeviceGuard() noexcept#
-
CudaDeviceGuard(CudaDeviceGuard const&) = delete#
-
CudaDeviceGuard &operator=(CudaDeviceGuard const&) = delete#
-
inline explicit CudaDeviceGuard(int32_t device)#