Class CpuMemoryBuffer
- Namespace
- DotCompute.Core.Memory
- Assembly
- DotCompute.Core.dll
CPU memory buffer implementation.
public sealed class CpuMemoryBuffer : IUnifiedMemoryBuffer, IAsyncDisposable, IDisposable
- Inheritance
-
CpuMemoryBuffer
- Implements
- Inherited Members
- Extension Methods
Constructors
CpuMemoryBuffer(long, MemoryOptions)
Initializes a new instance of the CpuMemoryBuffer class.
public CpuMemoryBuffer(long sizeInBytes, MemoryOptions options)
Parameters
sizeInByteslongThe size in bytes.
optionsMemoryOptionsThe options.
Properties
IsDisposed
Gets or sets a value indicating whether disposed.
public bool IsDisposed { get; }
Property Value
- bool
The is disposed.
Options
Gets or sets the options.
public MemoryOptions Options { get; }
Property Value
- MemoryOptions
The options.
SizeInBytes
Gets or sets the size in bytes.
public long SizeInBytes { get; }
Property Value
- long
The size in bytes.
State
Gets or sets the state.
public BufferState State { get; set; }
Property Value
- BufferState
The state.
Methods
CopyFromAsync<T>(ReadOnlyMemory<T>, long, CancellationToken)
Copies data from source memory to this CPU buffer with offset support.
public ValueTask CopyFromAsync<T>(ReadOnlyMemory<T> source, long offset, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
sourceReadOnlyMemory<T>Source data to copy from.
offsetlongOffset into this buffer in bytes.
cancellationTokenCancellationTokenCancellation token for the operation.
Returns
- ValueTask
Completed task when copy finishes.
Type Parameters
TType of elements to copy.
CopyFromHostAsync<T>(ReadOnlyMemory<T>, long, CancellationToken)
Gets copy from host asynchronously.
public ValueTask CopyFromHostAsync<T>(ReadOnlyMemory<T> source, long offset = 0, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
sourceReadOnlyMemory<T>The source.
offsetlongThe offset.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- ValueTask
The result of the operation.
Type Parameters
TThe T type parameter.
CopyToAsync<T>(Memory<T>, long, CancellationToken)
Copies data from this CPU buffer to destination memory with offset support.
public ValueTask CopyToAsync<T>(Memory<T> destination, long offset, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
destinationMemory<T>Destination memory to copy to.
offsetlongOffset into this buffer in bytes.
cancellationTokenCancellationTokenCancellation token for the operation.
Returns
- ValueTask
Completed task when copy finishes.
Type Parameters
TType of elements to copy.
CopyToHostAsync<T>(Memory<T>, long, CancellationToken)
Gets copy to host asynchronously.
public ValueTask CopyToHostAsync<T>(Memory<T> destination, long offset = 0, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
destinationMemory<T>The destination.
offsetlongThe offset.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- ValueTask
The result of the operation.
Type Parameters
TThe T type parameter.
Dispose()
Performs dispose.
public void Dispose()
DisposeAsync()
Gets dispose asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
The result of the operation.