CUDASparseMatrix[sparse,type]
yields a sparse matrix of given type which resides on a CUDA enabled GPU.
CUDASparseMatrix
CUDASparseMatrix[sparse,type]
yields a sparse matrix of given type which resides on a CUDA enabled GPU.
Details and Options
- The CUDALink application must be loaded using Needs["CUDALink`"].
- The resources used by a CUDASparseMatrix are automatically reclaimed from the GPU when they are no longer used.
- The data in a CUDASparseMatrix can be retrieved by Normal.
- A number of functions accept and return CUDASparseMatrix objects allowing operations to work with data that stays on the GPU.
- Possible types for CUDASparseMatrix are:
-
"Real32" "ComplexReal32" "Real64" "ComplexReal64"
Examples
open all close allBasic Examples (1)
First, load the CUDALink application:
Needs["CUDALink`"]Create a sparse vector of data that lives on the GPU:
mat = CUDASparseMatrix[ SparseArray[Table[{i, i} -> i, {i, 4}]], "Real32"]Retrieve the data from a CUDASparseMatrix:
Normal[mat]Compute a dot product on the GPU (the result also resides on the GPU):
CUDADot[mat, mat]Scope (1)
Possible Issues (1)
Normal of a CUDASparseMatrix is a SparseArray:
cuspmat = CUDASparseMatrix[SparseArray[Table[{i, i} -> 1., {i, 4}]]];
Normal[cuspmat]To get the underlying data, Normal is applied twice:
Normal[Normal[cuspmat]]Tech Notes
Related Guides
-
▪
- CUDALink
Text
Wolfram Research (2022), CUDASparseMatrix, Wolfram Language function, https://reference.wolfram.com/language/CUDALink/ref/CUDASparseMatrix.html.
CMS
Wolfram Language. 2022. "CUDASparseMatrix." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/CUDALink/ref/CUDASparseMatrix.html.
APA
Wolfram Language. (2022). CUDASparseMatrix. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/CUDALink/ref/CUDASparseMatrix.html
BibTeX
@misc{reference.wolfram_2026_cudasparsematrix, author="Wolfram Research", title="{CUDASparseMatrix}", year="2022", howpublished="\url{https://reference.wolfram.com/language/CUDALink/ref/CUDASparseMatrix.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_cudasparsematrix, organization={Wolfram Research}, title={CUDASparseMatrix}, year={2022}, url={https://reference.wolfram.com/language/CUDALink/ref/CUDASparseMatrix.html}, note=[Accessed: 15-June-2026]}