Documentation
¶
Overview ¶
Package cusparse provides lazy-loaded bindings for the modern cuSPARSE generic API.
The legacy typed cuSPARSE API is intentionally unbound because it is deprecated upstream.
Errors ¶
A function whose C call reports a failure returns a CallError pointer naming the C function and holding the status as a Result, so errors.Is(err, ErrInvalidValue) reports an invalid argument.
Sparse Matrix Descriptors ¶
- SpMatDescr.BlockedEllGet: returns the fields of the sparse matrix descriptor spMatDescr stored in Blocked-Ellpack (ELL) format.
- SpMatDescr.CooGet: returns the fields of the sparse matrix descriptor spMatDescr stored in COO format (Array of Structures layout).
- SpMatDescr.CooSetPointers: sets the pointers of the sparse matrix descriptor spMatDescr.
- SpMatDescr.CooSetStridedBatch: sets the batchCount and the batchStride fields of the sparse matrix descriptor spMatDescr.
- SpMatDescr.CscGet: returns the fields of the sparse matrix descriptor spMatDescr stored in CSC format.
- SpMatDescr.CscSetPointers: sets the pointers of the sparse matrix descriptor spMatDescr.
- SpMatDescr.CsrGet: returns the fields of the sparse matrix descriptor spMatDescr stored in CSR format.
- SpMatDescr.CsrSetPointers: sets the pointers of the sparse matrix descriptor spMatDescr.
- SpMatDescr.CsrSetStridedBatch: sets the batchCount and the batchStride fields of the sparse matrix descriptor spMatDescr.
- ConstSpMatDescr.SpMatGetAttribute: gets the attributes of the sparse matrix descriptor spMatDescr.
- ConstSpMatDescr.SpMatGetFormat: returns the format field of the sparse matrix descriptor spMatDescr.
- ConstSpMatDescr.SpMatGetIndexBase: returns the idxBase field of the sparse matrix descriptor spMatDescr.
- ConstSpMatDescr.SpMatGetSize: returns the sizes of the sparse matrix spMatDescr.
- ConstSpMatDescr.SpMatGetStridedBatch: returns the batchCount field of the sparse matrix descriptor spMatDescr.
- SpMatDescr.MatGetValues: returns the values field of the sparse matrix descriptor spMatDescr.
- SpMatDescr.MatSetAttribute: sets the attributes of the sparse matrix descriptor spMatDescr.
- SpMatDescr.MatSetValues: sets the values field of the sparse matrix descriptor spMatDescr.
Read-Only Descriptors ¶
- ConstSpMatDescr.BlockedEllGet: returns the fields of the sparse matrix descriptor spMatDescr stored in Blocked-Ellpack (ELL) format.
- ConstSpMatDescr.CooGet: returns the fields of the sparse matrix descriptor spMatDescr stored in COO format (Array of Structures layout).
- ConstSpMatDescr.CscGet: returns the fields of the sparse matrix descriptor spMatDescr stored in CSC format.
- ConstSpMatDescr.CsrGet: returns the fields of the sparse matrix descriptor spMatDescr stored in CSR format.
- ConstDnMatDescr.DnMatGet: returns the fields of the dense matrix descriptor dnMatDescr.
- ConstDnMatDescr.DnMatGetValues: returns the values field of the dense matrix descriptor dnMatDescr.
- ConstDnVecDescr.DnVecGet: returns the fields of the dense vector descriptor dnVecDescr.
- ConstDnVecDescr.DnVecGetValues: returns the values field of the dense vector descriptor dnVecDescr.
- ConstSpMatDescr.SpMatGetValues: returns the values field of the sparse matrix descriptor spMatDescr.
- ConstSpVecDescr.SpVecGet: returns the fields of the sparse vector descriptor spVecDescr.
- ConstSpVecDescr.SpVecGetValues: returns the values field of the sparse vector descriptor spVecDescr.
Descriptor Lifecycle ¶
- Create: initializes the cuSPARSE library and creates a handle on the cuSPARSE context.
- CreateBlockedEll: initializes the sparse matrix descriptor spMatDescr for the Blocked-Ellpack (ELL) format.
- CreateBsr: initializes the sparse matrix descriptor spMatDescr for the Block Compressed Row (BSR) format.
- CreateConstBlockedEll: initializes the sparse matrix descriptor spMatDescr for the Blocked-Ellpack (ELL) format.
- CreateConstBsr: initializes the sparse matrix descriptor spMatDescr for the Block Compressed Row (BSR) format.
- CreateConstCoo: initializes the sparse matrix descriptor spMatDescr in the COO format (Structure of Arrays layout).
- CreateConstCsc: initializes the sparse matrix descriptor spMatDescr in the CSC format.
- CreateConstCsr: initializes the sparse matrix descriptor spMatDescr in the CSR format.
- CreateConstDnMat: initializes the dense matrix descriptor dnMatDescr.
- CreateConstDnVec: initializes the dense vector descriptor dnVecDescr.
- CreateConstSlicedEll: initializes the sparse matrix descriptor spMatDescr for the Sliced Ellpack (SELL) format.
- CreateConstSpVec: initializes the sparse matrix descriptor spVecDescr.
- CreateCoo: initializes the sparse matrix descriptor spMatDescr in the COO format (Structure of Arrays layout).
- CreateCsc: initializes the sparse matrix descriptor spMatDescr in the CSC format.
- CreateCsr: initializes the sparse matrix descriptor spMatDescr in the CSR format.
- CreateDnMat: initializes the dense matrix descriptor dnMatDescr.
- CreateDnVec: initializes the dense vector descriptor dnVecDescr.
- CreateSlicedEll: initializes the sparse matrix descriptor spMatDescr for the Sliced Ellpack (SELL) format.
- CreateSpVec: initializes the sparse matrix descriptor spVecDescr.
- Handle.Close: releases CPU-side resources used by the cuSPARSE library.
- ConstDnMatDescr.Close: releases the host memory allocated for the dense matrix descriptor dnMatDescr.
- ConstDnVecDescr.Close: releases the host memory allocated for the dense vector descriptor dnVecDescr.
- ConstSpMatDescr.Close: releases the host memory allocated for the sparse matrix descriptor spMatDescr.
- ConstSpVecDescr.Close: releases the host memory allocated for the sparse vector descriptor spVecDescr.
Format Conversion ¶
- Handle.DenseToSparseAnalysis: converts the dense matrix matA into a sparse matrix matB in CSR, CSC, COO, or Blocked-ELL format.
- Handle.DenseToSparseBufferSize: returns the workspace size for cusparseDenseToSparse.
- Handle.DenseToSparseConvert: converts the dense matrix matA into a sparse matrix matB in CSR, CSC, COO, or Blocked-ELL format.
- Handle.SparseToDense: converts the sparse matrix matA in CSR, CSC, or COO format into its dense representation matB.
- Handle.SparseToDenseBufferSize: returns the workspace size for Handle.SparseToDense.
Dense Matrix Descriptors ¶
- DnMatDescr.MatGet: returns the fields of the dense matrix descriptor dnMatDescr.
- ConstDnMatDescr.DnMatGetStridedBatch: returns the number of batches and the batch stride of the dense matrix descriptor dnMatDescr.
- DnMatDescr.MatGetValues: returns the values field of the dense matrix descriptor dnMatDescr.
- DnMatDescr.MatSetStridedBatch: sets the number of batches and the batch stride of the dense matrix descriptor dnMatDescr.
- DnMatDescr.MatSetValues: sets the values field of the dense matrix descriptor dnMatDescr.
Dense Vector Descriptors ¶
- DnVecDescr.VecGet: returns the fields of the dense vector descriptor dnVecDescr.
- DnVecDescr.VecGetValues: returns the values field of the dense vector descriptor dnVecDescr.
- DnVecDescr.VecSetValues: set the values field of the dense vector descriptor dnVecDescr.
Vector Operations ¶
- Handle.Gather: gathers the elements of the dense vector vecY into the sparse vector vecX.
- Handle.Scatter: scatters the elements of the sparse vector vecX into the dense vector vecY.
Library Queries ¶
- GetErrorName: returns the string representation of an error code enum name.
- GetErrorString: Returns the description string for an error code.
- Handle.PointerMode: obtains the pointer mode used by the cuSPARSE library.
- GetProperty: returns the value of the requested property.
- Handle.Stream: gets the cuSPARSE library stream, which is being used to to execute all calls to the cuSPARSE library functions.
- Handle.Version: returns the version number of the cuSPARSE library.
Logging ¶
- LoggerForceDisable.
- LoggerOpenFile: opens a logging output file in the given path.
- LoggerSetCallback: sets the logging callback function.
- LoggerSetFile: sets the logging output file.
- LoggerSetLevel: sets the value of the logging level.
- LoggerSetMask: sets the value of the logging mask.
Sampled Dense-Dense Multiplication ¶
- Handle.SDDMM: performs the multiplication of matA and matB, followed by an element-wise multiplication with the sparsity pattern of matC.
- Handle.SDDMMBufferSize: returns the workspace size for Handle.SDDMM.
- Handle.SDDMMPreprocess: prepares the workspace buffer for Handle.SDDMM, which may accelerate subsequent calls to it.
Library Configuration ¶
- Handle.SetPointerMode: sets the pointer mode used by the cuSPARSE library.
- Handle.SetStream: sets the stream to be used by the cuSPARSE library to execute its routines.
Sparse Matrix Products ¶
- Handle.SpGEMMCompute: performs the multiplication of two sparse matrices matA and matB.
- Handle.SpGEMMCopy: performs the multiplication of two sparse matrices matA and matB.
- SpGEMMCreateDescr: performs the multiplication of two sparse matrices matA and matB where the structure of the output matrix matC can be reused for multiple computations with different values.
- SpGEMMDescr.GEMMDestroyDescr: performs the multiplication of two sparse matrices matA and matB where the structure of the output matrix matC can be reused for multiple computations with different values.
- Handle.SpGEMMEstimateMemory: performs the multiplication of two sparse matrices matA and matB.
- SpGEMMDescr.GEMMGetNumProducts: performs the multiplication of two sparse matrices matA and matB.
- Handle.SpGEMMWorkEstimation: performs the multiplication of two sparse matrices matA and matB.
Sparse Matrix-Matrix Operations ¶
- Handle.SpMM: performs the multiplication of a sparse matrix matA and a dense matrix matB.
- Handle.SpMMBufferSize: returns the workspace size for Handle.SpMM.
- Handle.SpMMPreprocess: prepares the workspace buffer for Handle.SpMM, which may accelerate subsequent calls to it.
Sparse Matrix-Vector Operations ¶
- Handle.SpMV: performs the multiplication of a sparse matrix matA and a dense vector vecX.
- Handle.SpMVBufferSize: returns the workspace size for Handle.SpMV.
- Handle.SpMVOp: is only available if macro CUSPARSE_ENABLE_EXPERIMENTAL_API is defined.
- Handle.SpMVOpBufferSize: returns the workspace size for Handle.SpMVOp.
- Handle.SpMVOpCreateDescr: is only available if macro CUSPARSE_ENABLE_EXPERIMENTAL_API is defined.
- Handle.SpMVOpCreatePlan: is only available if macro CUSPARSE_ENABLE_EXPERIMENTAL_API is defined.
- SpMVOpDescr.MVOpDestroyDescr: is only available if macro CUSPARSE_ENABLE_EXPERIMENTAL_API is defined.
- SpMVOpPlan.MVOpDestroyPlan: is only available if macro CUSPARSE_ENABLE_EXPERIMENTAL_API is defined.
- Handle.SpMVOpSetGlobalUserData: is only available if macro CUSPARSE_ENABLE_EXPERIMENTAL_API is defined.
- Handle.SpMVPreprocess: prepares the workspace buffer for Handle.SpMV, which may accelerate subsequent calls to it.
Sparse Triangular Solves ¶
- Handle.SpSMAnalysis: solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
- Handle.SpSMBufferSize: returns the workspace size for cusparseSpSM.
- SpSMCreateDescr: solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
- SpSMDescr.SMDestroyDescr: solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
- Handle.SpSMSolve: solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
- Handle.SpSMUpdateMatrix: solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
- Handle.SpSVAnalysis: solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
- Handle.SpSVBufferSize: returns the workspace size for cusparseSpSV.
- SpSVCreateDescr: solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
- SpSVDescr.SVDestroyDescr: solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
- Handle.SpSVSolve: solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
- Handle.SpSVUpdateMatrix: solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
Sparse Vector Descriptors ¶
- SpVecDescr.VecGet: returns the fields of the sparse vector descriptor spVecDescr.
- ConstSpVecDescr.SpVecGetIndexBase: returns the idxBase field of the sparse vector descriptor spVecDescr.
- SpVecDescr.VecGetValues: returns the values field of the sparse vector descriptor spVecDescr.
- SpVecDescr.VecSetValues: set the values field of the sparse vector descriptor spVecDescr.
Other ¶
- SpMatDescr.BsrSetStridedBatch: sets the batchCount and the batchStride fields of the sparse matrix descriptor spMatDescr.
Code generated by cusparse-survey. DO NOT EDIT.
Example ¶
Example creates a cuSPARSE handle and a CSR matrix descriptor for the generic API. It returns early when the cuSPARSE library is not available. The row-offset, column-index, and value arrays are CUDA device pointers, e.g. from the driver package's MemAlloc. It has no Output comment, so it is compiled but not run: what it prints depends on the host's cuSPARSE.
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/cusparse"
"github.com/tmc/lib/nvidia/driver"
)
func main() {
h, err := cusparse.Create()
if err != nil {
fmt.Println("cuSPARSE unavailable:", err)
return
}
defer h.Close()
version, err := h.Version()
if err != nil {
fmt.Println("version:", err)
return
}
fmt.Println("cuSPARSE version:", version)
var dRowOffsets, dColInd, dValues driver.DevicePtr // device allocations
mat, err := cusparse.CreateCsr(4, 4, 9, dRowOffsets, dColInd, dValues,
cusparse.Index32I, cusparse.Index32I,
cusparse.IndexBaseZero, cusparse.R32F)
if err != nil {
fmt.Println("csr:", err)
return
}
desc := cusparse.ConstSpMatDescr(mat)
defer desc.Close()
fmt.Println("4x4 CSR descriptor ready")
}
Output:
Index ¶
- Constants
- func Close() error
- func GetErrorName(status Result) (string, error)
- func GetErrorString(status Result) (string, error)
- func GetProperty(type_ LibraryPropertyType) (int32, error)
- func Has(symbol string) bool
- func HasBlockedEllGet() bool
- func HasBsrSetStridedBatch() bool
- func HasConstBlockedEllGet() bool
- func HasConstCooGet() bool
- func HasConstCscGet() bool
- func HasConstCsrGet() bool
- func HasConstDnMatGet() bool
- func HasConstDnMatGetValues() bool
- func HasConstDnVecGet() bool
- func HasConstDnVecGetValues() bool
- func HasConstSpMatGetValues() bool
- func HasConstSpVecGet() bool
- func HasConstSpVecGetValues() bool
- func HasCooGet() bool
- func HasCooSetPointers() bool
- func HasCooSetStridedBatch() bool
- func HasCreate() bool
- func HasCreateBlockedEll() bool
- func HasCreateBsr() bool
- func HasCreateConstBlockedEll() bool
- func HasCreateConstBsr() bool
- func HasCreateConstCoo() bool
- func HasCreateConstCsc() bool
- func HasCreateConstCsr() bool
- func HasCreateConstDnMat() bool
- func HasCreateConstDnVec() bool
- func HasCreateConstSlicedEll() bool
- func HasCreateConstSpVec() bool
- func HasCreateCoo() bool
- func HasCreateCsc() bool
- func HasCreateCsr() bool
- func HasCreateDnMat() bool
- func HasCreateDnVec() bool
- func HasCreateSlicedEll() bool
- func HasCreateSpVec() bool
- func HasCscGet() bool
- func HasCscSetPointers() bool
- func HasCsrGet() bool
- func HasCsrSetPointers() bool
- func HasCsrSetStridedBatch() bool
- func HasDenseToSparseAnalysis() bool
- func HasDenseToSparseBufferSize() bool
- func HasDenseToSparseConvert() bool
- func HasDestroy() bool
- func HasDestroyDnMat() bool
- func HasDestroyDnVec() bool
- func HasDestroySpMat() bool
- func HasDestroySpVec() bool
- func HasDnMatGet() bool
- func HasDnMatGetStridedBatch() bool
- func HasDnMatGetValues() bool
- func HasDnMatSetStridedBatch() bool
- func HasDnMatSetValues() bool
- func HasDnVecGet() bool
- func HasDnVecGetValues() bool
- func HasDnVecSetValues() bool
- func HasGather() bool
- func HasGetErrorName() bool
- func HasGetErrorString() bool
- func HasGetPointerMode() bool
- func HasGetProperty() bool
- func HasGetStream() bool
- func HasGetVersion() bool
- func HasLoggerForceDisable() bool
- func HasLoggerOpenFile() bool
- func HasLoggerSetCallback() bool
- func HasLoggerSetFile() bool
- func HasLoggerSetLevel() bool
- func HasLoggerSetMask() bool
- func HasSDDMM() bool
- func HasSDDMMBufferSize() bool
- func HasSDDMMPreprocess() bool
- func HasScatter() bool
- func HasSetPointerMode() bool
- func HasSetStream() bool
- func HasSpGEMMCompute() bool
- func HasSpGEMMCopy() bool
- func HasSpGEMMCreateDescr() bool
- func HasSpGEMMDestroyDescr() bool
- func HasSpGEMMEstimateMemory() bool
- func HasSpGEMMGetNumProducts() bool
- func HasSpGEMMWorkEstimation() bool
- func HasSpGEMMreuseCompute() bool
- func HasSpGEMMreuseCopy() bool
- func HasSpGEMMreuseNnz() bool
- func HasSpGEMMreuseWorkEstimation() bool
- func HasSpMM() bool
- func HasSpMMBufferSize() bool
- func HasSpMMPreprocess() bool
- func HasSpMV() bool
- func HasSpMVBufferSize() bool
- func HasSpMVOp() bool
- func HasSpMVOpBufferSize() bool
- func HasSpMVOpBufferSizeWithAlgorithm() bool
- func HasSpMVOpCreateDescr() bool
- func HasSpMVOpCreateDescrWithAlgorithm() bool
- func HasSpMVOpCreatePlan() bool
- func HasSpMVOpDestroyDescr() bool
- func HasSpMVOpDestroyPlan() bool
- func HasSpMVOpSetGlobalUserData() bool
- func HasSpMVPreprocess() bool
- func HasSpMatGetAttribute() bool
- func HasSpMatGetFormat() bool
- func HasSpMatGetIndexBase() bool
- func HasSpMatGetSize() bool
- func HasSpMatGetStridedBatch() bool
- func HasSpMatGetValues() bool
- func HasSpMatSetAttribute() bool
- func HasSpMatSetValues() bool
- func HasSpSMAnalysis() bool
- func HasSpSMBufferSize() bool
- func HasSpSMCreateDescr() bool
- func HasSpSMDestroyDescr() bool
- func HasSpSMSolve() bool
- func HasSpSMUpdateMatrix() bool
- func HasSpSVAnalysis() bool
- func HasSpSVBufferSize() bool
- func HasSpSVCreateDescr() bool
- func HasSpSVDestroyDescr() bool
- func HasSpSVSolve() bool
- func HasSpSVUpdateMatrix() bool
- func HasSpVecGet() bool
- func HasSpVecGetIndexBase() bool
- func HasSpVecGetValues() bool
- func HasSpVecSetValues() bool
- func HasSparseToDense() bool
- func HasSparseToDenseBufferSize() bool
- func Load(path string) error
- func Loaded() bool
- func LoggerForceDisable() error
- func LoggerOpenFile(logFile *byte) error
- func LoggerSetCallback(callback LoggerCallback) error
- func LoggerSetFile(file *FILE) error
- func LoggerSetLevel(level int32) error
- func LoggerSetMask(mask int32) error
- func Path() string
- type Action
- type ApiParam
- type BindFailure
- type Bsric02Info
- type Bsrilu02Info
- type Bsrsm2Info
- type Bsrsv2Info
- type CallError
- type ColorAlg
- type ColorInfo
- type ConstDnMatDescr
- func (c *ConstDnMatDescr) Close() error
- func (c ConstDnMatDescr) DnMatGet(rows *int64, cols *int64, ld *int64, values *uintptr, type_ *DataType, ...) error
- func (c ConstDnMatDescr) DnMatGetStridedBatch() (batchCount int32, batchStride int64, err error)
- func (c ConstDnMatDescr) DnMatGetValues(values *uintptr) error
- type ConstDnVecDescr
- type ConstSpMatDescr
- func CreateConstBlockedEll(rows int64, cols int64, ellBlockSize int64, ellCols int64, ...) (ConstSpMatDescr, error)
- func CreateConstBsr(brows int64, bcols int64, bnnz int64, rowBlockDim int64, colBlockDim int64, ...) (ConstSpMatDescr, error)
- func CreateConstCoo(rows int64, cols int64, nnz int64, cooRowInd driver.DevicePtr, ...) (ConstSpMatDescr, error)
- func CreateConstCsc(rows int64, cols int64, nnz int64, cscColOffsets driver.DevicePtr, ...) (ConstSpMatDescr, error)
- func CreateConstCsr(rows int64, cols int64, nnz int64, csrRowOffsets driver.DevicePtr, ...) (ConstSpMatDescr, error)
- func CreateConstSlicedEll(rows int64, cols int64, nnz int64, sellValuesSize int64, sliceSize int64, ...) (ConstSpMatDescr, error)
- func (c ConstSpMatDescr) BlockedEllGet(rows *int64, cols *int64, ellBlockSize *int64, ellCols *int64, ...) error
- func (c *ConstSpMatDescr) Close() error
- func (c ConstSpMatDescr) CooGet(rows *int64, cols *int64, nnz *int64, cooRowInd *uintptr, cooColInd *uintptr, ...) error
- func (c ConstSpMatDescr) CscGet(rows *int64, cols *int64, nnz *int64, cscColOffsets *uintptr, ...) error
- func (c ConstSpMatDescr) CsrGet(rows *int64, cols *int64, nnz *int64, csrRowOffsets *uintptr, ...) error
- func (c ConstSpMatDescr) SpMatGetAttribute(attribute SpMatAttribute, data unsafe.Pointer, dataSize uint) error
- func (c ConstSpMatDescr) SpMatGetFormat() (Format, error)
- func (c ConstSpMatDescr) SpMatGetIndexBase() (IndexBase, error)
- func (c ConstSpMatDescr) SpMatGetSize() (rows int64, cols int64, nnz int64, err error)
- func (c ConstSpMatDescr) SpMatGetStridedBatch() (int32, error)
- func (c ConstSpMatDescr) SpMatGetValues(values *uintptr) error
- type ConstSpVecDescr
- type Csr2CscAlg
- type Csric02Info
- type Csrilu02Info
- type Csru2csrInfo
- type DataType
- type DenseToSparseAlg
- type DiagType
- type Direction
- type DnMatDescr
- func (d DnMatDescr) MatGet(rows *int64, cols *int64, ld *int64, values *uintptr, type_ *DataType, ...) error
- func (d DnMatDescr) MatGetValues(values *uintptr) error
- func (d DnMatDescr) MatSetStridedBatch(batchCount int32, batchStride int64) error
- func (d DnMatDescr) MatSetValues(values driver.DevicePtr) error
- type DnVecDescr
- type FILE
- type FillMode
- type Format
- type Handle
- func (h *Handle) Close() error
- func (h Handle) DenseToSparseAnalysis(matA ConstDnMatDescr, matB SpMatDescr, alg DenseToSparseAlg, ...) error
- func (h Handle) DenseToSparseBufferSize(matA ConstDnMatDescr, matB SpMatDescr, alg DenseToSparseAlg) (uint, error)
- func (h Handle) DenseToSparseConvert(matA ConstDnMatDescr, matB SpMatDescr, alg DenseToSparseAlg, ...) error
- func (h Handle) Gather(vecY ConstDnVecDescr, vecX SpVecDescr) error
- func (h Handle) PointerMode() (PointerMode, error)
- func (h Handle) SDDMM(opA Operation, opB Operation, alpha Scalar, matA ConstDnMatDescr, ...) error
- func (h Handle) SDDMMBufferSize(opA Operation, opB Operation, alpha Scalar, matA ConstDnMatDescr, ...) (uint, error)
- func (h Handle) SDDMMPreprocess(opA Operation, opB Operation, alpha Scalar, matA ConstDnMatDescr, ...) error
- func (h Handle) Scatter(vecX ConstSpVecDescr, vecY DnVecDescr) error
- func (h Handle) SetPointerMode(mode PointerMode) error
- func (h Handle) SetStream(streamId driver.Stream) error
- func (h Handle) SpGEMMCompute(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, ...) error
- func (h Handle) SpGEMMCopy(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, ...) error
- func (h Handle) SpGEMMEstimateMemory(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, ...) error
- func (h Handle) SpGEMMWorkEstimation(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, ...) error
- func (h Handle) SpGEMMreuseCompute(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, ...) errordeprecated
- func (h Handle) SpGEMMreuseCopy(opA Operation, opB Operation, matA ConstSpMatDescr, matB ConstSpMatDescr, ...) errordeprecated
- func (h Handle) SpGEMMreuseNnz(opA Operation, opB Operation, matA ConstSpMatDescr, matB ConstSpMatDescr, ...) errordeprecated
- func (h Handle) SpGEMMreuseWorkEstimation(opA Operation, opB Operation, matA ConstSpMatDescr, matB ConstSpMatDescr, ...) errordeprecated
- func (h Handle) SpMM(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, ...) error
- func (h Handle) SpMMBufferSize(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, ...) (uint, error)
- func (h Handle) SpMMPreprocess(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, ...) error
- func (h Handle) SpMV(opA Operation, alpha Scalar, matA ConstSpMatDescr, vecX ConstDnVecDescr, ...) error
- func (h Handle) SpMVBufferSize(opA Operation, alpha Scalar, matA ConstSpMatDescr, vecX ConstDnVecDescr, ...) (uint, error)
- func (h Handle) SpMVOp(plan SpMVOpPlan, alpha Scalar, beta Scalar, vecX ConstDnVecDescr, ...) error
- func (h Handle) SpMVOpBufferSize(opA Operation, matA ConstSpMatDescr, vecX ConstDnVecDescr, vecY DnVecDescr, ...) (uint, error)
- func (h Handle) SpMVOpBufferSizeWithAlgorithm(opA Operation, matA ConstSpMatDescr, vecX ConstDnVecDescr, vecY DnVecDescr, ...) (uint, error)
- func (h Handle) SpMVOpCreateDescr(opA Operation, matA ConstSpMatDescr, vecX ConstDnVecDescr, vecY DnVecDescr, ...) (SpMVOpDescr, error)
- func (h Handle) SpMVOpCreateDescrWithAlgorithm(opA Operation, matA ConstSpMatDescr, vecX ConstDnVecDescr, vecY DnVecDescr, ...) (SpMVOpDescr, error)
- func (h Handle) SpMVOpCreatePlan(desc SpMVOpDescr, code uintptr, codeSize uint) (SpMVOpPlan, error)
- func (h Handle) SpMVOpSetGlobalUserData(plan SpMVOpPlan, globalDataName *byte, inputData uintptr, dataSize uint) error
- func (h Handle) SpMVPreprocess(opA Operation, alpha Scalar, matA ConstSpMatDescr, vecX ConstDnVecDescr, ...) error
- func (h Handle) SpSMAnalysis(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, ...) error
- func (h Handle) SpSMBufferSize(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, ...) (uint, error)
- func (h Handle) SpSMSolve(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, ...) error
- func (h Handle) SpSMUpdateMatrix(spsmDescr SpSMDescr, newValues driver.DevicePtr, updatePart SpSMUpdate) error
- func (h Handle) SpSVAnalysis(opA Operation, alpha Scalar, matA ConstSpMatDescr, vecX ConstDnVecDescr, ...) error
- func (h Handle) SpSVBufferSize(opA Operation, alpha Scalar, matA ConstSpMatDescr, vecX ConstDnVecDescr, ...) (uint, error)
- func (h Handle) SpSVSolve(opA Operation, alpha Scalar, matA ConstSpMatDescr, vecX ConstDnVecDescr, ...) error
- func (h Handle) SpSVUpdateMatrix(spsvDescr SpSVDescr, newValues driver.DevicePtr, updatePart SpSVUpdate) error
- func (h Handle) SparseToDense(matA ConstSpMatDescr, matB DnMatDescr, alg SparseToDenseAlg, ...) error
- func (h Handle) SparseToDenseBufferSize(matA ConstSpMatDescr, matB DnMatDescr, alg SparseToDenseAlg) (uint, error)
- func (h Handle) Stream() (driver.Stream, error)
- func (h Handle) Version() (int32, error)
- type IndexBase
- type IndexType
- type LibraryAttempt
- type LibraryConflictError
- type LibraryError
- type LibraryPropertyType
- type LoggerCallback
- type MatDescr
- type MatrixType
- type Operation
- type Order
- type PointerMode
- type PruneInfo
- type Result
- type SDDMMAlg
- type Scalar
- type ScalarError
- type SolvePolicy
- type SpGEAMAlg
- type SpGEAMDescr
- type SpGEMMAlg
- type SpGEMMDescr
- type SpMMAlg
- type SpMMOpAlg
- type SpMMOpPlan
- type SpMVAlg
- type SpMVDescr
- type SpMVOpAlg
- type SpMVOpDescr
- type SpMVOpPlan
- type SpMatAttribute
- type SpMatConvertAlg
- type SpMatConvertDescr
- type SpMatDescr
- func CreateBlockedEll(rows int64, cols int64, ellBlockSize int64, ellCols int64, ...) (SpMatDescr, error)
- func CreateBsr(brows int64, bcols int64, bnnz int64, rowBlockSize int64, colBlockSize int64, ...) (SpMatDescr, error)
- func CreateCoo(rows int64, cols int64, nnz int64, cooRowInd driver.DevicePtr, ...) (SpMatDescr, error)
- func CreateCsc(rows int64, cols int64, nnz int64, cscColOffsets driver.DevicePtr, ...) (SpMatDescr, error)
- func CreateCsr(rows int64, cols int64, nnz int64, csrRowOffsets driver.DevicePtr, ...) (SpMatDescr, error)
- func CreateSlicedEll(rows int64, cols int64, nnz int64, sellValuesSize int64, sliceSize int64, ...) (SpMatDescr, error)
- func (s SpMatDescr) BlockedEllGet(rows *int64, cols *int64, ellBlockSize *int64, ellCols *int64, ...) error
- func (s SpMatDescr) BsrSetStridedBatch(batchCount int32, offsetsBatchStride int64, columnsBatchStride int64, ...) error
- func (s SpMatDescr) CooGet(rows *int64, cols *int64, nnz *int64, cooRowInd *uintptr, cooColInd *uintptr, ...) error
- func (s SpMatDescr) CooSetPointers(cooRows driver.DevicePtr, cooColumns driver.DevicePtr, ...) error
- func (s SpMatDescr) CooSetStridedBatch(batchCount int32, batchStride int64) error
- func (s SpMatDescr) CscGet(rows *int64, cols *int64, nnz *int64, cscColOffsets *uintptr, ...) error
- func (s SpMatDescr) CscSetPointers(cscColOffsets driver.DevicePtr, cscRowInd driver.DevicePtr, ...) error
- func (s SpMatDescr) CsrGet(rows *int64, cols *int64, nnz *int64, csrRowOffsets *uintptr, ...) error
- func (s SpMatDescr) CsrSetPointers(csrRowOffsets driver.DevicePtr, csrColInd driver.DevicePtr, ...) error
- func (s SpMatDescr) CsrSetStridedBatch(batchCount int32, offsetsBatchStride int64, columnsValuesBatchStride int64) error
- func (s SpMatDescr) MatGetValues(values *uintptr) error
- func (s SpMatDescr) MatSetAttribute(attribute SpMatAttribute, data unsafe.Pointer, dataSize uint) error
- func (s SpMatDescr) MatSetValues(values driver.DevicePtr) error
- type SpMatPointers
- type SpMatSizes
- type SpMatStorage
- type SpSMAlg
- type SpSMDescr
- type SpSMUpdate
- type SpSVAlg
- type SpSVDescr
- type SpSVUpdate
- type SpVecDescr
- type SparseToDenseAlg
- type SymbolError
- type SymmetryType
- type VersionMismatchError
Examples ¶
Constants ¶
const ( // Version is CUSPARSE_VERSION. This is the version of the headers the bindings were generated from, not of the library loaded at run time. [Handle.Version] reports that. Version = 12904 // VerBuild is CUSPARSE_VER_BUILD. This is the version of the headers the bindings were generated from, not of the library loaded at run time. [Handle.Version] reports that. VerBuild = 2 // VerMajor is CUSPARSE_VER_MAJOR. This is the version of the headers the bindings were generated from, not of the library loaded at run time. [Handle.Version] reports that. VerMajor = 12 // VerMinor is CUSPARSE_VER_MINOR. This is the version of the headers the bindings were generated from, not of the library loaded at run time. [Handle.Version] reports that. VerMinor = 9 // VerPatch is CUSPARSE_VER_PATCH. This is the version of the headers the bindings were generated from, not of the library loaded at run time. [Handle.Version] reports that. VerPatch = 4 )
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close() error
Close unloads the library and clears all bound function pointers.
The function pointers are package-level state, so Close must not be called concurrently with any other call into this package: doing so is a use-after-free. It is intended for test teardown, not for reclaiming a live library.
func GetErrorName ¶
GetErrorName returns the string representation of an error code enum name.
If the error code is not recognized, “unrecognized error code” is returned.
- status: Error code to convert to string
Wraps cusparseGetErrorName.
func GetErrorString ¶
GetErrorString returns the description string for an error code.
If the error code is not recognized, “unrecognized error code” is returned.
- status: Error code to convert to string
Wraps cusparseGetErrorString.
func GetProperty ¶
func GetProperty(type_ LibraryPropertyType) (int32, error)
GetProperty returns the value of the requested property.
Refer to libraryPropertyType for supported types. libraryPropertyType (defined in library_types.h):
- MAJOR_VERSION: Enumerator to query the major version
- MINOR_VERSION: Enumerator to query the minor version
- PATCH_LEVEL: Number to identify the patch level
Parameters:
- type_: Requested property
- value: Value of the requested property
Wraps cusparseGetProperty.
func Has ¶
Has reports whether the named C symbol resolved in the loaded library, loading it first if necessary. It returns false if the library failed to load. Use it to gate on capabilities before calling into them.
func HasBlockedEllGet ¶
func HasBlockedEllGet() bool
HasBlockedEllGet reports whether cusparseBlockedEllGet resolved in the loaded library.
func HasBsrSetStridedBatch ¶
func HasBsrSetStridedBatch() bool
HasBsrSetStridedBatch reports whether cusparseBsrSetStridedBatch resolved in the loaded library.
func HasConstBlockedEllGet ¶
func HasConstBlockedEllGet() bool
HasConstBlockedEllGet reports whether cusparseConstBlockedEllGet resolved in the loaded library.
func HasConstCooGet ¶
func HasConstCooGet() bool
HasConstCooGet reports whether cusparseConstCooGet resolved in the loaded library.
func HasConstCscGet ¶
func HasConstCscGet() bool
HasConstCscGet reports whether cusparseConstCscGet resolved in the loaded library.
func HasConstCsrGet ¶
func HasConstCsrGet() bool
HasConstCsrGet reports whether cusparseConstCsrGet resolved in the loaded library.
func HasConstDnMatGet ¶
func HasConstDnMatGet() bool
HasConstDnMatGet reports whether cusparseConstDnMatGet resolved in the loaded library.
func HasConstDnMatGetValues ¶
func HasConstDnMatGetValues() bool
HasConstDnMatGetValues reports whether cusparseConstDnMatGetValues resolved in the loaded library.
func HasConstDnVecGet ¶
func HasConstDnVecGet() bool
HasConstDnVecGet reports whether cusparseConstDnVecGet resolved in the loaded library.
func HasConstDnVecGetValues ¶
func HasConstDnVecGetValues() bool
HasConstDnVecGetValues reports whether cusparseConstDnVecGetValues resolved in the loaded library.
func HasConstSpMatGetValues ¶
func HasConstSpMatGetValues() bool
HasConstSpMatGetValues reports whether cusparseConstSpMatGetValues resolved in the loaded library.
func HasConstSpVecGet ¶
func HasConstSpVecGet() bool
HasConstSpVecGet reports whether cusparseConstSpVecGet resolved in the loaded library.
func HasConstSpVecGetValues ¶
func HasConstSpVecGetValues() bool
HasConstSpVecGetValues reports whether cusparseConstSpVecGetValues resolved in the loaded library.
func HasCooGet ¶
func HasCooGet() bool
HasCooGet reports whether cusparseCooGet resolved in the loaded library.
func HasCooSetPointers ¶
func HasCooSetPointers() bool
HasCooSetPointers reports whether cusparseCooSetPointers resolved in the loaded library.
func HasCooSetStridedBatch ¶
func HasCooSetStridedBatch() bool
HasCooSetStridedBatch reports whether cusparseCooSetStridedBatch resolved in the loaded library.
func HasCreate ¶
func HasCreate() bool
HasCreate reports whether cusparseCreate resolved in the loaded library.
func HasCreateBlockedEll ¶
func HasCreateBlockedEll() bool
HasCreateBlockedEll reports whether cusparseCreateBlockedEll resolved in the loaded library.
func HasCreateBsr ¶
func HasCreateBsr() bool
HasCreateBsr reports whether cusparseCreateBsr resolved in the loaded library.
func HasCreateConstBlockedEll ¶
func HasCreateConstBlockedEll() bool
HasCreateConstBlockedEll reports whether cusparseCreateConstBlockedEll resolved in the loaded library.
func HasCreateConstBsr ¶
func HasCreateConstBsr() bool
HasCreateConstBsr reports whether cusparseCreateConstBsr resolved in the loaded library.
func HasCreateConstCoo ¶
func HasCreateConstCoo() bool
HasCreateConstCoo reports whether cusparseCreateConstCoo resolved in the loaded library.
func HasCreateConstCsc ¶
func HasCreateConstCsc() bool
HasCreateConstCsc reports whether cusparseCreateConstCsc resolved in the loaded library.
func HasCreateConstCsr ¶
func HasCreateConstCsr() bool
HasCreateConstCsr reports whether cusparseCreateConstCsr resolved in the loaded library.
func HasCreateConstDnMat ¶
func HasCreateConstDnMat() bool
HasCreateConstDnMat reports whether cusparseCreateConstDnMat resolved in the loaded library.
func HasCreateConstDnVec ¶
func HasCreateConstDnVec() bool
HasCreateConstDnVec reports whether cusparseCreateConstDnVec resolved in the loaded library.
func HasCreateConstSlicedEll ¶
func HasCreateConstSlicedEll() bool
HasCreateConstSlicedEll reports whether cusparseCreateConstSlicedEll resolved in the loaded library.
func HasCreateConstSpVec ¶
func HasCreateConstSpVec() bool
HasCreateConstSpVec reports whether cusparseCreateConstSpVec resolved in the loaded library.
func HasCreateCoo ¶
func HasCreateCoo() bool
HasCreateCoo reports whether cusparseCreateCoo resolved in the loaded library.
func HasCreateCsc ¶
func HasCreateCsc() bool
HasCreateCsc reports whether cusparseCreateCsc resolved in the loaded library.
func HasCreateCsr ¶
func HasCreateCsr() bool
HasCreateCsr reports whether cusparseCreateCsr resolved in the loaded library.
func HasCreateDnMat ¶
func HasCreateDnMat() bool
HasCreateDnMat reports whether cusparseCreateDnMat resolved in the loaded library.
func HasCreateDnVec ¶
func HasCreateDnVec() bool
HasCreateDnVec reports whether cusparseCreateDnVec resolved in the loaded library.
func HasCreateSlicedEll ¶
func HasCreateSlicedEll() bool
HasCreateSlicedEll reports whether cusparseCreateSlicedEll resolved in the loaded library.
func HasCreateSpVec ¶
func HasCreateSpVec() bool
HasCreateSpVec reports whether cusparseCreateSpVec resolved in the loaded library.
func HasCscGet ¶
func HasCscGet() bool
HasCscGet reports whether cusparseCscGet resolved in the loaded library.
func HasCscSetPointers ¶
func HasCscSetPointers() bool
HasCscSetPointers reports whether cusparseCscSetPointers resolved in the loaded library.
func HasCsrGet ¶
func HasCsrGet() bool
HasCsrGet reports whether cusparseCsrGet resolved in the loaded library.
func HasCsrSetPointers ¶
func HasCsrSetPointers() bool
HasCsrSetPointers reports whether cusparseCsrSetPointers resolved in the loaded library.
func HasCsrSetStridedBatch ¶
func HasCsrSetStridedBatch() bool
HasCsrSetStridedBatch reports whether cusparseCsrSetStridedBatch resolved in the loaded library.
func HasDenseToSparseAnalysis ¶
func HasDenseToSparseAnalysis() bool
HasDenseToSparseAnalysis reports whether cusparseDenseToSparse_analysis resolved in the loaded library.
func HasDenseToSparseBufferSize ¶
func HasDenseToSparseBufferSize() bool
HasDenseToSparseBufferSize reports whether cusparseDenseToSparse_bufferSize resolved in the loaded library.
func HasDenseToSparseConvert ¶
func HasDenseToSparseConvert() bool
HasDenseToSparseConvert reports whether cusparseDenseToSparse_convert resolved in the loaded library.
func HasDestroy ¶
func HasDestroy() bool
HasDestroy reports whether cusparseDestroy resolved in the loaded library.
func HasDestroyDnMat ¶
func HasDestroyDnMat() bool
HasDestroyDnMat reports whether cusparseDestroyDnMat resolved in the loaded library.
func HasDestroyDnVec ¶
func HasDestroyDnVec() bool
HasDestroyDnVec reports whether cusparseDestroyDnVec resolved in the loaded library.
func HasDestroySpMat ¶
func HasDestroySpMat() bool
HasDestroySpMat reports whether cusparseDestroySpMat resolved in the loaded library.
func HasDestroySpVec ¶
func HasDestroySpVec() bool
HasDestroySpVec reports whether cusparseDestroySpVec resolved in the loaded library.
func HasDnMatGet ¶
func HasDnMatGet() bool
HasDnMatGet reports whether cusparseDnMatGet resolved in the loaded library.
func HasDnMatGetStridedBatch ¶
func HasDnMatGetStridedBatch() bool
HasDnMatGetStridedBatch reports whether cusparseDnMatGetStridedBatch resolved in the loaded library.
func HasDnMatGetValues ¶
func HasDnMatGetValues() bool
HasDnMatGetValues reports whether cusparseDnMatGetValues resolved in the loaded library.
func HasDnMatSetStridedBatch ¶
func HasDnMatSetStridedBatch() bool
HasDnMatSetStridedBatch reports whether cusparseDnMatSetStridedBatch resolved in the loaded library.
func HasDnMatSetValues ¶
func HasDnMatSetValues() bool
HasDnMatSetValues reports whether cusparseDnMatSetValues resolved in the loaded library.
func HasDnVecGet ¶
func HasDnVecGet() bool
HasDnVecGet reports whether cusparseDnVecGet resolved in the loaded library.
func HasDnVecGetValues ¶
func HasDnVecGetValues() bool
HasDnVecGetValues reports whether cusparseDnVecGetValues resolved in the loaded library.
func HasDnVecSetValues ¶
func HasDnVecSetValues() bool
HasDnVecSetValues reports whether cusparseDnVecSetValues resolved in the loaded library.
func HasGather ¶
func HasGather() bool
HasGather reports whether cusparseGather resolved in the loaded library.
func HasGetErrorName ¶
func HasGetErrorName() bool
HasGetErrorName reports whether cusparseGetErrorName resolved in the loaded library.
func HasGetErrorString ¶
func HasGetErrorString() bool
HasGetErrorString reports whether cusparseGetErrorString resolved in the loaded library.
func HasGetPointerMode ¶
func HasGetPointerMode() bool
HasGetPointerMode reports whether cusparseGetPointerMode resolved in the loaded library.
func HasGetProperty ¶
func HasGetProperty() bool
HasGetProperty reports whether cusparseGetProperty resolved in the loaded library.
func HasGetStream ¶
func HasGetStream() bool
HasGetStream reports whether cusparseGetStream resolved in the loaded library.
func HasGetVersion ¶
func HasGetVersion() bool
HasGetVersion reports whether cusparseGetVersion resolved in the loaded library.
func HasLoggerForceDisable ¶
func HasLoggerForceDisable() bool
HasLoggerForceDisable reports whether cusparseLoggerForceDisable resolved in the loaded library.
func HasLoggerOpenFile ¶
func HasLoggerOpenFile() bool
HasLoggerOpenFile reports whether cusparseLoggerOpenFile resolved in the loaded library.
func HasLoggerSetCallback ¶
func HasLoggerSetCallback() bool
HasLoggerSetCallback reports whether cusparseLoggerSetCallback resolved in the loaded library.
func HasLoggerSetFile ¶
func HasLoggerSetFile() bool
HasLoggerSetFile reports whether cusparseLoggerSetFile resolved in the loaded library.
func HasLoggerSetLevel ¶
func HasLoggerSetLevel() bool
HasLoggerSetLevel reports whether cusparseLoggerSetLevel resolved in the loaded library.
func HasLoggerSetMask ¶
func HasLoggerSetMask() bool
HasLoggerSetMask reports whether cusparseLoggerSetMask resolved in the loaded library.
func HasSDDMM ¶
func HasSDDMM() bool
HasSDDMM reports whether cusparseSDDMM resolved in the loaded library.
func HasSDDMMBufferSize ¶
func HasSDDMMBufferSize() bool
HasSDDMMBufferSize reports whether cusparseSDDMM_bufferSize resolved in the loaded library.
func HasSDDMMPreprocess ¶
func HasSDDMMPreprocess() bool
HasSDDMMPreprocess reports whether cusparseSDDMM_preprocess resolved in the loaded library.
func HasScatter ¶
func HasScatter() bool
HasScatter reports whether cusparseScatter resolved in the loaded library.
func HasSetPointerMode ¶
func HasSetPointerMode() bool
HasSetPointerMode reports whether cusparseSetPointerMode resolved in the loaded library.
func HasSetStream ¶
func HasSetStream() bool
HasSetStream reports whether cusparseSetStream resolved in the loaded library.
func HasSpGEMMCompute ¶
func HasSpGEMMCompute() bool
HasSpGEMMCompute reports whether cusparseSpGEMM_compute resolved in the loaded library.
func HasSpGEMMCopy ¶
func HasSpGEMMCopy() bool
HasSpGEMMCopy reports whether cusparseSpGEMM_copy resolved in the loaded library.
func HasSpGEMMCreateDescr ¶
func HasSpGEMMCreateDescr() bool
HasSpGEMMCreateDescr reports whether cusparseSpGEMM_createDescr resolved in the loaded library.
func HasSpGEMMDestroyDescr ¶
func HasSpGEMMDestroyDescr() bool
HasSpGEMMDestroyDescr reports whether cusparseSpGEMM_destroyDescr resolved in the loaded library.
func HasSpGEMMEstimateMemory ¶
func HasSpGEMMEstimateMemory() bool
HasSpGEMMEstimateMemory reports whether cusparseSpGEMM_estimateMemory resolved in the loaded library.
func HasSpGEMMGetNumProducts ¶
func HasSpGEMMGetNumProducts() bool
HasSpGEMMGetNumProducts reports whether cusparseSpGEMM_getNumProducts resolved in the loaded library.
func HasSpGEMMWorkEstimation ¶
func HasSpGEMMWorkEstimation() bool
HasSpGEMMWorkEstimation reports whether cusparseSpGEMM_workEstimation resolved in the loaded library.
func HasSpGEMMreuseCompute ¶
func HasSpGEMMreuseCompute() bool
HasSpGEMMreuseCompute reports whether cusparseSpGEMMreuse_compute resolved in the loaded library.
func HasSpGEMMreuseCopy ¶
func HasSpGEMMreuseCopy() bool
HasSpGEMMreuseCopy reports whether cusparseSpGEMMreuse_copy resolved in the loaded library.
func HasSpGEMMreuseNnz ¶
func HasSpGEMMreuseNnz() bool
HasSpGEMMreuseNnz reports whether cusparseSpGEMMreuse_nnz resolved in the loaded library.
func HasSpGEMMreuseWorkEstimation ¶
func HasSpGEMMreuseWorkEstimation() bool
HasSpGEMMreuseWorkEstimation reports whether cusparseSpGEMMreuse_workEstimation resolved in the loaded library.
func HasSpMM ¶
func HasSpMM() bool
HasSpMM reports whether cusparseSpMM resolved in the loaded library.
func HasSpMMBufferSize ¶
func HasSpMMBufferSize() bool
HasSpMMBufferSize reports whether cusparseSpMM_bufferSize resolved in the loaded library.
func HasSpMMPreprocess ¶
func HasSpMMPreprocess() bool
HasSpMMPreprocess reports whether cusparseSpMM_preprocess resolved in the loaded library.
func HasSpMV ¶
func HasSpMV() bool
HasSpMV reports whether cusparseSpMV resolved in the loaded library.
func HasSpMVBufferSize ¶
func HasSpMVBufferSize() bool
HasSpMVBufferSize reports whether cusparseSpMV_bufferSize resolved in the loaded library.
func HasSpMVOp ¶
func HasSpMVOp() bool
HasSpMVOp reports whether cusparseSpMVOp resolved in the loaded library.
func HasSpMVOpBufferSize ¶
func HasSpMVOpBufferSize() bool
HasSpMVOpBufferSize reports whether cusparseSpMVOp_bufferSize resolved in the loaded library.
func HasSpMVOpBufferSizeWithAlgorithm ¶
func HasSpMVOpBufferSizeWithAlgorithm() bool
HasSpMVOpBufferSizeWithAlgorithm reports whether the physical symbol and the qualified algorithm-bearing runtime prototype are available.
func HasSpMVOpCreateDescr ¶
func HasSpMVOpCreateDescr() bool
HasSpMVOpCreateDescr reports whether cusparseSpMVOp_createDescr resolved in the loaded library.
func HasSpMVOpCreateDescrWithAlgorithm ¶
func HasSpMVOpCreateDescrWithAlgorithm() bool
HasSpMVOpCreateDescrWithAlgorithm reports whether the physical symbol and the qualified algorithm-bearing runtime prototype are available.
func HasSpMVOpCreatePlan ¶
func HasSpMVOpCreatePlan() bool
HasSpMVOpCreatePlan reports whether cusparseSpMVOp_createPlan resolved in the loaded library.
func HasSpMVOpDestroyDescr ¶
func HasSpMVOpDestroyDescr() bool
HasSpMVOpDestroyDescr reports whether cusparseSpMVOp_destroyDescr resolved in the loaded library.
func HasSpMVOpDestroyPlan ¶
func HasSpMVOpDestroyPlan() bool
HasSpMVOpDestroyPlan reports whether cusparseSpMVOp_destroyPlan resolved in the loaded library.
func HasSpMVOpSetGlobalUserData ¶
func HasSpMVOpSetGlobalUserData() bool
HasSpMVOpSetGlobalUserData reports whether cusparseSpMVOp_setGlobalUserData resolved in the loaded library.
func HasSpMVPreprocess ¶
func HasSpMVPreprocess() bool
HasSpMVPreprocess reports whether cusparseSpMV_preprocess resolved in the loaded library.
func HasSpMatGetAttribute ¶
func HasSpMatGetAttribute() bool
HasSpMatGetAttribute reports whether cusparseSpMatGetAttribute resolved in the loaded library.
func HasSpMatGetFormat ¶
func HasSpMatGetFormat() bool
HasSpMatGetFormat reports whether cusparseSpMatGetFormat resolved in the loaded library.
func HasSpMatGetIndexBase ¶
func HasSpMatGetIndexBase() bool
HasSpMatGetIndexBase reports whether cusparseSpMatGetIndexBase resolved in the loaded library.
func HasSpMatGetSize ¶
func HasSpMatGetSize() bool
HasSpMatGetSize reports whether cusparseSpMatGetSize resolved in the loaded library.
func HasSpMatGetStridedBatch ¶
func HasSpMatGetStridedBatch() bool
HasSpMatGetStridedBatch reports whether cusparseSpMatGetStridedBatch resolved in the loaded library.
func HasSpMatGetValues ¶
func HasSpMatGetValues() bool
HasSpMatGetValues reports whether cusparseSpMatGetValues resolved in the loaded library.
func HasSpMatSetAttribute ¶
func HasSpMatSetAttribute() bool
HasSpMatSetAttribute reports whether cusparseSpMatSetAttribute resolved in the loaded library.
func HasSpMatSetValues ¶
func HasSpMatSetValues() bool
HasSpMatSetValues reports whether cusparseSpMatSetValues resolved in the loaded library.
func HasSpSMAnalysis ¶
func HasSpSMAnalysis() bool
HasSpSMAnalysis reports whether cusparseSpSM_analysis resolved in the loaded library.
func HasSpSMBufferSize ¶
func HasSpSMBufferSize() bool
HasSpSMBufferSize reports whether cusparseSpSM_bufferSize resolved in the loaded library.
func HasSpSMCreateDescr ¶
func HasSpSMCreateDescr() bool
HasSpSMCreateDescr reports whether cusparseSpSM_createDescr resolved in the loaded library.
func HasSpSMDestroyDescr ¶
func HasSpSMDestroyDescr() bool
HasSpSMDestroyDescr reports whether cusparseSpSM_destroyDescr resolved in the loaded library.
func HasSpSMSolve ¶
func HasSpSMSolve() bool
HasSpSMSolve reports whether cusparseSpSM_solve resolved in the loaded library.
func HasSpSMUpdateMatrix ¶
func HasSpSMUpdateMatrix() bool
HasSpSMUpdateMatrix reports whether cusparseSpSM_updateMatrix resolved in the loaded library.
func HasSpSVAnalysis ¶
func HasSpSVAnalysis() bool
HasSpSVAnalysis reports whether cusparseSpSV_analysis resolved in the loaded library.
func HasSpSVBufferSize ¶
func HasSpSVBufferSize() bool
HasSpSVBufferSize reports whether cusparseSpSV_bufferSize resolved in the loaded library.
func HasSpSVCreateDescr ¶
func HasSpSVCreateDescr() bool
HasSpSVCreateDescr reports whether cusparseSpSV_createDescr resolved in the loaded library.
func HasSpSVDestroyDescr ¶
func HasSpSVDestroyDescr() bool
HasSpSVDestroyDescr reports whether cusparseSpSV_destroyDescr resolved in the loaded library.
func HasSpSVSolve ¶
func HasSpSVSolve() bool
HasSpSVSolve reports whether cusparseSpSV_solve resolved in the loaded library.
func HasSpSVUpdateMatrix ¶
func HasSpSVUpdateMatrix() bool
HasSpSVUpdateMatrix reports whether cusparseSpSV_updateMatrix resolved in the loaded library.
func HasSpVecGet ¶
func HasSpVecGet() bool
HasSpVecGet reports whether cusparseSpVecGet resolved in the loaded library.
func HasSpVecGetIndexBase ¶
func HasSpVecGetIndexBase() bool
HasSpVecGetIndexBase reports whether cusparseSpVecGetIndexBase resolved in the loaded library.
func HasSpVecGetValues ¶
func HasSpVecGetValues() bool
HasSpVecGetValues reports whether cusparseSpVecGetValues resolved in the loaded library.
func HasSpVecSetValues ¶
func HasSpVecSetValues() bool
HasSpVecSetValues reports whether cusparseSpVecSetValues resolved in the loaded library.
func HasSparseToDense ¶
func HasSparseToDense() bool
HasSparseToDense reports whether cusparseSparseToDense resolved in the loaded library.
func HasSparseToDenseBufferSize ¶
func HasSparseToDenseBufferSize() bool
HasSparseToDenseBufferSize reports whether cusparseSparseToDense_bufferSize resolved in the loaded library.
func Load ¶
Load opens the shared library from path, or from the default search list when path is empty, and binds all symbols. Callers that need to direct loading should call Load before any other function; otherwise the first call loads from the default search list.
Load is idempotent: calling it again with the same path, or with an empty path, returns nil. Calling it with a different path after a successful load returns *LibraryConflictError rather than replacing the library. After a failed load, Load retries.
func Loaded ¶
func Loaded() bool
Loaded reports whether the library is currently loaded. It does not trigger a load.
func LoggerForceDisable ¶
func LoggerForceDisable() error
LoggerForceDisable wraps cusparseLoggerForceDisable.
func LoggerOpenFile ¶
LoggerOpenFile opens a logging output file in the given path.
This function is experimental.
- logFile: Path of the logging output file
Wraps cusparseLoggerOpenFile.
func LoggerSetCallback ¶
func LoggerSetCallback(callback LoggerCallback) error
LoggerSetCallback sets the logging callback function.
This function is experimental.
- callback: Pointer to a callback function (see LoggerCallback)
Wraps cusparseLoggerSetCallback.
func LoggerSetFile ¶
LoggerSetFile sets the logging output file.
Note: once registered using this function call, the provided file handle must not be closed unless the function is called again to switch to a different file handle. This function is experimental.
- file: Pointer to an open file. File should have write permission
Wraps cusparseLoggerSetFile.
func LoggerSetLevel ¶
LoggerSetLevel sets the value of the logging level.
path. This function is experimental.
- level: Value of the logging level
Wraps cusparseLoggerSetLevel.
func LoggerSetMask ¶
LoggerSetMask sets the value of the logging mask.
This function is experimental.
- mask: Value of the logging mask
Wraps cusparseLoggerSetMask.
Types ¶
type BindFailure ¶
BindFailure names a symbol the loaded library exports but that could not be bound, and why.
func BindFailures ¶
func BindFailures() []BindFailure
BindFailures returns the symbols the loaded library exports that could not be bound, sorted by symbol name, or nil if every exported symbol bound. Calling one of these reports *SymbolError with the same Err.
A load that reports no error can still leave symbols unbound: the library is fine and the signatures are not representable here. Call this after Load to find that out at once rather than one call site at a time. It does not trigger a load, and returns nil if none has happened.
type CallError ¶
CallError reports that a library call returned a failure result.
Unwrap returns Result, so errors.Is(err, c) reports whether the call returned the Result constant c, and errors.As(err, &r) with r of type Result recovers the code.
type ConstDnMatDescr ¶
type ConstDnMatDescr uintptr
ConstDnMatDescr is an opaque handle for cusparseConstDnMatDescr_t.
func CreateConstDnMat ¶
func CreateConstDnMat(rows int64, cols int64, ld int64, values driver.DevicePtr, valueType DataType, order Order) (ConstDnMatDescr, error)
CreateConstDnMat initializes the dense matrix descriptor dnMatDescr.
CreateDnMat has the following constraints:
- values must be aligned to the size of the datatype specified by valueType. See cudaDataType_t for the description of the datatypes.
Parameters:
- dnMatDescr: Dense matrix descriptor
- rows: Number of rows of the dense matrix
- cols: Number of columns of the dense matrix
- ld: Leading dimension of the dense matrix
- values: Values of the dense matrix. Array with size elements
- valueType: Enumerator specifying the datatype of values
- order: Enumerator specifying the memory layout of the dense matrix
Wraps cusparseCreateConstDnMat.
func (*ConstDnMatDescr) Close ¶
func (c *ConstDnMatDescr) Close() error
Close releases the host memory allocated for the dense matrix descriptor dnMatDescr.
If c is zero, Close returns nil. Otherwise Close sets c to zero when the call succeeds and leaves it unchanged when it fails. Only c is zeroed: a copy of it still refers to the released object.
Wraps cusparseDestroyDnMat.
func (ConstDnMatDescr) DnMatGet ¶
func (c ConstDnMatDescr) DnMatGet(rows *int64, cols *int64, ld *int64, values *uintptr, type_ *DataType, order *Order) error
DnMatGet returns the fields of the dense matrix descriptor dnMatDescr.
- rows: Number of rows of the dense matrix
- cols: Number of columns of the dense matrix
- ld: Leading dimension of the dense matrix
- values: Values of the dense matrix. Array with ld * cols elements
- order: Enumerator specifying the memory layout of the dense matrix
Wraps cusparseConstDnMatGet.
func (ConstDnMatDescr) DnMatGetStridedBatch ¶
func (c ConstDnMatDescr) DnMatGetStridedBatch() (batchCount int32, batchStride int64, err error)
DnMatGetStridedBatch returns the number of batches and the batch stride of the dense matrix descriptor dnMatDescr.
- batchCount: Number of batches of the dense matrix
- batchStride: Address offset between a matrix and the next one in the batch
Wraps cusparseDnMatGetStridedBatch.
func (ConstDnMatDescr) DnMatGetValues ¶
func (c ConstDnMatDescr) DnMatGetValues(values *uintptr) error
DnMatGetValues returns the values field of the dense matrix descriptor dnMatDescr.
- values: Values of the dense matrix. Array with ld * cols elements
Wraps cusparseConstDnMatGetValues.
type ConstDnVecDescr ¶
type ConstDnVecDescr uintptr
ConstDnVecDescr is an opaque handle for cusparseConstDnVecDescr_t.
func CreateConstDnVec ¶
func CreateConstDnVec(size int64, values driver.DevicePtr, valueType DataType) (ConstDnVecDescr, error)
CreateConstDnVec initializes the dense vector descriptor dnVecDescr.
CreateDnVec has the following constraints:
- values must be aligned to the size of the datatype specified by valueType. Refer to cudaDataType_t for the description of the datatypes.
Parameters:
- dnVecDescr: Dense vector descriptor
- size: Size of the dense vector
- values: Values of the dense vector. Array with size elements
- valueType: Enumerator specifying the datatype of values
Wraps cusparseCreateConstDnVec.
func (*ConstDnVecDescr) Close ¶
func (c *ConstDnVecDescr) Close() error
Close releases the host memory allocated for the dense vector descriptor dnVecDescr.
If c is zero, Close returns nil. Otherwise Close sets c to zero when the call succeeds and leaves it unchanged when it fails. Only c is zeroed: a copy of it still refers to the released object.
Wraps cusparseDestroyDnVec.
func (ConstDnVecDescr) DnVecGet ¶
func (c ConstDnVecDescr) DnVecGet(size *int64, values *uintptr, valueType *DataType) error
DnVecGet returns the fields of the dense vector descriptor dnVecDescr.
- size: Size of the dense vector
- values: Values of the dense vector. Array with nnz elements
- valueType: Enumerator specifying the datatype of values
Wraps cusparseConstDnVecGet.
func (ConstDnVecDescr) DnVecGetValues ¶
func (c ConstDnVecDescr) DnVecGetValues(values *uintptr) error
DnVecGetValues returns the values field of the dense vector descriptor dnVecDescr.
- values: Values of the dense vector
Wraps cusparseConstDnVecGetValues.
type ConstSpMatDescr ¶
type ConstSpMatDescr uintptr
ConstSpMatDescr is an opaque handle for cusparseConstSpMatDescr_t.
func CreateConstBlockedEll ¶
func CreateConstBlockedEll(rows int64, cols int64, ellBlockSize int64, ellCols int64, ellColInd driver.DevicePtr, ellValue driver.DevicePtr, ellIdxType IndexType, idxBase IndexBase, valueType DataType) (ConstSpMatDescr, error)
CreateConstBlockedEll initializes the sparse matrix descriptor spMatDescr for the Blocked-Ellpack (ELL) format.
Blocked-ELL Column indices ( ellColInd) are in the range [0, cols / ellBlockSize -1]. The array can contain -1 values for indicating empty blocks.
- spMatDescr: Sparse matrix descriptor
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- ellBlockSize: Size of the ELL-Block
- ellCols: Actual number of columns of the Blocked-Ellpack format ( ellValue columns)
- ellColInd: Blocked-ELL Column indices. Array with [ellCols / ellBlockSize][rows / ellBlockSize] elements
- ellValue: Values of the sparse matrix. Array with rows * ellCols elements
- ellIdxType: Data type of ellColInd
- idxBase: Index base of ellColInd
- valueType: Data type of ellValue
Wraps cusparseCreateConstBlockedEll.
func CreateConstBsr ¶
func CreateConstBsr(brows int64, bcols int64, bnnz int64, rowBlockDim int64, colBlockDim int64, bsrRowOffsets driver.DevicePtr, bsrColInd driver.DevicePtr, bsrValues driver.DevicePtr, bsrRowOffsetsType IndexType, bsrColIndType IndexType, idxBase IndexBase, valueType DataType, order Order) (ConstSpMatDescr, error)
CreateConstBsr initializes the sparse matrix descriptor spMatDescr for the Block Compressed Row (BSR) format.
CreateBsr has the following constraints:
- bsrRowOffsets, bsrColInd, and bsrValues must be aligned to the size of the datatypes specified by bsrRowOffsetsType, bsrColIndType, and valueType, respectively. See cudaDataType_t for the description of the datatypes.
Parameters:
- spMatDescr: Sparse matrix descriptor
- brows: Number of block rows of the sparse matrix
- bcols: Number of block columns of the sparse matrix
- bnnz: Number of blocks of the sparse matrix
- bsrRowOffsets: Block row offsets of the sparse matrix. Array of size brows + 1
- bsrColInd: Block column indices of the sparse matrix. Array of size bnnz
- bsrValues: Values of the sparse matrix. Array of size bnnz * rowBlockSize * colBlockSize
- bsrRowOffsetsType: Data type of bsrRowOffsets
- bsrColIndType: Data type of bsrColInd
- idxBase: Base index of bsrRowOffsets and bsrColInd
- valueType: Datatype of bsrValues
- order: Enumerator specifying the memory layout of values in each block
Wraps cusparseCreateConstBsr.
func CreateConstCoo ¶
func CreateConstCoo(rows int64, cols int64, nnz int64, cooRowInd driver.DevicePtr, cooColInd driver.DevicePtr, cooValues driver.DevicePtr, cooIdxType IndexType, idxBase IndexBase, valueType DataType) (ConstSpMatDescr, error)
CreateConstCoo initializes the sparse matrix descriptor spMatDescr in the COO format (Structure of Arrays layout).
CreateCoo has the following constraints:
- cooRowInd, cooColInd, and cooValues must be aligned to the size of the datatypes specified by cooIdxType, cooIdxType, and valueType. respectively. See cudaDataType_t for the description of the datatypes.
Parameters:
- spMatDescr: Sparse matrix descriptor
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of non-zero entries of the sparse matrix
- cooRowInd: Row indices of the sparse matrix. Array with nnz elements
- cooColInd: Column indices of the sparse matrix. Array with nnz elements
- cooValues: Values of the sparse matrix. Array with nnz elements
- cooIdxType: Data type of cooRowInd and cooColInd
- idxBase: Index base of cooRowInd and cooColInd
- valueType: Datatype of cooValues
Wraps cusparseCreateConstCoo.
func CreateConstCsc ¶
func CreateConstCsc(rows int64, cols int64, nnz int64, cscColOffsets driver.DevicePtr, cscRowInd driver.DevicePtr, cscValues driver.DevicePtr, cscColOffsetsType IndexType, cscRowIndType IndexType, idxBase IndexBase, valueType DataType) (ConstSpMatDescr, error)
CreateConstCsc initializes the sparse matrix descriptor spMatDescr in the CSC format.
CreateCsc has the following constraints:
- cscColOffsets, cscRowInd, and cscValues must be aligned to the size of the datatypes specified by cscColOffsetsType, cscRowIndType, and valueType, respectively. See cudaDataType_t for the description of the datatypes.
Parameters:
- spMatDescr: Sparse matrix descriptor
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of non-zero entries of the sparse matrix
- cscColOffsets: Column offsets of the sparse matrix. Array with cols + 1 elements
- cscRowInd: Row indices of the sparse matrix. Array with nnz elements
- cscValues: Values of the sparse matrix. Array with nnz elements
- cscColOffsetsType: Data type of cscColOffsets
- cscRowIndType: Data type of cscRowInd
- idxBase: Index base of cscColOffsets and cscRowInd
- valueType: Datatype of cscValues
Wraps cusparseCreateConstCsc.
func CreateConstCsr ¶
func CreateConstCsr(rows int64, cols int64, nnz int64, csrRowOffsets driver.DevicePtr, csrColInd driver.DevicePtr, csrValues driver.DevicePtr, csrRowOffsetsType IndexType, csrColIndType IndexType, idxBase IndexBase, valueType DataType) (ConstSpMatDescr, error)
CreateConstCsr initializes the sparse matrix descriptor spMatDescr in the CSR format.
CreateCsr has the following constraints:
- csrRowOffsets, csrColInd, and csrValues must be aligned to the size of the datatypes specified by csrRowOffsetsType, csrColIndType, and valueType, respectively. See cudaDataType_t for the description of the datatypes.
Parameters:
- spMatDescr: Sparse matrix descriptor
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of non-zero entries of the sparse matrix
- csrRowOffsets: Row offsets of the sparse matrix. Array with rows + 1 elements
- csrColInd: Column indices of the sparse matrix. Array with nnz elements
- csrValues: Values of the sparse matrix. Array with nnz elements
- csrRowOffsetsType: Data type of csrRowOffsets
- csrColIndType: Data type of csrColInd
- idxBase: Index base of csrRowOffsets and csrColInd
- valueType: Datatype of csrValues
Wraps cusparseCreateConstCsr.
func CreateConstSlicedEll ¶
func CreateConstSlicedEll(rows int64, cols int64, nnz int64, sellValuesSize int64, sliceSize int64, sellSliceOffsets driver.DevicePtr, sellColInd driver.DevicePtr, sellValues driver.DevicePtr, sellSliceOffsetsType IndexType, sellColIndType IndexType, idxBase IndexBase, valueType DataType) (ConstSpMatDescr, error)
CreateConstSlicedEll initializes the sparse matrix descriptor spMatDescr for the Sliced Ellpack (SELL) format.
Note: Sliced Ellpack Column array sellColInd contains -1 values for indicating padded entries. CreateSlicedEll has the following constraints:
- sellSliceOffsets, sellColInd, and sellValues must be aligned to the size of the datatypes specified by sellSliceOffsetsType, sellColIndType, and valueType, respectively. See cudaDataType_t for the description of the datatypes.
Parameters:
- spMatDescr: Sparse matrix descriptor
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of nonzero elements in the sparse matrix
- sellValuesSize: Total number of elements in sellValues array (nonzero and padding)
- sliceSize: The number of rows per slice
- sellSliceOffsets: Slice offsets of the sparse matrix. Array of size ⌈rowssliceSize⌉+1
- sellColInd: Column indexes of the sparse matrix. Array of size sellValuesSize
- sellValues: Values of the sparse matrix. Array of size sellValuesSize elements
- sellSliceOffsetsType: Data type of sellSliceOffsets
- sellColIndType: Data type of sellColInd
- idxBase: Index base of sellColInd
- valueType: Data type of sellValues
Wraps cusparseCreateConstSlicedEll.
func (ConstSpMatDescr) BlockedEllGet ¶
func (c ConstSpMatDescr) BlockedEllGet(rows *int64, cols *int64, ellBlockSize *int64, ellCols *int64, ellColInd *uintptr, ellValue *uintptr, ellIdxType *IndexType, idxBase *IndexBase, valueType *DataType) error
BlockedEllGet returns the fields of the sparse matrix descriptor spMatDescr stored in Blocked-Ellpack (ELL) format.
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- ellBlockSize: Size of the ELL-Block
- ellCols: Actual number of columns of the Blocked-Ellpack format
- ellColInd: Column indices for the ELL-Block. Array with [cols / ellBlockSize][rows / ellBlockSize] elements
- ellValue: Values of the sparse matrix. Array with rows * ellCols elements
- ellIdxType: Data type of ellColInd
- idxBase: Index base of ellColInd
- valueType: Datatype of ellValue
Wraps cusparseConstBlockedEllGet.
func (*ConstSpMatDescr) Close ¶
func (c *ConstSpMatDescr) Close() error
Close releases the host memory allocated for the sparse matrix descriptor spMatDescr.
If c is zero, Close returns nil. Otherwise Close sets c to zero when the call succeeds and leaves it unchanged when it fails. Only c is zeroed: a copy of it still refers to the released object.
Wraps cusparseDestroySpMat.
func (ConstSpMatDescr) CooGet ¶
func (c ConstSpMatDescr) CooGet(rows *int64, cols *int64, nnz *int64, cooRowInd *uintptr, cooColInd *uintptr, cooValues *uintptr, idxType *IndexType, idxBase *IndexBase, valueType *DataType) error
CooGet returns the fields of the sparse matrix descriptor spMatDescr stored in COO format (Array of Structures layout).
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of non-zero entries of the sparse matrix
- cooRowInd: Row indices of the sparse matrix. Array nnz elements
- cooColInd: Column indices of the sparse matrix. Array nnz elements
- cooValues: Values of the sparse matrix. Array nnz elements
- idxBase: Index base of cooRowInd and cooColInd
- valueType: Datatype of cooValues
Wraps cusparseConstCooGet.
func (ConstSpMatDescr) CscGet ¶
func (c ConstSpMatDescr) CscGet(rows *int64, cols *int64, nnz *int64, cscColOffsets *uintptr, cscRowInd *uintptr, cscValues *uintptr, cscColOffsetsType *IndexType, cscRowIndType *IndexType, idxBase *IndexBase, valueType *DataType) error
CscGet returns the fields of the sparse matrix descriptor spMatDescr stored in CSC format.
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of non-zero entries of the sparse matrix
- cscColOffsets: Col offsets of the sparse matrix. Array with cols + 1 elements
- cscRowInd: Row indices of the sparse matrix. Array with nnz elements
- cscValues: Values of the sparse matrix. Array with nnz elements
- cscColOffsetsType: Data type of cscColOffsets
- cscRowIndType: Data type of cscRowInd
- idxBase: Index base of cscColOffsets and cscRowInd
- valueType: Datatype of cscValues
Wraps cusparseConstCscGet.
func (ConstSpMatDescr) CsrGet ¶
func (c ConstSpMatDescr) CsrGet(rows *int64, cols *int64, nnz *int64, csrRowOffsets *uintptr, csrColInd *uintptr, csrValues *uintptr, csrRowOffsetsType *IndexType, csrColIndType *IndexType, idxBase *IndexBase, valueType *DataType) error
CsrGet returns the fields of the sparse matrix descriptor spMatDescr stored in CSR format.
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of non-zero entries of the sparse matrix
- csrRowOffsets: Row offsets of the sparse matrix. Array with rows + 1 elements
- csrColInd: Column indices of the sparse matrix. Array with nnz elements
- csrValues: Values of the sparse matrix. Array with nnz elements
- csrRowOffsetsType: Data type of csrRowOffsets
- csrColIndType: Data type of csrColInd
- idxBase: Index base of csrRowOffsets and csrColInd
- valueType: Datatype of csrValues
Wraps cusparseConstCsrGet.
func (ConstSpMatDescr) SpMatGetAttribute ¶
func (c ConstSpMatDescr) SpMatGetAttribute(attribute SpMatAttribute, data unsafe.Pointer, dataSize uint) error
SpMatGetAttribute gets the attributes of the sparse matrix descriptor spMatDescr.
- Attribute: SpmatFillMode; Meaning: Indicates if the lower or upper part of a matrix is stored in sparse storage; Possible Values: FillModeLower FillModeUpper
- Attribute: SpmatDiagType; Meaning: Indicates if the matrix diagonal entries are unity; Possible Values: DiagTypeNonUnit DiagTypeUnit
Parameters:
- attribute: Attribute enumerator
- data: Attribute value
- dataSize: Size of the attribute in bytes for safety
Wraps cusparseSpMatGetAttribute.
func (ConstSpMatDescr) SpMatGetFormat ¶
func (c ConstSpMatDescr) SpMatGetFormat() (Format, error)
SpMatGetFormat returns the format field of the sparse matrix descriptor spMatDescr.
- format: Storage format of the sparse matrix
Wraps cusparseSpMatGetFormat.
func (ConstSpMatDescr) SpMatGetIndexBase ¶
func (c ConstSpMatDescr) SpMatGetIndexBase() (IndexBase, error)
SpMatGetIndexBase returns the idxBase field of the sparse matrix descriptor spMatDescr.
- idxBase: Index base of the sparse matrix
Wraps cusparseSpMatGetIndexBase.
func (ConstSpMatDescr) SpMatGetSize ¶
func (c ConstSpMatDescr) SpMatGetSize() (rows int64, cols int64, nnz int64, err error)
SpMatGetSize returns the sizes of the sparse matrix spMatDescr.
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of non-zero entries of the sparse matrix
Wraps cusparseSpMatGetSize.
func (ConstSpMatDescr) SpMatGetStridedBatch ¶
func (c ConstSpMatDescr) SpMatGetStridedBatch() (int32, error)
SpMatGetStridedBatch returns the batchCount field of the sparse matrix descriptor spMatDescr.
- batchCount: Number of batches of the sparse matrix
Wraps cusparseSpMatGetStridedBatch.
func (ConstSpMatDescr) SpMatGetValues ¶
func (c ConstSpMatDescr) SpMatGetValues(values *uintptr) error
SpMatGetValues returns the values field of the sparse matrix descriptor spMatDescr.
- values: Values of the sparse matrix. Array with nnz elements
Wraps cusparseConstSpMatGetValues.
type ConstSpVecDescr ¶
type ConstSpVecDescr uintptr
ConstSpVecDescr is an opaque handle for cusparseConstSpVecDescr_t.
func CreateConstSpVec ¶
func CreateConstSpVec(size int64, nnz int64, indices driver.DevicePtr, values driver.DevicePtr, idxType IndexType, idxBase IndexBase, valueType DataType) (ConstSpVecDescr, error)
CreateConstSpVec initializes the sparse matrix descriptor spVecDescr.
CreateSpVec has the following constraints:
- indices and values must be aligned to the size of the datatypes specified by idxType and valueType, respectively. See cudaDataType_t for the description of the datatypes.
Parameters:
- spVecDescr: Sparse vector descriptor
- size: Size of the sparse vector
- nnz: Number of non-zero entries of the sparse vector
- indices: Indices of the sparse vector. Array with nnz elements
- values: Values of the sparse vector. Array with nnz elements
- idxType: Enumerator specifying the data type of indices
- idxBase: Enumerator specifying the the index base of indices
- valueType: Enumerator specifying the datatype of values
Wraps cusparseCreateConstSpVec.
func (*ConstSpVecDescr) Close ¶
func (c *ConstSpVecDescr) Close() error
Close releases the host memory allocated for the sparse vector descriptor spVecDescr.
If c is zero, Close returns nil. Otherwise Close sets c to zero when the call succeeds and leaves it unchanged when it fails. Only c is zeroed: a copy of it still refers to the released object.
Wraps cusparseDestroySpVec.
func (ConstSpVecDescr) SpVecGet ¶
func (c ConstSpVecDescr) SpVecGet(size *int64, nnz *int64, indices *uintptr, values *uintptr, idxType *IndexType, idxBase *IndexBase, valueType *DataType) error
SpVecGet returns the fields of the sparse vector descriptor spVecDescr.
- size: Size of the sparse vector
- nnz: Number of non-zero entries of the sparse vector
- indices: Indices of the sparse vector. Array with nnz elements
- values: Values of the sparse vector. Array with nnz elements
- idxType: Enumerator specifying the data type of indices
- idxBase: Enumerator specifying the the index base of indices
- valueType: Enumerator specifying the datatype of values
Wraps cusparseConstSpVecGet.
func (ConstSpVecDescr) SpVecGetIndexBase ¶
func (c ConstSpVecDescr) SpVecGetIndexBase() (IndexBase, error)
SpVecGetIndexBase returns the idxBase field of the sparse vector descriptor spVecDescr.
- idxBase: Enumerator specifying the the index base of indices
Wraps cusparseSpVecGetIndexBase.
func (ConstSpVecDescr) SpVecGetValues ¶
func (c ConstSpVecDescr) SpVecGetValues(values *uintptr) error
SpVecGetValues returns the values field of the sparse vector descriptor spVecDescr.
- values: Values of the sparse vector. Array with nnz elements
Wraps cusparseConstSpVecGetValues.
type Csr2CscAlg ¶
type Csr2CscAlg int32
Csr2CscAlg represents cusparseCsr2CscAlg_t.
const ( Csr2cscAlgDefault Csr2CscAlg = 1 Csr2cscALG1 Csr2CscAlg = 1 )
func (Csr2CscAlg) String ¶
func (e Csr2CscAlg) String() string
String returns the constant name, or a numeric representation for unknown values.
type DataType ¶
type DataType int32
DataType identifies a CUDA data representation.
const ( // real as a half R16F DataType = 2 // complex as a pair of half numbers C16F DataType = 6 // real as a nv_bfloat16 R16BF DataType = 14 // complex as a pair of nv_bfloat16 numbers C16BF DataType = 15 // real as a float R32F DataType = 0 // complex as a pair of float numbers C32F DataType = 4 // real as a double R64F DataType = 1 // complex as a pair of double numbers C64F DataType = 5 // real as a signed 4-bit int R4I DataType = 16 // complex as a pair of signed 4-bit int numbers C4I DataType = 17 // real as a unsigned 4-bit int R4U DataType = 18 // complex as a pair of unsigned 4-bit int numbers C4U DataType = 19 // real as a signed 8-bit int R8I DataType = 3 // complex as a pair of signed 8-bit int numbers C8I DataType = 7 // real as a unsigned 8-bit int R8U DataType = 8 // complex as a pair of unsigned 8-bit int numbers C8U DataType = 9 // real as a signed 16-bit int R16I DataType = 20 // complex as a pair of signed 16-bit int numbers C16I DataType = 21 // real as a unsigned 16-bit int R16U DataType = 22 // complex as a pair of unsigned 16-bit int numbers C16U DataType = 23 // real as a signed 32-bit int R32I DataType = 10 // complex as a pair of signed 32-bit int numbers C32I DataType = 11 // real as a unsigned 32-bit int R32U DataType = 12 // complex as a pair of unsigned 32-bit int numbers C32U DataType = 13 // real as a signed 64-bit int R64I DataType = 24 // complex as a pair of signed 64-bit int numbers C64I DataType = 25 // real as a unsigned 64-bit int R64U DataType = 26 // complex as a pair of unsigned 64-bit int numbers C64U DataType = 27 // real as a nv_fp8_e4m3 R8F_E4M3 DataType = 28 // real as an unsigned nv_fp8_e4m3 R8F_UE4M3 DataType = R8F_E4M3 // real as a nv_fp8_e5m2 R8F_E5M2 DataType = 29 // real as an exponent-only unsigned nv_fp8_e8m0 R8F_UE8M0 DataType = 30 // real as a nv_fp6_e2m3 R6F_E2M3 DataType = 31 // real as a nv_fp6_e3m2 R6F_E3M2 DataType = 32 // real as a nv_fp4_e2m1 R4F_E2M1 DataType = 33 // real as an unsigned nv_fp8_ue5m3 R8FUe5m3 DataType = 34 )
DataType constants.
type DenseToSparseAlg ¶
type DenseToSparseAlg int32
DenseToSparseAlg represents cusparseDenseToSparseAlg_t.
const (
DensetosparseAlgDefault DenseToSparseAlg = 0
)
func (DenseToSparseAlg) String ¶
func (e DenseToSparseAlg) String() string
String returns the constant name, or a numeric representation for unknown values.
type DnMatDescr ¶
type DnMatDescr uintptr
DnMatDescr is an opaque handle for cusparseDnMatDescr_t.
func CreateDnMat ¶
func CreateDnMat(rows int64, cols int64, ld int64, values driver.DevicePtr, valueType DataType, order Order) (DnMatDescr, error)
CreateDnMat initializes the dense matrix descriptor dnMatDescr.
CreateDnMat has the following constraints:
- values must be aligned to the size of the datatype specified by valueType. See cudaDataType_t for the description of the datatypes.
Parameters:
- dnMatDescr: Dense matrix descriptor
- rows: Number of rows of the dense matrix
- cols: Number of columns of the dense matrix
- ld: Leading dimension of the dense matrix
- values: Values of the dense matrix. Array with size elements
- valueType: Enumerator specifying the datatype of values
- order: Enumerator specifying the memory layout of the dense matrix
Wraps cusparseCreateDnMat.
func (DnMatDescr) MatGet ¶
func (d DnMatDescr) MatGet(rows *int64, cols *int64, ld *int64, values *uintptr, type_ *DataType, order *Order) error
MatGet returns the fields of the dense matrix descriptor dnMatDescr.
- rows: Number of rows of the dense matrix
- cols: Number of columns of the dense matrix
- ld: Leading dimension of the dense matrix
- values: Values of the dense matrix. Array with ld * cols elements
- order: Enumerator specifying the memory layout of the dense matrix
Wraps cusparseDnMatGet.
func (DnMatDescr) MatGetValues ¶
func (d DnMatDescr) MatGetValues(values *uintptr) error
MatGetValues returns the values field of the dense matrix descriptor dnMatDescr.
- values: Values of the dense matrix. Array with ld * cols elements
Wraps cusparseDnMatGetValues.
func (DnMatDescr) MatSetStridedBatch ¶
func (d DnMatDescr) MatSetStridedBatch(batchCount int32, batchStride int64) error
MatSetStridedBatch sets the number of batches and the batch stride of the dense matrix descriptor dnMatDescr.
- batchCount: Number of batches of the dense matrix
- batchStride: Address offset between a matrix and the next one in the batch. batchStride ≥ ld * cols if the matrix uses column-major layout, batchStride ≥ ld * rows otherwise
Wraps cusparseDnMatSetStridedBatch.
func (DnMatDescr) MatSetValues ¶
func (d DnMatDescr) MatSetValues(values driver.DevicePtr) error
MatSetValues sets the values field of the dense matrix descriptor dnMatDescr.
DnMatDescr.MatSetValues has the following constraints:
- values must be aligned to the size of the datatype specified in dnMatDescr. See cudaDataType_t for the description of the datatypes.
Parameters:
- values: Values of the dense matrix. Array with ld * cols elements
Wraps cusparseDnMatSetValues.
type DnVecDescr ¶
type DnVecDescr uintptr
DnVecDescr is an opaque handle for cusparseDnVecDescr_t.
func CreateDnVec ¶
CreateDnVec initializes the dense vector descriptor dnVecDescr.
CreateDnVec has the following constraints:
- values must be aligned to the size of the datatype specified by valueType. Refer to cudaDataType_t for the description of the datatypes.
Parameters:
- dnVecDescr: Dense vector descriptor
- size: Size of the dense vector
- values: Values of the dense vector. Array with size elements
- valueType: Enumerator specifying the datatype of values
Wraps cusparseCreateDnVec.
func (DnVecDescr) VecGet ¶
func (d DnVecDescr) VecGet(size *int64, values *uintptr, valueType *DataType) error
VecGet returns the fields of the dense vector descriptor dnVecDescr.
- size: Size of the dense vector
- values: Values of the dense vector. Array with nnz elements
- valueType: Enumerator specifying the datatype of values
Wraps cusparseDnVecGet.
func (DnVecDescr) VecGetValues ¶
func (d DnVecDescr) VecGetValues(values *uintptr) error
VecGetValues returns the values field of the dense vector descriptor dnVecDescr.
- values: Values of the dense vector
Wraps cusparseDnVecGetValues.
func (DnVecDescr) VecSetValues ¶
func (d DnVecDescr) VecSetValues(values driver.DevicePtr) error
VecSetValues sets the values field of the dense vector descriptor dnVecDescr.
DnVecDescr.VecSetValues has the following constraints:
- values must be aligned to the size of the datatype specified in dnVecDescr. Refer to cudaDataType_t for the description of the datatypes.
Parameters:
- values: Values of the dense vector. Array with size elements
Wraps cusparseDnVecSetValues.
type Format ¶
type Format int32
Format represents cusparseFormat_t.
const ( FormatCsr Format = 1 // Compressed Sparse Row (CSR) FormatCsc Format = 2 // Compressed Sparse Column (CSC) FormatCoo Format = 3 // Coordinate (COO) - Structure of Arrays FormatBlockedEll Format = 5 // Blocked ELL FormatBsr Format = 6 // Blocked Compressed Sparse Row (BSR) FormatSlicedEllpack Format = 7 // Sliced ELL )
type Handle ¶
type Handle uintptr
Handle is an opaque handle for cusparseHandle_t.
func Create ¶
Create initializes the cuSPARSE library and creates a handle on the cuSPARSE context.
It must be called before any other cuSPARSE API function is invoked. It allocates hardware resources necessary for accessing the GPU.
- handle: The pointer to the handle to the cuSPARSE context
Wraps cusparseCreate.
func (*Handle) Close ¶
Close releases CPU-side resources used by the cuSPARSE library.
The release of GPU-side resources may be deferred until the application shuts down.
If h is zero, Close returns nil. Otherwise Close sets h to zero when the call succeeds and leaves it unchanged when it fails. Only h is zeroed: a copy of it still refers to the released object.
Wraps cusparseDestroy.
func (Handle) DenseToSparseAnalysis ¶
func (h Handle) DenseToSparseAnalysis(matA ConstDnMatDescr, matB SpMatDescr, alg DenseToSparseAlg, externalBuffer driver.DevicePtr) error
DenseToSparseAnalysis converts the dense matrix matA into a sparse matrix matB in CSR, CSC, COO, or Blocked-ELL format.
The function Handle.DenseToSparseBufferSize returns the size of the workspace needed by Handle.DenseToSparseAnalysis. The function Handle.DenseToSparseAnalysis updates the number of non-zero elements in the sparse matrix descriptor matB. The user is responsible to allocate the memory required by the sparse matrix:
- Row/Column indices and value arrays for CSC and CSR respectively
- Row, column, value arrays for COO
- Column ( ellColInd), value ( ellValue) arrays for Blocked-ELL
Finally, we call Handle.DenseToSparseConvert for filling the arrays allocated in the previous step. cusparseDenseToSparse() supports the following index type for representing the sparse vector matB:
cusparseDenseToSparse() supports the following data types:
- A/B: CUDA_R_*8I, CUDA_R_16F, CUDA_R_16BF, CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
cusparseDense2Sparse() supports the following algorithm:
- DensetosparseAlgDefault: Default algorithm
cusparseDenseToSparse() has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- Provides deterministic (bit-wise) results for each run
- The routine does not guarantee the indices of matB to be sorted
cusparseDenseToSparse() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - cusparseDenseToSparse (CSR) and cuSPARSE Library Samples - cusparseDenseToSparse (Blocked-ELL) for code examples.
- matA: Dense matrix A
- matB: Sparse matrix B
- alg: Algorithm for the computation
Wraps cusparseDenseToSparseAnalysis, bound as cusparseDenseToSparse_analysis.
func (Handle) DenseToSparseBufferSize ¶
func (h Handle) DenseToSparseBufferSize(matA ConstDnMatDescr, matB SpMatDescr, alg DenseToSparseAlg) (uint, error)
DenseToSparseBufferSize returns the workspace size for cusparseDenseToSparse.
- matA: Dense matrix A
- matB: Sparse matrix B
- alg: Algorithm for the computation
- bufferSize: Workspace size
Wraps cusparseDenseToSparseBufferSize, bound as cusparseDenseToSparse_bufferSize.
func (Handle) DenseToSparseConvert ¶
func (h Handle) DenseToSparseConvert(matA ConstDnMatDescr, matB SpMatDescr, alg DenseToSparseAlg, externalBuffer driver.DevicePtr) error
DenseToSparseConvert converts the dense matrix matA into a sparse matrix matB in CSR, CSC, COO, or Blocked-ELL format.
The function Handle.DenseToSparseBufferSize returns the size of the workspace needed by Handle.DenseToSparseAnalysis. The function Handle.DenseToSparseAnalysis updates the number of non-zero elements in the sparse matrix descriptor matB. The user is responsible to allocate the memory required by the sparse matrix:
- Row/Column indices and value arrays for CSC and CSR respectively
- Row, column, value arrays for COO
- Column ( ellColInd), value ( ellValue) arrays for Blocked-ELL
Finally, we call Handle.DenseToSparseConvert for filling the arrays allocated in the previous step. cusparseDenseToSparse() supports the following index type for representing the sparse vector matB:
cusparseDenseToSparse() supports the following data types:
- A/B: CUDA_R_*8I, CUDA_R_16F, CUDA_R_16BF, CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
cusparseDense2Sparse() supports the following algorithm:
- DensetosparseAlgDefault: Default algorithm
cusparseDenseToSparse() has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- Provides deterministic (bit-wise) results for each run
- The routine does not guarantee the indices of matB to be sorted
cusparseDenseToSparse() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - cusparseDenseToSparse (CSR) and cuSPARSE Library Samples - cusparseDenseToSparse (Blocked-ELL) for code examples.
- matA: Dense matrix A
- matB: Sparse matrix B
- alg: Algorithm for the computation
Wraps cusparseDenseToSparseConvert, bound as cusparseDenseToSparse_convert.
func (Handle) Gather ¶
func (h Handle) Gather(vecY ConstDnVecDescr, vecX SpVecDescr) error
Gather gathers the elements of the dense vector vecY into the sparse vector vecX.
In other words,
for i=0 to nnz-1
X_values[i] = Y[X_indices[i]]
Handle.Gather supports the following index type for representing the sparse vector vecX:
Handle.Gather supports the following data types:
- X/Y: CUDA_R_16F, CUDA_R_16BF, CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
Handle.Gather has the following constraints:
- The arrays representing the sparse vector vecX must be aligned to 16 bytes
Handle.Gather has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- Provides deterministic (bit-wise) results for each run if the the sparse vector vecX indices are distinct
- The routine allows indices of vecX to be unsorted
Handle.Gather supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - Handle.Gather for a code example.
- vecY: Dense vector Y
- vecX: Sparse vector X
Wraps cusparseGather.
func (Handle) PointerMode ¶
func (h Handle) PointerMode() (PointerMode, error)
PointerMode obtains the pointer mode used by the cuSPARSE library.
Please see the section on the PointerMode type for more details.
- mode: One of the enumerated pointer mode types
Wraps cusparseGetPointerMode.
func (Handle) SDDMM ¶
func (h Handle) SDDMM(opA Operation, opB Operation, alpha Scalar, matA ConstDnMatDescr, matB ConstDnMatDescr, beta Scalar, matC SpMatDescr, computeType DataType, alg SDDMMAlg, externalBuffer driver.DevicePtr) error
SDDMM performs the multiplication of matA and matB, followed by an element-wise multiplication with the sparsity pattern of matC.
Formally, it performs the following operation: C=α(op(A)⋅op(B))∘spy(C)+βC where
- op(A) is a dense matrix of size m×k
- op(B) is a dense matrix of size k×n
- C is a sparse matrix of size m×n
- α and β are scalars
- ∘ denotes the Hadamard (entry-wise) matrix product, and spy(C) is the structural sparsity pattern matrix of C defined as: spy(C)ᵢⱼ = 1 if Cᵢⱼ is an entry stored in matC, and 0 otherwise.
Also, for matrix A and B: op(A) = A if opA == OperationNonTranspose, and op(A) = Aᵀ if opA == OperationTranspose; op(B) = B if opB == OperationNonTranspose, and op(B) = Bᵀ if opB == OperationTranspose. The function Handle.SDDMMBufferSize returns the size of the workspace needed by Handle.SDDMM or Handle.SDDMMPreprocess. Calling Handle.SDDMMPreprocess is optional. It may accelerate subsequent calls to Handle.SDDMM. It is useful when Handle.SDDMM is called multiple times with the same sparsity pattern ( matC). Calling Handle.SDDMMPreprocess with buffer makes that buffer “active” for matC Handle.SDDMM calls. Subsequent calls to Handle.SDDMM with matC and the active buffer must use the same values for all parameters as the call to Handle.SDDMMPreprocess. The exceptions are: alpha, beta, matA, matB, and the values (but not indices) of matC may be different. Importantly, the buffer contents must be unmodified since the call to Handle.SDDMMPreprocess. When Handle.SDDMM is called with matC and its active buffer, it may read acceleration data from the buffer. Calling Handle.SDDMMPreprocess again with matC and a new buffer will make the new buffer active, forgetting about the previously-active buffer and making it inactive. For Handle.SDDMM, there can only be one active buffer per sparse matrix at a time. To get the effect of multiple active buffers for a single sparse matrix, create multiple matrix handles that all point to the same index and value buffers, and call Handle.SDDMMPreprocess once per handle with different workspace buffers. Calling Handle.SDDMM with an inactive buffer is always permitted. However, there may be no acceleration from the preprocessing in that case. For the purposes of thread safety, Handle.SDDMMPreprocess is writing to matC internal state. Currently supported sparse matrix formats:
Handle.SDDMM supports the following index type for representing the sparse matrix matA:
The data types combinations currently supported for Handle.SDDMM are listed below: Uniform-precision computation:
- A/X/Y/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
Mixed-precision computation:
A/B C computeType CUDA_R_16F CUDA_R_32F CUDA_R_32F CUDA_R_16F CUDA_R_16F CUDA_R_32F
Handle.SDDMM for FormatBsr also supports the following mixed-precision computation:
A/B C computeType CUDA_R_16BF CUDA_R_32F CUDA_R_32F CUDA_R_16BF CUDA_R_16BF CUDA_R_32F
NOTE: CUDA_R_16F, CUDA_R_16BF data types always imply mixed-precision computation. Handle.SDDMM for CUSPASRE_FORMAT_BSR supports block sizes of 2, 4, 8, 16, 32, 64 and 128. Handle.SDDMM supports the following algorithms:
- SddmmAlgDefault: Default algorithm. It supports batched computation.
Performance notes: Handle.SDDMM for FormatCsr provides the best performance when matA and matB satisfy:
- matA: matA is in row-major order and opA is OperationNonTranspose, or matA is in col-major order and opA is not OperationNonTranspose
- matB: matB is in col-major order and opB is OperationNonTranspose, or matB is in row-major order and opB is not OperationNonTranspose
Handle.SDDMM for FormatBsr provides the best performance when matA and matB satisfy:
- matA: matA is in row-major order and opA is OperationNonTranspose, or matA is in col-major order and opA is not OperationNonTranspose
- matB: matB is in row-major order and opB is OperationNonTranspose, or matB is in col-major order and opB is not OperationNonTranspose
Handle.SDDMM supports the following batch modes:
- Cᵢ=(A⋅B)∘Cᵢ
- Cᵢ=(Aᵢ⋅B)∘Cᵢ
- Cᵢ=(A⋅Bᵢ)∘Cᵢ
- Cᵢ=(Aᵢ⋅Bᵢ)∘Cᵢ
The number of batches and their strides can be set by using SpMatDescr.CsrSetStridedBatch and DnMatDescr.MatSetStridedBatch. The maximum number of batches for Handle.SDDMM is 65,535. Handle.SDDMM has the following properties:
- The routine requires no extra storage
- Provides deterministic (bit-wise) results for each run
- The routine supports asynchronous execution
- The routine allows the indices of matC to be unsorted
Handle.SDDMM supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - Handle.SDDMM for a code example. For batched computation please visit Handle.SDDMM CSR Batched.
- opA: Operation op(A)
- opB: Operation op(B)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Dense matrix matA
- matB: Dense matrix matB
- beta: β scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matC: Sparse matrix matC
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- externalBuffer: Pointer to a workspace buffer of at least bufferSize bytes
Wraps cusparseSDDMM.
func (Handle) SDDMMBufferSize ¶
func (h Handle) SDDMMBufferSize(opA Operation, opB Operation, alpha Scalar, matA ConstDnMatDescr, matB ConstDnMatDescr, beta Scalar, matC SpMatDescr, computeType DataType, alg SDDMMAlg) (uint, error)
SDDMMBufferSize returns the workspace size for Handle.SDDMM.
- opA: Operation op(A)
- opB: Operation op(B)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Dense matrix matA
- matB: Dense matrix matB
- beta: β scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matC: Sparse matrix matC
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- bufferSize: Workspace size
Wraps cusparseSDDMMBufferSize, bound as cusparseSDDMM_bufferSize.
func (Handle) SDDMMPreprocess ¶
func (h Handle) SDDMMPreprocess(opA Operation, opB Operation, alpha Scalar, matA ConstDnMatDescr, matB ConstDnMatDescr, beta Scalar, matC SpMatDescr, computeType DataType, alg SDDMMAlg, externalBuffer driver.DevicePtr) error
SDDMMPreprocess prepares the workspace buffer for Handle.SDDMM, which may accelerate subsequent calls to it.
Handle.SDDMM performs the multiplication of matA and matB, followed by an element-wise multiplication with the sparsity pattern of matC. Formally, it performs the following operation: C=α(op(A)⋅op(B))∘spy(C)+βC where
- op(A) is a dense matrix of size m×k
- op(B) is a dense matrix of size k×n
- C is a sparse matrix of size m×n
- α and β are scalars
- ∘ denotes the Hadamard (entry-wise) matrix product, and spy(C) is the structural sparsity pattern matrix of C defined as: spy(C)ᵢⱼ = 1 if Cᵢⱼ is an entry stored in matC, and 0 otherwise.
Also, for matrix A and B: op(A) = A if opA == OperationNonTranspose, and op(A) = Aᵀ if opA == OperationTranspose; op(B) = B if opB == OperationNonTranspose, and op(B) = Bᵀ if opB == OperationTranspose. The function Handle.SDDMMBufferSize returns the size of the workspace needed by Handle.SDDMM or Handle.SDDMMPreprocess. Calling Handle.SDDMMPreprocess is optional. It may accelerate subsequent calls to Handle.SDDMM. It is useful when Handle.SDDMM is called multiple times with the same sparsity pattern ( matC). Calling Handle.SDDMMPreprocess with buffer makes that buffer “active” for matC Handle.SDDMM calls. Subsequent calls to Handle.SDDMM with matC and the active buffer must use the same values for all parameters as the call to Handle.SDDMMPreprocess. The exceptions are: alpha, beta, matA, matB, and the values (but not indices) of matC may be different. Importantly, the buffer contents must be unmodified since the call to Handle.SDDMMPreprocess. When Handle.SDDMM is called with matC and its active buffer, it may read acceleration data from the buffer. Calling Handle.SDDMMPreprocess again with matC and a new buffer will make the new buffer active, forgetting about the previously-active buffer and making it inactive. For Handle.SDDMM, there can only be one active buffer per sparse matrix at a time. To get the effect of multiple active buffers for a single sparse matrix, create multiple matrix handles that all point to the same index and value buffers, and call Handle.SDDMMPreprocess once per handle with different workspace buffers. Calling Handle.SDDMM with an inactive buffer is always permitted. However, there may be no acceleration from the preprocessing in that case. For the purposes of thread safety, Handle.SDDMMPreprocess is writing to matC internal state. Currently supported sparse matrix formats:
Handle.SDDMM supports the following index type for representing the sparse matrix matA:
The data types combinations currently supported for Handle.SDDMM are listed below: Uniform-precision computation:
- A/X/Y/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
Mixed-precision computation:
A/B C computeType CUDA_R_16F CUDA_R_32F CUDA_R_32F CUDA_R_16F CUDA_R_16F CUDA_R_32F
Handle.SDDMM for FormatBsr also supports the following mixed-precision computation:
A/B C computeType CUDA_R_16BF CUDA_R_32F CUDA_R_32F CUDA_R_16BF CUDA_R_16BF CUDA_R_32F
NOTE: CUDA_R_16F, CUDA_R_16BF data types always imply mixed-precision computation. Handle.SDDMM for CUSPASRE_FORMAT_BSR supports block sizes of 2, 4, 8, 16, 32, 64 and 128. Handle.SDDMM supports the following algorithms:
- SddmmAlgDefault: Default algorithm. It supports batched computation.
Performance notes: Handle.SDDMM for FormatCsr provides the best performance when matA and matB satisfy:
- matA: matA is in row-major order and opA is OperationNonTranspose, or matA is in col-major order and opA is not OperationNonTranspose
- matB: matB is in col-major order and opB is OperationNonTranspose, or matB is in row-major order and opB is not OperationNonTranspose
Handle.SDDMM for FormatBsr provides the best performance when matA and matB satisfy:
- matA: matA is in row-major order and opA is OperationNonTranspose, or matA is in col-major order and opA is not OperationNonTranspose
- matB: matB is in row-major order and opB is OperationNonTranspose, or matB is in col-major order and opB is not OperationNonTranspose
Handle.SDDMM supports the following batch modes:
- Cᵢ=(A⋅B)∘Cᵢ
- Cᵢ=(Aᵢ⋅B)∘Cᵢ
- Cᵢ=(A⋅Bᵢ)∘Cᵢ
- Cᵢ=(Aᵢ⋅Bᵢ)∘Cᵢ
The number of batches and their strides can be set by using SpMatDescr.CsrSetStridedBatch and DnMatDescr.MatSetStridedBatch. The maximum number of batches for Handle.SDDMM is 65,535. Handle.SDDMM has the following properties:
- The routine requires no extra storage
- Provides deterministic (bit-wise) results for each run
- The routine supports asynchronous execution
- The routine allows the indices of matC to be unsorted
Handle.SDDMM supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - Handle.SDDMM for a code example. For batched computation please visit Handle.SDDMM CSR Batched.
- opA: Operation op(A)
- opB: Operation op(B)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Dense matrix matA
- matB: Dense matrix matB
- beta: β scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matC: Sparse matrix matC
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- externalBuffer: Pointer to a workspace buffer of at least bufferSize bytes
Wraps cusparseSDDMMPreprocess, bound as cusparseSDDMM_preprocess.
func (Handle) Scatter ¶
func (h Handle) Scatter(vecX ConstSpVecDescr, vecY DnVecDescr) error
Scatter scatters the elements of the sparse vector vecX into the dense vector vecY.
In other words,
for i=0 to nnz-1
Y[X_indices[i]] = X_values[i]
Handle.Scatter supports the following index type for representing the sparse vector vecX:
Handle.Scatter supports the following data types:
- X/Y: CUDA_R_8I, CUDA_R_16F, CUDA_R_16BF, CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
Handle.Scatter has the following constraints:
- The arrays representing the sparse vector vecX must be aligned to 16 bytes
Handle.Scatter has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- Provides deterministic (bit-wise) results for each run if the the sparse vector vecX indices are distinct
- The routine allows indices of vecX to be unsorted
Handle.Scatter supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - Handle.Scatter for a code example.
- vecX: Sparse vector X
- vecY: Dense vector Y
Wraps cusparseScatter.
func (Handle) SetPointerMode ¶
func (h Handle) SetPointerMode(mode PointerMode) error
SetPointerMode sets the pointer mode used by the cuSPARSE library.
The default is for the values to be passed by reference on the host. Please see the section on the cublasPointerMode_t type for more details.
- mode: One of the enumerated pointer mode types
Wraps cusparseSetPointerMode.
func (Handle) SetStream ¶
SetStream sets the stream to be used by the cuSPARSE library to execute its routines.
- streamId: The stream to be used by the library
Wraps cusparseSetStream.
func (Handle) SpGEMMCompute ¶
func (h Handle) SpGEMMCompute(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, matB ConstSpMatDescr, beta Scalar, matC SpMatDescr, computeType DataType, alg SpGEMMAlg, spgemmDescr SpGEMMDescr, bufferSize2 *uint, externalBuffer2 driver.DevicePtr) error
SpGEMMCompute performs the multiplication of two sparse matrices matA and matB.
C′=αop(A)⋅op(B)+βC where α,β are scalars, and C,C′ have the same sparsity pattern. The functions Handle.SpGEMMWorkEstimation, Handle.SpGEMMEstimateMemory, and Handle.SpGEMMCompute are used for both determining the buffer size and performing the actual computation. cusparseSpGEMM supports the following index type for representing the sparse matrix A, B and C (all matrices must have the same index type):
Currently, the function has the following limitations:
- Only CSR format FormatCsr is supported
- Only opA, opB equal to OperationNonTranspose are supported
The data types combinations currently supported for cusparseSpGEMM are listed below : Uniform-precision computation:
- A/B/C/computeType: CUDA_R_16F DEPRECATED, CUDA_R_16BF DEPRECATED, CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
cusparseSpGEMM routine runs for the following algorithms:
- SpgemmDefault: Default algorithm. Currently, it is SpgemmALG1.
- SpgemmALG1: Algorithm 1: Invokes Handle.SpGEMMCompute twice. The first invocation provides an upper bound of the memory required for the computation. The required memory is generally several times larger of the actual memory used. The user can provide an arbitrary buffer size bufferSize2 in the second invocation. If it is not sufficient, the routine will returns ErrInsufficientResources status. Provides better performance than other algorithms. Provides deterministic (bit-wise) results for each run.
- SpgemmALG2: Algorithm 2: Invokes Handle.SpGEMMEstimateMemory to get the amount of the memory required for the computation. Requires less memory for the computation than Algorithm 1. Performance is lower than Algorithm 1, higher than Algorithm 3. Provides deterministic (bit-wise) results for each run.
- SpgemmALG3: Algorithm 3: Computes the intermediate products in chunks, one chunk at a time. Invokes Handle.SpGEMMEstimateMemory to get the amount of the memory required for the computation. The user can control the amount of required memory by changing the chunk size via chunk_fraction. The chunk size is a fraction of total intermediate products: chunk_fraction * (*num_prods). Provides deterministic (bit-wise) results for each run.
cusparseSpGEMM() has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- The routine allows the indices of matA and matB to be unsorted
- The routine guarantees the indices of matC to be sorted
cusparseSpGEMM() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - cusparseSpGEMM for a code example for SpgemmDefault and SpgemmALG1, and cuSPARSE Library Samples - memory-optimzed cusparseSpGEMM for a code example for SpgemmALG2 and SpgemmALG3.
- opA: Operation op(A)
- opB: Operation op(B)
- alpha: α scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- matB: Sparse matrix B
- beta: β scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matC: Sparse matrix C
- computeType: Enumerator specifying the datatype in which the computation is executed
- alg: Enumerator specifying the algorithm for the computation
- spgemmDescr: Opaque descriptor for storing internal data used across the three steps
- bufferSize2: Number of bytes of workspace requested by Handle.SpGEMMCompute
- externalBuffer2: Pointer to workspace buffer needed by Handle.SpGEMMCompute and Handle.SpGEMMCopy
Wraps cusparseSpGEMMCompute, bound as cusparseSpGEMM_compute.
func (Handle) SpGEMMCopy ¶
func (h Handle) SpGEMMCopy(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, matB ConstSpMatDescr, beta Scalar, matC SpMatDescr, computeType DataType, alg SpGEMMAlg, spgemmDescr SpGEMMDescr) error
SpGEMMCopy performs the multiplication of two sparse matrices matA and matB.
C′=αop(A)⋅op(B)+βC where α,β are scalars, and C,C′ have the same sparsity pattern. The functions Handle.SpGEMMWorkEstimation, Handle.SpGEMMEstimateMemory, and Handle.SpGEMMCompute are used for both determining the buffer size and performing the actual computation. cusparseSpGEMM supports the following index type for representing the sparse matrix A, B and C (all matrices must have the same index type):
Currently, the function has the following limitations:
- Only CSR format FormatCsr is supported
- Only opA, opB equal to OperationNonTranspose are supported
The data types combinations currently supported for cusparseSpGEMM are listed below : Uniform-precision computation:
- A/B/C/computeType: CUDA_R_16F DEPRECATED, CUDA_R_16BF DEPRECATED, CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
cusparseSpGEMM routine runs for the following algorithms:
- SpgemmDefault: Default algorithm. Currently, it is SpgemmALG1.
- SpgemmALG1: Algorithm 1: Invokes Handle.SpGEMMCompute twice. The first invocation provides an upper bound of the memory required for the computation. The required memory is generally several times larger of the actual memory used. The user can provide an arbitrary buffer size bufferSize2 in the second invocation. If it is not sufficient, the routine will returns ErrInsufficientResources status. Provides better performance than other algorithms. Provides deterministic (bit-wise) results for each run.
- SpgemmALG2: Algorithm 2: Invokes Handle.SpGEMMEstimateMemory to get the amount of the memory required for the computation. Requires less memory for the computation than Algorithm 1. Performance is lower than Algorithm 1, higher than Algorithm 3. Provides deterministic (bit-wise) results for each run.
- SpgemmALG3: Algorithm 3: Computes the intermediate products in chunks, one chunk at a time. Invokes Handle.SpGEMMEstimateMemory to get the amount of the memory required for the computation. The user can control the amount of required memory by changing the chunk size via chunk_fraction. The chunk size is a fraction of total intermediate products: chunk_fraction * (*num_prods). Provides deterministic (bit-wise) results for each run.
cusparseSpGEMM() has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- The routine allows the indices of matA and matB to be unsorted
- The routine guarantees the indices of matC to be sorted
cusparseSpGEMM() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - cusparseSpGEMM for a code example for SpgemmDefault and SpgemmALG1, and cuSPARSE Library Samples - memory-optimzed cusparseSpGEMM for a code example for SpgemmALG2 and SpgemmALG3.
- opA: Operation op(A)
- opB: Operation op(B)
- alpha: α scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- matB: Sparse matrix B
- beta: β scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matC: Sparse matrix C
- computeType: Enumerator specifying the datatype in which the computation is executed
- alg: Enumerator specifying the algorithm for the computation
- spgemmDescr: Opaque descriptor for storing internal data used across the three steps
Wraps cusparseSpGEMMCopy, bound as cusparseSpGEMM_copy.
func (Handle) SpGEMMEstimateMemory ¶
func (h Handle) SpGEMMEstimateMemory(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, matB ConstSpMatDescr, beta Scalar, matC SpMatDescr, computeType DataType, alg SpGEMMAlg, spgemmDescr SpGEMMDescr, chunkFraction float32, bufferSize3 *uint, externalBuffer3 driver.DevicePtr, bufferSize2 *uint) error
SpGEMMEstimateMemory performs the multiplication of two sparse matrices matA and matB.
C′=αop(A)⋅op(B)+βC where α,β are scalars, and C,C′ have the same sparsity pattern. The functions Handle.SpGEMMWorkEstimation, Handle.SpGEMMEstimateMemory, and Handle.SpGEMMCompute are used for both determining the buffer size and performing the actual computation. cusparseSpGEMM supports the following index type for representing the sparse matrix A, B and C (all matrices must have the same index type):
Currently, the function has the following limitations:
- Only CSR format FormatCsr is supported
- Only opA, opB equal to OperationNonTranspose are supported
The data types combinations currently supported for cusparseSpGEMM are listed below : Uniform-precision computation:
- A/B/C/computeType: CUDA_R_16F DEPRECATED, CUDA_R_16BF DEPRECATED, CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
cusparseSpGEMM routine runs for the following algorithms:
- SpgemmDefault: Default algorithm. Currently, it is SpgemmALG1.
- SpgemmALG1: Algorithm 1: Invokes Handle.SpGEMMCompute twice. The first invocation provides an upper bound of the memory required for the computation. The required memory is generally several times larger of the actual memory used. The user can provide an arbitrary buffer size bufferSize2 in the second invocation. If it is not sufficient, the routine will returns ErrInsufficientResources status. Provides better performance than other algorithms. Provides deterministic (bit-wise) results for each run.
- SpgemmALG2: Algorithm 2: Invokes Handle.SpGEMMEstimateMemory to get the amount of the memory required for the computation. Requires less memory for the computation than Algorithm 1. Performance is lower than Algorithm 1, higher than Algorithm 3. Provides deterministic (bit-wise) results for each run.
- SpgemmALG3: Algorithm 3: Computes the intermediate products in chunks, one chunk at a time. Invokes Handle.SpGEMMEstimateMemory to get the amount of the memory required for the computation. The user can control the amount of required memory by changing the chunk size via chunkFraction. The chunk size is a fraction of total intermediate products: chunkFraction * (*num_prods). Provides deterministic (bit-wise) results for each run.
cusparseSpGEMM() has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- The routine allows the indices of matA and matB to be unsorted
- The routine guarantees the indices of matC to be sorted
cusparseSpGEMM() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - cusparseSpGEMM for a code example for SpgemmDefault and SpgemmALG1, and cuSPARSE Library Samples - memory-optimzed cusparseSpGEMM for a code example for SpgemmALG2 and SpgemmALG3.
- opA: Operation op(A)
- opB: Operation op(B)
- alpha: α scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- matB: Sparse matrix B
- beta: β scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matC: Sparse matrix C
- computeType: Enumerator specifying the datatype in which the computation is executed
- alg: Enumerator specifying the algorithm for the computation
- spgemmDescr: Opaque descriptor for storing internal data used across the three steps
- chunkFraction: The fraction of total intermediate products being computed in a chunk. Used by SpgemmALG3 only. Value is in range (0,1]
- bufferSize3: Number of bytes of workspace requested by Handle.SpGEMMEstimateMemory
- externalBuffer3: Pointer to workspace buffer needed by Handle.SpGEMMEstimateMemory
- bufferSize2: Number of bytes of workspace requested by Handle.SpGEMMCompute
Wraps cusparseSpGEMMEstimateMemory, bound as cusparseSpGEMM_estimateMemory.
func (Handle) SpGEMMWorkEstimation ¶
func (h Handle) SpGEMMWorkEstimation(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, matB ConstSpMatDescr, beta Scalar, matC SpMatDescr, computeType DataType, alg SpGEMMAlg, spgemmDescr SpGEMMDescr, bufferSize1 *uint, externalBuffer1 driver.DevicePtr) error
SpGEMMWorkEstimation performs the multiplication of two sparse matrices matA and matB.
C′=αop(A)⋅op(B)+βC where α,β are scalars, and C,C′ have the same sparsity pattern. The functions Handle.SpGEMMWorkEstimation, Handle.SpGEMMEstimateMemory, and Handle.SpGEMMCompute are used for both determining the buffer size and performing the actual computation. cusparseSpGEMM supports the following index type for representing the sparse matrix A, B and C (all matrices must have the same index type):
Currently, the function has the following limitations:
- Only CSR format FormatCsr is supported
- Only opA, opB equal to OperationNonTranspose are supported
The data types combinations currently supported for cusparseSpGEMM are listed below : Uniform-precision computation:
- A/B/C/computeType: CUDA_R_16F DEPRECATED, CUDA_R_16BF DEPRECATED, CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
cusparseSpGEMM routine runs for the following algorithms:
- SpgemmDefault: Default algorithm. Currently, it is SpgemmALG1.
- SpgemmALG1: Algorithm 1: Invokes Handle.SpGEMMCompute twice. The first invocation provides an upper bound of the memory required for the computation. The required memory is generally several times larger of the actual memory used. The user can provide an arbitrary buffer size bufferSize2 in the second invocation. If it is not sufficient, the routine will returns ErrInsufficientResources status. Provides better performance than other algorithms. Provides deterministic (bit-wise) results for each run.
- SpgemmALG2: Algorithm 2: Invokes Handle.SpGEMMEstimateMemory to get the amount of the memory required for the computation. Requires less memory for the computation than Algorithm 1. Performance is lower than Algorithm 1, higher than Algorithm 3. Provides deterministic (bit-wise) results for each run.
- SpgemmALG3: Algorithm 3: Computes the intermediate products in chunks, one chunk at a time. Invokes Handle.SpGEMMEstimateMemory to get the amount of the memory required for the computation. The user can control the amount of required memory by changing the chunk size via chunk_fraction. The chunk size is a fraction of total intermediate products: chunk_fraction * (*num_prods). Provides deterministic (bit-wise) results for each run.
cusparseSpGEMM() has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- The routine allows the indices of matA and matB to be unsorted
- The routine guarantees the indices of matC to be sorted
cusparseSpGEMM() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - cusparseSpGEMM for a code example for SpgemmDefault and SpgemmALG1, and cuSPARSE Library Samples - memory-optimzed cusparseSpGEMM for a code example for SpgemmALG2 and SpgemmALG3.
- opA: Operation op(A)
- opB: Operation op(B)
- alpha: α scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- matB: Sparse matrix B
- beta: β scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matC: Sparse matrix C
- computeType: Enumerator specifying the datatype in which the computation is executed
- alg: Enumerator specifying the algorithm for the computation
- spgemmDescr: Opaque descriptor for storing internal data used across the three steps
- bufferSize1: Number of bytes of workspace requested by Handle.SpGEMMWorkEstimation
- externalBuffer1: Pointer to workspace buffer needed by Handle.SpGEMMWorkEstimation and Handle.SpGEMMCompute
Wraps cusparseSpGEMMWorkEstimation, bound as cusparseSpGEMM_workEstimation.
func (Handle) SpGEMMreuseCompute
deprecated
func (h Handle) SpGEMMreuseCompute(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, matB ConstSpMatDescr, beta Scalar, matC SpMatDescr, computeType DataType, alg SpGEMMAlg, spgemmDescr SpGEMMDescr) error
SpGEMMreuseCompute performs the multiplication of two sparse matrices matA and matB where the structure of the output matrix matC can be reused for multiple computations with different values.
C′=αop(A)⋅op(B)+βC where α and β are scalars. The functions Handle.SpGEMMreuseWorkEstimation, Handle.SpGEMMreuseNnz, and Handle.SpGEMMreuseCopy are used for determining the buffer size and performing the actual computation.
Note: cusparseSpGEMMreuse() output CSR matrix ( matC) is sorted by column indices. MEMORY REQUIREMENT: cusparseSpGEMMreuse requires to keep in memory all intermediate products to reuse the structure of the output matrix. On the other hand, the number of intermediate products is orders of magnitude higher than the number of non-zero entries in general. In order to minimize the memory requirements, the routine uses multiple buffers that can be deallocated after they are no more needed. If the number of intermediate product exceeds 2^31-1, the routine will returns ErrInsufficientResources status. Currently, the function has the following limitations:
- Only 32-bit indices Index32I is supported
- Only CSR format FormatCsr is supported
- Only opA, opB equal to OperationNonTranspose are supported
The data types combinations currently supported for cusparseSpGEMMreuse are listed below. Uniform-precision computation:
- A/B/C/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
Mixed-precision computation: DEPRECATED
A/B C computeType CUDA_R_16F CUDA_R_16F CUDA_R_32F CUDA_R_16BF CUDA_R_16BF CUDA_R_32F
cusparseSpGEMMreuse routine runs for the following algorithm:
- SpgemmDefault, SpgemmCsrAlgNondeterminitic: Default algorithm. Provides deterministic (bit-wise) structure for the output matrix for each run, while value computation is not deterministic.
- SpgemmCsrAlgDeterminitic: Provides deterministic (bit-wise) structure for the output matrix and value computation for each run.
cusparseSpGEMMreuse() has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- The routine allows the indices of matA and matB to be unsorted
- The routine guarantees the indices of matC to be sorted
cusparseSpGEMMreuse() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - cusparseSpGEMMreuse for a code example.
The kinds of alpha and beta must match computeType; a host Scalar of another kind is a *ScalarError.
Wraps cusparseSpGEMMreuseCompute, bound as cusparseSpGEMMreuse_compute.
Deprecated: Deprecated by NVIDIA.
func (Handle) SpGEMMreuseCopy
deprecated
func (h Handle) SpGEMMreuseCopy(opA Operation, opB Operation, matA ConstSpMatDescr, matB ConstSpMatDescr, matC SpMatDescr, alg SpGEMMAlg, spgemmDescr SpGEMMDescr, bufferSize5 *uint, externalBuffer5 driver.DevicePtr) error
SpGEMMreuseCopy performs the multiplication of two sparse matrices matA and matB where the structure of the output matrix matC can be reused for multiple computations with different values.
C′=αop(A)⋅op(B)+βC where α and β are scalars. The functions Handle.SpGEMMreuseWorkEstimation, Handle.SpGEMMreuseNnz, and Handle.SpGEMMreuseCopy are used for determining the buffer size and performing the actual computation.
Note: cusparseSpGEMMreuse() output CSR matrix ( matC) is sorted by column indices. MEMORY REQUIREMENT: cusparseSpGEMMreuse requires to keep in memory all intermediate products to reuse the structure of the output matrix. On the other hand, the number of intermediate products is orders of magnitude higher than the number of non-zero entries in general. In order to minimize the memory requirements, the routine uses multiple buffers that can be deallocated after they are no more needed. If the number of intermediate product exceeds 2^31-1, the routine will returns ErrInsufficientResources status. Currently, the function has the following limitations:
- Only 32-bit indices Index32I is supported
- Only CSR format FormatCsr is supported
- Only opA, opB equal to OperationNonTranspose are supported
The data types combinations currently supported for cusparseSpGEMMreuse are listed below. Uniform-precision computation:
- A/B/C/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
Mixed-precision computation: DEPRECATED
A/B C computeType CUDA_R_16F CUDA_R_16F CUDA_R_32F CUDA_R_16BF CUDA_R_16BF CUDA_R_32F
cusparseSpGEMMreuse routine runs for the following algorithm:
- SpgemmDefault, SpgemmCsrAlgNondeterminitic: Default algorithm. Provides deterministic (bit-wise) structure for the output matrix for each run, while value computation is not deterministic.
- SpgemmCsrAlgDeterminitic: Provides deterministic (bit-wise) structure for the output matrix and value computation for each run.
cusparseSpGEMMreuse() has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- The routine allows the indices of matA and matB to be unsorted
- The routine guarantees the indices of matC to be sorted
cusparseSpGEMMreuse() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - cusparseSpGEMMreuse for a code example.
Wraps cusparseSpGEMMreuseCopy, bound as cusparseSpGEMMreuse_copy.
Deprecated: Deprecated by NVIDIA.
func (Handle) SpGEMMreuseNnz
deprecated
func (h Handle) SpGEMMreuseNnz(opA Operation, opB Operation, matA ConstSpMatDescr, matB ConstSpMatDescr, matC SpMatDescr, alg SpGEMMAlg, spgemmDescr SpGEMMDescr, bufferSize2 *uint, externalBuffer2 driver.DevicePtr, bufferSize3 *uint, externalBuffer3 driver.DevicePtr, bufferSize4 *uint, externalBuffer4 driver.DevicePtr) error
SpGEMMreuseNnz performs the multiplication of two sparse matrices matA and matB where the structure of the output matrix matC can be reused for multiple computations with different values.
C′=αop(A)⋅op(B)+βC where α and β are scalars. The functions Handle.SpGEMMreuseWorkEstimation, Handle.SpGEMMreuseNnz, and Handle.SpGEMMreuseCopy are used for determining the buffer size and performing the actual computation.
Note: cusparseSpGEMMreuse() output CSR matrix ( matC) is sorted by column indices. MEMORY REQUIREMENT: cusparseSpGEMMreuse requires to keep in memory all intermediate products to reuse the structure of the output matrix. On the other hand, the number of intermediate products is orders of magnitude higher than the number of non-zero entries in general. In order to minimize the memory requirements, the routine uses multiple buffers that can be deallocated after they are no more needed. If the number of intermediate product exceeds 2^31-1, the routine will returns ErrInsufficientResources status. Currently, the function has the following limitations:
- Only 32-bit indices Index32I is supported
- Only CSR format FormatCsr is supported
- Only opA, opB equal to OperationNonTranspose are supported
The data types combinations currently supported for cusparseSpGEMMreuse are listed below. Uniform-precision computation:
- A/B/C/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
Mixed-precision computation: DEPRECATED
A/B C computeType CUDA_R_16F CUDA_R_16F CUDA_R_32F CUDA_R_16BF CUDA_R_16BF CUDA_R_32F
cusparseSpGEMMreuse routine runs for the following algorithm:
- SpgemmDefault, SpgemmCsrAlgNondeterminitic: Default algorithm. Provides deterministic (bit-wise) structure for the output matrix for each run, while value computation is not deterministic.
- SpgemmCsrAlgDeterminitic: Provides deterministic (bit-wise) structure for the output matrix and value computation for each run.
cusparseSpGEMMreuse() has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- The routine allows the indices of matA and matB to be unsorted
- The routine guarantees the indices of matC to be sorted
cusparseSpGEMMreuse() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - cusparseSpGEMMreuse for a code example.
Wraps cusparseSpGEMMreuseNnz, bound as cusparseSpGEMMreuse_nnz.
Deprecated: Deprecated by NVIDIA.
func (Handle) SpGEMMreuseWorkEstimation
deprecated
func (h Handle) SpGEMMreuseWorkEstimation(opA Operation, opB Operation, matA ConstSpMatDescr, matB ConstSpMatDescr, matC SpMatDescr, alg SpGEMMAlg, spgemmDescr SpGEMMDescr, bufferSize1 *uint, externalBuffer1 driver.DevicePtr) error
SpGEMMreuseWorkEstimation performs the multiplication of two sparse matrices matA and matB where the structure of the output matrix matC can be reused for multiple computations with different values.
C′=αop(A)⋅op(B)+βC where α and β are scalars. The functions Handle.SpGEMMreuseWorkEstimation, Handle.SpGEMMreuseNnz, and Handle.SpGEMMreuseCopy are used for determining the buffer size and performing the actual computation.
Note: cusparseSpGEMMreuse() output CSR matrix ( matC) is sorted by column indices. MEMORY REQUIREMENT: cusparseSpGEMMreuse requires to keep in memory all intermediate products to reuse the structure of the output matrix. On the other hand, the number of intermediate products is orders of magnitude higher than the number of non-zero entries in general. In order to minimize the memory requirements, the routine uses multiple buffers that can be deallocated after they are no more needed. If the number of intermediate product exceeds 2^31-1, the routine will returns ErrInsufficientResources status. Currently, the function has the following limitations:
- Only 32-bit indices Index32I is supported
- Only CSR format FormatCsr is supported
- Only opA, opB equal to OperationNonTranspose are supported
The data types combinations currently supported for cusparseSpGEMMreuse are listed below. Uniform-precision computation:
- A/B/C/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
Mixed-precision computation: DEPRECATED
A/B C computeType CUDA_R_16F CUDA_R_16F CUDA_R_32F CUDA_R_16BF CUDA_R_16BF CUDA_R_32F
cusparseSpGEMMreuse routine runs for the following algorithm:
- SpgemmDefault, SpgemmCsrAlgNondeterminitic: Default algorithm. Provides deterministic (bit-wise) structure for the output matrix for each run, while value computation is not deterministic.
- SpgemmCsrAlgDeterminitic: Provides deterministic (bit-wise) structure for the output matrix and value computation for each run.
cusparseSpGEMMreuse() has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- The routine allows the indices of matA and matB to be unsorted
- The routine guarantees the indices of matC to be sorted
cusparseSpGEMMreuse() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - cusparseSpGEMMreuse for a code example.
Wraps cusparseSpGEMMreuseWorkEstimation, bound as cusparseSpGEMMreuse_workEstimation.
Deprecated: Deprecated by NVIDIA.
func (Handle) SpMM ¶
func (h Handle) SpMM(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, matB ConstDnMatDescr, beta Scalar, matC DnMatDescr, computeType DataType, alg SpMMAlg, externalBuffer driver.DevicePtr) error
SpMM performs the multiplication of a sparse matrix matA and a dense matrix matB.
C=αop(A)⋅op(B)+βC where
- op(A) is a sparse matrix of size m×k
- op(B) is a dense matrix of size k×n
- C is a dense matrix of size m×n
- α and β are scalars
The routine can be also used to perform the multiplication of a dense matrix and a sparse matrix by switching the dense matrices layout: C_(C)=B_(C)⋅A+βC_(C)→C_(R)=Aᵀ⋅B_(R)+βC_(R) where B_(C) , C_(C) indicate column-major layout, while B_(R) , C_(R) refer to row-major layout Also, for matrix A and B: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose; op(B) = B if opB == OperationNonTranspose, op(B) = Bᵀ if opB == OperationTranspose, and op(B) = Bᴴ if opB == OperationConjugateTranspose. When using the (conjugate) transpose of the sparse matrix A, this routine may produce slightly different results during different runs with the same input parameters. The function Handle.SpMMBufferSize returns the size of the workspace needed by Handle.SpMM Calling Handle.SpMMPreprocess is optional. It may accelerate subsequent calls to Handle.SpMM. It is useful when Handle.SpMM is called multiple times with the same sparsity pattern ( matA). It provides performance advantages with SpmmCsrALG1 or SpmmCsrALG3. For all other formats and algorithms have no effect. Calling Handle.SpMMPreprocess with buffer makes that buffer “active” for matA Handle.SpMM calls. Subsequent calls to Handle.SpMM with matA and the active buffer must use the same values for all parameters as the call to Handle.SpMMPreprocess. The exceptions are: alpha, beta, matX, matY, and the values (but not indices) of matA may be different. Importantly, the buffer contents must be unmodified since the call to Handle.SpMMPreprocess. When Handle.SpMM is called with matA and its active buffer, it may read acceleration data from the buffer. Calling Handle.SpMMPreprocess again with matA and a new buffer will make the new buffer active, forgetting about the previously-active buffer and making it inactive. For Handle.SpMM, there can only be one active buffer per sparse matrix at a time. To get the effect of multiple active buffers for a single sparse matrix, create multiple matrix handles that all point to the same index and value buffers, and call Handle.SpMMPreprocess once per handle with different workspace buffers. Calling Handle.SpMM with an inactive buffer is always permitted. However, there may be no acceleration from the preprocessing in that case. For the purposes of thread safety, Handle.SpMMPreprocess is writing to matA internal state. Handle.SpMM supports the following sparse matrix formats:
- FormatCoo
- FormatCsr
- FormatCsc
- FormatBsr
- FormatBlockedEll
- (1): COO/CSR/CSC/BSR FORMATS
Handle.SpMM supports the following index type for representing the sparse matrix matA:
Handle.SpMM supports the following data types: Uniform-precision computation:
- A/B/C/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
Mixed-precision computation:
A/B C computeType CUDA_R_8I CUDA_R_32I CUDA_R_32I CUDA_R_8I CUDA_R_32F CUDA_R_32F CUDA_R_16F CUDA_R_32F CUDA_R_32F CUDA_R_16BF CUDA_R_32F CUDA_R_32F CUDA_R_16F CUDA_R_16F CUDA_R_32F CUDA_R_16BF CUDA_R_16BF CUDA_R_32F CUDA_C_16F CUDA_C_16F CUDA_C_32F [DEPRECATED] CUDA_C_16BF CUDA_C_16BF CUDA_C_32F [DEPRECATED]
NOTE: CUDA_R_16F, CUDA_R_16BF, CUDA_C_16F, and CUDA_C_16BF data types always imply mixed-precision computation. Handle.SpMM supports the following algorithms:
- SpmmAlgDefault: Default algorithm for any sparse matrix format
- SpmmCooALG1: Algorithm 1 for COO sparse matrix format: May provide better performance for small number of nnz; Provides the best performance with column-major layout; It supports batched computation; May produce slightly different results during different runs with the same input parameters
- SpmmCooALG2: Algorithm 2 for COO sparse matrix format: It provides deterministic result; Provides the best performance with column-major layout; In general, slower than Algorithm 1; It supports batched computation; It requires additional memory; If opA != OperationNonTranspose, it is identical to SpmmCooALG1
- SpmmCooALG3: Algorithm 3 for COO sparse matrix format: May provide better performance for large number of nnz; May produce slightly different results during different runs with the same input parameters
- SpmmCooALG4: Algorithm 4 for COO sparse matrix format: Provides better performance with row-major layout; It supports batched computation; May produce slightly different results during different runs with the same input parameters
- SpmmCsrALG1: Algorithm 1 for CSR/CSC sparse matrix format: Provides the best performance with column-major layout; It supports batched computation; It requires additional memory; May produce slightly different results during different runs with the same input parameters
- SpmmCsrALG2: Algorithm 2 for CSR/CSC sparse matrix format: Provides the best performance with row-major layout; It supports batched computation; It requires additional memory; May produce slightly different results during different runs with the same input parameters
- SpmmCsrALG3: Algorithm 3 for CSR sparse matrix format: It provides deterministic result; It requires additional memory; It supports only CSR matrix and opA == OperationNonTranspose; It does not support opB == OperationConjugateTranspose; It does not support CUDA_C_16F and CUDA_C_16BF data types
- SpmmBsrALG1: Algorithm 1 for BSR sparse matrix format: It provides deterministic result; It requires no additional memory; It supports only opA == OperationNonTranspose; It does not support CUDA_C_16F and CUDA_C_16BF data types; It does not support column-major blocks in A
NOTE: When using Handle.SpMM for mixed-precision computation on COO or CSR matrices, it defaults to algorithms SpmmCooALG2 and SpmmCsrALG3, respectively. If the required computation isn’t supported by those algorithms, the mixed-precision operation will fail. Performance notes:
- Row-major layout provides higher performance than column-major
- SpmmCooALG4 and SpmmCsrALG2 should be used with row-major layout, while SpmmCooALG1, SpmmCooALG2, SpmmCooALG3, and SpmmCsrALG1 with column-major layout
- For beta != 1, most algorithms scale the output matrix before the main computation
- For n == 1, the routine may use Handle.SpMV
Handle.SpMM with all algorithms support the following batch modes except for SpmmCsrALG3:
- Cᵢ=A⋅Bᵢ
- Cᵢ=Aᵢ⋅B
- Cᵢ=Aᵢ⋅Bᵢ
The number of batches and their strides can be set by using SpMatDescr.CooSetStridedBatch, SpMatDescr.CsrSetStridedBatch, and DnMatDescr.MatSetStridedBatch. The maximum number of batches for Handle.SpMM is 65,535. Handle.SpMM has the following properties:
- The routine requires no extra storage for SpmmCooALG1, SpmmCooALG3, SpmmCooALG4, SpmmBsrALG1
- The routine supports asynchronous execution
- Provides deterministic (bit-wise) results for each run only for SpmmCooALG2, SpmmCsrALG3, and SpmmBsrALG1 algorithms
- compute-sanitizer could report false race conditions for this routine. This is for optimization purposes and does not affect the correctness of the computation
- The routine allows the indices of matA to be unsorted
Handle.SpMM supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - Handle.SpMM CSR and Handle.SpMM COO for a code example. For batched computation please visit Handle.SpMM CSR Batched and Handle.SpMM COO Batched.
- (2): BLOCKED-ELLPACK FORMAT
Handle.SpMM supports the following data types for FormatBlockedEll format and the following GPU architectures for exploiting NVIDIA Tensor Cores:
A/B C computeType opB Compute Capability CUDA_R_16F CUDA_R_16F CUDA_R_16F N, T ≥ 70 CUDA_R_16F CUDA_R_16F CUDA_R_32F N, T ≥ 70 CUDA_R_16F CUDA_R_32F CUDA_R_32F N, T ≥ 70 CUDA_R_8I CUDA_R_32I CUDA_R_32I N column-major ≥ 75 CUDA_R_8I CUDA_R_32I CUDA_R_32I T row-major ≥ 75 CUDA_R_16BF CUDA_R_16BF CUDA_R_32F N, T ≥ 80 CUDA_R_16BF CUDA_R_32F CUDA_R_32F N, T ≥ 80 CUDA_R_32F CUDA_R_32F CUDA_R_32F N, T ≥ 80 CUDA_R_64F CUDA_R_64F CUDA_R_64F N, T ≥ 80
Handle.SpMM supports the following algorithms with FormatBlockedEll format:
- SpmmAlgDefault: Default algorithm for any sparse matrix format
- SpmmBlockedEllALG1: Default algorithm for Blocked-ELL format
Performance notes:
- Blocked-ELL Handle.SpMM provides the best performance with Power-of-2 Block-Sizes.
- Large Block-Sizes (e.g. ≥ 64) provide the best performance.
The function has the following limitations:
- The pointer mode must be equal to PointerModeHost
- Only opA == OperationNonTranspose is supported.
- opB == OperationConjugateTranspose is not supported.
- Only Index32I is supported.
Please visit cuSPARSE Library Samples - Handle.SpMM Blocked-ELL for a code example.
- opA: Operation op(A)
- opB: Operation op(B)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- matB: Dense matrix B
- beta: β scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matC: Dense matrix C
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- externalBuffer: Pointer to workspace buffer of at least bufferSize bytes
Wraps cusparseSpMM.
func (Handle) SpMMBufferSize ¶
func (h Handle) SpMMBufferSize(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, matB ConstDnMatDescr, beta Scalar, matC DnMatDescr, computeType DataType, alg SpMMAlg) (uint, error)
SpMMBufferSize returns the workspace size for Handle.SpMM.
- opA: Operation op(A)
- opB: Operation op(B)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- matB: Dense matrix B
- beta: β scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matC: Dense matrix C
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- bufferSize: Workspace size
Wraps cusparseSpMMBufferSize, bound as cusparseSpMM_bufferSize.
func (Handle) SpMMPreprocess ¶
func (h Handle) SpMMPreprocess(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, matB ConstDnMatDescr, beta Scalar, matC DnMatDescr, computeType DataType, alg SpMMAlg, externalBuffer driver.DevicePtr) error
SpMMPreprocess prepares the workspace buffer for Handle.SpMM, which may accelerate subsequent calls to it.
Handle.SpMM performs the multiplication of a sparse matrix matA and a dense matrix matB. C=αop(A)⋅op(B)+βC where
- op(A) is a sparse matrix of size m×k
- op(B) is a dense matrix of size k×n
- C is a dense matrix of size m×n
- α and β are scalars
The routine can be also used to perform the multiplication of a dense matrix and a sparse matrix by switching the dense matrices layout: C_(C)=B_(C)⋅A+βC_(C)→C_(R)=Aᵀ⋅B_(R)+βC_(R) where B_(C) , C_(C) indicate column-major layout, while B_(R) , C_(R) refer to row-major layout Also, for matrix A and B: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose; op(B) = B if opB == OperationNonTranspose, op(B) = Bᵀ if opB == OperationTranspose, and op(B) = Bᴴ if opB == OperationConjugateTranspose. When using the (conjugate) transpose of the sparse matrix A, this routine may produce slightly different results during different runs with the same input parameters. The function Handle.SpMMBufferSize returns the size of the workspace needed by Handle.SpMM Calling Handle.SpMMPreprocess is optional. It may accelerate subsequent calls to Handle.SpMM. It is useful when Handle.SpMM is called multiple times with the same sparsity pattern ( matA). It provides performance advantages with SpmmCsrALG1 or SpmmCsrALG3. For all other formats and algorithms have no effect. Calling Handle.SpMMPreprocess with buffer makes that buffer “active” for matA Handle.SpMM calls. Subsequent calls to Handle.SpMM with matA and the active buffer must use the same values for all parameters as the call to Handle.SpMMPreprocess. The exceptions are: alpha, beta, matX, matY, and the values (but not indices) of matA may be different. Importantly, the buffer contents must be unmodified since the call to Handle.SpMMPreprocess. When Handle.SpMM is called with matA and its active buffer, it may read acceleration data from the buffer. Calling Handle.SpMMPreprocess again with matA and a new buffer will make the new buffer active, forgetting about the previously-active buffer and making it inactive. For Handle.SpMM, there can only be one active buffer per sparse matrix at a time. To get the effect of multiple active buffers for a single sparse matrix, create multiple matrix handles that all point to the same index and value buffers, and call Handle.SpMMPreprocess once per handle with different workspace buffers. Calling Handle.SpMM with an inactive buffer is always permitted. However, there may be no acceleration from the preprocessing in that case. For the purposes of thread safety, Handle.SpMMPreprocess is writing to matA internal state. Handle.SpMM supports the following sparse matrix formats:
- FormatCoo
- FormatCsr
- FormatCsc
- FormatBsr
- FormatBlockedEll
- (1): COO/CSR/CSC/BSR FORMATS
Handle.SpMM supports the following index type for representing the sparse matrix matA:
Handle.SpMM supports the following data types: Uniform-precision computation:
- A/B/C/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
Mixed-precision computation:
A/B C computeType CUDA_R_8I CUDA_R_32I CUDA_R_32I CUDA_R_8I CUDA_R_32F CUDA_R_32F CUDA_R_16F CUDA_R_32F CUDA_R_32F CUDA_R_16BF CUDA_R_32F CUDA_R_32F CUDA_R_16F CUDA_R_16F CUDA_R_32F CUDA_R_16BF CUDA_R_16BF CUDA_R_32F CUDA_C_16F CUDA_C_16F CUDA_C_32F [DEPRECATED] CUDA_C_16BF CUDA_C_16BF CUDA_C_32F [DEPRECATED]
NOTE: CUDA_R_16F, CUDA_R_16BF, CUDA_C_16F, and CUDA_C_16BF data types always imply mixed-precision computation. Handle.SpMM supports the following algorithms:
- SpmmAlgDefault: Default algorithm for any sparse matrix format
- SpmmCooALG1: Algorithm 1 for COO sparse matrix format: May provide better performance for small number of nnz; Provides the best performance with column-major layout; It supports batched computation; May produce slightly different results during different runs with the same input parameters
- SpmmCooALG2: Algorithm 2 for COO sparse matrix format: It provides deterministic result; Provides the best performance with column-major layout; In general, slower than Algorithm 1; It supports batched computation; It requires additional memory; If opA != OperationNonTranspose, it is identical to SpmmCooALG1
- SpmmCooALG3: Algorithm 3 for COO sparse matrix format: May provide better performance for large number of nnz; May produce slightly different results during different runs with the same input parameters
- SpmmCooALG4: Algorithm 4 for COO sparse matrix format: Provides better performance with row-major layout; It supports batched computation; May produce slightly different results during different runs with the same input parameters
- SpmmCsrALG1: Algorithm 1 for CSR/CSC sparse matrix format: Provides the best performance with column-major layout; It supports batched computation; It requires additional memory; May produce slightly different results during different runs with the same input parameters
- SpmmCsrALG2: Algorithm 2 for CSR/CSC sparse matrix format: Provides the best performance with row-major layout; It supports batched computation; It requires additional memory; May produce slightly different results during different runs with the same input parameters
- SpmmCsrALG3: Algorithm 3 for CSR sparse matrix format: It provides deterministic result; It requires additional memory; It supports only CSR matrix and opA == OperationNonTranspose; It does not support opB == OperationConjugateTranspose; It does not support CUDA_C_16F and CUDA_C_16BF data types
- SpmmBsrALG1: Algorithm 1 for BSR sparse matrix format: It provides deterministic result; It requires no additional memory; It supports only opA == OperationNonTranspose; It does not support CUDA_C_16F and CUDA_C_16BF data types; It does not support column-major blocks in A
NOTE: When using Handle.SpMM for mixed-precision computation on COO or CSR matrices, it defaults to algorithms SpmmCooALG2 and SpmmCsrALG3, respectively. If the required computation isn’t supported by those algorithms, the mixed-precision operation will fail. Performance notes:
- Row-major layout provides higher performance than column-major
- SpmmCooALG4 and SpmmCsrALG2 should be used with row-major layout, while SpmmCooALG1, SpmmCooALG2, SpmmCooALG3, and SpmmCsrALG1 with column-major layout
- For beta != 1, most algorithms scale the output matrix before the main computation
- For n == 1, the routine may use Handle.SpMV
Handle.SpMM with all algorithms support the following batch modes except for SpmmCsrALG3:
- Cᵢ=A⋅Bᵢ
- Cᵢ=Aᵢ⋅B
- Cᵢ=Aᵢ⋅Bᵢ
The number of batches and their strides can be set by using SpMatDescr.CooSetStridedBatch, SpMatDescr.CsrSetStridedBatch, and DnMatDescr.MatSetStridedBatch. The maximum number of batches for Handle.SpMM is 65,535. Handle.SpMM has the following properties:
- The routine requires no extra storage for SpmmCooALG1, SpmmCooALG3, SpmmCooALG4, SpmmBsrALG1
- The routine supports asynchronous execution
- Provides deterministic (bit-wise) results for each run only for SpmmCooALG2, SpmmCsrALG3, and SpmmBsrALG1 algorithms
- compute-sanitizer could report false race conditions for this routine. This is for optimization purposes and does not affect the correctness of the computation
- The routine allows the indices of matA to be unsorted
Handle.SpMM supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - Handle.SpMM CSR and Handle.SpMM COO for a code example. For batched computation please visit Handle.SpMM CSR Batched and Handle.SpMM COO Batched.
- (2): BLOCKED-ELLPACK FORMAT
Handle.SpMM supports the following data types for FormatBlockedEll format and the following GPU architectures for exploiting NVIDIA Tensor Cores:
A/B C computeType opB Compute Capability CUDA_R_16F CUDA_R_16F CUDA_R_16F N, T ≥ 70 CUDA_R_16F CUDA_R_16F CUDA_R_32F N, T ≥ 70 CUDA_R_16F CUDA_R_32F CUDA_R_32F N, T ≥ 70 CUDA_R_8I CUDA_R_32I CUDA_R_32I N column-major ≥ 75 CUDA_R_8I CUDA_R_32I CUDA_R_32I T row-major ≥ 75 CUDA_R_16BF CUDA_R_16BF CUDA_R_32F N, T ≥ 80 CUDA_R_16BF CUDA_R_32F CUDA_R_32F N, T ≥ 80 CUDA_R_32F CUDA_R_32F CUDA_R_32F N, T ≥ 80 CUDA_R_64F CUDA_R_64F CUDA_R_64F N, T ≥ 80
Handle.SpMM supports the following algorithms with FormatBlockedEll format:
- SpmmAlgDefault: Default algorithm for any sparse matrix format
- SpmmBlockedEllALG1: Default algorithm for Blocked-ELL format
Performance notes:
- Blocked-ELL Handle.SpMM provides the best performance with Power-of-2 Block-Sizes.
- Large Block-Sizes (e.g. ≥ 64) provide the best performance.
The function has the following limitations:
- The pointer mode must be equal to PointerModeHost
- Only opA == OperationNonTranspose is supported.
- opB == OperationConjugateTranspose is not supported.
- Only Index32I is supported.
Please visit cuSPARSE Library Samples - Handle.SpMM Blocked-ELL for a code example.
- opA: Operation op(A)
- opB: Operation op(B)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- matB: Dense matrix B
- beta: β scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matC: Dense matrix C
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- externalBuffer: Pointer to workspace buffer of at least bufferSize bytes
Wraps cusparseSpMMPreprocess, bound as cusparseSpMM_preprocess.
func (Handle) SpMV ¶
func (h Handle) SpMV(opA Operation, alpha Scalar, matA ConstSpMatDescr, vecX ConstDnVecDescr, beta Scalar, vecY DnVecDescr, computeType DataType, alg SpMVAlg, externalBuffer driver.DevicePtr) error
SpMV performs the multiplication of a sparse matrix matA and a dense vector vecX.
Y=αop(A)⋅X+βY, where
- op(A) is a sparse matrix of size m×k
- X is a dense vector of size k
- Y is a dense vector of size m
- α and β are scalars
Also, for matrix A: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose. The function Handle.SpMVBufferSize returns the size of the workspace needed by Handle.SpMVPreprocess and Handle.SpMV The sparse matrix formats currently supported are listed below:
Handle.SpMV supports the following index type for representing the sparse matrix matA:
Handle.SpMV supports the following data types: Uniform-precision computation:
- A/X/Y/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
Mixed-precision computation:
A/X Y computeType Notes CUDA_R_8I CUDA_R_32I CUDA_R_32I CUDA_R_8I CUDA_R_32F CUDA_R_32F CUDA_R_16F CUDA_R_32F CUDA_R_32F CUDA_R_16BF CUDA_R_32F CUDA_R_32F CUDA_R_16F CUDA_R_16F CUDA_R_32F CUDA_R_16BF CUDA_R_16BF CUDA_R_32F CUDA_C_32F CUDA_C_32F CUDA_C_32F CUDA_C_16F CUDA_C_16F CUDA_C_32F [DEPRECATED] CUDA_C_16BF CUDA_C_16BF CUDA_C_32F [DEPRECATED]
A: CUDA_R_32F; X/Y/computeType: CUDA_R_64F.
Mixed Regular/Complex computation:
- A: CUDA_R_32F; X/Y/computeType: CUDA_C_32F
- A: CUDA_R_64F; X/Y/computeType: CUDA_C_64F
NOTE: CUDA_R_16F, CUDA_R_16BF, CUDA_C_16F, and CUDA_C_16BF data types always imply mixed-precision computation. Handle.SpMV supports the following algorithms:
- SpmvAlgDefault: Default algorithm for any sparse matrix format.
- SpmvCooALG1: Default algorithm for COO sparse matrix format. May produce slightly different results during different runs with the same input parameters.
- SpmvCooALG2: Provides deterministic (bit-wise) results for each run. If opA != OperationNonTranspose, it is identical to SpmvCooALG1.
- SpmvCsrALG1: Default algorithm for CSR/CSC sparse matrix format. May produce slightly different results during different runs with the same input parameters.
- SpmvCsrALG2: Provides deterministic (bit-wise) results for each run. If opA != OperationNonTranspose, it is identical to SpmvCsrALG1.
- SpmvSellALG1: Default algorithm for Sliced Ellpack sparse matrix format. Provides deterministic (bit-wise) results for each run.
- SpmvBsrALG1: Default algorithm for BSR sparse matrix format. Provides deterministic (bit-wise) results for each run. Supports only opA == OperationNonTranspose. Supports both row-major and column-major block layouts in A.
Calling Handle.SpMVPreprocess is optional. It may accelerate subsequent calls to Handle.SpMV. It is useful when Handle.SpMV is called multiple times with the same sparsity pattern ( matA). Calling Handle.SpMVPreprocess with buffer makes that buffer “active” for matA Handle.SpMV calls. Subsequent calls to Handle.SpMV with matA and the active buffer must use the same values for all parameters as the call to Handle.SpMVPreprocess. The exceptions are: alpha, beta, vecX, vecY, and the values (but not indices) of matA may be different. Importantly, the buffer contents must be unmodified since the call to Handle.SpMVPreprocess. When Handle.SpMV is called with matA and its active buffer, it may read acceleration data from the buffer. Calling Handle.SpMVPreprocess again with matA and a new buffer will make the new buffer active, forgetting about the previously-active buffer and making it inactive. For Handle.SpMV, there can only be one active buffer per sparse matrix at a time. To get the effect of multiple active buffers for a single sparse matrix, create multiple matrix handles that all point to the same index and value buffers, and call Handle.SpMVPreprocess once per handle with different workspace buffers. Calling Handle.SpMV with an inactive buffer is always permitted. However, there may be no acceleration from the preprocessing in that case. For the purposes of thread safety, Handle.SpMVPreprocess is writing to matA internal state. Performance notes:
- SpmvCooALG1 and SpmvCsrALG1 provide higher performance than SpmvCooALG2 and SpmvCsrALG2.
- In general, opA == OperationNonTranspose is 3x faster than opA != OperationNonTranspose.
- Using Handle.SpMVPreprocess helps improve performance of Handle.SpMV in CSR. It is beneficial when we need to run Handle.SpMV multiple times with a same matrix ( Handle.SpMVPreprocess is executed only once).
Handle.SpMV has the following properties:
- The routine requires extra storage for CSR/CSC format (all algorithms) and for COO format with SpmvCooALG2 algorithm.
- Provides deterministic (bit-wise) results for each run only for SpmvCooALG2, SpmvCsrALG2 and SpmvBsrALG1 algorithms, and opA == OperationNonTranspose.
- The routine supports asynchronous execution.
- compute-sanitizer could report false race conditions for this routine when beta == 0. This is for optimization purposes and does not affect the correctness of the computation.
- The routine allows the indices of matA to be unsorted.
Handle.SpMV supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - Handle.SpMV CSR and Handle.SpMV COO for a code example.
- opA: Operation op(A)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- vecX: Dense vector X
- beta: β scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- vecY: Dense vector Y
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- externalBuffer: Pointer to a workspace buffer of at least bufferSize bytes
Wraps cusparseSpMV.
func (Handle) SpMVBufferSize ¶
func (h Handle) SpMVBufferSize(opA Operation, alpha Scalar, matA ConstSpMatDescr, vecX ConstDnVecDescr, beta Scalar, vecY DnVecDescr, computeType DataType, alg SpMVAlg) (uint, error)
SpMVBufferSize returns the workspace size for Handle.SpMV.
- opA: Operation op(A)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- vecX: Dense vector X
- beta: β scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- vecY: Dense vector Y
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- bufferSize: Workspace size
Wraps cusparseSpMVBufferSize, bound as cusparseSpMV_bufferSize.
func (Handle) SpMVOp ¶
func (h Handle) SpMVOp(plan SpMVOpPlan, alpha Scalar, beta Scalar, vecX ConstDnVecDescr, vecY ConstDnVecDescr, vecZ DnVecDescr) error
SpMVOp is only available if macro CUSPARSE_ENABLE_EXPERIMENTAL_API is defined.
It performs the multiplication of a sparse matrix matA and a dense vector vecX. This function is experimental. Zᵢ=epilogue(α∑_(k)(op(Aᵢₖ)⋅Xₖ)+βYᵢ) where
op(A) is a sparse matrix of size m×k.
X is a dense vector of size k.
Y is a dense vector of size m.
Z is a dense vector of size m. It is allowed to alias Y.
α and β are scalars.
epilogue is a custom function with the following signature
__device__ <computetype> spmv_op_epilogue(int64_t row, <computetype> value);
Handle.SpMVOp supports sparse format FormatCsr and opA=[OperationNonTranspose]. The following index type combinations are supported:
- csrRowOffsetsType: Index32I; csrColIndType: Index32I
- csrRowOffsetsType: Index64I; csrColIndType: Index32I
Handle.SpMVOp supports the following type combinations:
- A: CUDA_R_32F; X/Y/Z/computeType: CUDA_R_32F
- A: CUDA_R_32F; X/Y/Z/computeType: CUDA_R_64F
- A: CUDA_R_64F; X/Y/Z/computeType: CUDA_R_64F
Handle.SpMVOp supports the following algorithms:
- SpmvopAlgDefault: Default algorithm; currently equivalent to SpmvopALG1.
- SpmvopALG1: Deterministic algorithm. Supports updating the values of matA between calls to Handle.SpMVOp without rebuilding the descriptor or the execution plan, either in-place or via SpMatDescr.CsrSetPointers.
- SpmvopALG2: Alternative deterministic algorithm. Compared to SpmvopALG1, it may offer higher performance at the cost of significantly more buffer usage and more expensive preprocessing in Handle.SpMVOpCreateDescr. Does not support updating the values of matA between calls without rebuilding the descriptor and the execution plan.
The function Handle.SpMVOpBufferSize returns the size of the workspace needed by Handle.SpMVOpCreateDescr and Handle.SpMVOp. Currently, it accepts NULL for vecX, vecY and vecZ. The function Handle.SpMVOpCreateDescr prepares the internal data represented by the descriptor which is needed by Handle.SpMVOpCreatePlan and Handle.SpMVOp. The passed-in device buffer must remain valid and unmodified until the associated descriptor is destroyed. It supports passing dummy vecX, vecY and vecZ objects, as long as their data type attributes are valid. Other attributes are ignored during the descriptor creation. If epilogueLTOBuffer is NULL or epilogueLTOBufferSize is 0, the built-in default epilogue will be employed without Link-Time-Optimization (LTO):
__device__ <computetype> spmv_op_epilogue(int64_t row, <computetype> value) { return value; }
The function Handle.SpMVOpCreatePlan takes in the descriptor and the LTO-IR of the custom epilogue, and returns the execution plan. The same descriptor can be used to create multiple execution plans, each with its own epilogue and epilogue auxiliary data. A caching system is employed to avoid redundant JIT compilation: plans compiled from identical LTO-IR (same epilogueLTOBuffer content and epilogueLTOBufferSize) share a single CUmodule. The function Handle.SpMVOpSetGlobalUserData copies epilogueDataSize bytes from the host buffer epilogueData to the device __device__ or __constant__ variable named epilogueDataName in the compiled epilogue module. epilogueDataName must match the symbol name of the variable as declared in the epilogue device code. The invocation is optional; it should be called only if the epilogue requires auxiliary data. It can be invoked repeatedly before Handle.SpMVOp to update the auxiliary data. As a consequence of the plan caching, calling Handle.SpMVOpSetGlobalUserData affects every plan that links to the same compiled epilogue, not only the plan passed as argument. If multiple plans share the same LTO-IR but require different runtime constant values, the caller is responsible for serializing each Handle.SpMVOpSetGlobalUserData + Handle.SpMVOp pair so that each plan’s constants are current at the time it executes. Handle.SpMVOp has the following properties:
- It supports a customizable epilogue function, enabling users to apply additional elementwise and more complex operations to the output vector.
- It provides improved numerical accuracy than Handle.SpMV due to the fact that accumulation is partially performed using Kahan’s summation.
- The routine produces deterministic (bit-wise) results for each run, assuming that the epilogue function is deterministic.
- In general, it is significantly faster than Handle.SpMV with the deterministic algorithm SpmvCsrALG2, at the cost of more buffer usage.
- SpmvopALG1 (and SpmvopAlgDefault) supports updating the values of matA between calls to Handle.SpMVOp without rebuilding the descriptor or the execution plan. The updated values can be provided in-place (by modifying the device memory previously registered in the matrix descriptor) or by calling SpMatDescr.CsrSetPointers with the new value pointer before each Handle.SpMVOp call.
- The routine supports asynchronous execution.
- The routine allows the indices of matA to be unsorted.
- It supports CUDA graph capture optimizations.
Please visit cuSPARSE Library Samples - Handle.SpMVOp for a code example.
Requires CUDA 13.1 or later; see HasSpMVOp.
- plan: Opaque descriptor for storing the multiplication execution plan, namely all the information necessary to execute Handle.SpMVOp
- alpha: α scalar used for multiplication of type computeType. Its kind must match the compute type. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- beta: β scalar used for multiplication of type computeType. Its kind must match the compute type. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- vecX: Dense vector X
- vecY: Dense vector Y
- vecZ: Dense vector Z
Wraps cusparseSpMVOp.
func (Handle) SpMVOpBufferSize ¶
func (h Handle) SpMVOpBufferSize(opA Operation, matA ConstSpMatDescr, vecX ConstDnVecDescr, vecY DnVecDescr, vecZ DnVecDescr, computeType DataType) (uint, error)
SpMVOpBufferSize returns the workspace size for Handle.SpMVOp. On qualified newer libraries it selects the source-declared default algorithm. Requires CUDA 13.1 or later with a qualified runtime component. Unqualified runtime component versions return ErrNotSupported.
func (Handle) SpMVOpBufferSizeWithAlgorithm ¶
func (h Handle) SpMVOpBufferSizeWithAlgorithm(opA Operation, matA ConstSpMatDescr, vecX ConstDnVecDescr, vecY DnVecDescr, vecZ DnVecDescr, computeType DataType, alg SpMVOpAlg) (uint, error)
SpMVOpBufferSizeWithAlgorithm returns the workspace size for Handle.SpMVOp.
Requires CUDA 13.3 or later with a qualified runtime component; see HasSpMVOpBufferSizeWithAlgorithm.
- opA: Operation op(A)
- matA: Sparse matrix A
- vecX: Dense vector X
- vecY: Dense vector Y
- vecZ: Dense vector Z
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation (see algorithm table above)
- bufferSize: Workspace size
Wraps cusparseSpMVOpBufferSize, bound as cusparseSpMVOp_bufferSize.
func (Handle) SpMVOpCreateDescr ¶
func (h Handle) SpMVOpCreateDescr(opA Operation, matA ConstSpMatDescr, vecX ConstDnVecDescr, vecY DnVecDescr, vecZ DnVecDescr, computeType DataType, buffer driver.DevicePtr) (SpMVOpDescr, error)
SpMVOpCreateDescr creates an experimental multiplication descriptor. On qualified newer libraries it selects the source-declared default algorithm. Requires CUDA 13.1 or later with a qualified runtime component. Unqualified runtime component versions return ErrNotSupported.
func (Handle) SpMVOpCreateDescrWithAlgorithm ¶
func (h Handle) SpMVOpCreateDescrWithAlgorithm(opA Operation, matA ConstSpMatDescr, vecX ConstDnVecDescr, vecY DnVecDescr, vecZ DnVecDescr, computeType DataType, alg SpMVOpAlg, buffer driver.DevicePtr) (SpMVOpDescr, error)
SpMVOpCreateDescrWithAlgorithm is only available if macro CUSPARSE_ENABLE_EXPERIMENTAL_API is defined.
It performs the multiplication of a sparse matrix matA and a dense vector vecX. This function is experimental. Zᵢ=epilogue(α∑_(k)(op(Aᵢₖ)⋅Xₖ)+βYᵢ) where
op(A) is a sparse matrix of size m×k.
X is a dense vector of size k.
Y is a dense vector of size m.
Z is a dense vector of size m. It is allowed to alias Y.
α and β are scalars.
epilogue is a custom function with the following signature
__device__ <computetype> spmv_op_epilogue(int64_t row, <computetype> value);
Handle.SpMVOp supports sparse format FormatCsr and opA=[OperationNonTranspose]. The following index type combinations are supported:
- csrRowOffsetsType: Index32I; csrColIndType: Index32I
- csrRowOffsetsType: Index64I; csrColIndType: Index32I
Handle.SpMVOp supports the following type combinations:
- A: CUDA_R_32F; X/Y/Z/computeType: CUDA_R_32F
- A: CUDA_R_32F; X/Y/Z/computeType: CUDA_R_64F
- A: CUDA_R_64F; X/Y/Z/computeType: CUDA_R_64F
Handle.SpMVOp supports the following algorithms:
- SpmvopAlgDefault: Default algorithm; currently equivalent to SpmvopALG1.
- SpmvopALG1: Deterministic algorithm. Supports updating the values of matA between calls to Handle.SpMVOp without rebuilding the descriptor or the execution plan, either in-place or via SpMatDescr.CsrSetPointers.
- SpmvopALG2: Alternative deterministic algorithm. Compared to SpmvopALG1, it may offer higher performance at the cost of significantly more buffer usage and more expensive preprocessing in Handle.SpMVOpCreateDescrWithAlgorithm. Does not support updating the values of matA between calls without rebuilding the descriptor and the execution plan.
The function Handle.SpMVOpBufferSize returns the size of the workspace needed by Handle.SpMVOpCreateDescrWithAlgorithm and Handle.SpMVOp. Currently, it accepts NULL for vecX, vecY and vecZ. The function Handle.SpMVOpCreateDescrWithAlgorithm prepares the internal data represented by the descriptor which is needed by Handle.SpMVOpCreatePlan and Handle.SpMVOp. The passed-in device buffer must remain valid and unmodified until the associated descriptor is destroyed. It supports passing dummy vecX, vecY and vecZ objects, as long as their data type attributes are valid. Other attributes are ignored during the descriptor creation. If epilogueLTOBuffer is NULL or epilogueLTOBufferSize is 0, the built-in default epilogue will be employed without Link-Time-Optimization (LTO):
__device__ <computetype> spmv_op_epilogue(int64_t row, <computetype> value) { return value; }
The function Handle.SpMVOpCreatePlan takes in the descriptor and the LTO-IR of the custom epilogue, and returns the execution plan. The same descriptor can be used to create multiple execution plans, each with its own epilogue and epilogue auxiliary data. A caching system is employed to avoid redundant JIT compilation: plans compiled from identical LTO-IR (same epilogueLTOBuffer content and epilogueLTOBufferSize) share a single CUmodule. The function Handle.SpMVOpSetGlobalUserData copies epilogueDataSize bytes from the host buffer epilogueData to the device __device__ or __constant__ variable named epilogueDataName in the compiled epilogue module. epilogueDataName must match the symbol name of the variable as declared in the epilogue device code. The invocation is optional; it should be called only if the epilogue requires auxiliary data. It can be invoked repeatedly before Handle.SpMVOp to update the auxiliary data. As a consequence of the plan caching, calling Handle.SpMVOpSetGlobalUserData affects every plan that links to the same compiled epilogue, not only the plan passed as argument. If multiple plans share the same LTO-IR but require different runtime constant values, the caller is responsible for serializing each Handle.SpMVOpSetGlobalUserData + Handle.SpMVOp pair so that each plan’s constants are current at the time it executes. Handle.SpMVOp has the following properties:
- It supports a customizable epilogue function, enabling users to apply additional elementwise and more complex operations to the output vector.
- It provides improved numerical accuracy than Handle.SpMV due to the fact that accumulation is partially performed using Kahan’s summation.
- The routine produces deterministic (bit-wise) results for each run, assuming that the epilogue function is deterministic.
- In general, it is significantly faster than Handle.SpMV with the deterministic algorithm SpmvCsrALG2, at the cost of more buffer usage.
- SpmvopALG1 (and SpmvopAlgDefault) supports updating the values of matA between calls to Handle.SpMVOp without rebuilding the descriptor or the execution plan. The updated values can be provided in-place (by modifying the device memory previously registered in the matrix descriptor) or by calling SpMatDescr.CsrSetPointers with the new value pointer before each Handle.SpMVOp call.
- The routine supports asynchronous execution.
- The routine allows the indices of matA to be unsorted.
- It supports CUDA graph capture optimizations.
Please visit cuSPARSE Library Samples - Handle.SpMVOp for a code example.
Requires CUDA 13.3 or later with a qualified runtime component; see HasSpMVOpCreateDescrWithAlgorithm.
- opA: Operation op(A)
- matA: Sparse matrix A
- vecX: Dense vector X
- vecY: Dense vector Y
- vecZ: Dense vector Z
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation (see algorithm table above)
- buffer: Pointer to a workspace buffer of at least bufferSize bytes
Wraps cusparseSpMVOpCreateDescr, bound as cusparseSpMVOp_createDescr.
func (Handle) SpMVOpCreatePlan ¶
func (h Handle) SpMVOpCreatePlan(desc SpMVOpDescr, code uintptr, codeSize uint) (SpMVOpPlan, error)
SpMVOpCreatePlan is only available if macro CUSPARSE_ENABLE_EXPERIMENTAL_API is defined.
It performs the multiplication of a sparse matrix matA and a dense vector vecX. This function is experimental. Zᵢ=epilogue(α∑_(k)(op(Aᵢₖ)⋅Xₖ)+βYᵢ) where
op(A) is a sparse matrix of size m×k.
X is a dense vector of size k.
Y is a dense vector of size m.
Z is a dense vector of size m. It is allowed to alias Y.
α and β are scalars.
epilogue is a custom function with the following signature
__device__ <computetype> spmv_op_epilogue(int64_t row, <computetype> value);
Handle.SpMVOp supports sparse format FormatCsr and opA=[OperationNonTranspose]. The following index type combinations are supported:
- csrRowOffsetsType: Index32I; csrColIndType: Index32I
- csrRowOffsetsType: Index64I; csrColIndType: Index32I
Handle.SpMVOp supports the following type combinations:
- A: CUDA_R_32F; X/Y/Z/computeType: CUDA_R_32F
- A: CUDA_R_32F; X/Y/Z/computeType: CUDA_R_64F
- A: CUDA_R_64F; X/Y/Z/computeType: CUDA_R_64F
Handle.SpMVOp supports the following algorithms:
- SpmvopAlgDefault: Default algorithm; currently equivalent to SpmvopALG1.
- SpmvopALG1: Deterministic algorithm. Supports updating the values of matA between calls to Handle.SpMVOp without rebuilding the descriptor or the execution plan, either in-place or via SpMatDescr.CsrSetPointers.
- SpmvopALG2: Alternative deterministic algorithm. Compared to SpmvopALG1, it may offer higher performance at the cost of significantly more buffer usage and more expensive preprocessing in Handle.SpMVOpCreateDescr. Does not support updating the values of matA between calls without rebuilding the descriptor and the execution plan.
The function Handle.SpMVOpBufferSize returns the size of the workspace needed by Handle.SpMVOpCreateDescr and Handle.SpMVOp. Currently, it accepts NULL for vecX, vecY and vecZ. The function Handle.SpMVOpCreateDescr prepares the internal data represented by the descriptor which is needed by Handle.SpMVOpCreatePlan and Handle.SpMVOp. The passed-in device buffer must remain valid and unmodified until the associated descriptor is destroyed. It supports passing dummy vecX, vecY and vecZ objects, as long as their data type attributes are valid. Other attributes are ignored during the descriptor creation. If epilogueLTOBuffer is NULL or epilogueLTOBufferSize is 0, the built-in default epilogue will be employed without Link-Time-Optimization (LTO):
__device__ <computetype> spmv_op_epilogue(int64_t row, <computetype> value) { return value; }
The function Handle.SpMVOpCreatePlan takes in the descriptor and the LTO-IR of the custom epilogue, and returns the execution plan. The same descriptor can be used to create multiple execution plans, each with its own epilogue and epilogue auxiliary data. A caching system is employed to avoid redundant JIT compilation: plans compiled from identical LTO-IR (same epilogueLTOBuffer content and epilogueLTOBufferSize) share a single CUmodule. The function Handle.SpMVOpSetGlobalUserData copies epilogueDataSize bytes from the host buffer epilogueData to the device __device__ or __constant__ variable named epilogueDataName in the compiled epilogue module. epilogueDataName must match the symbol name of the variable as declared in the epilogue device code. The invocation is optional; it should be called only if the epilogue requires auxiliary data. It can be invoked repeatedly before Handle.SpMVOp to update the auxiliary data. As a consequence of the plan caching, calling Handle.SpMVOpSetGlobalUserData affects every plan that links to the same compiled epilogue, not only the plan passed as argument. If multiple plans share the same LTO-IR but require different runtime constant values, the caller is responsible for serializing each Handle.SpMVOpSetGlobalUserData + Handle.SpMVOp pair so that each plan’s constants are current at the time it executes. Handle.SpMVOp has the following properties:
- It supports a customizable epilogue function, enabling users to apply additional elementwise and more complex operations to the output vector.
- It provides improved numerical accuracy than Handle.SpMV due to the fact that accumulation is partially performed using Kahan’s summation.
- The routine produces deterministic (bit-wise) results for each run, assuming that the epilogue function is deterministic.
- In general, it is significantly faster than Handle.SpMV with the deterministic algorithm SpmvCsrALG2, at the cost of more buffer usage.
- SpmvopALG1 (and SpmvopAlgDefault) supports updating the values of matA between calls to Handle.SpMVOp without rebuilding the descriptor or the execution plan. The updated values can be provided in-place (by modifying the device memory previously registered in the matrix descriptor) or by calling SpMatDescr.CsrSetPointers with the new value pointer before each Handle.SpMVOp call.
- The routine supports asynchronous execution.
- The routine allows the indices of matA to be unsorted.
- It supports CUDA graph capture optimizations.
Please visit cuSPARSE Library Samples - Handle.SpMVOp for a code example.
Requires CUDA 13.1 or later; see HasSpMVOpCreatePlan.
- plan: Opaque descriptor for storing the multiplication execution plan, namely all the information necessary to execute Handle.SpMVOp
Wraps cusparseSpMVOpCreatePlan, bound as cusparseSpMVOp_createPlan.
func (Handle) SpMVOpSetGlobalUserData ¶
func (h Handle) SpMVOpSetGlobalUserData(plan SpMVOpPlan, globalDataName *byte, inputData uintptr, dataSize uint) error
SpMVOpSetGlobalUserData is only available if macro CUSPARSE_ENABLE_EXPERIMENTAL_API is defined.
It performs the multiplication of a sparse matrix matA and a dense vector vecX. This function is experimental. Zᵢ=epilogue(α∑_(k)(op(Aᵢₖ)⋅Xₖ)+βYᵢ) where
op(A) is a sparse matrix of size m×k.
X is a dense vector of size k.
Y is a dense vector of size m.
Z is a dense vector of size m. It is allowed to alias Y.
α and β are scalars.
epilogue is a custom function with the following signature
__device__ <computetype> spmv_op_epilogue(int64_t row, <computetype> value);
Handle.SpMVOp supports sparse format FormatCsr and opA=[OperationNonTranspose]. The following index type combinations are supported:
- csrRowOffsetsType: Index32I; csrColIndType: Index32I
- csrRowOffsetsType: Index64I; csrColIndType: Index32I
Handle.SpMVOp supports the following type combinations:
- A: CUDA_R_32F; X/Y/Z/computeType: CUDA_R_32F
- A: CUDA_R_32F; X/Y/Z/computeType: CUDA_R_64F
- A: CUDA_R_64F; X/Y/Z/computeType: CUDA_R_64F
Handle.SpMVOp supports the following algorithms:
- SpmvopAlgDefault: Default algorithm; currently equivalent to SpmvopALG1.
- SpmvopALG1: Deterministic algorithm. Supports updating the values of matA between calls to Handle.SpMVOp without rebuilding the descriptor or the execution plan, either in-place or via SpMatDescr.CsrSetPointers.
- SpmvopALG2: Alternative deterministic algorithm. Compared to SpmvopALG1, it may offer higher performance at the cost of significantly more buffer usage and more expensive preprocessing in Handle.SpMVOpCreateDescr. Does not support updating the values of matA between calls without rebuilding the descriptor and the execution plan.
The function Handle.SpMVOpBufferSize returns the size of the workspace needed by Handle.SpMVOpCreateDescr and Handle.SpMVOp. Currently, it accepts NULL for vecX, vecY and vecZ. The function Handle.SpMVOpCreateDescr prepares the internal data represented by the descriptor which is needed by Handle.SpMVOpCreatePlan and Handle.SpMVOp. The passed-in device buffer must remain valid and unmodified until the associated descriptor is destroyed. It supports passing dummy vecX, vecY and vecZ objects, as long as their data type attributes are valid. Other attributes are ignored during the descriptor creation. If epilogueLTOBuffer is NULL or epilogueLTOBufferSize is 0, the built-in default epilogue will be employed without Link-Time-Optimization (LTO):
__device__ <computetype> spmv_op_epilogue(int64_t row, <computetype> value) { return value; }
The function Handle.SpMVOpCreatePlan takes in the descriptor and the LTO-IR of the custom epilogue, and returns the execution plan. The same descriptor can be used to create multiple execution plans, each with its own epilogue and epilogue auxiliary data. A caching system is employed to avoid redundant JIT compilation: plans compiled from identical LTO-IR (same epilogueLTOBuffer content and epilogueLTOBufferSize) share a single CUmodule. The function Handle.SpMVOpSetGlobalUserData copies epilogueDataSize bytes from the host buffer epilogueData to the device __device__ or __constant__ variable named epilogueDataName in the compiled epilogue module. epilogueDataName must match the symbol name of the variable as declared in the epilogue device code. The invocation is optional; it should be called only if the epilogue requires auxiliary data. It can be invoked repeatedly before Handle.SpMVOp to update the auxiliary data. As a consequence of the plan caching, calling Handle.SpMVOpSetGlobalUserData affects every plan that links to the same compiled epilogue, not only the plan passed as argument. If multiple plans share the same LTO-IR but require different runtime constant values, the caller is responsible for serializing each Handle.SpMVOpSetGlobalUserData + Handle.SpMVOp pair so that each plan’s constants are current at the time it executes. Handle.SpMVOp has the following properties:
- It supports a customizable epilogue function, enabling users to apply additional elementwise and more complex operations to the output vector.
- It provides improved numerical accuracy than Handle.SpMV due to the fact that accumulation is partially performed using Kahan’s summation.
- The routine produces deterministic (bit-wise) results for each run, assuming that the epilogue function is deterministic.
- In general, it is significantly faster than Handle.SpMV with the deterministic algorithm SpmvCsrALG2, at the cost of more buffer usage.
- SpmvopALG1 (and SpmvopAlgDefault) supports updating the values of matA between calls to Handle.SpMVOp without rebuilding the descriptor or the execution plan. The updated values can be provided in-place (by modifying the device memory previously registered in the matrix descriptor) or by calling SpMatDescr.CsrSetPointers with the new value pointer before each Handle.SpMVOp call.
- The routine supports asynchronous execution.
- The routine allows the indices of matA to be unsorted.
- It supports CUDA graph capture optimizations.
Please visit cuSPARSE Library Samples - Handle.SpMVOp for a code example.
Requires CUDA 13.1 or later; see HasSpMVOpSetGlobalUserData.
- plan: Opaque descriptor for storing the multiplication execution plan, namely all the information necessary to execute Handle.SpMVOp
Wraps cusparseSpMVOpSetGlobalUserData, bound as cusparseSpMVOp_setGlobalUserData.
func (Handle) SpMVPreprocess ¶
func (h Handle) SpMVPreprocess(opA Operation, alpha Scalar, matA ConstSpMatDescr, vecX ConstDnVecDescr, beta Scalar, vecY DnVecDescr, computeType DataType, alg SpMVAlg, externalBuffer driver.DevicePtr) error
SpMVPreprocess prepares the workspace buffer for Handle.SpMV, which may accelerate subsequent calls to it.
Handle.SpMV performs the multiplication of a sparse matrix matA and a dense vector vecX. Y=αop(A)⋅X+βY, where
- op(A) is a sparse matrix of size m×k
- X is a dense vector of size k
- Y is a dense vector of size m
- α and β are scalars
Also, for matrix A: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose. The function Handle.SpMVBufferSize returns the size of the workspace needed by Handle.SpMVPreprocess and Handle.SpMV The sparse matrix formats currently supported are listed below:
Handle.SpMV supports the following index type for representing the sparse matrix matA:
Handle.SpMV supports the following data types: Uniform-precision computation:
- A/X/Y/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
Mixed-precision computation:
A/X Y computeType Notes CUDA_R_8I CUDA_R_32I CUDA_R_32I CUDA_R_8I CUDA_R_32F CUDA_R_32F CUDA_R_16F CUDA_R_32F CUDA_R_32F CUDA_R_16BF CUDA_R_32F CUDA_R_32F CUDA_R_16F CUDA_R_16F CUDA_R_32F CUDA_R_16BF CUDA_R_16BF CUDA_R_32F CUDA_C_32F CUDA_C_32F CUDA_C_32F CUDA_C_16F CUDA_C_16F CUDA_C_32F [DEPRECATED] CUDA_C_16BF CUDA_C_16BF CUDA_C_32F [DEPRECATED]
A: CUDA_R_32F; X/Y/computeType: CUDA_R_64F.
Mixed Regular/Complex computation:
- A: CUDA_R_32F; X/Y/computeType: CUDA_C_32F
- A: CUDA_R_64F; X/Y/computeType: CUDA_C_64F
NOTE: CUDA_R_16F, CUDA_R_16BF, CUDA_C_16F, and CUDA_C_16BF data types always imply mixed-precision computation. Handle.SpMV supports the following algorithms:
- SpmvAlgDefault: Default algorithm for any sparse matrix format.
- SpmvCooALG1: Default algorithm for COO sparse matrix format. May produce slightly different results during different runs with the same input parameters.
- SpmvCooALG2: Provides deterministic (bit-wise) results for each run. If opA != OperationNonTranspose, it is identical to SpmvCooALG1.
- SpmvCsrALG1: Default algorithm for CSR/CSC sparse matrix format. May produce slightly different results during different runs with the same input parameters.
- SpmvCsrALG2: Provides deterministic (bit-wise) results for each run. If opA != OperationNonTranspose, it is identical to SpmvCsrALG1.
- SpmvSellALG1: Default algorithm for Sliced Ellpack sparse matrix format. Provides deterministic (bit-wise) results for each run.
- SpmvBsrALG1: Default algorithm for BSR sparse matrix format. Provides deterministic (bit-wise) results for each run. Supports only opA == OperationNonTranspose. Supports both row-major and column-major block layouts in A.
Calling Handle.SpMVPreprocess is optional. It may accelerate subsequent calls to Handle.SpMV. It is useful when Handle.SpMV is called multiple times with the same sparsity pattern ( matA). Calling Handle.SpMVPreprocess with buffer makes that buffer “active” for matA Handle.SpMV calls. Subsequent calls to Handle.SpMV with matA and the active buffer must use the same values for all parameters as the call to Handle.SpMVPreprocess. The exceptions are: alpha, beta, vecX, vecY, and the values (but not indices) of matA may be different. Importantly, the buffer contents must be unmodified since the call to Handle.SpMVPreprocess. When Handle.SpMV is called with matA and its active buffer, it may read acceleration data from the buffer. Calling Handle.SpMVPreprocess again with matA and a new buffer will make the new buffer active, forgetting about the previously-active buffer and making it inactive. For Handle.SpMV, there can only be one active buffer per sparse matrix at a time. To get the effect of multiple active buffers for a single sparse matrix, create multiple matrix handles that all point to the same index and value buffers, and call Handle.SpMVPreprocess once per handle with different workspace buffers. Calling Handle.SpMV with an inactive buffer is always permitted. However, there may be no acceleration from the preprocessing in that case. For the purposes of thread safety, Handle.SpMVPreprocess is writing to matA internal state. Performance notes:
- SpmvCooALG1 and SpmvCsrALG1 provide higher performance than SpmvCooALG2 and SpmvCsrALG2.
- In general, opA == OperationNonTranspose is 3x faster than opA != OperationNonTranspose.
- Using Handle.SpMVPreprocess helps improve performance of Handle.SpMV in CSR. It is beneficial when we need to run Handle.SpMV multiple times with a same matrix ( Handle.SpMVPreprocess is executed only once).
Handle.SpMV has the following properties:
- The routine requires extra storage for CSR/CSC format (all algorithms) and for COO format with SpmvCooALG2 algorithm.
- Provides deterministic (bit-wise) results for each run only for SpmvCooALG2, SpmvCsrALG2 and SpmvBsrALG1 algorithms, and opA == OperationNonTranspose.
- The routine supports asynchronous execution.
- compute-sanitizer could report false race conditions for this routine when beta == 0. This is for optimization purposes and does not affect the correctness of the computation.
- The routine allows the indices of matA to be unsorted.
Handle.SpMV supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - Handle.SpMV CSR and Handle.SpMV COO for a code example.
Requires CUDA 12.4 or later; see HasSpMVPreprocess.
- opA: Operation op(A)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- vecX: Dense vector X
- beta: β scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- vecY: Dense vector Y
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- externalBuffer: Pointer to a workspace buffer of at least bufferSize bytes
Wraps cusparseSpMVPreprocess, bound as cusparseSpMV_preprocess.
func (Handle) SpSMAnalysis ¶
func (h Handle) SpSMAnalysis(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, matB ConstDnMatDescr, matC DnMatDescr, computeType DataType, alg SpSMAlg, spsmDescr SpSMDescr, externalBuffer driver.DevicePtr) error
SpSMAnalysis solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
op(A)⋅C=αop(B) where
- op(A) is a sparse square matrix of size m×m
- op(B) is a dense matrix of size m×n
- C is a dense matrix of size m×n
- α is a scalar
Also, for matrix A: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose; op(B) = B if opB == OperationNonTranspose, and op(B) = Bᵀ if opB == OperationTranspose. The function Handle.SpSMBufferSize returns the size of the workspace needed by Handle.SpSMAnalysis and Handle.SpSMSolve. The function Handle.SpSMAnalysis performs the analysis phase, while Handle.SpSMSolve executes the solve phase for a sparse triangular linear system. The opaque data structure spsmDescr is used to share information among all functions. The function Handle.SpSMUpdateMatrix updates spsmDescr with new matrix values. The routine supports arbitrary sparsity for the input matrix, but only the upper or lower triangular part is taken into account in the computation. Handle.SpSMBufferSize requires a buffer size for the analysis phase which is proportional to number of non-zero entries of the sparse matrix The externalBuffer is stored into spsmDescr and used by Handle.SpSMSolve. For this reason, the device memory buffer must be deallocated only after Handle.SpSMSolve NOTE: all parameters must be consistent across cusparseSpSM API calls and the matrix descriptions and externalBuffer must not be modified between Handle.SpSMAnalysis and Handle.SpSMSolve The sparse matrix formats currently supported are listed below:
The cusparseSpSM() supports the following shapes and properties:
- FillModeLower and FillModeUpper fill modes
- DiagTypeNonUnit and DiagTypeUnit diagonal types
The fill mode and diagonal type can be set by SpMatDescr.MatSetAttribute. cusparseSpSM() supports the following index type for representing the sparse matrix matA:
cusparseSpSM() supports the following data types: Uniform-precision computation:
- A/B/C/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
cusparseSpSM() supports the following algorithms:
- SpsmAlgDefault: Default algorithm
cusparseSpSM() has the following properties:
- The routine requires no extra storage
- Provides deterministic (bit-wise) results for each run for the solving phase Handle.SpSMSolve
- The Handle.SpSMSolve routine supports asynchronous execution
- The routine supports in-place operation. The same device pointer must be provided to the values parameter of the dense matrices matB and matC. All other dense matrix descriptor parameters (e.g., order) can be set independently
- Handle.SpSMBufferSize and Handle.SpSMAnalysis routines accept descriptors of NULL values for matB and matC. These two routines do not accept NULL descriptors
- The routine allows the indices of matA to be unsorted
cusparseSpSM() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Handle.SpSMUpdateMatrix updates the sparse matrix after calling the analysis phase. This functions supports the following update strategies ( updatePart):
- SpsmUpdateGeneral: Updates the sparse matrix values with values of newValues array
- SpsmUpdateDiagonal: Updates the diagonal part of the matrix with diagonal values stored in newValues array. That is, newValues has the new diagonal values only
Please visit cuSPARSE Library Samples - cusparseSpSM CSR and cuSPARSE Library Samples - cusparseSpSM COO for code examples.
- opA: Operation op(A)
- opB: Operation op(B)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- matB: Dense matrix B
- matC: Dense matrix C
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- spsmDescr: Opaque descriptor for storing internal data used across the three steps
- externalBuffer: Pointer to a workspace buffer of at least bufferSize bytes. It is used by Handle.SpSMAnalysis and Handle.SpSMSolve
Wraps cusparseSpSMAnalysis, bound as cusparseSpSM_analysis.
func (Handle) SpSMBufferSize ¶
func (h Handle) SpSMBufferSize(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, matB ConstDnMatDescr, matC DnMatDescr, computeType DataType, alg SpSMAlg, spsmDescr SpSMDescr) (uint, error)
SpSMBufferSize returns the workspace size for cusparseSpSM.
- opA: Operation op(A)
- opB: Operation op(B)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- matB: Dense matrix B
- matC: Dense matrix C
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- spsmDescr: Opaque descriptor for storing internal data used across the three steps
- bufferSize: Workspace size
Wraps cusparseSpSMBufferSize, bound as cusparseSpSM_bufferSize.
func (Handle) SpSMSolve ¶
func (h Handle) SpSMSolve(opA Operation, opB Operation, alpha Scalar, matA ConstSpMatDescr, matB ConstDnMatDescr, matC DnMatDescr, computeType DataType, alg SpSMAlg, spsmDescr SpSMDescr) error
SpSMSolve solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
op(A)⋅C=αop(B) where
- op(A) is a sparse square matrix of size m×m
- op(B) is a dense matrix of size m×n
- C is a dense matrix of size m×n
- α is a scalar
Also, for matrix A: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose; op(B) = B if opB == OperationNonTranspose, and op(B) = Bᵀ if opB == OperationTranspose. The function Handle.SpSMBufferSize returns the size of the workspace needed by Handle.SpSMAnalysis and Handle.SpSMSolve. The function Handle.SpSMAnalysis performs the analysis phase, while Handle.SpSMSolve executes the solve phase for a sparse triangular linear system. The opaque data structure spsmDescr is used to share information among all functions. The function Handle.SpSMUpdateMatrix updates spsmDescr with new matrix values. The routine supports arbitrary sparsity for the input matrix, but only the upper or lower triangular part is taken into account in the computation. Handle.SpSMBufferSize requires a buffer size for the analysis phase which is proportional to number of non-zero entries of the sparse matrix The externalBuffer is stored into spsmDescr and used by Handle.SpSMSolve. For this reason, the device memory buffer must be deallocated only after Handle.SpSMSolve NOTE: all parameters must be consistent across cusparseSpSM API calls and the matrix descriptions and externalBuffer must not be modified between Handle.SpSMAnalysis and Handle.SpSMSolve The sparse matrix formats currently supported are listed below:
The cusparseSpSM() supports the following shapes and properties:
- FillModeLower and FillModeUpper fill modes
- DiagTypeNonUnit and DiagTypeUnit diagonal types
The fill mode and diagonal type can be set by SpMatDescr.MatSetAttribute. cusparseSpSM() supports the following index type for representing the sparse matrix matA:
cusparseSpSM() supports the following data types: Uniform-precision computation:
- A/B/C/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
cusparseSpSM() supports the following algorithms:
- SpsmAlgDefault: Default algorithm
cusparseSpSM() has the following properties:
- The routine requires no extra storage
- Provides deterministic (bit-wise) results for each run for the solving phase Handle.SpSMSolve
- The Handle.SpSMSolve routine supports asynchronous execution
- The routine supports in-place operation. The same device pointer must be provided to the values parameter of the dense matrices matB and matC. All other dense matrix descriptor parameters (e.g., order) can be set independently
- Handle.SpSMBufferSize and Handle.SpSMAnalysis routines accept descriptors of NULL values for matB and matC. These two routines do not accept NULL descriptors
- The routine allows the indices of matA to be unsorted
cusparseSpSM() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Handle.SpSMUpdateMatrix updates the sparse matrix after calling the analysis phase. This functions supports the following update strategies ( updatePart):
- SpsmUpdateGeneral: Updates the sparse matrix values with values of newValues array
- SpsmUpdateDiagonal: Updates the diagonal part of the matrix with diagonal values stored in newValues array. That is, newValues has the new diagonal values only
Please visit cuSPARSE Library Samples - cusparseSpSM CSR and cuSPARSE Library Samples - cusparseSpSM COO for code examples.
- opA: Operation op(A)
- opB: Operation op(B)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- matB: Dense matrix B
- matC: Dense matrix C
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- spsmDescr: Opaque descriptor for storing internal data used across the three steps
Wraps cusparseSpSMSolve, bound as cusparseSpSM_solve.
func (Handle) SpSMUpdateMatrix ¶
func (h Handle) SpSMUpdateMatrix(spsmDescr SpSMDescr, newValues driver.DevicePtr, updatePart SpSMUpdate) error
SpSMUpdateMatrix solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
op(A)⋅C=αop(B) where
- op(A) is a sparse square matrix of size m×m
- op(B) is a dense matrix of size m×n
- C is a dense matrix of size m×n
- α is a scalar
Also, for matrix A: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose; op(B) = B if opB == OperationNonTranspose, and op(B) = Bᵀ if opB == OperationTranspose. The function Handle.SpSMBufferSize returns the size of the workspace needed by Handle.SpSMAnalysis and Handle.SpSMSolve. The function Handle.SpSMAnalysis performs the analysis phase, while Handle.SpSMSolve executes the solve phase for a sparse triangular linear system. The opaque data structure spsmDescr is used to share information among all functions. The function Handle.SpSMUpdateMatrix updates spsmDescr with new matrix values. The routine supports arbitrary sparsity for the input matrix, but only the upper or lower triangular part is taken into account in the computation. Handle.SpSMBufferSize requires a buffer size for the analysis phase which is proportional to number of non-zero entries of the sparse matrix The externalBuffer is stored into spsmDescr and used by Handle.SpSMSolve. For this reason, the device memory buffer must be deallocated only after Handle.SpSMSolve NOTE: all parameters must be consistent across cusparseSpSM API calls and the matrix descriptions and externalBuffer must not be modified between Handle.SpSMAnalysis and Handle.SpSMSolve The sparse matrix formats currently supported are listed below:
The cusparseSpSM() supports the following shapes and properties:
- FillModeLower and FillModeUpper fill modes
- DiagTypeNonUnit and DiagTypeUnit diagonal types
The fill mode and diagonal type can be set by SpMatDescr.MatSetAttribute. cusparseSpSM() supports the following index type for representing the sparse matrix matA:
cusparseSpSM() supports the following data types: Uniform-precision computation:
- A/B/C/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
cusparseSpSM() supports the following algorithms:
- SpsmAlgDefault: Default algorithm
cusparseSpSM() has the following properties:
- The routine requires no extra storage
- Provides deterministic (bit-wise) results for each run for the solving phase Handle.SpSMSolve
- The Handle.SpSMSolve routine supports asynchronous execution
- The routine supports in-place operation. The same device pointer must be provided to the values parameter of the dense matrices matB and matC. All other dense matrix descriptor parameters (e.g., order) can be set independently
- Handle.SpSMBufferSize and Handle.SpSMAnalysis routines accept descriptors of NULL values for matB and matC. These two routines do not accept NULL descriptors
- The routine allows the indices of matA to be unsorted
cusparseSpSM() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Handle.SpSMUpdateMatrix updates the sparse matrix after calling the analysis phase. This functions supports the following update strategies ( updatePart):
- SpsmUpdateGeneral: Updates the sparse matrix values with values of newValues array
- SpsmUpdateDiagonal: Updates the diagonal part of the matrix with diagonal values stored in newValues array. That is, newValues has the new diagonal values only
Please visit cuSPARSE Library Samples - cusparseSpSM CSR and cuSPARSE Library Samples - cusparseSpSM COO for code examples.
Requires CUDA 12.4 or later; see HasSpSMUpdateMatrix.
- spsmDescr: Opaque descriptor for storing internal data used across the three steps
Wraps cusparseSpSMUpdateMatrix, bound as cusparseSpSM_updateMatrix.
func (Handle) SpSVAnalysis ¶
func (h Handle) SpSVAnalysis(opA Operation, alpha Scalar, matA ConstSpMatDescr, vecX ConstDnVecDescr, vecY DnVecDescr, computeType DataType, alg SpSVAlg, spsvDescr SpSVDescr, externalBuffer driver.DevicePtr) error
SpSVAnalysis solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
op(A)⋅Y=αX where
- op(A) is a sparse square matrix of size m×m
- X is a dense vector of size m
- Y is a dense vector of size m
- α is a scalar
Also, for matrix A: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose. The function Handle.SpSVBufferSize returns the size of the workspace needed by Handle.SpSVAnalysis and Handle.SpSVSolve. The function Handle.SpSVAnalysis performs the analysis phase, while Handle.SpSVSolve executes the solve phase for a sparse triangular linear system. The opaque data structure spsvDescr is used to share information among all functions. The function Handle.SpSVUpdateMatrix updates spsvDescr with new matrix values. The routine supports arbitrary sparsity for the input matrix, but only the upper or lower triangular part is taken into account in the computation. NOTE: all parameters must be consistent across cusparseSpSV API calls and the matrix descriptions and externalBuffer must not be modified between Handle.SpSVAnalysis and Handle.SpSVSolve. The function Handle.SpSVUpdateMatrix can be used to update the values on the sparse matrix stored inside the opaque data structure spsvDescr The sparse matrix formats currently supported are listed below:
The cusparseSpSV() supports the following shapes and properties:
- FillModeLower and FillModeUpper fill modes
- DiagTypeNonUnit and DiagTypeUnit diagonal types
The fill mode and diagonal type can be set by SpMatDescr.MatSetAttribute. cusparseSpSV() supports the following index type for representing the sparse matrix matA:
cusparseSpSV() supports the following data types: Uniform-precision computation:
- A/X/Y/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
cusparseSpSV() supports the following algorithms:
- SpsvAlgDefault: Default algorithm
cusparseSpSV() has the following properties:
- The routine requires extra storage for the analysis phase which is proportional to number of non-zero entries of the sparse matrix
- Provides deterministic (bit-wise) results for each run for the solving phase Handle.SpSVSolve
- The routine supports in-place operation
- The Handle.SpSVSolve routine supports asynchronous execution
- Handle.SpSVBufferSize and Handle.SpSVAnalysis routines accept NULL for vecX and vecY
- The routine allows the indices of matA to be unsorted
cusparseSpSV() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Handle.SpSVUpdateMatrix updates the sparse matrix after calling the analysis phase. This functions supports the following update strategies ( updatePart):
- SpsvUpdateGeneral: Updates the sparse matrix values with values of newValues array
- SpsvUpdateDiagonal: Updates the diagonal part of the matrix with diagonal values stored in newValues array. That is, newValues has the new diagonal values only
Please visit cuSPARSE Library Samples - cusparseSpSV CSR and cuSPARSE Library Samples - cusparseSpSV COO for code examples.
- opA: Operation op(A)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- vecX: Dense vector X
- vecY: Dense vector Y
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- spsvDescr: Opaque descriptor for storing internal data used across the three steps
- externalBuffer: Pointer to a workspace buffer of at least bufferSize bytes. It is used by Handle.SpSVAnalysis and Handle.SpSVSolve
Wraps cusparseSpSVAnalysis, bound as cusparseSpSV_analysis.
func (Handle) SpSVBufferSize ¶
func (h Handle) SpSVBufferSize(opA Operation, alpha Scalar, matA ConstSpMatDescr, vecX ConstDnVecDescr, vecY DnVecDescr, computeType DataType, alg SpSVAlg, spsvDescr SpSVDescr) (uint, error)
SpSVBufferSize returns the workspace size for cusparseSpSV.
- opA: Operation op(A)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- vecX: Dense vector X
- vecY: Dense vector Y
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- spsvDescr: Opaque descriptor for storing internal data used across the three steps
- bufferSize: Workspace size
Wraps cusparseSpSVBufferSize, bound as cusparseSpSV_bufferSize.
func (Handle) SpSVSolve ¶
func (h Handle) SpSVSolve(opA Operation, alpha Scalar, matA ConstSpMatDescr, vecX ConstDnVecDescr, vecY DnVecDescr, computeType DataType, alg SpSVAlg, spsvDescr SpSVDescr) error
SpSVSolve solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
op(A)⋅Y=αX where
- op(A) is a sparse square matrix of size m×m
- X is a dense vector of size m
- Y is a dense vector of size m
- α is a scalar
Also, for matrix A: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose. The function Handle.SpSVBufferSize returns the size of the workspace needed by Handle.SpSVAnalysis and Handle.SpSVSolve. The function Handle.SpSVAnalysis performs the analysis phase, while Handle.SpSVSolve executes the solve phase for a sparse triangular linear system. The opaque data structure spsvDescr is used to share information among all functions. The function Handle.SpSVUpdateMatrix updates spsvDescr with new matrix values. The routine supports arbitrary sparsity for the input matrix, but only the upper or lower triangular part is taken into account in the computation. NOTE: all parameters must be consistent across cusparseSpSV API calls and the matrix descriptions and externalBuffer must not be modified between Handle.SpSVAnalysis and Handle.SpSVSolve. The function Handle.SpSVUpdateMatrix can be used to update the values on the sparse matrix stored inside the opaque data structure spsvDescr The sparse matrix formats currently supported are listed below:
The cusparseSpSV() supports the following shapes and properties:
- FillModeLower and FillModeUpper fill modes
- DiagTypeNonUnit and DiagTypeUnit diagonal types
The fill mode and diagonal type can be set by SpMatDescr.MatSetAttribute. cusparseSpSV() supports the following index type for representing the sparse matrix matA:
cusparseSpSV() supports the following data types: Uniform-precision computation:
- A/X/Y/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
cusparseSpSV() supports the following algorithms:
- SpsvAlgDefault: Default algorithm
cusparseSpSV() has the following properties:
- The routine requires extra storage for the analysis phase which is proportional to number of non-zero entries of the sparse matrix
- Provides deterministic (bit-wise) results for each run for the solving phase Handle.SpSVSolve
- The routine supports in-place operation
- The Handle.SpSVSolve routine supports asynchronous execution
- Handle.SpSVBufferSize and Handle.SpSVAnalysis routines accept NULL for vecX and vecY
- The routine allows the indices of matA to be unsorted
cusparseSpSV() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Handle.SpSVUpdateMatrix updates the sparse matrix after calling the analysis phase. This functions supports the following update strategies ( updatePart):
- SpsvUpdateGeneral: Updates the sparse matrix values with values of newValues array
- SpsvUpdateDiagonal: Updates the diagonal part of the matrix with diagonal values stored in newValues array. That is, newValues has the new diagonal values only
Please visit cuSPARSE Library Samples - cusparseSpSV CSR and cuSPARSE Library Samples - cusparseSpSV COO for code examples.
- opA: Operation op(A)
- alpha: α scalar used for multiplication of type computeType. Its kind must match computeType; a host Scalar of another kind is a *ScalarError. It holds a host value or, under Handle.SetPointerMode with PointerModeDevice, a device address made with DeviceScalar.
- matA: Sparse matrix A
- vecX: Dense vector X
- vecY: Dense vector Y
- computeType: Datatype in which the computation is executed
- alg: Algorithm for the computation
- spsvDescr: Opaque descriptor for storing internal data used across the three steps
Wraps cusparseSpSVSolve, bound as cusparseSpSV_solve.
func (Handle) SpSVUpdateMatrix ¶
func (h Handle) SpSVUpdateMatrix(spsvDescr SpSVDescr, newValues driver.DevicePtr, updatePart SpSVUpdate) error
SpSVUpdateMatrix solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
op(A)⋅Y=αX where
- op(A) is a sparse square matrix of size m×m
- X is a dense vector of size m
- Y is a dense vector of size m
- α is a scalar
Also, for matrix A: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose. The function Handle.SpSVBufferSize returns the size of the workspace needed by Handle.SpSVAnalysis and Handle.SpSVSolve. The function Handle.SpSVAnalysis performs the analysis phase, while Handle.SpSVSolve executes the solve phase for a sparse triangular linear system. The opaque data structure spsvDescr is used to share information among all functions. The function Handle.SpSVUpdateMatrix updates spsvDescr with new matrix values. The routine supports arbitrary sparsity for the input matrix, but only the upper or lower triangular part is taken into account in the computation. NOTE: all parameters must be consistent across cusparseSpSV API calls and the matrix descriptions and externalBuffer must not be modified between Handle.SpSVAnalysis and Handle.SpSVSolve. The function Handle.SpSVUpdateMatrix can be used to update the values on the sparse matrix stored inside the opaque data structure spsvDescr The sparse matrix formats currently supported are listed below:
The cusparseSpSV() supports the following shapes and properties:
- FillModeLower and FillModeUpper fill modes
- DiagTypeNonUnit and DiagTypeUnit diagonal types
The fill mode and diagonal type can be set by SpMatDescr.MatSetAttribute. cusparseSpSV() supports the following index type for representing the sparse matrix matA:
cusparseSpSV() supports the following data types: Uniform-precision computation:
- A/X/Y/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
cusparseSpSV() supports the following algorithms:
- SpsvAlgDefault: Default algorithm
cusparseSpSV() has the following properties:
- The routine requires extra storage for the analysis phase which is proportional to number of non-zero entries of the sparse matrix
- Provides deterministic (bit-wise) results for each run for the solving phase Handle.SpSVSolve
- The routine supports in-place operation
- The Handle.SpSVSolve routine supports asynchronous execution
- Handle.SpSVBufferSize and Handle.SpSVAnalysis routines accept NULL for vecX and vecY
- The routine allows the indices of matA to be unsorted
cusparseSpSV() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Handle.SpSVUpdateMatrix updates the sparse matrix after calling the analysis phase. This functions supports the following update strategies ( updatePart):
- SpsvUpdateGeneral: Updates the sparse matrix values with values of newValues array
- SpsvUpdateDiagonal: Updates the diagonal part of the matrix with diagonal values stored in newValues array. That is, newValues has the new diagonal values only
Please visit cuSPARSE Library Samples - cusparseSpSV CSR and cuSPARSE Library Samples - cusparseSpSV COO for code examples.
- spsvDescr: Opaque descriptor for storing internal data used across the three steps
Wraps cusparseSpSVUpdateMatrix, bound as cusparseSpSV_updateMatrix.
func (Handle) SparseToDense ¶
func (h Handle) SparseToDense(matA ConstSpMatDescr, matB DnMatDescr, alg SparseToDenseAlg, externalBuffer driver.DevicePtr) error
SparseToDense converts the sparse matrix matA in CSR, CSC, or COO format into its dense representation matB.
Blocked-ELL is not currently supported. The function Handle.SparseToDenseBufferSize returns the size of the workspace needed by Handle.SparseToDense. Handle.SparseToDense supports the following index type for representing the sparse matrix matA:
Handle.SparseToDense supports the following data types:
- A/B: CUDA_R_8I, CUDA_R_16F, CUDA_R_16BF, CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
cusparseSparse2Dense() supports the following algorithm:
- SparsetodenseAlgDefault: Default algorithm
Handle.SparseToDense has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- Provides deterministic (bit-wise) results for each run
- The routine allows the indices of matA to be unsorted
Handle.SparseToDense supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - Handle.SparseToDense for a code example.
- matA: Sparse matrix A
- matB: Dense matrix B
- alg: Algorithm for the computation
Wraps cusparseSparseToDense.
func (Handle) SparseToDenseBufferSize ¶
func (h Handle) SparseToDenseBufferSize(matA ConstSpMatDescr, matB DnMatDescr, alg SparseToDenseAlg) (uint, error)
SparseToDenseBufferSize returns the workspace size for Handle.SparseToDense.
- matA: Sparse matrix A
- matB: Dense matrix B
- alg: Algorithm for the computation
- bufferSize: Workspace size
Wraps cusparseSparseToDenseBufferSize, bound as cusparseSparseToDense_bufferSize.
type LibraryAttempt ¶
LibraryAttempt records one failed attempt to open the shared library.
type LibraryConflictError ¶
type LibraryConflictError struct {
Loaded string
Requested string
// Implicit reports that the loaded library was opened lazily and no
// successful Load has since acknowledged it. A
// caller that sees this called some
// other function first, and that call took the default search list.
Implicit bool
}
LibraryConflictError reports a Load call naming a different library than the one already loaded. Only one library is loaded per process.
func (*LibraryConflictError) Error ¶
func (e *LibraryConflictError) Error() string
Error reports the conflicting library paths, and whether the library that is already loaded got there without a Load call.
type LibraryError ¶
type LibraryError struct {
Library string
Env string
Path string
Attempts []LibraryAttempt
Hint string
}
LibraryError reports that libcusparse could not be opened. Attempts lists every name tried in order. Path is set when an explicit path, from Load or CUSPARSE_LIB_PATH, was requested and failed. Hint reports pkg-config discovery results and query failures, when discovery ran.
func (*LibraryError) Error ¶
func (e *LibraryError) Error() string
Error describes the library load attempts and their errors.
func (*LibraryError) Unwrap ¶
func (e *LibraryError) Unwrap() []error
Unwrap returns the error from each attempt.
type LibraryPropertyType ¶
type LibraryPropertyType int32
LibraryPropertyType identifies a CUDA library property.
const ( MajorVersion LibraryPropertyType = 0 MinorVersion LibraryPropertyType = 1 PatchLevel LibraryPropertyType = 2 )
LibraryPropertyType constants.
type LoggerCallback ¶
type LoggerCallback uintptr
LoggerCallback represents cusparseLoggerCallback_t.
- logLevel: Selected log level
- functionName: The name of the API that logged this message
- message: The log message
type MatrixType ¶
type MatrixType int32
MatrixType represents cusparseMatrixType_t.
const ( MatrixTypeGeneral MatrixType = 0 MatrixTypeSymmetric MatrixType = 1 MatrixTypeHermitian MatrixType = 2 MatrixTypeTriangular MatrixType = 3 )
func (MatrixType) String ¶
func (e MatrixType) String() string
String returns the constant name, or a numeric representation for unknown values.
type PointerMode ¶
type PointerMode int32
PointerMode represents cusparsePointerMode_t.
const ( PointerModeHost PointerMode = 0 PointerModeDevice PointerMode = 1 )
func (PointerMode) String ¶
func (e PointerMode) String() string
String returns the constant name, or a numeric representation for unknown values.
type Result ¶
type Result int32
Result represents a cusparse API error code (cusparseStatus_t).
const ( Success Result = 0 ErrNotInitialized Result = 1 ErrAllocFailed Result = 2 ErrInvalidValue Result = 3 ErrArchMismatch Result = 4 ErrMappingError Result = 5 ErrExecutionFailed Result = 6 ErrInternalError Result = 7 ErrMatrixTypeNotSupported Result = 8 ErrZeroPivot Result = 9 ErrNotSupported Result = 10 ErrInsufficientResources Result = 11 )
cusparse error codes from cusparse.h.
type SDDMMAlg ¶
type SDDMMAlg int32
SDDMMAlg represents cusparseSDDMMAlg_t.
const (
SddmmAlgDefault SDDMMAlg = 0
)
type Scalar ¶
type Scalar struct {
// contains filtered or unexported fields
}
A Scalar is a value, such as the alpha and beta of a matrix product, that the library reads through a pointer. Make one for a value in host memory with Float32Scalar, Float64Scalar, Complex64Scalar, Complex128Scalar, or Int32Scalar, or for a value in device memory with DeviceScalar.
A call copies a host value into memory of its own, passes the library a pointer to the copy, and reuses that memory once the call returns, so a Scalar never reaches the library and can live anywhere.
The cuSPARSE documentation says only that host scalars are "passed by reference on the host", not when they are read, and that routines can be captured into CUDA graphs. The call assumes what cuBLAS documents for itself: that the library reads a host scalar before the call returns, and that capture into a CUDA graph keeps the value (cuBLAS documentation, sections 2.1.5 and 2.1.12).
The kind of a host Scalar must be the type the library reads. Where a call names that type in another parameter, a Scalar of another kind is a *ScalarError; where the type is in a descriptor, the call cannot check it. The zero Scalar is a host zero of every kind.
func Complex64Scalar ¶
Complex64Scalar returns a host Scalar holding the complex64 x.
func Complex128Scalar ¶
func Complex128Scalar(x complex128) Scalar
Complex128Scalar returns a host Scalar holding the complex128 x.
func DeviceScalar ¶
DeviceScalar returns a Scalar the library reads from device memory at p. A call passes p unchanged, which the library reads as an address only under Handle.SetPointerMode with PointerModeDevice. The device memory must stay valid until the stream work completes. A DeviceScalar has no kind, so no call checks it.
func Float32Scalar ¶
Float32Scalar returns a host Scalar holding the float32 x.
func Float64Scalar ¶
Float64Scalar returns a host Scalar holding the float64 x.
func Int32Scalar ¶
Int32Scalar returns a host Scalar holding the int32 x.
type ScalarError ¶
type ScalarError struct {
Func string // the C symbol called
Param string // the scalar parameter
Kind string // the Scalar's kind, such as "float32"
Want string // the kinds the call allows, such as "float64 or complex128"
}
A ScalarError reports a host Scalar whose kind is not the type the call names for it in another parameter.
func (*ScalarError) Error ¶
func (e *ScalarError) Error() string
type SolvePolicy ¶
type SolvePolicy int32
SolvePolicy represents cusparseSolvePolicy_t.
const ( SolvePolicyNoLevel SolvePolicy = 0 SolvePolicyUseLevel SolvePolicy = 1 )
func (SolvePolicy) String ¶
func (e SolvePolicy) String() string
String returns the constant name, or a numeric representation for unknown values.
type SpGEAMDescr ¶
type SpGEAMDescr uintptr
SpGEAMDescr is an opaque handle for cusparseSpGEAMDescr_t.
type SpGEMMDescr ¶
type SpGEMMDescr uintptr
SpGEMMDescr is an opaque handle for cusparseSpGEMMDescr_t.
func SpGEMMCreateDescr ¶
func SpGEMMCreateDescr() (SpGEMMDescr, error)
SpGEMMCreateDescr performs the multiplication of two sparse matrices matA and matB where the structure of the output matrix matC can be reused for multiple computations with different values.
C′=αop(A)⋅op(B)+βC where α and β are scalars. The functions Handle.SpGEMMreuseWorkEstimation, Handle.SpGEMMreuseNnz, and Handle.SpGEMMreuseCopy are used for determining the buffer size and performing the actual computation.
Note: cusparseSpGEMMreuse() output CSR matrix ( matC) is sorted by column indices. MEMORY REQUIREMENT: cusparseSpGEMMreuse requires to keep in memory all intermediate products to reuse the structure of the output matrix. On the other hand, the number of intermediate products is orders of magnitude higher than the number of non-zero entries in general. In order to minimize the memory requirements, the routine uses multiple buffers that can be deallocated after they are no more needed. If the number of intermediate product exceeds 2^31-1, the routine will returns ErrInsufficientResources status. Currently, the function has the following limitations:
- Only 32-bit indices Index32I is supported
- Only CSR format FormatCsr is supported
- Only opA, opB equal to OperationNonTranspose are supported
The data types combinations currently supported for cusparseSpGEMMreuse are listed below. Uniform-precision computation:
- A/B/C/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
Mixed-precision computation: DEPRECATED
A/B C computeType CUDA_R_16F CUDA_R_16F CUDA_R_32F CUDA_R_16BF CUDA_R_16BF CUDA_R_32F
cusparseSpGEMMreuse routine runs for the following algorithm:
- SpgemmDefault, SpgemmCsrAlgNondeterminitic: Default algorithm. Provides deterministic (bit-wise) structure for the output matrix for each run, while value computation is not deterministic.
- SpgemmCsrAlgDeterminitic: Provides deterministic (bit-wise) structure for the output matrix and value computation for each run.
cusparseSpGEMMreuse() has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- The routine allows the indices of matA and matB to be unsorted
- The routine guarantees the indices of matC to be sorted
cusparseSpGEMMreuse() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - cusparseSpGEMMreuse for a code example.
Wraps cusparseSpGEMMCreateDescr, bound as cusparseSpGEMM_createDescr.
func (SpGEMMDescr) GEMMDestroyDescr ¶
func (s SpGEMMDescr) GEMMDestroyDescr() error
GEMMDestroyDescr performs the multiplication of two sparse matrices matA and matB where the structure of the output matrix matC can be reused for multiple computations with different values.
C′=αop(A)⋅op(B)+βC where α and β are scalars. The functions Handle.SpGEMMreuseWorkEstimation, Handle.SpGEMMreuseNnz, and Handle.SpGEMMreuseCopy are used for determining the buffer size and performing the actual computation.
Note: cusparseSpGEMMreuse() output CSR matrix ( matC) is sorted by column indices. MEMORY REQUIREMENT: cusparseSpGEMMreuse requires to keep in memory all intermediate products to reuse the structure of the output matrix. On the other hand, the number of intermediate products is orders of magnitude higher than the number of non-zero entries in general. In order to minimize the memory requirements, the routine uses multiple buffers that can be deallocated after they are no more needed. If the number of intermediate product exceeds 2^31-1, the routine will returns ErrInsufficientResources status. Currently, the function has the following limitations:
- Only 32-bit indices Index32I is supported
- Only CSR format FormatCsr is supported
- Only opA, opB equal to OperationNonTranspose are supported
The data types combinations currently supported for cusparseSpGEMMreuse are listed below. Uniform-precision computation:
- A/B/C/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
Mixed-precision computation: DEPRECATED
A/B C computeType CUDA_R_16F CUDA_R_16F CUDA_R_32F CUDA_R_16BF CUDA_R_16BF CUDA_R_32F
cusparseSpGEMMreuse routine runs for the following algorithm:
- SpgemmDefault, SpgemmCsrAlgNondeterminitic: Default algorithm. Provides deterministic (bit-wise) structure for the output matrix for each run, while value computation is not deterministic.
- SpgemmCsrAlgDeterminitic: Provides deterministic (bit-wise) structure for the output matrix and value computation for each run.
cusparseSpGEMMreuse() has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- The routine allows the indices of matA and matB to be unsorted
- The routine guarantees the indices of matC to be sorted
cusparseSpGEMMreuse() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - cusparseSpGEMMreuse for a code example.
Wraps cusparseSpGEMMDestroyDescr, bound as cusparseSpGEMM_destroyDescr.
func (SpGEMMDescr) GEMMGetNumProducts ¶
func (s SpGEMMDescr) GEMMGetNumProducts(numProds *int64) error
GEMMGetNumProducts performs the multiplication of two sparse matrices matA and matB.
C′=αop(A)⋅op(B)+βC where α,β are scalars, and C,C′ have the same sparsity pattern. The functions Handle.SpGEMMWorkEstimation, Handle.SpGEMMEstimateMemory, and Handle.SpGEMMCompute are used for both determining the buffer size and performing the actual computation. cusparseSpGEMM supports the following index type for representing the sparse matrix A, B and C (all matrices must have the same index type):
Currently, the function has the following limitations:
- Only CSR format FormatCsr is supported
- Only opA, opB equal to OperationNonTranspose are supported
The data types combinations currently supported for cusparseSpGEMM are listed below : Uniform-precision computation:
- A/B/C/computeType: CUDA_R_16F DEPRECATED, CUDA_R_16BF DEPRECATED, CUDA_R_32F, CUDA_R_64F, CUDA_C_16F DEPRECATED, CUDA_C_16BF DEPRECATED, CUDA_C_32F, CUDA_C_64F
cusparseSpGEMM routine runs for the following algorithms:
- SpgemmDefault: Default algorithm. Currently, it is SpgemmALG1.
- SpgemmALG1: Algorithm 1: Invokes Handle.SpGEMMCompute twice. The first invocation provides an upper bound of the memory required for the computation. The required memory is generally several times larger of the actual memory used. The user can provide an arbitrary buffer size bufferSize2 in the second invocation. If it is not sufficient, the routine will returns ErrInsufficientResources status. Provides better performance than other algorithms. Provides deterministic (bit-wise) results for each run.
- SpgemmALG2: Algorithm 2: Invokes Handle.SpGEMMEstimateMemory to get the amount of the memory required for the computation. Requires less memory for the computation than Algorithm 1. Performance is lower than Algorithm 1, higher than Algorithm 3. Provides deterministic (bit-wise) results for each run.
- SpgemmALG3: Algorithm 3: Computes the intermediate products in chunks, one chunk at a time. Invokes Handle.SpGEMMEstimateMemory to get the amount of the memory required for the computation. The user can control the amount of required memory by changing the chunk size via chunk_fraction. The chunk size is a fraction of total intermediate products: chunk_fraction * (*numProds). Provides deterministic (bit-wise) results for each run.
cusparseSpGEMM() has the following properties:
- The routine requires no extra storage
- The routine supports asynchronous execution
- The routine allows the indices of matA and matB to be unsorted
- The routine guarantees the indices of matC to be sorted
cusparseSpGEMM() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Please visit cuSPARSE Library Samples - cusparseSpGEMM for a code example for SpgemmDefault and SpgemmALG1, and cuSPARSE Library Samples - memory-optimzed cusparseSpGEMM for a code example for SpgemmALG2 and SpgemmALG3.
- numProds: Pointer to a 64-bit integer that stores the number of intermediate products calculated by Handle.SpGEMMWorkEstimation
Wraps cusparseSpGEMMGetNumProducts, bound as cusparseSpGEMM_getNumProducts.
type SpMMOpAlg ¶
type SpMMOpAlg int32
SpMMOpAlg represents cusparseSpMMOpAlg_t.
const (
SpmmOpAlgDefault SpMMOpAlg = 0
)
type SpMVOpDescr ¶
type SpMVOpDescr uintptr
SpMVOpDescr is an opaque handle for cusparseSpMVOpDescr_t.
func (SpMVOpDescr) MVOpDestroyDescr ¶
func (s SpMVOpDescr) MVOpDestroyDescr() error
MVOpDestroyDescr is only available if macro CUSPARSE_ENABLE_EXPERIMENTAL_API is defined.
It performs the multiplication of a sparse matrix matA and a dense vector vecX. This function is experimental. Zᵢ=epilogue(α∑_(k)(op(Aᵢₖ)⋅Xₖ)+βYᵢ) where
op(A) is a sparse matrix of size m×k.
X is a dense vector of size k.
Y is a dense vector of size m.
Z is a dense vector of size m. It is allowed to alias Y.
α and β are scalars.
epilogue is a custom function with the following signature
__device__ <computetype> spmv_op_epilogue(int64_t row, <computetype> value);
Handle.SpMVOp supports sparse format FormatCsr and opA=[OperationNonTranspose]. The following index type combinations are supported:
- csrRowOffsetsType: Index32I; csrColIndType: Index32I
- csrRowOffsetsType: Index64I; csrColIndType: Index32I
Handle.SpMVOp supports the following type combinations:
- A: CUDA_R_32F; X/Y/Z/computeType: CUDA_R_32F
- A: CUDA_R_32F; X/Y/Z/computeType: CUDA_R_64F
- A: CUDA_R_64F; X/Y/Z/computeType: CUDA_R_64F
Handle.SpMVOp supports the following algorithms:
- SpmvopAlgDefault: Default algorithm; currently equivalent to SpmvopALG1.
- SpmvopALG1: Deterministic algorithm. Supports updating the values of matA between calls to Handle.SpMVOp without rebuilding the descriptor or the execution plan, either in-place or via SpMatDescr.CsrSetPointers.
- SpmvopALG2: Alternative deterministic algorithm. Compared to SpmvopALG1, it may offer higher performance at the cost of significantly more buffer usage and more expensive preprocessing in Handle.SpMVOpCreateDescr. Does not support updating the values of matA between calls without rebuilding the descriptor and the execution plan.
The function Handle.SpMVOpBufferSize returns the size of the workspace needed by Handle.SpMVOpCreateDescr and Handle.SpMVOp. Currently, it accepts NULL for vecX, vecY and vecZ. The function Handle.SpMVOpCreateDescr prepares the internal data represented by the descriptor which is needed by Handle.SpMVOpCreatePlan and Handle.SpMVOp. The passed-in device buffer must remain valid and unmodified until the associated descriptor is destroyed. It supports passing dummy vecX, vecY and vecZ objects, as long as their data type attributes are valid. Other attributes are ignored during the descriptor creation. If epilogueLTOBuffer is NULL or epilogueLTOBufferSize is 0, the built-in default epilogue will be employed without Link-Time-Optimization (LTO):
__device__ <computetype> spmv_op_epilogue(int64_t row, <computetype> value) { return value; }
The function Handle.SpMVOpCreatePlan takes in the descriptor and the LTO-IR of the custom epilogue, and returns the execution plan. The same descriptor can be used to create multiple execution plans, each with its own epilogue and epilogue auxiliary data. A caching system is employed to avoid redundant JIT compilation: plans compiled from identical LTO-IR (same epilogueLTOBuffer content and epilogueLTOBufferSize) share a single CUmodule. The function Handle.SpMVOpSetGlobalUserData copies epilogueDataSize bytes from the host buffer epilogueData to the device __device__ or __constant__ variable named epilogueDataName in the compiled epilogue module. epilogueDataName must match the symbol name of the variable as declared in the epilogue device code. The invocation is optional; it should be called only if the epilogue requires auxiliary data. It can be invoked repeatedly before Handle.SpMVOp to update the auxiliary data. As a consequence of the plan caching, calling Handle.SpMVOpSetGlobalUserData affects every plan that links to the same compiled epilogue, not only the plan passed as argument. If multiple plans share the same LTO-IR but require different runtime constant values, the caller is responsible for serializing each Handle.SpMVOpSetGlobalUserData + Handle.SpMVOp pair so that each plan’s constants are current at the time it executes. Handle.SpMVOp has the following properties:
- It supports a customizable epilogue function, enabling users to apply additional elementwise and more complex operations to the output vector.
- It provides improved numerical accuracy than Handle.SpMV due to the fact that accumulation is partially performed using Kahan’s summation.
- The routine produces deterministic (bit-wise) results for each run, assuming that the epilogue function is deterministic.
- In general, it is significantly faster than Handle.SpMV with the deterministic algorithm SpmvCsrALG2, at the cost of more buffer usage.
- SpmvopALG1 (and SpmvopAlgDefault) supports updating the values of matA between calls to Handle.SpMVOp without rebuilding the descriptor or the execution plan. The updated values can be provided in-place (by modifying the device memory previously registered in the matrix descriptor) or by calling SpMatDescr.CsrSetPointers with the new value pointer before each Handle.SpMVOp call.
- The routine supports asynchronous execution.
- The routine allows the indices of matA to be unsorted.
- It supports CUDA graph capture optimizations.
Please visit cuSPARSE Library Samples - Handle.SpMVOp for a code example.
Requires CUDA 13.1 or later; see HasSpMVOpDestroyDescr.
Wraps cusparseSpMVOpDestroyDescr, bound as cusparseSpMVOp_destroyDescr.
type SpMVOpPlan ¶
type SpMVOpPlan uintptr
SpMVOpPlan is an opaque handle for cusparseSpMVOpPlan_t.
func (SpMVOpPlan) MVOpDestroyPlan ¶
func (s SpMVOpPlan) MVOpDestroyPlan() error
MVOpDestroyPlan is only available if macro CUSPARSE_ENABLE_EXPERIMENTAL_API is defined.
It performs the multiplication of a sparse matrix matA and a dense vector vecX. This function is experimental. Zᵢ=epilogue(α∑_(k)(op(Aᵢₖ)⋅Xₖ)+βYᵢ) where
op(A) is a sparse matrix of size m×k.
X is a dense vector of size k.
Y is a dense vector of size m.
Z is a dense vector of size m. It is allowed to alias Y.
α and β are scalars.
epilogue is a custom function with the following signature
__device__ <computetype> spmv_op_epilogue(int64_t row, <computetype> value);
Handle.SpMVOp supports sparse format FormatCsr and opA=[OperationNonTranspose]. The following index type combinations are supported:
- csrRowOffsetsType: Index32I; csrColIndType: Index32I
- csrRowOffsetsType: Index64I; csrColIndType: Index32I
Handle.SpMVOp supports the following type combinations:
- A: CUDA_R_32F; X/Y/Z/computeType: CUDA_R_32F
- A: CUDA_R_32F; X/Y/Z/computeType: CUDA_R_64F
- A: CUDA_R_64F; X/Y/Z/computeType: CUDA_R_64F
Handle.SpMVOp supports the following algorithms:
- SpmvopAlgDefault: Default algorithm; currently equivalent to SpmvopALG1.
- SpmvopALG1: Deterministic algorithm. Supports updating the values of matA between calls to Handle.SpMVOp without rebuilding the descriptor or the execution plan, either in-place or via SpMatDescr.CsrSetPointers.
- SpmvopALG2: Alternative deterministic algorithm. Compared to SpmvopALG1, it may offer higher performance at the cost of significantly more buffer usage and more expensive preprocessing in Handle.SpMVOpCreateDescr. Does not support updating the values of matA between calls without rebuilding the descriptor and the execution plan.
The function Handle.SpMVOpBufferSize returns the size of the workspace needed by Handle.SpMVOpCreateDescr and Handle.SpMVOp. Currently, it accepts NULL for vecX, vecY and vecZ. The function Handle.SpMVOpCreateDescr prepares the internal data represented by the descriptor which is needed by Handle.SpMVOpCreatePlan and Handle.SpMVOp. The passed-in device buffer must remain valid and unmodified until the associated descriptor is destroyed. It supports passing dummy vecX, vecY and vecZ objects, as long as their data type attributes are valid. Other attributes are ignored during the descriptor creation. If epilogueLTOBuffer is NULL or epilogueLTOBufferSize is 0, the built-in default epilogue will be employed without Link-Time-Optimization (LTO):
__device__ <computetype> spmv_op_epilogue(int64_t row, <computetype> value) { return value; }
The function Handle.SpMVOpCreatePlan takes in the descriptor and the LTO-IR of the custom epilogue, and returns the execution plan. The same descriptor can be used to create multiple execution plans, each with its own epilogue and epilogue auxiliary data. A caching system is employed to avoid redundant JIT compilation: plans compiled from identical LTO-IR (same epilogueLTOBuffer content and epilogueLTOBufferSize) share a single CUmodule. The function Handle.SpMVOpSetGlobalUserData copies epilogueDataSize bytes from the host buffer epilogueData to the device __device__ or __constant__ variable named epilogueDataName in the compiled epilogue module. epilogueDataName must match the symbol name of the variable as declared in the epilogue device code. The invocation is optional; it should be called only if the epilogue requires auxiliary data. It can be invoked repeatedly before Handle.SpMVOp to update the auxiliary data. As a consequence of the plan caching, calling Handle.SpMVOpSetGlobalUserData affects every plan that links to the same compiled epilogue, not only the plan passed as argument. If multiple plans share the same LTO-IR but require different runtime constant values, the caller is responsible for serializing each Handle.SpMVOpSetGlobalUserData + Handle.SpMVOp pair so that each plan’s constants are current at the time it executes. Handle.SpMVOp has the following properties:
- It supports a customizable epilogue function, enabling users to apply additional elementwise and more complex operations to the output vector.
- It provides improved numerical accuracy than Handle.SpMV due to the fact that accumulation is partially performed using Kahan’s summation.
- The routine produces deterministic (bit-wise) results for each run, assuming that the epilogue function is deterministic.
- In general, it is significantly faster than Handle.SpMV with the deterministic algorithm SpmvCsrALG2, at the cost of more buffer usage.
- SpmvopALG1 (and SpmvopAlgDefault) supports updating the values of matA between calls to Handle.SpMVOp without rebuilding the descriptor or the execution plan. The updated values can be provided in-place (by modifying the device memory previously registered in the matrix descriptor) or by calling SpMatDescr.CsrSetPointers with the new value pointer before each Handle.SpMVOp call.
- The routine supports asynchronous execution.
- The routine allows the indices of matA to be unsorted.
- It supports CUDA graph capture optimizations.
Please visit cuSPARSE Library Samples - Handle.SpMVOp for a code example.
Requires CUDA 13.1 or later; see HasSpMVOpDestroyPlan.
Wraps cusparseSpMVOpDestroyPlan, bound as cusparseSpMVOp_destroyPlan.
type SpMatAttribute ¶
type SpMatAttribute int32
SpMatAttribute represents cusparseSpMatAttribute_t.
const ( SpmatFillMode SpMatAttribute = 0 SpmatDiagType SpMatAttribute = 1 SpmatStorage SpMatAttribute = 2 SpmatSymmetryType SpMatAttribute = 3 )
func (SpMatAttribute) String ¶
func (e SpMatAttribute) String() string
String returns the constant name, or a numeric representation for unknown values.
type SpMatConvertAlg ¶
type SpMatConvertAlg int32
SpMatConvertAlg represents cusparseSpMatConvertAlg_t.
const (
SpmatConvertAlgDefault SpMatConvertAlg = 0
)
func (SpMatConvertAlg) String ¶
func (e SpMatConvertAlg) String() string
String returns the constant name, or a numeric representation for unknown values.
type SpMatConvertDescr ¶
type SpMatConvertDescr uintptr
SpMatConvertDescr is an opaque handle for cusparseSpMatConvertDescr_t.
type SpMatDescr ¶
type SpMatDescr uintptr
SpMatDescr is an opaque handle for cusparseSpMatDescr_t.
func CreateBlockedEll ¶
func CreateBlockedEll(rows int64, cols int64, ellBlockSize int64, ellCols int64, ellColInd driver.DevicePtr, ellValue driver.DevicePtr, ellIdxType IndexType, idxBase IndexBase, valueType DataType) (SpMatDescr, error)
CreateBlockedEll initializes the sparse matrix descriptor spMatDescr for the Blocked-Ellpack (ELL) format.
Blocked-ELL Column indices ( ellColInd) are in the range [0, cols / ellBlockSize -1]. The array can contain -1 values for indicating empty blocks.
- spMatDescr: Sparse matrix descriptor
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- ellBlockSize: Size of the ELL-Block
- ellCols: Actual number of columns of the Blocked-Ellpack format ( ellValue columns)
- ellColInd: Blocked-ELL Column indices. Array with [ellCols / ellBlockSize][rows / ellBlockSize] elements
- ellValue: Values of the sparse matrix. Array with rows * ellCols elements
- ellIdxType: Data type of ellColInd
- idxBase: Index base of ellColInd
- valueType: Data type of ellValue
Wraps cusparseCreateBlockedEll.
func CreateBsr ¶
func CreateBsr(brows int64, bcols int64, bnnz int64, rowBlockSize int64, colBlockSize int64, bsrRowOffsets driver.DevicePtr, bsrColInd driver.DevicePtr, bsrValues driver.DevicePtr, bsrRowOffsetsType IndexType, bsrColIndType IndexType, idxBase IndexBase, valueType DataType, order Order) (SpMatDescr, error)
CreateBsr initializes the sparse matrix descriptor spMatDescr for the Block Compressed Row (BSR) format.
CreateBsr has the following constraints:
- bsrRowOffsets, bsrColInd, and bsrValues must be aligned to the size of the datatypes specified by bsrRowOffsetsType, bsrColIndType, and valueType, respectively. See cudaDataType_t for the description of the datatypes.
Parameters:
- spMatDescr: Sparse matrix descriptor
- brows: Number of block rows of the sparse matrix
- bcols: Number of block columns of the sparse matrix
- bnnz: Number of blocks of the sparse matrix
- rowBlockSize: Number of rows of each block
- colBlockSize: Number of columns of each block
- bsrRowOffsets: Block row offsets of the sparse matrix. Array of size brows + 1
- bsrColInd: Block column indices of the sparse matrix. Array of size bnnz
- bsrValues: Values of the sparse matrix. Array of size bnnz * rowBlockSize * colBlockSize
- bsrRowOffsetsType: Data type of bsrRowOffsets
- bsrColIndType: Data type of bsrColInd
- idxBase: Base index of bsrRowOffsets and bsrColInd
- valueType: Datatype of bsrValues
- order: Enumerator specifying the memory layout of values in each block
Wraps cusparseCreateBsr.
func CreateCoo ¶
func CreateCoo(rows int64, cols int64, nnz int64, cooRowInd driver.DevicePtr, cooColInd driver.DevicePtr, cooValues driver.DevicePtr, cooIdxType IndexType, idxBase IndexBase, valueType DataType) (SpMatDescr, error)
CreateCoo initializes the sparse matrix descriptor spMatDescr in the COO format (Structure of Arrays layout).
CreateCoo has the following constraints:
- cooRowInd, cooColInd, and cooValues must be aligned to the size of the datatypes specified by cooIdxType, cooIdxType, and valueType. respectively. See cudaDataType_t for the description of the datatypes.
Parameters:
- spMatDescr: Sparse matrix descriptor
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of non-zero entries of the sparse matrix
- cooRowInd: Row indices of the sparse matrix. Array with nnz elements
- cooColInd: Column indices of the sparse matrix. Array with nnz elements
- cooValues: Values of the sparse matrix. Array with nnz elements
- cooIdxType: Data type of cooRowInd and cooColInd
- idxBase: Index base of cooRowInd and cooColInd
- valueType: Datatype of cooValues
Wraps cusparseCreateCoo.
func CreateCsc ¶
func CreateCsc(rows int64, cols int64, nnz int64, cscColOffsets driver.DevicePtr, cscRowInd driver.DevicePtr, cscValues driver.DevicePtr, cscColOffsetsType IndexType, cscRowIndType IndexType, idxBase IndexBase, valueType DataType) (SpMatDescr, error)
CreateCsc initializes the sparse matrix descriptor spMatDescr in the CSC format.
CreateCsc has the following constraints:
- cscColOffsets, cscRowInd, and cscValues must be aligned to the size of the datatypes specified by cscColOffsetsType, cscRowIndType, and valueType, respectively. See cudaDataType_t for the description of the datatypes.
Parameters:
- spMatDescr: Sparse matrix descriptor
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of non-zero entries of the sparse matrix
- cscColOffsets: Column offsets of the sparse matrix. Array with cols + 1 elements
- cscRowInd: Row indices of the sparse matrix. Array with nnz elements
- cscValues: Values of the sparse matrix. Array with nnz elements
- cscColOffsetsType: Data type of cscColOffsets
- cscRowIndType: Data type of cscRowInd
- idxBase: Index base of cscColOffsets and cscRowInd
- valueType: Datatype of cscValues
Wraps cusparseCreateCsc.
func CreateCsr ¶
func CreateCsr(rows int64, cols int64, nnz int64, csrRowOffsets driver.DevicePtr, csrColInd driver.DevicePtr, csrValues driver.DevicePtr, csrRowOffsetsType IndexType, csrColIndType IndexType, idxBase IndexBase, valueType DataType) (SpMatDescr, error)
CreateCsr initializes the sparse matrix descriptor spMatDescr in the CSR format.
CreateCsr has the following constraints:
- csrRowOffsets, csrColInd, and csrValues must be aligned to the size of the datatypes specified by csrRowOffsetsType, csrColIndType, and valueType, respectively. See cudaDataType_t for the description of the datatypes.
Parameters:
- spMatDescr: Sparse matrix descriptor
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of non-zero entries of the sparse matrix
- csrRowOffsets: Row offsets of the sparse matrix. Array with rows + 1 elements
- csrColInd: Column indices of the sparse matrix. Array with nnz elements
- csrValues: Values of the sparse matrix. Array with nnz elements
- csrRowOffsetsType: Data type of csrRowOffsets
- csrColIndType: Data type of csrColInd
- idxBase: Index base of csrRowOffsets and csrColInd
- valueType: Datatype of csrValues
Wraps cusparseCreateCsr.
func CreateSlicedEll ¶
func CreateSlicedEll(rows int64, cols int64, nnz int64, sellValuesSize int64, sliceSize int64, sellSliceOffsets driver.DevicePtr, sellColInd driver.DevicePtr, sellValues driver.DevicePtr, sellSliceOffsetsType IndexType, sellColIndType IndexType, idxBase IndexBase, valueType DataType) (SpMatDescr, error)
CreateSlicedEll initializes the sparse matrix descriptor spMatDescr for the Sliced Ellpack (SELL) format.
Note: Sliced Ellpack Column array sellColInd contains -1 values for indicating padded entries. CreateSlicedEll has the following constraints:
- sellSliceOffsets, sellColInd, and sellValues must be aligned to the size of the datatypes specified by sellSliceOffsetsType, sellColIndType, and valueType, respectively. See cudaDataType_t for the description of the datatypes.
Parameters:
- spMatDescr: Sparse matrix descriptor
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of nonzero elements in the sparse matrix
- sellValuesSize: Total number of elements in sellValues array (nonzero and padding)
- sliceSize: The number of rows per slice
- sellSliceOffsets: Slice offsets of the sparse matrix. Array of size ⌈rowssliceSize⌉+1
- sellColInd: Column indexes of the sparse matrix. Array of size sellValuesSize
- sellValues: Values of the sparse matrix. Array of size sellValuesSize elements
- sellSliceOffsetsType: Data type of sellSliceOffsets
- sellColIndType: Data type of sellColInd
- idxBase: Index base of sellColInd
- valueType: Data type of sellValues
Wraps cusparseCreateSlicedEll.
func (SpMatDescr) BlockedEllGet ¶
func (s SpMatDescr) BlockedEllGet(rows *int64, cols *int64, ellBlockSize *int64, ellCols *int64, ellColInd *uintptr, ellValue *uintptr, ellIdxType *IndexType, idxBase *IndexBase, valueType *DataType) error
BlockedEllGet returns the fields of the sparse matrix descriptor spMatDescr stored in Blocked-Ellpack (ELL) format.
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- ellBlockSize: Size of the ELL-Block
- ellCols: Actual number of columns of the Blocked-Ellpack format
- ellColInd: Column indices for the ELL-Block. Array with [cols / ellBlockSize][rows / ellBlockSize] elements
- ellValue: Values of the sparse matrix. Array with rows * ellCols elements
- ellIdxType: Data type of ellColInd
- idxBase: Index base of ellColInd
- valueType: Datatype of ellValue
Wraps cusparseBlockedEllGet.
func (SpMatDescr) BsrSetStridedBatch ¶
func (s SpMatDescr) BsrSetStridedBatch(batchCount int32, offsetsBatchStride int64, columnsBatchStride int64, valuesBatchStride int64) error
BsrSetStridedBatch sets the batchCount and the batchStride fields of the sparse matrix descriptor spMatDescr.
- batchCount: Number of batches of the sparse matrix
- offsetsBatchStride: Address offset between consecutive batches for the row offset array
- columnsBatchStride: Address offset between consecutive batches for the column array
- valuesBatchStride: Address offset between consecutive batches for the values array
Wraps cusparseBsrSetStridedBatch.
func (SpMatDescr) CooGet ¶
func (s SpMatDescr) CooGet(rows *int64, cols *int64, nnz *int64, cooRowInd *uintptr, cooColInd *uintptr, cooValues *uintptr, idxType *IndexType, idxBase *IndexBase, valueType *DataType) error
CooGet returns the fields of the sparse matrix descriptor spMatDescr stored in COO format (Array of Structures layout).
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of non-zero entries of the sparse matrix
- cooRowInd: Row indices of the sparse matrix. Array nnz elements
- cooColInd: Column indices of the sparse matrix. Array nnz elements
- cooValues: Values of the sparse matrix. Array nnz elements
- idxBase: Index base of cooRowInd and cooColInd
- valueType: Datatype of cooValues
Wraps cusparseCooGet.
func (SpMatDescr) CooSetPointers ¶
func (s SpMatDescr) CooSetPointers(cooRows driver.DevicePtr, cooColumns driver.DevicePtr, cooValues driver.DevicePtr) error
CooSetPointers sets the pointers of the sparse matrix descriptor spMatDescr.
SpMatDescr.CooSetPointers has the following constraints:
- cooRows, cooColumns, and cooValues must be aligned to the size of their corresponding datatypes specified in spMatDescr. See cudaDataType_t for the description of the datatypes.
Parameters:
- cooRows: Row indices of the sparse matrix. Array with nnz elements
- cooColumns: Column indices of the sparse matrix. Array with nnz elements
- cooValues: Values of the sparse matrix. Array with nnz elements
Wraps cusparseCooSetPointers.
func (SpMatDescr) CooSetStridedBatch ¶
func (s SpMatDescr) CooSetStridedBatch(batchCount int32, batchStride int64) error
CooSetStridedBatch sets the batchCount and the batchStride fields of the sparse matrix descriptor spMatDescr.
- batchCount: Number of batches of the sparse matrix
- batchStride: address offset between consecutive batches
Wraps cusparseCooSetStridedBatch.
func (SpMatDescr) CscGet ¶
func (s SpMatDescr) CscGet(rows *int64, cols *int64, nnz *int64, cscColOffsets *uintptr, cscRowInd *uintptr, cscValues *uintptr, cscColOffsetsType *IndexType, cscRowIndType *IndexType, idxBase *IndexBase, valueType *DataType) error
CscGet returns the fields of the sparse matrix descriptor spMatDescr stored in CSC format.
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of non-zero entries of the sparse matrix
- cscColOffsets: Col offsets of the sparse matrix. Array with cols + 1 elements
- cscRowInd: Row indices of the sparse matrix. Array with nnz elements
- cscValues: Values of the sparse matrix. Array with nnz elements
- cscColOffsetsType: Data type of cscColOffsets
- cscRowIndType: Data type of cscRowInd
- idxBase: Index base of cscColOffsets and cscRowInd
- valueType: Datatype of cscValues
Wraps cusparseCscGet.
func (SpMatDescr) CscSetPointers ¶
func (s SpMatDescr) CscSetPointers(cscColOffsets driver.DevicePtr, cscRowInd driver.DevicePtr, cscValues driver.DevicePtr) error
CscSetPointers sets the pointers of the sparse matrix descriptor spMatDescr.
SpMatDescr.CscSetPointers has the following constraints:
- cscColOffsets, cscRowInd, and cscValues must be aligned to the size of their corresponding datatypes specified in spMatDescr. See cudaDataType_t for the description of the datatypes.
Parameters:
- cscColOffsets: Col offsets of the sparse matrix. Array with cols + 1 elements
- cscRowInd: Row indices of the sparse matrix. Array with nnz elements
- cscValues: Values of the sparse matrix. Array with nnz elements
Wraps cusparseCscSetPointers.
func (SpMatDescr) CsrGet ¶
func (s SpMatDescr) CsrGet(rows *int64, cols *int64, nnz *int64, csrRowOffsets *uintptr, csrColInd *uintptr, csrValues *uintptr, csrRowOffsetsType *IndexType, csrColIndType *IndexType, idxBase *IndexBase, valueType *DataType) error
CsrGet returns the fields of the sparse matrix descriptor spMatDescr stored in CSR format.
- rows: Number of rows of the sparse matrix
- cols: Number of columns of the sparse matrix
- nnz: Number of non-zero entries of the sparse matrix
- csrRowOffsets: Row offsets of the sparse matrix. Array with rows + 1 elements
- csrColInd: Column indices of the sparse matrix. Array with nnz elements
- csrValues: Values of the sparse matrix. Array with nnz elements
- csrRowOffsetsType: Data type of csrRowOffsets
- csrColIndType: Data type of csrColInd
- idxBase: Index base of csrRowOffsets and csrColInd
- valueType: Datatype of csrValues
Wraps cusparseCsrGet.
func (SpMatDescr) CsrSetPointers ¶
func (s SpMatDescr) CsrSetPointers(csrRowOffsets driver.DevicePtr, csrColInd driver.DevicePtr, csrValues driver.DevicePtr) error
CsrSetPointers sets the pointers of the sparse matrix descriptor spMatDescr.
SpMatDescr.CsrSetPointers has the following constraints:
- csrRowOffsets, csrColInd, and csrValues must be aligned to the size of their corresponding datatypes specified in spMatDescr. See cudaDataType_t for the description of the datatypes.
Parameters:
- csrRowOffsets: Row offsets of the sparse matrix. Array with rows + 1 elements
- csrColInd: Column indices of the sparse matrix. Array with nnz elements
- csrValues: Values of the sparse matrix. Array with nnz elements
Wraps cusparseCsrSetPointers.
func (SpMatDescr) CsrSetStridedBatch ¶
func (s SpMatDescr) CsrSetStridedBatch(batchCount int32, offsetsBatchStride int64, columnsValuesBatchStride int64) error
CsrSetStridedBatch sets the batchCount and the batchStride fields of the sparse matrix descriptor spMatDescr.
- batchCount: Number of batches of the sparse matrix
- offsetsBatchStride: Address offset between consecutive batches for the row offset array
- columnsValuesBatchStride: Address offset between consecutive batches for the column and value arrays
Wraps cusparseCsrSetStridedBatch.
func (SpMatDescr) MatGetValues ¶
func (s SpMatDescr) MatGetValues(values *uintptr) error
MatGetValues returns the values field of the sparse matrix descriptor spMatDescr.
- values: Values of the sparse matrix. Array with nnz elements
Wraps cusparseSpMatGetValues.
func (SpMatDescr) MatSetAttribute ¶
func (s SpMatDescr) MatSetAttribute(attribute SpMatAttribute, data unsafe.Pointer, dataSize uint) error
MatSetAttribute sets the attributes of the sparse matrix descriptor spMatDescr.
- Attribute: SpmatFillMode; Meaning: Indicates if the lower or upper part of a matrix is stored in sparse storage; Possible Values: FillModeLower FillModeUpper
- Attribute: SpmatDiagType; Meaning: Indicates if the matrix diagonal entries are unity; Possible Values: DiagTypeNonUnit DiagTypeUnit
Parameters:
- attribute: Attribute enumerator
- data: Attribute value
- dataSize: Size of the attribute in bytes for safety
Wraps cusparseSpMatSetAttribute.
func (SpMatDescr) MatSetValues ¶
func (s SpMatDescr) MatSetValues(values driver.DevicePtr) error
MatSetValues sets the values field of the sparse matrix descriptor spMatDescr.
SpMatDescr.MatSetValues has the following constraints:
- values must be aligned to the size of its corresponding datatype specified in spMatDescr. See cudaDataType_t for the description of the datatypes.
Parameters:
- values: Values of the sparse matrix. Array with nnz elements
Wraps cusparseSpMatSetValues.
type SpMatPointers ¶
SpMatPointers represents cusparseSpMatPointers_t.
type SpMatSizes ¶
SpMatSizes represents cusparseSpMatSizes_t.
type SpMatStorage ¶
type SpMatStorage int32
SpMatStorage represents cusparseSpMatStorage_t.
const ( StoreFull SpMatStorage = 0 StoreLower SpMatStorage = 1 StoreUpper SpMatStorage = 2 )
func (SpMatStorage) String ¶
func (e SpMatStorage) String() string
String returns the constant name, or a numeric representation for unknown values.
type SpSMAlg ¶
type SpSMAlg int32
SpSMAlg represents cusparseSpSMAlg_t.
const (
SpsmAlgDefault SpSMAlg = 0
)
type SpSMDescr ¶
type SpSMDescr uintptr
SpSMDescr is an opaque handle for cusparseSpSMDescr_t.
func SpSMCreateDescr ¶
SpSMCreateDescr solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
op(A)⋅C=αop(B) where
- op(A) is a sparse square matrix of size m×m
- op(B) is a dense matrix of size m×n
- C is a dense matrix of size m×n
- α is a scalar
Also, for matrix A: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose; op(B) = B if opB == OperationNonTranspose, and op(B) = Bᵀ if opB == OperationTranspose. The function Handle.SpSMBufferSize returns the size of the workspace needed by Handle.SpSMAnalysis and Handle.SpSMSolve. The function Handle.SpSMAnalysis performs the analysis phase, while Handle.SpSMSolve executes the solve phase for a sparse triangular linear system. The opaque data structure spsmDescr is used to share information among all functions. The function Handle.SpSMUpdateMatrix updates spsmDescr with new matrix values. The routine supports arbitrary sparsity for the input matrix, but only the upper or lower triangular part is taken into account in the computation. Handle.SpSMBufferSize requires a buffer size for the analysis phase which is proportional to number of non-zero entries of the sparse matrix The externalBuffer is stored into spsmDescr and used by Handle.SpSMSolve. For this reason, the device memory buffer must be deallocated only after Handle.SpSMSolve NOTE: all parameters must be consistent across cusparseSpSM API calls and the matrix descriptions and externalBuffer must not be modified between Handle.SpSMAnalysis and Handle.SpSMSolve The sparse matrix formats currently supported are listed below:
The cusparseSpSM() supports the following shapes and properties:
- FillModeLower and FillModeUpper fill modes
- DiagTypeNonUnit and DiagTypeUnit diagonal types
The fill mode and diagonal type can be set by SpMatDescr.MatSetAttribute. cusparseSpSM() supports the following index type for representing the sparse matrix matA:
cusparseSpSM() supports the following data types: Uniform-precision computation:
- A/B/C/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
cusparseSpSM() supports the following algorithms:
- SpsmAlgDefault: Default algorithm
cusparseSpSM() has the following properties:
- The routine requires no extra storage
- Provides deterministic (bit-wise) results for each run for the solving phase Handle.SpSMSolve
- The Handle.SpSMSolve routine supports asynchronous execution
- The routine supports in-place operation. The same device pointer must be provided to the values parameter of the dense matrices matB and matC. All other dense matrix descriptor parameters (e.g., order) can be set independently
- Handle.SpSMBufferSize and Handle.SpSMAnalysis routines accept descriptors of NULL values for matB and matC. These two routines do not accept NULL descriptors
- The routine allows the indices of matA to be unsorted
cusparseSpSM() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Handle.SpSMUpdateMatrix updates the sparse matrix after calling the analysis phase. This functions supports the following update strategies ( updatePart):
- SpsmUpdateGeneral: Updates the sparse matrix values with values of newValues array
- SpsmUpdateDiagonal: Updates the diagonal part of the matrix with diagonal values stored in newValues array. That is, newValues has the new diagonal values only
Please visit cuSPARSE Library Samples - cusparseSpSM CSR and cuSPARSE Library Samples - cusparseSpSM COO for code examples.
Wraps cusparseSpSMCreateDescr, bound as cusparseSpSM_createDescr.
func (SpSMDescr) SMDestroyDescr ¶
SMDestroyDescr solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
op(A)⋅C=αop(B) where
- op(A) is a sparse square matrix of size m×m
- op(B) is a dense matrix of size m×n
- C is a dense matrix of size m×n
- α is a scalar
Also, for matrix A: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose; op(B) = B if opB == OperationNonTranspose, and op(B) = Bᵀ if opB == OperationTranspose. The function Handle.SpSMBufferSize returns the size of the workspace needed by Handle.SpSMAnalysis and Handle.SpSMSolve. The function Handle.SpSMAnalysis performs the analysis phase, while Handle.SpSMSolve executes the solve phase for a sparse triangular linear system. The opaque data structure spsmDescr is used to share information among all functions. The function Handle.SpSMUpdateMatrix updates spsmDescr with new matrix values. The routine supports arbitrary sparsity for the input matrix, but only the upper or lower triangular part is taken into account in the computation. Handle.SpSMBufferSize requires a buffer size for the analysis phase which is proportional to number of non-zero entries of the sparse matrix The externalBuffer is stored into spsmDescr and used by Handle.SpSMSolve. For this reason, the device memory buffer must be deallocated only after Handle.SpSMSolve NOTE: all parameters must be consistent across cusparseSpSM API calls and the matrix descriptions and externalBuffer must not be modified between Handle.SpSMAnalysis and Handle.SpSMSolve The sparse matrix formats currently supported are listed below:
The cusparseSpSM() supports the following shapes and properties:
- FillModeLower and FillModeUpper fill modes
- DiagTypeNonUnit and DiagTypeUnit diagonal types
The fill mode and diagonal type can be set by SpMatDescr.MatSetAttribute. cusparseSpSM() supports the following index type for representing the sparse matrix matA:
cusparseSpSM() supports the following data types: Uniform-precision computation:
- A/B/C/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
cusparseSpSM() supports the following algorithms:
- SpsmAlgDefault: Default algorithm
cusparseSpSM() has the following properties:
- The routine requires no extra storage
- Provides deterministic (bit-wise) results for each run for the solving phase Handle.SpSMSolve
- The Handle.SpSMSolve routine supports asynchronous execution
- The routine supports in-place operation. The same device pointer must be provided to the values parameter of the dense matrices matB and matC. All other dense matrix descriptor parameters (e.g., order) can be set independently
- Handle.SpSMBufferSize and Handle.SpSMAnalysis routines accept descriptors of NULL values for matB and matC. These two routines do not accept NULL descriptors
- The routine allows the indices of matA to be unsorted
cusparseSpSM() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Handle.SpSMUpdateMatrix updates the sparse matrix after calling the analysis phase. This functions supports the following update strategies ( updatePart):
- SpsmUpdateGeneral: Updates the sparse matrix values with values of newValues array
- SpsmUpdateDiagonal: Updates the diagonal part of the matrix with diagonal values stored in newValues array. That is, newValues has the new diagonal values only
Please visit cuSPARSE Library Samples - cusparseSpSM CSR and cuSPARSE Library Samples - cusparseSpSM COO for code examples.
Wraps cusparseSpSMDestroyDescr, bound as cusparseSpSM_destroyDescr.
type SpSMUpdate ¶
type SpSMUpdate int32
SpSMUpdate represents cusparseSpSMUpdate_t.
const ( SpsmUpdateGeneral SpSMUpdate = 0 SpsmUpdateDiagonal SpSMUpdate = 1 )
func (SpSMUpdate) String ¶
func (e SpSMUpdate) String() string
String returns the constant name, or a numeric representation for unknown values.
type SpSVDescr ¶
type SpSVDescr uintptr
SpSVDescr is an opaque handle for cusparseSpSVDescr_t.
func SpSVCreateDescr ¶
SpSVCreateDescr solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
op(A)⋅Y=αX where
- op(A) is a sparse square matrix of size m×m
- X is a dense vector of size m
- Y is a dense vector of size m
- α is a scalar
Also, for matrix A: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose. The function Handle.SpSVBufferSize returns the size of the workspace needed by Handle.SpSVAnalysis and Handle.SpSVSolve. The function Handle.SpSVAnalysis performs the analysis phase, while Handle.SpSVSolve executes the solve phase for a sparse triangular linear system. The opaque data structure spsvDescr is used to share information among all functions. The function Handle.SpSVUpdateMatrix updates spsvDescr with new matrix values. The routine supports arbitrary sparsity for the input matrix, but only the upper or lower triangular part is taken into account in the computation. NOTE: all parameters must be consistent across cusparseSpSV API calls and the matrix descriptions and externalBuffer must not be modified between Handle.SpSVAnalysis and Handle.SpSVSolve. The function Handle.SpSVUpdateMatrix can be used to update the values on the sparse matrix stored inside the opaque data structure spsvDescr The sparse matrix formats currently supported are listed below:
The cusparseSpSV() supports the following shapes and properties:
- FillModeLower and FillModeUpper fill modes
- DiagTypeNonUnit and DiagTypeUnit diagonal types
The fill mode and diagonal type can be set by SpMatDescr.MatSetAttribute. cusparseSpSV() supports the following index type for representing the sparse matrix matA:
cusparseSpSV() supports the following data types: Uniform-precision computation:
- A/X/Y/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
cusparseSpSV() supports the following algorithms:
- SpsvAlgDefault: Default algorithm
cusparseSpSV() has the following properties:
- The routine requires extra storage for the analysis phase which is proportional to number of non-zero entries of the sparse matrix
- Provides deterministic (bit-wise) results for each run for the solving phase Handle.SpSVSolve
- The routine supports in-place operation
- The Handle.SpSVSolve routine supports asynchronous execution
- Handle.SpSVBufferSize and Handle.SpSVAnalysis routines accept NULL for vecX and vecY
- The routine allows the indices of matA to be unsorted
cusparseSpSV() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Handle.SpSVUpdateMatrix updates the sparse matrix after calling the analysis phase. This functions supports the following update strategies ( updatePart):
- SpsvUpdateGeneral: Updates the sparse matrix values with values of newValues array
- SpsvUpdateDiagonal: Updates the diagonal part of the matrix with diagonal values stored in newValues array. That is, newValues has the new diagonal values only
Please visit cuSPARSE Library Samples - cusparseSpSV CSR and cuSPARSE Library Samples - cusparseSpSV COO for code examples.
Wraps cusparseSpSVCreateDescr, bound as cusparseSpSV_createDescr.
func (SpSVDescr) SVDestroyDescr ¶
SVDestroyDescr solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
op(A)⋅Y=αX where
- op(A) is a sparse square matrix of size m×m
- X is a dense vector of size m
- Y is a dense vector of size m
- α is a scalar
Also, for matrix A: op(A) = A if opA == OperationNonTranspose, op(A) = Aᵀ if opA == OperationTranspose, and op(A) = Aᴴ if opA == OperationConjugateTranspose. The function Handle.SpSVBufferSize returns the size of the workspace needed by Handle.SpSVAnalysis and Handle.SpSVSolve. The function Handle.SpSVAnalysis performs the analysis phase, while Handle.SpSVSolve executes the solve phase for a sparse triangular linear system. The opaque data structure spsvDescr is used to share information among all functions. The function Handle.SpSVUpdateMatrix updates spsvDescr with new matrix values. The routine supports arbitrary sparsity for the input matrix, but only the upper or lower triangular part is taken into account in the computation. NOTE: all parameters must be consistent across cusparseSpSV API calls and the matrix descriptions and externalBuffer must not be modified between Handle.SpSVAnalysis and Handle.SpSVSolve. The function Handle.SpSVUpdateMatrix can be used to update the values on the sparse matrix stored inside the opaque data structure spsvDescr The sparse matrix formats currently supported are listed below:
The cusparseSpSV() supports the following shapes and properties:
- FillModeLower and FillModeUpper fill modes
- DiagTypeNonUnit and DiagTypeUnit diagonal types
The fill mode and diagonal type can be set by SpMatDescr.MatSetAttribute. cusparseSpSV() supports the following index type for representing the sparse matrix matA:
cusparseSpSV() supports the following data types: Uniform-precision computation:
- A/X/Y/computeType: CUDA_R_32F, CUDA_R_64F, CUDA_C_32F, CUDA_C_64F
cusparseSpSV() supports the following algorithms:
- SpsvAlgDefault: Default algorithm
cusparseSpSV() has the following properties:
- The routine requires extra storage for the analysis phase which is proportional to number of non-zero entries of the sparse matrix
- Provides deterministic (bit-wise) results for each run for the solving phase Handle.SpSVSolve
- The routine supports in-place operation
- The Handle.SpSVSolve routine supports asynchronous execution
- Handle.SpSVBufferSize and Handle.SpSVAnalysis routines accept NULL for vecX and vecY
- The routine allows the indices of matA to be unsorted
cusparseSpSV() supports the following optimizations:
- CUDA graph capture
- Hardware Memory Compression
Handle.SpSVUpdateMatrix updates the sparse matrix after calling the analysis phase. This functions supports the following update strategies ( updatePart):
- SpsvUpdateGeneral: Updates the sparse matrix values with values of newValues array
- SpsvUpdateDiagonal: Updates the diagonal part of the matrix with diagonal values stored in newValues array. That is, newValues has the new diagonal values only
Please visit cuSPARSE Library Samples - cusparseSpSV CSR and cuSPARSE Library Samples - cusparseSpSV COO for code examples.
Wraps cusparseSpSVDestroyDescr, bound as cusparseSpSV_destroyDescr.
type SpSVUpdate ¶
type SpSVUpdate int32
SpSVUpdate represents cusparseSpSVUpdate_t.
const ( SpsvUpdateGeneral SpSVUpdate = 0 SpsvUpdateDiagonal SpSVUpdate = 1 )
func (SpSVUpdate) String ¶
func (e SpSVUpdate) String() string
String returns the constant name, or a numeric representation for unknown values.
type SpVecDescr ¶
type SpVecDescr uintptr
SpVecDescr is an opaque handle for cusparseSpVecDescr_t.
func CreateSpVec ¶
func CreateSpVec(size int64, nnz int64, indices driver.DevicePtr, values driver.DevicePtr, idxType IndexType, idxBase IndexBase, valueType DataType) (SpVecDescr, error)
CreateSpVec initializes the sparse matrix descriptor spVecDescr.
CreateSpVec has the following constraints:
- indices and values must be aligned to the size of the datatypes specified by idxType and valueType, respectively. See cudaDataType_t for the description of the datatypes.
Parameters:
- spVecDescr: Sparse vector descriptor
- size: Size of the sparse vector
- nnz: Number of non-zero entries of the sparse vector
- indices: Indices of the sparse vector. Array with nnz elements
- values: Values of the sparse vector. Array with nnz elements
- idxType: Enumerator specifying the data type of indices
- idxBase: Enumerator specifying the the index base of indices
- valueType: Enumerator specifying the datatype of values
Wraps cusparseCreateSpVec.
func (SpVecDescr) VecGet ¶
func (s SpVecDescr) VecGet(size *int64, nnz *int64, indices *uintptr, values *uintptr, idxType *IndexType, idxBase *IndexBase, valueType *DataType) error
VecGet returns the fields of the sparse vector descriptor spVecDescr.
- size: Size of the sparse vector
- nnz: Number of non-zero entries of the sparse vector
- indices: Indices of the sparse vector. Array with nnz elements
- values: Values of the sparse vector. Array with nnz elements
- idxType: Enumerator specifying the data type of indices
- idxBase: Enumerator specifying the the index base of indices
- valueType: Enumerator specifying the datatype of values
Wraps cusparseSpVecGet.
func (SpVecDescr) VecGetValues ¶
func (s SpVecDescr) VecGetValues(values *uintptr) error
VecGetValues returns the values field of the sparse vector descriptor spVecDescr.
- values: Values of the sparse vector. Array with nnz elements
Wraps cusparseSpVecGetValues.
func (SpVecDescr) VecSetValues ¶
func (s SpVecDescr) VecSetValues(values driver.DevicePtr) error
VecSetValues sets the values field of the sparse vector descriptor spVecDescr.
DnVecDescr.VecSetValues has the following constraints:
- values must be aligned to the size of the datatype specified in spVecDescr. See cudaDataType_t for the description of the datatypes.
Parameters:
- values: Values of the sparse vector. Array with nnz elements
Wraps cusparseSpVecSetValues.
type SparseToDenseAlg ¶
type SparseToDenseAlg int32
SparseToDenseAlg represents cusparseSparseToDenseAlg_t.
const (
SparsetodenseAlgDefault SparseToDenseAlg = 0
)
func (SparseToDenseAlg) String ¶
func (e SparseToDenseAlg) String() string
String returns the constant name, or a numeric representation for unknown values.
type SymbolError ¶
SymbolError reports that a symbol is not callable.
Err distinguishes the two ways that happens. A nil Err means the loaded library does not export the symbol, which is what an installation older than the symbol looks like. A non-nil Err means the library does export it and the binding itself failed; the library is not at fault.
func (*SymbolError) Error ¶
func (e *SymbolError) Error() string
Error reports the uncallable library symbol and, when the symbol was present but could not be bound, why.
func (*SymbolError) Unwrap ¶
func (e *SymbolError) Unwrap() error
Unwrap returns the reason the symbol could not be bound, or nil when the loaded library does not export it.
type SymmetryType ¶
type SymmetryType int32
SymmetryType represents cusparseSymmetryType_t.
const ( General SymmetryType = 0 Symmetric SymmetryType = 1 Hermitian SymmetryType = 2 )
func (SymmetryType) String ¶
func (e SymmetryType) String() string
String returns the constant name, or a numeric representation for unknown values.
type VersionMismatchError ¶
type VersionMismatchError struct {
Path string // the library that was opened
Want int // major version these bindings were generated for
Got int // major version the library reports
Raw int // the version value the library reported, undecoded
}
VersionMismatchError reports that the shared library that opened is not from the version train cusparse was generated for. dlsym matches on name alone, so a library from a neighbouring train opens and resolves nearly every symbol; asking it its own version is what tells the two apart.
func (*VersionMismatchError) Error ¶
func (e *VersionMismatchError) Error() string
Error reports which library was opened and the two majors that disagree.
A decoder is only a decoder for the version schemes it was measured against, and a library from a train that predates the scheme can report a value it does not decode. Naming a major of 0 in that case would attribute to the library a claim it never made, so the raw value is reported instead.
Source Files
¶
- const_dn_mat_descr.gen.go
- const_dn_vec_descr.gen.go
- const_sp_mat_descr.gen.go
- const_sp_vec_descr.gen.go
- constants.gen.go
- dn_mat_descr.gen.go
- dn_vec_descr.gen.go
- doc.gen.go
- enums.gen.go
- funcs.gen.go
- handle.gen.go
- handles.gen.go
- init.gen.go
- loader_unix.gen.go
- provenance.gen.go
- result.gen.go
- sp_gemm_descr.gen.go
- sp_mat_descr.gen.go
- sp_mv_op_descr.gen.go
- sp_mv_op_plan.gen.go
- sp_sm_descr.gen.go
- sp_sv_descr.gen.go
- sp_vec_descr.gen.go
- spmvop.gen.go
- structs.gen.go
- types.gen.go