Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jagot/threadedsparsearrays.jl
https://github.com/jagot/threadedsparsearrays.jl
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jagot/threadedsparsearrays.jl
- Owner: jagot
- License: mit
- Created: 2020-03-23T20:31:54.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-27T17:16:45.000Z (about 1 year ago)
- Last Synced: 2024-08-09T22:41:58.512Z (5 months ago)
- Language: Julia
- Size: 29.3 KB
- Stars: 17
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ThreadedSparseArrays.jl
[![Build Status](https://github.com/jagot/ThreadedSparseArrays.jl/workflows/CI/badge.svg)](https://github.com/jagot/ThreadedSparseArrays.jl/actions)
[![Codecov](https://codecov.io/gh/jagot/ThreadedSparseArrays.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/jagot/ThreadedSparseArrays.jl)Simple package providing a wrapper type enabling threaded sparse
matrix–dense matrix multiplication. Based on [this
PR](https://github.com/JuliaLang/julia/pull/29525).## Installation
Install with:
```
] add ThreadedSparseArrays
```Note that you *must* enable threading in Julia for
ThreadedSparseArrays to work. You can do so by setting the
[JULIA_NUM_THREADS](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_NUM_THREADS-1)
environment variable. To test that it is set properly, run
```julia
Threads.nthreads()
```
and make sure it returns the number of threads you wanted.## Example usage
To use ThreadedSparseArrays, all you need to do is to wrap your sparse
matrix using the ThreadedSparseMatrixCSC type, like this:
```julia
using SparseArrays
using ThreadedSparseArraysA = sprand(10000, 100, 0.05); # sparse
X1 = randn(100, 100); # dense
X2 = randn(10000, 100); # denseAt = ThreadedSparseMatrixCSC(A); # threaded version
# threaded sparse matrix–dense matrix multiplication
B1 = At*X1;
B2 = At'X2;
```## Notes
* If the right hand side `X` is a `Vector`, you need to use `At'X` to
get threading. `At*X` will not work.
* You might only get speedups for large matrices. Use `@btime` from
the [BenchmarkTools.jl](https://github.com/JuliaCI/BenchmarkTools.jl)
package to check if your use case is improved.