Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::Compute::MetalDevicePlugin Class Referenceexport

Metal device plugin for device-agnostic registration. More...

Static Public Member Functions

static int getDeviceCount ()
 Gets the number of available Metal devices.
static std::string getPluginName ()
 Gets the plugin name identifying the Metal device type.
static bool hasDefaultDevice ()
 Gets the default Metal device.
static bool isAvailable ()
 Checks if the Metal framework is available and functional.
static bool isMPSAvailable ()
 Checks if Metal Performance Shaders are available.
static void registerDevices ()
 Registers all available Metal devices with the DeviceRegistry.

Static Private Member Functions

static bool isDeviceUsable (void *device)
 Checks if a specific Metal device is usable for computation.

Detailed Description

Metal device plugin for device-agnostic registration.

This plugin encapsulates all Metal-specific logic for device discovery and registration, providing a clean static interface to the DeviceRegistrar while handling Metal framework API interactions internally.

Key responsibilities:

  • Metal framework availability detection
  • Metal device enumeration and capability checking
  • Device registration with appropriate factory functions
  • Error handling for Metal-related failures
  • Graceful degradation when Metal is not available

Member Function Documentation

◆ getDeviceCount()

int Mila::Dnn::Compute::MetalDevicePlugin::getDeviceCount ( )
inlinestatic

Gets the number of available Metal devices.

Returns
Number of Metal devices available, or 0 if Metal is not available
Note
This method does not throw exceptions - returns 0 on any error

◆ getPluginName()

std::string Mila::Dnn::Compute::MetalDevicePlugin::getPluginName ( )
inlinestatic

Gets the plugin name identifying the Metal device type.

Returns
String "Metal" identifying this as the Metal device plugin

◆ hasDefaultDevice()

bool Mila::Dnn::Compute::MetalDevicePlugin::hasDefaultDevice ( )
inlinestatic

Gets the default Metal device.

Returns information about the system's default Metal device, which is typically the primary GPU.

Returns
true if default device is available, false otherwise

◆ isAvailable()

bool Mila::Dnn::Compute::MetalDevicePlugin::isAvailable ( )
inlinestatic

Checks if the Metal framework is available and functional.

Performs a lightweight check to determine if Metal operations can be performed. This is useful for early detection of Metal availability without attempting full device enumeration.

Returns
true if Metal framework is available and functional, false otherwise
Note
This method does not throw exceptions - returns false on any error

◆ isDeviceUsable()

bool Mila::Dnn::Compute::MetalDevicePlugin::isDeviceUsable ( void * device)
inlinestaticprivate

Checks if a specific Metal device is usable for computation.

Performs device-specific capability checking to ensure the device meets minimum requirements for neural network operations. This includes feature set validation and memory availability checks.

Parameters
deviceMetal device to check
Returns
true if device is usable, false otherwise
Note
This method performs actual device queries
Returns false for any device that cannot be properly queried
Here is the caller graph for this function:

◆ isMPSAvailable()

bool Mila::Dnn::Compute::MetalDevicePlugin::isMPSAvailable ( )
inlinestatic

Checks if Metal Performance Shaders are available.

Metal Performance Shaders (MPS) provide optimized neural network primitives for Apple Silicon and other Metal-capable devices.

Returns
true if MPS is available, false otherwise

◆ registerDevices()

void Mila::Dnn::Compute::MetalDevicePlugin::registerDevices ( )
inlinestatic

Registers all available Metal devices with the DeviceRegistry.

Performs Metal framework initialization, enumerates available Metal devices, and registers each device with an appropriate factory function. Handles Metal unavailability gracefully without throwing exceptions.

Device naming convention: "Metal:N" where N is the device index (0-based)

Note
This method is safe to call even when Metal is not available
Registers devices only if Metal framework is available and functional
Each device is registered with a factory that creates MetalDevice instances
Here is the call graph for this function:

The documentation for this class was generated from the following file: