Template Class DevicePool¶
Defined in File DevicePool.hpp
Class Documentation¶
-
template<typename DeviceIndexType = int>
class DevicePool¶ Manages the available GPU devices in a pool of requestable resources.
Public Functions
-
inline DevicePool()¶
-
inline DevicePool([[maybe_unused]] DevicePool &&dp)¶
-
inline void refresh()¶
Dynamically refresh the available pool devices.
-
virtual ~DevicePool() = default¶
-
inline auto getActiveDevices() -> const std::unordered_set<DeviceIndexType>&¶
Get the indices of devices currently active.
- Returns
const std::unordered_set<DeviceIndexType>&
-
inline bool isActive(const DeviceIndexType &index)¶
Check if a given device index is active.
- Parameters
index – Device index label.
- Returns
true
- Returns
false
-
inline bool isInactive(const DeviceIndexType &index)¶
Check if a given device index is inactive.
- Parameters
index – Device index label.
- Returns
true
- Returns
false
-
inline int acquireDevice()¶
Acquire and return the index for an unused device. Returned device index becomes active.
- Returns
int
-
inline void releaseDevice(DeviceIndexType dev_id)¶
Deactivate given device index, and return to pool.
- Parameters
dev_id –
-
inline void syncDevice()¶
Synchronize device with host.
Public Static Functions
-
static inline std::size_t getTotalDevices()¶
Get the total number of available devices.
- Returns
std::size_t
-
static inline std::vector<cudaUUID_t> getDeviceUIDs()¶
Get the UIDs of available devices.
- Returns
std::vector<cudaUUID_t>
-
static inline void setDeviceIdx(int device_id)¶
Explicitly set the device ID for the given thread.
-
inline DevicePool()¶