Class CudaRawMemoryBuffer
- Namespace
- DotCompute.Backends.CUDA.Memory
- Assembly
- DotCompute.Backends.CUDA.dll
Raw untyped CUDA memory buffer for byte-level operations.
public sealed class CudaRawMemoryBuffer : IUnifiedMemoryBuffer, IDisposable, IAsyncDisposable
- Inheritance
-
CudaRawMemoryBuffer
- Implements
- Inherited Members
- Extension Methods
Remarks
Initializes a new instance of the CudaRawMemoryBuffer class.
Constructors
CudaRawMemoryBuffer(nint, long, bool)
Raw untyped CUDA memory buffer for byte-level operations.
public CudaRawMemoryBuffer(nint devicePtr, long sizeInBytes, bool ownsMemory = true)
Parameters
devicePtrnintThe device memory pointer.
sizeInByteslongThe size in bytes.
ownsMemoryboolWhether this buffer owns the memory.
Remarks
Initializes a new instance of the CudaRawMemoryBuffer class.
Properties
DevicePointer
public nint DevicePointer { get; }
Property Value
HostPointer
public nint HostPointer { get; }
Property Value
IsDisposed
Gets whether the buffer has been disposed.
public bool IsDisposed { get; }
Property Value
IsUnified
public static bool IsUnified { get; }
Property Value
Location
public static MemoryLocation Location { 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
AsMemory()
public Memory<byte> AsMemory()
Returns
AsReadOnlySpan()
public ReadOnlySpan<byte> AsReadOnlySpan()
Returns
AsSpan()
public Span<byte> AsSpan()
Returns
CopyFrom(IUnifiedMemoryBuffer)
public void CopyFrom(IUnifiedMemoryBuffer source)
Parameters
sourceIUnifiedMemoryBuffer
CopyFromAsync<TSource>(ReadOnlyMemory<TSource>, long, CancellationToken)
Copies data from a source memory into this buffer.
public ValueTask CopyFromAsync<TSource>(ReadOnlyMemory<TSource> source, long offset, CancellationToken cancellationToken = default) where TSource : unmanaged
Parameters
sourceReadOnlyMemory<TSource>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
TSource
CopyTo(IUnifiedMemoryBuffer)
public void CopyTo(IUnifiedMemoryBuffer destination)
Parameters
destinationIUnifiedMemoryBuffer
CopyToAsync<TDest>(Memory<TDest>, long, CancellationToken)
Copies data from this buffer to a destination memory.
public ValueTask CopyToAsync<TDest>(Memory<TDest> destination, long offset, CancellationToken cancellationToken = default) where TDest : unmanaged
Parameters
destinationMemory<TDest>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
TDest
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.
Prefetch(int)
public void Prefetch(int deviceId = -1)
Parameters
deviceIdint
Synchronize()
public static void Synchronize()