Table of Contents

Class MetalBackend

Namespace
DotCompute.Backends.Metal
Assembly
DotCompute.Backends.Metal.dll

Main entry point for Metal compute backend

public sealed class MetalBackend : IDisposable
Inheritance
MetalBackend
Implements
Inherited Members
Extension Methods

Constructors

MetalBackend(ILogger<MetalBackend>, ILoggerFactory)

public MetalBackend(ILogger<MetalBackend> logger, ILoggerFactory loggerFactory)

Parameters

logger ILogger<MetalBackend>
loggerFactory ILoggerFactory

Methods

AllocateBufferAsync<T>(int)

Allocate a buffer on the Metal device

public Task<IUnifiedMemoryBuffer> AllocateBufferAsync<T>(int size) where T : unmanaged

Parameters

size int

Returns

Task<IUnifiedMemoryBuffer>

Type Parameters

T

CompileFunction(string, string)

Compile a Metal function from source code

public nint CompileFunction(string source, string functionName)

Parameters

source string
functionName string

Returns

nint

CopyFromBufferAsync<T>(IUnifiedMemoryBuffer<T>, T[])

Copy data from a Metal buffer asynchronously

public Task CopyFromBufferAsync<T>(IUnifiedMemoryBuffer<T> buffer, T[] data) where T : unmanaged

Parameters

buffer IUnifiedMemoryBuffer<T>
data T[]

Returns

Task

Type Parameters

T

CopyToBufferAsync<T>(IUnifiedMemoryBuffer<T>, T[])

Copy data to a Metal buffer asynchronously

public Task CopyToBufferAsync<T>(IUnifiedMemoryBuffer<T> buffer, T[] data) where T : unmanaged

Parameters

buffer IUnifiedMemoryBuffer<T>
data T[]

Returns

Task

Type Parameters

T

CreateCommandQueue()

Create a Metal command queue

public nint CreateCommandQueue()

Returns

nint

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

ExecuteComputeShaderAsync(nint, params IUnifiedMemoryBuffer[])

Execute a compute shader asynchronously

public Task ExecuteComputeShaderAsync(nint function, params IUnifiedMemoryBuffer[] buffers)

Parameters

function nint
buffers IUnifiedMemoryBuffer[]

Returns

Task

GetAccelerators()

Get all available Metal accelerators

public IReadOnlyList<MetalAccelerator> GetAccelerators()

Returns

IReadOnlyList<MetalAccelerator>

GetDefaultAccelerator()

Get default Metal accelerator

public MetalAccelerator? GetDefaultAccelerator()

Returns

MetalAccelerator

IsAvailable()

Check if Metal is available on this platform

public static bool IsAvailable()

Returns

bool