JuliaGPU/CUDA.jl

Option for deterministic sparse matrix vector multiplication

Open

#1607 aperta il 30 set 2022

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)Julia (274 fork)batch import
cuda librariesenhancementgood first issue

Metriche repository

Star
 (1408 star)
Metriche merge PR
 (Merge medio 5g 5h) (16 PR mergiate in 30 g)

Descrizione

I would like to request deterministic sparse matrix vector multiplications. Essentially, the following code should always return the same result:

using CUDA
using Random

Random.seed!(546784)

A = cu(sprand(Float64, 1000, 1000, 0.6))
x = cu(rand(Float64, 1000))

y1 = A * x
y2 = A * x

maximum(abs.(y2 - y1))

A similar issue is #938.

What I found out so far

We need to use CUSPARSE_SPMV_COO_ALG2 or CUSPARSE_SPMV_CSR_ALG2. This will probably be related to changing the argument algo of mv!(): https://github.com/JuliaGPU/CUDA.jl/blob/33a71872b0aebe13f8210229e1265b779f90b78e/lib/cusparse/generic.jl#L112-L113

Unfortunately, the algorithm information seems to get lost in the wrapper function: https://github.com/JuliaGPU/CUDA.jl/blob/99f962abb8296e36f58963c80a4b52cc116e6560/lib/cusparse/interfaces.jl#L6-L9

The wrapper seems to be used for implementing the operators: https://github.com/JuliaGPU/CUDA.jl/blob/99f962abb8296e36f58963c80a4b52cc116e6560/lib/cusparse/interfaces.jl#L38-L60

The remaining question for the maintainers is now: Where do we pass in the algorithm?

Guida contributor