Open oxinabox opened 6 years ago
I'm not sure about what to call this function, but could we possibly do a pigeon-hole sort of optimization within the broadcast!
definition itself when we detect this case?
I guess I found a similar bottleneck today. But I think the improved computation can potentially be done in much fewer lines of code. https://discourse.julialang.org/t/speeding-up-elementwise-vector-sparsematrixcsc-multiplication-broadcasting/79437
I can't workout what this operation is called.
mul!(A, Diagonal(b), A)
?
I would like to know if this would be a good PR to the SparseArrays stdlib I can't workout what this operation is called. It does
A.*b
inplace forA::SparseMatrixCSC
and ab::AbstractVector
.It seems loosely relevant to JuliaLang/julia#26561 (in that i was thinking about at that problem when I wrote it)
Inplace operations can avoid allocating memory so is faster.
Benchmarks
@btime A.*x;
7.920 μs (17 allocations: 22.58 KiB)@btime sparse_column_vecmul!(A, x)
1.044 μs (4 allocations: 2.47 KiB)Not a perfectly fair comparison as
A
was being mutated but i doubt that changed the timing.over 7x speedup is not to be sneered at given how big sparse matrixes become.