What is the best way of adapting Symmetric to the GPU? Can it be done? Should it be done?
I currently have the following function Aadj
which I would like to create a GPU version of:
using CUDA
using CUDA.CUSPARSE
using LinearAlgebra
using SparseArrays
n = 5
m = 6
Es = [1, 1, 2, 2, 3, 4]
Ed = [2, 3, 3, 5, 4, 5]
M = sparse(Es, Ed, ones(Float64, m), n, n)
p = 4 * ones(m)
Aadj = p::AbstractVector -> (M.nzval .= p ./ 2; Symmetric(M))
R = Aadj(p)
The trivial attempt below fails because of getindex (The Symmetric view tries to iterate over M’s elements right?):
M_d = CuSparseMatrixCSC(M)
p_d = CuArray(p)
Aadj_GPU = p_d::CuArray -> (M_d.nzVal .= p_d ./ 2; Symmetric(M_d))
R = Aadj_GPU(p_d)