muSPARSE API Reference
This reference covers the muSPARSE APIs supported in MUSA SDK 5.2. It introduces the sparse data model, descriptor model, and execution workflow, presents storage formats as a separate chapter, and organizes the supported APIs into Basic, Legacy, and Generic chapters that follow the cuSPARSE document structure within the MUSA SDK 5.2 scope.
1. Introduction
1.1 What Is muSPARSE
muSPARSE provides GPU-accelerated sparse linear algebra routines for MUSA devices. The library combines two programming models:
- APIs that use raw arrays together with
musparseMatDescr_t - generic APIs that use dense and sparse vector or matrix descriptors
The generic APIs are the main way to express sparse vector operations, sparse matrix-vector operations, sparse matrix-matrix operations, and sparse-dense conversion workflows in this release.
1.2 Document Scope in MUSA SDK 5.2
Use this reference to verify the muSPARSE functions, types, parameters, storage conventions, and status values supported in MUSA SDK 5.2.
Note: Some muSPARSE declarations may appear in the public headers but are absent from this reference. These declarations are experimental in MUSA SDK 5.2 and are provided for reference only.
1.3 Supported API Groups
| API chapter | Supported APIs | Coverage in this reference |
|---|---|---|
| Basic APIs | musparseCreate, musparseDestroy, musparseSetStream, musparseGetStream, musparseSetPointerMode, musparseGetPointerMode | Detailed function entries |
| Legacy APIs | musparseCreateMatDescr, musparseDestroyMatDescr, musparseGetMatIndexBase, musparseGetMatType, musparseGetMatFillMode, musparseGetMatDiagType | Detailed function entries |
| Generic APIs | musparseCreateDnVec, musparseDestroyDnVec, musparseAxpby, musparseSpVV, musparseCreateCsr, musparseSpMV, musparseSpMM, musparseSparseToDense | Types, descriptor constructors, scoped compute APIs, and detailed function entries |
1.4 How to Use This Document
Start with Chapter 2 to understand the muSPARSE data model, descriptor roles, and workspace behavior. Use Chapter 3 for storage conventions, Chapter 4 for basic status and management APIs, Chapter 5 for legacy matrix-descriptor material, and Chapter 6 for the generic APIs covered by this reference.
2. Using the muSPARSE API
2.1 Sparse Data Model
muSPARSE operates on vectors and matrices in which only nonzero entries are stored explicitly. The generic API uses descriptors to describe those sparse objects and the dense inputs or outputs they interact with.
Typical sparse workflows in this reference include:
Here, A, B, and C may be sparse or dense depending on the API family, C' is the updated output for helper families that accumulate through matC, x and y are vectors, and op(.) selects the original, transposed, or conjugate-transposed form.
The op(A) \cdot y = \alpha \cdot x and C' := \alpha \cdot op(A) \cdot op(B) + \beta \cdot C forms are included as conceptual background only. The related helper families are experimental in MUSA SDK 5.2 and are not part of the published API scope of this reference.
2.2 Handles, Streams, And Pointer Mode
Every muSPARSE routine covered here takes a musparseHandle_t library context handle. The handle identifies the execution context used by the library call.
The management API also controls:
- the MUSA stream associated with the handle
- whether scalar pointer arguments are read from host memory or device memory
Use musparseSetStream and musparseGetStream to bind or query the stream. Use musparseSetPointerMode and musparseGetPointerMode to control whether scalar arguments such as alpha, beta, or result pointers are interpreted in host or device memory.
2.3 Generic Dense And Sparse Descriptors
The generic API uses descriptors instead of raw shape and pointer bundles.
| Descriptor type | Role |
|---|---|
musparseDnVecDescr_t | Dense vector descriptor |
musparseSpVecDescr_t | Sparse vector descriptor |
musparseDnMatDescr_t | Dense matrix descriptor |
musparseSpMatDescr_t | Sparse matrix descriptor |
The generic descriptor-constructor coverage in this reference directly includes dense vectors and CSR sparse matrices. Later operation sections use the same descriptor model for dense matrices, sparse matrices, and sparse vectors in compute or conversion routines. This reference documents CSR in detail. The musparseSparseToDense API covered here accepts sparse matrix descriptors in CSR, COO, or CSC format.
2.4 Workspace And Staged Execution
Several muSPARSE operations require caller-provided temporary storage.
In the published API scope of this reference, the compute APIs that use caller-managed workspace are:
musparseSpVVmusparseSpMVmusparseSpMMmusparseSparseToDense
The public header also declares companion helpers for workspace queries, preprocessing, analysis, or staged conversion. Those helper declarations are experimental in MUSA SDK 5.2 and are not part of the published API scope of this reference.
When a workflow includes preprocessing, keep the sparse structure unchanged between preprocess and compute steps. If the sparsity pattern changes, the previously prepared metadata or temporary storage assumptions may no longer be valid.
2.5 Generic Sparse Vector Operations
The sparse vector operations covered here use descriptor-based inputs rather than typed raw-array entry points.
The vector-level kernels covered here are:
musparseAxpby, which updates a dense vector from a sparse vectormusparseSpVV, which computes a sparse-dense inner product using caller-managed workspace
These routines use dense and sparse vector descriptors together with a compute data type and, in some cases, caller-managed workspace.
2.6 Generic Sparse Matrix-Vector Operations
The matrix-vector section covers sparse matrix-vector multiplication.
In the generic API naming used here, SpMV means sparse matrix-vector
multiplication.
For multiplication, the core operation is:
For conceptual background only, the public header also contains sparse triangular solve families with the following problem form:
This equation is included for reference only and does not indicate that the related API family is in the current published scope of this document.
The API in this family is:
musparseSpMV, which uses caller-managed workspace
2.7 Generic Sparse Matrix-Matrix Operations
The matrix-matrix section covers sparse-dense multiplication.
The main problem forms are:
For conceptual background only, the public header also contains related generic families with the following problem forms:
These equations are included for reference only and do not indicate that the related API families are in the current published scope of this document.
The API in this family is:
musparseSpMM, which uses caller-managed workspace
The public header also contains other generic matrix helper families, but they are experimental in MUSA SDK 5.2 and are not part of the published API scope of this reference.
2.8 Sparse-Dense Conversion
The conversion section covers movement from sparse matrices to dense matrix representations in the published API scope of this reference.
musparseSparseToDenseconverts a sparse matrix descriptor into a dense matrix descriptor using caller-managed workspace
The public header also declares reverse conversion helpers for dense-to-sparse workflows, but they are experimental in MUSA SDK 5.2 and are not part of the published API scope of this reference.
The sparse-dense conversion helper families support CSR, COO, and CSC sparse matrix descriptors. This scoped reference describes CSR in detail because CSR is the sparse matrix constructor covered by the published API scope. COO and CSC are standard sparse matrix formats accepted by the conversion helpers, but this reference does not expand them as separate storage-format sections.
2.9 Error Handling
All functions covered here return musparseStatus_t. A return value of MUSPARSE_STATUS_SUCCESS indicates that the API call completed successfully.
Depending on the API family, non-success returns can report:
- invalid values or unsupported configurations
- allocation, execution, or internal failures
- unsupported matrix types
3. muSPARSE Storage Formats
The muSPARSE APIs covered in MUSA SDK 5.2 use a focused subset of the full header-level storage model. This chapter describes the formats and descriptor conventions needed for:
- dense vectors
- sparse vectors
- dense matrices
- CSR sparse matrices
musparseMatDescr_tused by raw-array sparse APIs
3.1 Index Base
muSPARSE supports both zero-based and one-based indexing through
musparseIndexBase_t.
| Value | Meaning |
|---|---|
MUSPARSE_INDEX_BASE_ZERO | The first logical entry has index 0. |
MUSPARSE_INDEX_BASE_ONE | The first logical entry has index 1. |
For CSR matrices, the index base applies to the column index array and to the row offset array. Legacy matrix descriptors store the selected base explicitly.