Gpu devicedenseblock - CyrilB1531/lodestar GitHub Wiki

Development build. This page describes main, not a released package. The latest published Lodestar.Gpu is 0.1.0 — read its documentation.

HomeGpuGPU kernels

DeviceDenseBlock

A row-major dense block held on the accelerator between two operations.

public sealed class DeviceDenseBlock : IDisposable

Example — the shape a caller writes.

using Lodestar.Gpu.Compute;

using var context = GpuContext.Create(preferCpu: true);
using var block = DeviceDenseBlock.Upload(
    context, [1.0, 2.0, 3.0, 4.0], rowCount: 2, columnCount: 2);

int rows = block.RowCount;  // => 2
double first = block.Download()[0];  // => 1

Members — one page each.

Member What it does
DeviceDenseBlock.Upload Uploads a host block to the accelerator
DeviceDenseBlock.Download Copies the block back, ending the chain
DeviceDenseBlock.Dispose Frees the device memory the block holds

PropertiesRowCount and ColumnCount.

Remarksthis is the type that makes a chain a chain. A kernel returning double[] has already paid a device-to-host copy, so the next one pays a host-to-device copy undoing it. A block produced on the accelerator and consumed there crosses the bus once at each end of the chain instead, and Download is where a caller says the chain is over.

Measured: two sparse-dense products chained ran 1.24× to 2.94× faster than the same two with a download and re-upload between them. The gain is largest where the work is smallest, which inverts the usual intuition — a large job amortises a round trip on its own.

bench/README.md's GPU gate deferred this type until three kernels existed, on the ground that chainability is a claim about two operations sharing a residency and cannot be measured with one.

Applies to — net10.0, netstandard2.1.

See alsoTiledSparseDenseProduct, the namespace index.