Class UnifiedMemoryService
- Namespace
- DotCompute.Runtime.Services.Memory
- Assembly
- DotCompute.Runtime.dll
Implementation of unified memory service with cross-device coherence support.
public class UnifiedMemoryService : IUnifiedMemoryService, IDisposable
- Inheritance
-
UnifiedMemoryService
- Implements
- Inherited Members
- Extension Methods
Constructors
UnifiedMemoryService(ILogger<UnifiedMemoryService>)
Implementation of unified memory service with cross-device coherence support.
public UnifiedMemoryService(ILogger<UnifiedMemoryService> logger)
Parameters
loggerILogger<UnifiedMemoryService>
Methods
AllocateUnifiedAsync(long, params string[])
Allocates unified memory that can be accessed by multiple accelerators.
public Task<IUnifiedMemoryBuffer> AllocateUnifiedAsync(long sizeInBytes, params string[] acceleratorIds)
Parameters
sizeInByteslongThe size in bytes to allocate.
acceleratorIdsstring[]The accelerator IDs that will access this memory.
Returns
- Task<IUnifiedMemoryBuffer>
The allocated unified memory buffer.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetAssociatedAccelerators(IUnifiedMemoryBuffer)
Gets the accelerator IDs associated with a buffer.
public IReadOnlySet<string> GetAssociatedAccelerators(IUnifiedMemoryBuffer buffer)
Parameters
bufferIUnifiedMemoryBufferThe buffer to query.
Returns
- IReadOnlySet<string>
The associated accelerator IDs.
GetCoherenceStatus(IUnifiedMemoryBuffer)
Gets the coherence status for a buffer.
public MemoryCoherenceStatus GetCoherenceStatus(IUnifiedMemoryBuffer buffer)
Parameters
bufferIUnifiedMemoryBufferThe buffer to check.
Returns
- MemoryCoherenceStatus
The coherence status.
MarkDirty(IUnifiedMemoryBuffer, string)
Marks a buffer as modified on a specific device, making it incoherent.
public void MarkDirty(IUnifiedMemoryBuffer buffer, string acceleratorId)
Parameters
bufferIUnifiedMemoryBufferThe buffer that was modified.
acceleratorIdstringThe accelerator ID where modification occurred.
MigrateAsync(IUnifiedMemoryBuffer, string, string)
Migrates data between accelerators with proper coherence management.
public Task MigrateAsync(IUnifiedMemoryBuffer buffer, string sourceAcceleratorId, string targetAcceleratorId)
Parameters
bufferIUnifiedMemoryBufferThe buffer to migrate.
sourceAcceleratorIdstringThe source accelerator ID.
targetAcceleratorIdstringThe target accelerator ID.
Returns
SynchronizeCoherenceAsync(IUnifiedMemoryBuffer, params string[])
Synchronizes memory coherence across the specified accelerators.
public Task SynchronizeCoherenceAsync(IUnifiedMemoryBuffer buffer, params string[] acceleratorIds)
Parameters
bufferIUnifiedMemoryBufferThe buffer to synchronize.
acceleratorIdsstring[]The accelerator IDs to synchronize.
Returns
UnregisterBuffer(IUnifiedMemoryBuffer)
Unregisters a buffer from the service.
public void UnregisterBuffer(IUnifiedMemoryBuffer buffer)
Parameters
bufferIUnifiedMemoryBufferThe buffer to unregister.