|
Mila
Deep Neural Network Library
|
Abstract interface for compute device implementations. More...
Public Member Functions | |
| virtual std::size_t | getAllocationGranularity () const |
| The multiple the driver rounds a device allocation larger than 1 MiB up to. | |
| virtual DeviceId | getDeviceId () const =0 |
| Gets the device identifier. | |
| virtual std::string | getDeviceName () const =0 |
| Gets the human-readable device name. | |
| virtual constexpr DeviceType | getDeviceType () const =0 |
| Gets the device type. | |
| virtual DeviceMemoryInfo | getMemoryInfo () const |
| Current free and total device memory. | |
Static Public Member Functions | |
| static constexpr DeviceId | Cpu () noexcept |
| Create CPU device identifier. | |
| static constexpr DeviceId | Cuda (int index) noexcept |
| Create CUDA device identifier. | |
| template<DeviceType TDeviceType> | |
| static constexpr DeviceId | getDeviceId (int index) noexcept |
| static constexpr DeviceId | Metal (int index) noexcept |
| Create Metal device identifier. | |
| static constexpr DeviceId | Rocm (int index) noexcept |
| Create ROCm device identifier. | |
Abstract interface for compute device implementations.
Defines the common interface for all compute device types (CPU, CUDA, Metal, ROCm, etc.). Concrete device implementations inherit from this class and are registered with DeviceRegistry for runtime discovery.
This class also serves as the primary factory for DeviceId values via static methods, providing a clean API: Device::Cuda(0), Device::Cpu().
|
inlinestaticconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
Create CUDA device identifier.
| index | Zero-based CUDA device index (0, 1, 2, ...). |
|
inlinevirtual |
The multiple the driver rounds a device allocation larger than 1 MiB up to.
Zero for a device whose allocations are not rounded. See Specifications/MemoryFootprint.md 11.8.
Reimplemented in Mila::Dnn::Compute::CudaDevice.
|
pure virtual |
Gets the device identifier.
Implemented in Mila::Dnn::Compute::CpuDevice, and Mila::Dnn::Compute::CudaDevice.
|
pure virtual |
Gets the human-readable device name.
Implemented in Mila::Dnn::Compute::CpuDevice, and Mila::Dnn::Compute::CudaDevice.
|
constexprpure virtual |
Gets the device type.
Implemented in Mila::Dnn::Compute::CpuDevice, and Mila::Dnn::Compute::CudaDevice.
|
inlinevirtual |
Current free and total device memory.
Answers "will this model fit" together with a footprint from Model::getRequiredMemory. Zeroed by default for devices with no distinct memory pool to report; a caller seeing total_bytes == 0 should treat the figure as unavailable rather than as a device with no memory.
NOTE on Windows: WDDM oversubscribes into shared host memory rather than failing, so free_bytes running out does not produce an allocation error – it produces a model that runs pathologically slowly. Callers should warn rather than refuse.
Reimplemented in Mila::Dnn::Compute::CudaDevice.
|
inlinestaticconstexprnoexcept |
Create Metal device identifier.
| index | Zero-based Metal device index. |
|
inlinestaticconstexprnoexcept |
Create ROCm device identifier.
| index | Zero-based ROCm device index. |