Table of Contents

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

buffer IUnifiedMemoryBuffer<T>

The source buffer.

data Memory<T>

The destination memory to copy to.

offset long

The offset in bytes where to start reading from.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask

A task representing the copy operation.

Type Parameters

T

The 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

buffer IUnifiedMemoryBuffer<T>

The source buffer.

data T[]

The destination array to copy to.

offset long

The offset in bytes where to start reading from.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask

A task representing the copy operation.

Type Parameters

T

The 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

buffer IUnifiedMemoryBuffer<T>

The target buffer.

data 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 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

buffer IUnifiedMemoryBuffer<T>

The target buffer.

data T[]

The source array 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 unmanaged element type.