Class MemoryBufferExtensions
- Namespace
- DotCompute.Core.Extensions
- Assembly
- DotCompute.Core.dll
Extension methods for IUnifiedMemoryBuffer.
public static class MemoryBufferExtensions
- Inheritance
-
MemoryBufferExtensions
- Inherited Members
Methods
ReadAsync<T>(IUnifiedMemoryBuffer<T>, Memory<T>, long, CancellationToken)
Reads data from the memory buffer to a host memory from the specified offset.
public static ValueTask ReadAsync<T>(this IUnifiedMemoryBuffer<T> buffer, Memory<T> data, long offset, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
bufferIUnifiedMemoryBuffer<T>The source buffer.
dataMemory<T>The destination memory to copy to.
offsetlongThe offset in bytes where to start reading from.
cancellationTokenCancellationTokenCancellation token.
Returns
- ValueTask
A task representing the copy operation.
Type Parameters
TThe unmanaged element type.
ReadAsync<T>(IUnifiedMemoryBuffer<T>, T[], long, CancellationToken)
Reads data from the memory buffer to a host array from the specified offset.
public static ValueTask ReadAsync<T>(this IUnifiedMemoryBuffer<T> buffer, T[] data, long offset, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
bufferIUnifiedMemoryBuffer<T>The source buffer.
dataT[]The destination array to copy to.
offsetlongThe offset in bytes where to start reading from.
cancellationTokenCancellationTokenCancellation token.
Returns
- ValueTask
A task representing the copy operation.
Type Parameters
TThe unmanaged element type.
WriteAsync<T>(IUnifiedMemoryBuffer<T>, ReadOnlyMemory<T>, long, CancellationToken)
Writes data to the memory buffer from a host memory at the specified offset.
public static ValueTask WriteAsync<T>(this IUnifiedMemoryBuffer<T> buffer, ReadOnlyMemory<T> data, long offset, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
bufferIUnifiedMemoryBuffer<T>The target buffer.
dataReadOnlyMemory<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 unmanaged element type.
WriteAsync<T>(IUnifiedMemoryBuffer<T>, T[], long, CancellationToken)
Writes data to the memory buffer from a host array at the specified offset.
public static ValueTask WriteAsync<T>(this IUnifiedMemoryBuffer<T> buffer, T[] data, long offset, CancellationToken cancellationToken = default) where T : unmanaged
Parameters
bufferIUnifiedMemoryBuffer<T>The target buffer.
dataT[]The source array to copy from.
offsetlongThe offset in bytes where to start copying.
cancellationTokenCancellationTokenCancellation token.
Returns
- ValueTask
A task representing the copy operation.
Type Parameters
TThe unmanaged element type.