CUDA Device Management¶
- group cuda_device_management
Functions
-
inline cuda_device_id get_current_cuda_device()¶
Returns a
cuda_device_id
for the current device.The current device is the device on which the calling thread executes device code.
- Returns:
cuda_device_id
for the current device
-
inline int get_num_cuda_devices()¶
Returns the number of CUDA devices in the system.
- Returns:
Number of CUDA devices in the system
-
inline std::pair<std::size_t, std::size_t> available_device_memory()¶
Returns the available and total device memory in bytes for the current device.
- Returns:
The available and total device memory in bytes for the current device as a std::pair.
-
inline std::size_t percent_of_free_device_memory(int percent)¶
Returns the approximate specified percent of available device memory on the current CUDA device, aligned (down) to the nearest CUDA allocation size.
- Parameters:
percent – The percent of free memory to return.
- Returns:
The recommended initial device memory pool size in bytes.
-
struct cuda_device_id¶
- #include <cuda_device.hpp>
Strong type for a CUDA device identifier.
Public Types
-
using value_type = int¶
Integer type used for device identifier.
Public Functions
-
inline explicit constexpr cuda_device_id(value_type dev_id) noexcept¶
Construct a
cuda_device_id
from the specified integer value.- Parameters:
dev_id – The device’s integer identifier
-
inline constexpr value_type value() const noexcept¶
The wrapped integer value.
- Returns:
The wrapped integer value
-
using value_type = int¶
-
struct cuda_set_device_raii¶
- #include <cuda_device.hpp>
RAII class that sets the current CUDA device to the specified device on construction and restores the previous device on destruction.
Public Functions
-
inline explicit cuda_set_device_raii(cuda_device_id dev_id)¶
Construct a new cuda_set_device_raii object and sets the current CUDA device to
dev_id
- Parameters:
dev_id – The device to set as the current CUDA device
-
inline ~cuda_set_device_raii() noexcept¶
Reactivates the previous CUDA device.
-
inline explicit cuda_set_device_raii(cuda_device_id dev_id)¶
-
inline cuda_device_id get_current_cuda_device()¶