Table of Contents

Class Gemm

Namespace
NVMathNet.LinAlg
Assembly
NVMath.Net.dll

Stateless helpers for classic cuBLAS GEMM operations. Supports single-precision (System.Single), double-precision (System.Double), and half-precision (System.Half) element types.

Computes C = alpha * op(A) * op(B) + beta * C where all matrices are in column-major layout on the GPU device.

For mixed-precision or epilog support, see NVMathNet.LinAlg.Matmul (cuBLASLt).

public static class Gemm

Inheritance

Inherited Members

Methods

Dgemm(DeviceBuffer<double>, DeviceBuffer<double>, DeviceBuffer<double>, int, int, int, double, double, bool, bool, CudaStream?)

Synchronously computes C = alpha * op(A) * op(B) + beta * C using double-precision.

public static void Dgemm(DeviceBuffer<double> a, DeviceBuffer<double> b, DeviceBuffer<double> c, int m, int n, int k, double alpha = 1, double beta = 0, bool transposeA = false, bool transposeB = false, CudaStream? stream = null)

Parameters

a DeviceBuffer<double>

Device buffer for matrix A (m × k or k × m when transposed).

b DeviceBuffer<double>

Device buffer for matrix B (k × n or n × k when transposed).

c DeviceBuffer<double>

Device buffer for matrix C (m × n); updated in place.

m int

Rows of op(A) and C.

n int

Columns of op(B) and C.

k int

Inner dimension (columns of op(A) / rows of op(B)).

alpha double

Scalar multiplier for A*B. Default: 1.

beta double

Scalar multiplier for existing values in C. Default: 0.

transposeA bool

If true, use AT.

transposeB bool

If true, use BT.

stream CudaStream?

Optional CUDA stream; null creates a private stream.

DgemmAsync(DeviceBuffer<double>, DeviceBuffer<double>, DeviceBuffer<double>, int, int, int, double, double, bool, bool, CudaStream?, CancellationToken)

Asynchronously computes C = alpha * op(A) * op(B) + beta * C using double-precision.

public static Task DgemmAsync(DeviceBuffer<double> a, DeviceBuffer<double> b, DeviceBuffer<double> c, int m, int n, int k, double alpha = 1, double beta = 0, bool transposeA = false, bool transposeB = false, CudaStream? stream = null, CancellationToken ct = default)

Parameters

a DeviceBuffer<double>

Device buffer for matrix A (m × k or k × m when transposed).

b DeviceBuffer<double>

Device buffer for matrix B (k × n or n × k when transposed).

c DeviceBuffer<double>

Device buffer for matrix C (m × n); updated in place.

m int

Rows of op(A) and C.

n int

Columns of op(B) and C.

k int

Inner dimension (columns of op(A) / rows of op(B)).

alpha double

Scalar multiplier for A*B. Default: 1.

beta double

Scalar multiplier for existing values in C. Default: 0.

transposeA bool

If true, use AT.

transposeB bool

If true, use BT.

stream CudaStream?

Optional CUDA stream; null creates a private stream.

ct CancellationToken

Cancellation token.

Returns

Task

HgemmAsync(DeviceBuffer<Half>, DeviceBuffer<Half>, DeviceBuffer<Half>, int, int, int, Half, Half, bool, bool, CudaStream?, CancellationToken)

Asynchronously computes C = alpha * op(A) * op(B) + beta * C using half-precision.

public static Task HgemmAsync(DeviceBuffer<Half> a, DeviceBuffer<Half> b, DeviceBuffer<Half> c, int m, int n, int k, Half alpha, Half beta, bool transposeA = false, bool transposeB = false, CudaStream? stream = null, CancellationToken ct = default)

Parameters

a DeviceBuffer<Half>

Device buffer for matrix A (m × k or k × m when transposed).

b DeviceBuffer<Half>

Device buffer for matrix B (k × n or n × k when transposed).

c DeviceBuffer<Half>

Device buffer for matrix C (m × n); updated in place.

m int

Rows of op(A) and C.

n int

Columns of op(B) and C.

k int

Inner dimension (columns of op(A) / rows of op(B)).

alpha Half

Scalar multiplier for A*B. Default: 1.

beta Half

Scalar multiplier for existing values in C. Default: 0.

transposeA bool

If true, use AT.

transposeB bool

If true, use BT.

stream CudaStream?

Optional CUDA stream; null creates a private stream.

ct CancellationToken

Cancellation token.

Returns

Task

Sgemm(DeviceBuffer<float>, DeviceBuffer<float>, DeviceBuffer<float>, int, int, int, float, float, bool, bool, CudaStream?)

Synchronously computes C = alpha * op(A) * op(B) + beta * C using single-precision.

public static void Sgemm(DeviceBuffer<float> a, DeviceBuffer<float> b, DeviceBuffer<float> c, int m, int n, int k, float alpha = 1, float beta = 0, bool transposeA = false, bool transposeB = false, CudaStream? stream = null)

Parameters

a DeviceBuffer<float>

Device buffer for matrix A (m × k or k × m when transposed).

b DeviceBuffer<float>

Device buffer for matrix B (k × n or n × k when transposed).

c DeviceBuffer<float>

Device buffer for matrix C (m × n); updated in place.

m int

Rows of op(A) and C.

n int

Columns of op(B) and C.

k int

Inner dimension (columns of op(A) / rows of op(B)).

alpha float

Scalar multiplier for A*B. Default: 1.

beta float

Scalar multiplier for existing values in C. Default: 0.

transposeA bool

If true, use AT.

transposeB bool

If true, use BT.

stream CudaStream?

Optional CUDA stream; null creates a private stream.

SgemmAsync(DeviceBuffer<float>, DeviceBuffer<float>, DeviceBuffer<float>, int, int, int, float, float, bool, bool, CudaStream?, CancellationToken)

Asynchronously computes C = alpha * op(A) * op(B) + beta * C using single-precision.

public static Task SgemmAsync(DeviceBuffer<float> a, DeviceBuffer<float> b, DeviceBuffer<float> c, int m, int n, int k, float alpha = 1, float beta = 0, bool transposeA = false, bool transposeB = false, CudaStream? stream = null, CancellationToken ct = default)

Parameters

a DeviceBuffer<float>

Device buffer for matrix A (m × k or k × m when transposed).

b DeviceBuffer<float>

Device buffer for matrix B (k × n or n × k when transposed).

c DeviceBuffer<float>

Device buffer for matrix C (m × n); updated in place.

m int

Rows of op(A) and C.

n int

Columns of op(B) and C.

k int

Inner dimension (columns of op(A) / rows of op(B)).

alpha float

Scalar multiplier for A*B. Default: 1.

beta float

Scalar multiplier for existing values in C. Default: 0.

transposeA bool

If true, use AT.

transposeB bool

If true, use BT.

stream CudaStream?

Optional CUDA stream; null creates a private stream.

ct CancellationToken

Cancellation token.

Returns

Task