Simple package providing a wrapper type enabling threaded sparse matrix–dense matrix multiplication. Based on this PR.
] add ThreadedSparseArrays
Note that you must enable threading in Julia for ThreadedSparseArrays to work. You can do so by setting the JULIA_NUM_THREADS environment variable. To test that it is set properly, run
and make sure it returns the number of threads you wanted.
To use ThreadedSparseArrays, all you need to do is to wrap your sparse matrix using the ThreadedSparseMatrixCSC type, like this:
using SparseArrays using ThreadedSparseArrays A = sprand(10000, 100, 0.05); # sparse X1 = randn(100, 100); # dense X2 = randn(10000, 100); # dense At = ThreadedSparseMatrixCSC(A); # threaded version # threaded sparse matrix–dense matrix multiplication B1 = At*X1; B2 = At'X2;
- If the right hand side
Vector, you need to use
At'Xto get threading.
At*Xwill not work.
- You might only get speedups for large matrices. Use
@btimefrom the BenchmarkTools.jl package to check if your use case is improved.