Interface IMemoryManagementPort
- Namespace
- DotCompute.Abstractions.Ports
- Assembly
- DotCompute.Abstractions.dll
Port interface for memory management operations. Part of hexagonal architecture - defines the contract that backend adapters must implement.
public interface IMemoryManagementPort
Remarks
This port abstracts memory allocation, transfer, and synchronization from backend-specific implementations. Each backend (CUDA, Metal, OpenCL, CPU) provides an adapter that implements this interface.
Properties
Capabilities
Gets the memory management capabilities of this backend.
MemoryCapabilities Capabilities { get; }
Property Value
Methods
AllocateAsync<T>(int, BufferAllocationFlags, CancellationToken)
Allocates a buffer of the specified size.
ValueTask<IPortBuffer<T>> AllocateAsync<T>(int length, BufferAllocationFlags flags = BufferAllocationFlags.None, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
lengthintNumber of elements to allocate.
flagsBufferAllocationFlagsBuffer allocation flags.
cancellationTokenCancellationTokenCancellation token.
Returns
- ValueTask<IPortBuffer<T>>
The allocated buffer.
Type Parameters
TThe element type (must be unmanaged).
CopyAsync<T>(IPortBuffer<T>, IPortBuffer<T>, CancellationToken)
Copies data between buffers.
ValueTask CopyAsync<T>(IPortBuffer<T> source, IPortBuffer<T> destination, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
sourceIPortBuffer<T>Source buffer.
destinationIPortBuffer<T>Destination buffer.
cancellationTokenCancellationTokenCancellation token.
Returns
Type Parameters
TThe element type.
CopyRangeAsync<T>(IPortBuffer<T>, int, IPortBuffer<T>, int, int, CancellationToken)
Copies a range of data between buffers.
ValueTask CopyRangeAsync<T>(IPortBuffer<T> source, int sourceOffset, IPortBuffer<T> destination, int destinationOffset, int count, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
sourceIPortBuffer<T>sourceOffsetintdestinationIPortBuffer<T>destinationOffsetintcountintcancellationTokenCancellationToken
Returns
Type Parameters
T
GetStatistics()
Gets current memory statistics.
MemoryStatistics GetStatistics()