Gpu 0.1.0 devicesparsematrix - CyrilB1531/lodestar GitHub Wiki

Lodestar.Gpu 0.1.0. This page is frozen at that release. Read the current documentation for what main says now. A link to a decision or a migration page follows main, and leaves the archive.

DeviceSparseMatrix

A CSR matrix held on the accelerator across many products.

public sealed class DeviceSparseMatrix : IDisposable

Example — the shape a caller writes.

using Lodestar.Gpu.Compute;

using var context = GpuContext.Create(preferCpu: true);
using var matrix = DeviceSparseMatrix.Upload(
    context, [0, 1, 2], [0, 1], [2.0, 3.0], rowCount: 2, columnCount: 2);

int rows = matrix.RowCount;  // => 2
int stored = matrix.NonZeroCount;  // => 2

Members — one page each.

Member What it does
DeviceSparseMatrix.Upload Uploads a CSR matrix to the accelerator
DeviceSparseMatrix.Dispose Frees the three device buffers

PropertiesRowCount, ColumnCount and NonZeroCount.

Remarks — the three CSR arrays are taken as spans rather than as a CsrMatrix. Decision 0101 forbids an edge from a core package into this one, and an edge the other way would floor this package on a published Lodestar.Abstractions for the sake of one type. A caller holding a CsrMatrix passes its RowPointers, ColumnIndices and Values directly.

Double precision, because CsrMatrix is. A consumer card runs FP64 at a fraction of FP32, and the kernel clears its gate anyway — it is bound by memory bandwidth rather than by the double-precision units, which is the one prediction this package got wrong in the kernel's favour.

Applies to — net10.0, netstandard2.1.

See alsoTiledSparseDenseProduct, the namespace index.