Skip to content

Commit df3b823

Browse files
Added usage instructions
1 parent 7f4b8b3 commit df3b823

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ThreadedSparseArrays
1+
# ThreadedSparseArrays.jl
22

33
[![Build Status](https://travis-ci.com/jagot/ThreadedSparseArrays.jl.svg?branch=master)](https://travis-ci.com/jagot/ThreadedSparseArrays.jl)
44
[![Build Status](https://ci.appveyor.com/api/projects/status/github/jagot/ThreadedSparseArrays.jl?svg=true)](https://ci.appveyor.com/project/jagot/ThreadedSparseArrays-jl)
@@ -7,3 +7,45 @@
77
Simple package providing a wrapper type enabling threaded sparse
88
matrix–dense matrix multiplication. Based on [this
99
PR](https://github.com/JuliaLang/julia/pull/29525).
10+
11+
## Installation
12+
ThreadedSparseArrays.jl is not yet a registered package, but you can
13+
install it with:
14+
```
15+
] add [email protected]:jagot/ThreadedSparseArrays.jl.git
16+
```
17+
18+
Note that you *must* enable threading in Julia for
19+
ThreadedSparseArrays to work. You can do so by setting the
20+
[JULIA_NUM_THREADS](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_NUM_THREADS-1)
21+
environment variable. To test that it is set properly, run
22+
```julia
23+
Threads.nthreads()
24+
```
25+
and make sure it returns the number of threads you wanted.
26+
27+
28+
## Example usage
29+
To use ThreadedSparseArrays, all you need to do is to wrap your sparse
30+
matrix using the ThreadedSparseMatrixCSC type, like this:
31+
```julia
32+
using SparseArrays
33+
using ThreadedSparseArrays
34+
35+
A = sprand(10000, 100, 0.05); # sparse
36+
X1 = randn(100, 100); # dense
37+
X2 = randn(10000, 100); # dense
38+
39+
At = ThreadedSparseMatrixCSC(A); # threaded version
40+
41+
# threaded sparse matrix–dense matrix multiplication
42+
B1 = At*X1;
43+
B2 = At'X2;
44+
```
45+
46+
## Notes
47+
* If the right hand side `X` is a `Vector`, you need to use `At'X` to
48+
get threading. `A*X` will not work.
49+
* You might only get speedups for large matrices. Use `@btime` from
50+
the [BenchmarkTools.jl](https://github.com/JuliaCI/BenchmarkTools.jl)
51+
package to check if your use case is improved.

0 commit comments

Comments
 (0)