Table of Contents

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

devicePointer nint

The device memory pointer.

sizeInBytes long

The size in bytes.

options MemoryOptions

Memory allocation options.

Properties

DevicePointer

Gets the device memory pointer.

public nint DevicePointer { get; }

Property Value

nint

IsDisposed

Gets whether the buffer has been disposed.

public bool IsDisposed { get; }

Property Value

bool

Options

Gets the memory allocation options.

public MemoryOptions Options { get; }

Property Value

MemoryOptions

SizeInBytes

Gets the size of the buffer in bytes.

public long SizeInBytes { get; }

Property Value

long

State

Gets the current state of the buffer.

public BufferState State { get; }

Property Value

BufferState

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

source ReadOnlyMemory<T>

The source memory to copy from.

offset long

The offset in bytes where to start copying.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask

A task representing the copy operation.

Type Parameters

T

The 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

destination Memory<T>

The destination memory to copy to.

offset long

The offset in bytes where to start copying from.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask

A task representing the copy operation.

Type Parameters

T

The 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.