Search code examples
sparse-matrixgpu

Sparse Matrix Multiplication on GPU or CPU?


What do you think? What would be faster and how much faster: Doing sparse matrix (CSR) multiplication (with a vector) on the GPU or the CPU (multithreaded)?


Solution

  • It depends upon the size of the matrix and number of iterations that needs to be performed. This is because you need to copy the matrix data from CPU memory to GPU memory and copy back the results from the GPU to CPU. If you are gonna perform only one iteration on the matrix, its always better to do it on the CPU rather than doing it on a GPU. Moreover, GPU suffers from startup time. So, if you have more iterations to be performed, then go for GPU, else my option will be CPU. Likewise size of the matrix also affects the performance due to the data copying.