Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
DeviceRegistryHelpers.ixx File Reference

Utility functions for compute device discovery and management. More...

#include <vector>
#include <string>
import Compute.DeviceType;
import Compute.DeviceId;
import Compute.DeviceRegistry;

Namespaces

namespace  Mila
 Mila main API namespace.

Functions

DeviceId Mila::Dnn::Compute::getBestDevice (DeviceType type, bool preferMemory=false)
 Gets the best DeviceId of a specific type based on performance characteristics.
std::size_t Mila::Dnn::Compute::getDeviceCount (DeviceType type) noexcept
 Count instantiated devices of the given DeviceType.
std::vector< std::string > Mila::Dnn::Compute::listDevicesByName ()
 Lists all available compute devices by name.
std::vector< std::string > Mila::Dnn::Compute::listDevicesByType (DeviceType type)
 Lists compute devices of a specific type.

Detailed Description

Utility functions for compute device discovery and management.

Small helpers for listing and selecting devices via DeviceRegistry.

Function Documentation

◆ getBestDevice()

DeviceId Mila::Dnn::Compute::getBestDevice ( DeviceType type,
bool preferMemory = false )
export

Gets the best DeviceId of a specific type based on performance characteristics.

For CUDA the function consults Cuda::getBestDeviceId(preferMemory) and returns the matching DeviceId when available. If no device of the requested type is found the function returns a DeviceId with the requested type and index == -1 to indicate "none".

Parameters
typeThe device type to filter by (e.g., DeviceType::Cuda)
preferMemoryWhen true, prioritizes memory bandwidth over compute capability
Returns
DeviceId Best available device id for the requested type, or index == -1 if none

◆ getDeviceCount()

std::size_t Mila::Dnn::Compute::getDeviceCount ( DeviceType type)
exportnoexcept

Count instantiated devices of the given DeviceType.

Lightweight, thread-safe convenience helper intended for tests and diagnostics. Non-throwing; returns 0 on error.

◆ listDevicesByName()

std::vector< std::string > Mila::Dnn::Compute::listDevicesByName ( )
export

Lists all available compute devices by name.

Returns
std::vector<std::string> A list of device identifiers (e.g., "CUDA:0", "CPU:0").

◆ listDevicesByType()

std::vector< std::string > Mila::Dnn::Compute::listDevicesByType ( DeviceType type)
export

Lists compute devices of a specific type.

Parameters
typeThe device type to filter by
Returns
std::vector<std::string> List of matching device identifiers