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

Class representing a Metal compute device instance. More...

Inheritance diagram for Mila::Dnn::Compute::MetalDevice:
Collaboration diagram for Mila::Dnn::Compute::MetalDevice:

Public Member Functions

 MetalDevice (int device_index)
 Constructs a MetalDevice with specified device index.
DeviceId getDeviceId () const override
 Gets the CUDA device ID.
int getDeviceIndex () const
 Gets the Metal device index.
size_t getDeviceMemorySize () const
 Gets device memory information.
std::string getDeviceName () const override
 Gets the name of this Metal device.
constexpr DeviceType getDeviceType () const override
 Gets the type of this compute device.
size_t getMaxThreadsPerThreadgroup () const
 Gets the maximum threads per threadgroup.
void * getNativeDevice () const
 Gets the raw Metal device handle.
size_t getRecommendedMaxWorkingSetSize () const
 Gets the recommended maximum working set size.
bool isMPSSupported () const
 Checks if the device supports Metal Performance Shaders.
bool isUnifiedMemorySupported () const
 Checks if the device supports unified memory.
bool supportsComputeShaders () const
 Checks if the device supports compute shaders.
bool supportsGPUFamily () const
 Checks if the device supports specific Metal GPU family.

Private Attributes

int device_index_
 The Metal device index.
std::string device_name_
 Cached device name.

Detailed Description

Class representing a Metal compute device instance.

This class provides an interface to interact with a specific Apple Metal-capable GPU within the Mila framework. It handles device properties and capabilities for a single device instance. Device discovery and registration is handled by MetalDevicePlugin. Device activation and context management is handled by the DeviceContext class.

Constructor & Destructor Documentation

◆ MetalDevice()

Mila::Dnn::Compute::MetalDevice::MetalDevice ( int device_index)
inlineexplicit

Constructs a MetalDevice with specified device index.

Parameters
device_indexThe Metal device index to initialize.

Member Function Documentation

◆ getDeviceId()

DeviceId Mila::Dnn::Compute::MetalDevice::getDeviceId ( ) const
inlineoverride

Gets the CUDA device ID.

Returns
int The device ID for this CUDA device (0-based)

◆ getDeviceIndex()

int Mila::Dnn::Compute::MetalDevice::getDeviceIndex ( ) const
inline

Gets the Metal device index.

Returns
int The device index for this Metal device.

◆ getDeviceMemorySize()

size_t Mila::Dnn::Compute::MetalDevice::getDeviceMemorySize ( ) const
inline

Gets device memory information.

Returns
size_t Available device memory in bytes, or 0 if unavailable.

◆ getDeviceName()

std::string Mila::Dnn::Compute::MetalDevice::getDeviceName ( ) const
inlineoverride

Gets the name of this Metal device.

Returns
std::string The device name in format "Metal:<device_index>" or actual device name if available.

◆ getDeviceType()

DeviceType Mila::Dnn::Compute::MetalDevice::getDeviceType ( ) const
inlineconstexproverride

Gets the type of this compute device.

Returns
DeviceType The device type (Metal).

◆ getMaxThreadsPerThreadgroup()

size_t Mila::Dnn::Compute::MetalDevice::getMaxThreadsPerThreadgroup ( ) const
inline

Gets the maximum threads per threadgroup.

Returns
size_t Maximum threads per threadgroup, or 0 if unavailable.

◆ getNativeDevice()

void * Mila::Dnn::Compute::MetalDevice::getNativeDevice ( ) const
inline

Gets the raw Metal device handle.

Returns
Native Metal device handle (id<MTLDevice> on Apple platforms, nullptr elsewhere)
Note
This returns a platform-specific handle for advanced Metal operations
Returns nullptr on non-Apple platforms

◆ getRecommendedMaxWorkingSetSize()

size_t Mila::Dnn::Compute::MetalDevice::getRecommendedMaxWorkingSetSize ( ) const
inline

Gets the recommended maximum working set size.

Returns
size_t Recommended maximum working set size in bytes, or 0 if unavailable.

◆ isMPSSupported()

bool Mila::Dnn::Compute::MetalDevice::isMPSSupported ( ) const
inline

Checks if the device supports Metal Performance Shaders.

Returns
bool True if MPS is supported, false otherwise.

◆ isUnifiedMemorySupported()

bool Mila::Dnn::Compute::MetalDevice::isUnifiedMemorySupported ( ) const
inline

Checks if the device supports unified memory.

Returns
bool True if unified memory is supported, false otherwise.

◆ supportsComputeShaders()

bool Mila::Dnn::Compute::MetalDevice::supportsComputeShaders ( ) const
inline

Checks if the device supports compute shaders.

Returns
bool True if compute shaders are supported, false otherwise.

◆ supportsGPUFamily()

bool Mila::Dnn::Compute::MetalDevice::supportsGPUFamily ( ) const
inline

Checks if the device supports specific Metal GPU family.

Returns
bool True if the specified GPU family is supported, false otherwise.

Member Data Documentation

◆ device_index_

int Mila::Dnn::Compute::MetalDevice::device_index_
private

The Metal device index.

◆ device_name_

std::string Mila::Dnn::Compute::MetalDevice::device_name_
private

Cached device name.


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