Class UnifiedMemoryBuffer
- Namespace
- DotCompute.Backends.CUDA.Memory.Models
- Assembly
- DotCompute.Backends.CUDA.dll
Represents a CUDA unified memory buffer accessible from both host and device.
public sealed class UnifiedMemoryBuffer : IUnifiedMemoryBuffer, IAsyncDisposable, IDisposable
- Inheritance
-
UnifiedMemoryBuffer
- Implements
- Inherited Members
- Extension Methods
Remarks
Initializes a new instance of the UnifiedMemoryBuffer class.
Constructors
UnifiedMemoryBuffer(nint, long, int, CudaMemoryFlags)
Represents a CUDA unified memory buffer accessible from both host and device.
public UnifiedMemoryBuffer(nint pointer, long sizeInBytes, int deviceId, CudaMemoryFlags flags)
Parameters
pointernintsizeInByteslongdeviceIdintflagsCudaMemoryFlags
Remarks
Initializes a new instance of the UnifiedMemoryBuffer class.
Properties
AccessStats
Gets the access pattern statistics.
public AccessPatternStats AccessStats { get; set; }
Property Value
CurrentResidence
Gets or sets the current residence location.
public MemoryResidence CurrentResidence { get; set; }
Property Value
DeviceId
Gets the device ID associated with this buffer.
public int DeviceId { get; }
Property Value
Flags
Gets the managed memory flags used for allocation.
public CudaMemoryFlags Flags { get; }
Property Value
IsDisposed
Gets whether the buffer has been disposed.
public bool IsDisposed { get; }
Property Value
Options
Gets the memory allocation options.
public MemoryOptions Options { get; }
Property Value
Pointer
Gets the pointer to the unified memory.
public nint Pointer { get; }
Property Value
SizeInBytes
Gets the size of the buffer in bytes.
public long SizeInBytes { get; }
Property Value
State
Gets the current state of the buffer.
public BufferState State { get; }
Property Value
Methods
CopyFromAsync<T>(ReadOnlyMemory<T>, long, CancellationToken)
Asynchronously copies data from host memory to this buffer.
public ValueTask CopyFromAsync<T>(ReadOnlyMemory<T> source, long offset = 0, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
sourceReadOnlyMemory<T>offsetlongcancellationTokenCancellationToken
Returns
Type Parameters
T
CopyToAsync<T>(Memory<T>, long, CancellationToken)
Asynchronously copies data from this buffer to host memory.
public ValueTask CopyToAsync<T>(Memory<T> destination, long offset = 0, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
destinationMemory<T>offsetlongcancellationTokenCancellationToken
Returns
Type Parameters
T
Dispose()
Disposes the unified memory buffer.
public void Dispose()
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.