Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CUSPARSE: Adding a value to the diagonal #1372

Closed
ChrisRackauckas opened this issue Feb 14, 2022 · 1 comment
Closed

CUSPARSE: Adding a value to the diagonal #1372

ChrisRackauckas opened this issue Feb 14, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@ChrisRackauckas
Copy link
Member

I cannot figure out how to add a value to the diagonal, and it's showing some missing dispatches.

using CUDA
CUDA.allowscalar(false)
W = cu(sprand(100,100,0.1))
J = cu(sprand(100,100,0.1))
idxs = diagind(W)
λ = 1.0
@. @view(W[idxs]) = @view(W[idxs]) + λ # Scalar indexing

Base.:+(A::CUSPARSE.CuSparseMatrix,I::UniformScaling) = A + Diagonal(CuArray(ones(size(A,1))))
Base.:-(A::CUSPARSE.CuSparseMatrix,I::UniformScaling) = A - Diagonal(CuArray(ones(size(A,1))))

@show typeof(W + λ*I) # CuArray not sparse :(
W .= W + λ*I # Scalar index

This is the last piece to finish SciML/OrdinaryDiffEq.jl#1566 I think.

@ChrisRackauckas ChrisRackauckas added the enhancement New feature or request label Feb 14, 2022
ChrisRackauckas added a commit to SciML/OrdinaryDiffEq.jl that referenced this issue Feb 14, 2022
CUSPARSE is still missing some dispatches for full generic handling, but specializing this would still make sense anyways.

Currently still blocked on #1566 by JuliaGPU/CUDA.jl#1372
@maleadt
Copy link
Member

maleadt commented Feb 23, 2022

#1390

@maleadt maleadt closed this as completed Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants