Class CudaDevicePointerBuffer
- Namespace
- DotCompute.Backends.CUDA.RingKernels
- Assembly
- DotCompute.Backends.CUDA.dll
Simple read-only wrapper for CUDA device memory pointers used by message queues.
public sealed class CudaDevicePointerBuffer : IUnifiedMemoryBuffer, IAsyncDisposable, IDisposable
- Inheritance
-
CudaDevicePointerBuffer
- Implements
- Inherited Members
- Extension Methods
Remarks
This is a lightweight wrapper that provides access to device memory pointers without the full complexity of IUnifiedMemoryBuffer implementation.
Constructors
CudaDevicePointerBuffer(nint, long, MemoryOptions)
Initializes a new instance of the CudaDevicePointerBuffer class.
public CudaDevicePointerBuffer(nint devicePointer, long sizeInBytes, MemoryOptions options = MemoryOptions.None)
Parameters
devicePointernintThe device memory pointer.
sizeInByteslongThe size in bytes.
optionsMemoryOptionsMemory allocation options.
Properties
DevicePointer
Gets the device memory pointer.
public nint DevicePointer { 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
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)
Copies data from a source memory into this buffer.
public ValueTask CopyFromAsync<T>(ReadOnlyMemory<T> source, long offset = 0, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
sourceReadOnlyMemory<T>The source memory to copy from.
offsetlongThe offset in bytes where to start copying.
cancellationTokenCancellationTokenCancellation token.
Returns
- ValueTask
A task representing the copy operation.
Type Parameters
TThe element type.
CopyToAsync<T>(Memory<T>, long, CancellationToken)
Copies data from this buffer to a destination memory.
public ValueTask CopyToAsync<T>(Memory<T> destination, long offset = 0, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
destinationMemory<T>The destination memory to copy to.
offsetlongThe offset in bytes where to start copying from.
cancellationTokenCancellationTokenCancellation token.
Returns
- ValueTask
A task representing the copy operation.
Type Parameters
TThe element type.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
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.