I can't create a single-precision sparse matrix on the GPU. Does version 2017a allow that yet?

 Réponse acceptée

Joss Knight
Joss Knight le 15 Mar 2017

1 vote

You can't create a single-precision sparse matrix on the CPU either, so the answer is no, this is not supported. Do you have an application in mind?

7 commentaires

Tung-Duong
Tung-Duong le 15 Mar 2017
Just my luck. I have a NVidia 980 and GPU performance for double precision just sucks (based on gpubench). Even my older nVidia 570 is doing better.
Joss Knight
Joss Knight le 16 Mar 2017
The reason that MATLAB never added support for sparse single is because there aren't very many interesting sparse problems for which single precision isn't deleteriously inaccurate. So most likely you wouldn't want to be using single anyway.
Tung-Duong
Tung-Duong le 16 Mar 2017
Surely, solving a sparse linear system with an iterative method like the conjugate gradient, or plain gradient, shouldn't be a problem, right?
Joss Knight
Joss Knight le 21 Mar 2017
I'm not an expert, but I understand that system solves in single precision are unreliable for typical sparse systems because they tend to be internally poorly conditioned.
I've added your request to an existing one for the implementation of non-double sparse arrays.
Thomas Richner
Thomas Richner le 11 Déc 2017
Modifié(e) : Thomas Richner le 11 Déc 2017
I could use a sparse single matrix both for CPU and GPU. Applications that don't involve matrix division but rather run the forwards can safely use single sparse matrices. In my case I'm modeling biological neural networks. This involves integrating thousands of ODEs through time. There are up to n^2 connections among n neurons, but only a low percentage of neurons are connected, so it is sparse. The state of each synapse can be stored as a single. Integration error for very long simulations is not a problem, because the overall behavior of the system is analyzed. For example, when studying Lorenz's strange attractor, adding more bits of precision isn't all that important--understanding the nature of the nonlinear dynamics is more important. So, yes, there are good uses of sparse single matrices in forward models, but perhaps not so in inverse models.
Tung-Duong
Tung-Duong le 12 Déc 2017
Thanks for the reply. That's also the type of application I have in mind, where collective behavior matters more than numerical precision. Which version do you use? With 2017a, I just tried single(A) where A is sparse matrix and it says "Attempt to convert to unimplemented sparse type".
Thomas Richner
Thomas Richner le 3 Juil 2019
2 years later and I still miss seriously miss single and half precision sparse every day. Sad. It isn't only about memory savings--the single precision compute performance of a nvidia 1080 ti is 10x that of double precision.
I'm hoping that with deep nerual nets gaining traction in Matlab, they might find reason to implement single and half precision sparse arrays. Pytorch has these.
Until then I'm left either converting back and forth between double and single (which is slow) or running entirely with double with smaller simulations.

Connectez-vous pour commenter.

Plus de réponses (1)

Mike Croucher
Mike Croucher le 13 Août 2025

1 vote

Single Sparse is now supported, starting with R2025a on both the CPU and GPU. A detailed write up, including performance benchmarks, can be found at New in MATLAB: Single precision sparse matrices » The MATLAB Blog - MATLAB & Simulink

Catégories

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by