Skip to content

Commit 7de4c45

Browse files
authored
Merge pull request #1412 from JuliaGPU/tb/sparse_coo
Fix sparse COO to CSR conversion.
2 parents fb0a550 + bbc30fb commit 7de4c45

File tree

4 files changed

+39
-41
lines changed

4 files changed

+39
-41
lines changed

.buildkite/pipeline.yml

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,6 @@ steps:
2020
if: build.message !~ /\[skip tests\]/
2121
timeout_in_minutes: 120
2222

23-
- label: "Julia 1.6 (debug)"
24-
plugins:
25-
- JuliaCI/julia#v1:
26-
version: 1.6
27-
- JuliaCI/julia-test#v1:
28-
julia_args: "-g2"
29-
test_args: "--sanitize --quickfail --jobs=1"
30-
- JuliaCI/julia-coverage#v1:
31-
codecov: true
32-
dirs:
33-
- src
34-
- lib
35-
- examples
36-
agents:
37-
queue: "juliagpu"
38-
cuda: "11.0"
39-
cap: "sm_80"
40-
env:
41-
JULIA_CUDA_VERSION: '11.6'
42-
JULIA_CUDA_USE_COMPAT: 'false' # NVIDIA bug #3418723: injection tools prevent probing libcuda
43-
JULIA_CUDA_USE_BINARYBUILDER: 'true'
44-
if: build.message !~ /\[skip tests\]/ &&
45-
!build.pull_request.draft
46-
timeout_in_minutes: 180
47-
4823
- label: "Julia 1.7"
4924
plugins:
5025
- JuliaCI/julia#v1:
@@ -301,6 +276,31 @@ steps:
301276
if: build.message !~ /\[skip tests\]/ && !build.pull_request.draft
302277
timeout_in_minutes: 60
303278

279+
- label: "Compute Sanitizer"
280+
plugins:
281+
- JuliaCI/julia#v1:
282+
version: 1.6
283+
- JuliaCI/julia-test#v1:
284+
julia_args: "-g2"
285+
test_args: "--sanitize --quickfail --jobs=1"
286+
- JuliaCI/julia-coverage#v1:
287+
codecov: true
288+
dirs:
289+
- src
290+
- lib
291+
- examples
292+
agents:
293+
queue: "juliagpu"
294+
cuda: "11.0"
295+
cap: "sm_80"
296+
env:
297+
JULIA_CUDA_VERSION: '11.6'
298+
JULIA_CUDA_USE_COMPAT: 'false' # NVIDIA bug #3418723: injection tools prevent probing libcuda
299+
JULIA_CUDA_USE_BINARYBUILDER: 'true'
300+
if: build.message !~ /\[skip benchmarks\]/ &&
301+
build.branch =~ /^master$$/
302+
timeout_in_minutes: 240
303+
304304

305305
# other tasks
306306

@@ -337,8 +337,7 @@ steps:
337337
queue: "benchmark"
338338
cuda: "*"
339339
if: build.message !~ /\[skip benchmarks\]/ &&
340-
build.branch =~ /^master$$/ &&
341-
!build.pull_request.draft
340+
build.branch =~ /^master$$/
342341
timeout_in_minutes: 30
343342

344343
- label: "Benchmarks on 1.7"
@@ -368,8 +367,7 @@ steps:
368367
queue: "benchmark"
369368
cuda: "*"
370369
if: build.message !~ /\[skip benchmarks\]/ &&
371-
build.branch =~ /^master$$/ &&
372-
!build.pull_request.draft
370+
build.branch =~ /^master$$/
373371
timeout_in_minutes: 30
374372

375373
- wait

lib/cusparse/conversions.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -380,23 +380,23 @@ end
380380

381381
## CSR to COO and vice-versa
382382

383+
# TODO: we can do similar for CSC conversions, but that requires the columns to be sorted
384+
383385
function CuSparseMatrixCSR(coo::CuSparseMatrixCOO{Tv}, ind::SparseChar='O') where {Tv}
384386
m,n = size(coo)
385-
nnz = coo.nnz
386-
csrRowPtr = CUDA.zeros(Cint, nnz)
387-
cusparseXcoo2csr(handle(), coo.rowInd, nnz, m, csrRowPtr, ind)
388-
CuSparseMatrixCSR{Tv}(csrRowPtr, coo.colInd, coo.nzVal, size(coo))
387+
csrRowPtr = CuVector{Cint}(undef, m+1)
388+
cusparseXcoo2csr(handle(), coo.rowInd, nnz(coo), m, csrRowPtr, ind)
389+
CuSparseMatrixCSR{Tv}(csrRowPtr, coo.colInd, nonzeros(coo), size(coo))
389390
end
390391

391392
function CuSparseMatrixCOO(csr::CuSparseMatrixCSR{Tv}, ind::SparseChar='O') where {Tv}
392393
m,n = size(csr)
393-
nnz = csr.nnz
394-
cooRowInd = CUDA.zeros(Cint, nnz)
395-
cusparseXcsr2coo(handle(), csr.rowPtr, nnz, m, cooRowInd, ind)
396-
CuSparseMatrixCOO{Tv}(cooRowInd, csr.colVal, csr.nzVal, size(csr), nnz)
394+
cooRowInd = CuVector{Cint}(undef, nnz(csr))
395+
cusparseXcsr2coo(handle(), csr.rowPtr, nnz(csr), m, cooRowInd, ind)
396+
CuSparseMatrixCOO{Tv}(cooRowInd, csr.colVal, nonzeros(csr), size(csr), nnz(csr))
397397
end
398398

399-
### CSC/BST to COO and viceversa
399+
### CSC/BSR to COO and viceversa
400400

401401
CuSparseMatrixCSC(coo::CuSparseMatrixCOO) = CuSparseMatrixCSC(CuSparseMatrixCSR(coo)) # no direct conversion
402402
CuSparseMatrixCOO(csc::CuSparseMatrixCSC) = CuSparseMatrixCOO(CuSparseMatrixCSR(csc)) # no direct conversion

src/array.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ is_unified(a::CuArray) = isa(a.storage.buffer, Mem.UnifiedBuffer)
128128

129129
# type and dimensionality specified, accepting dims as series of Ints
130130
CuArray{T,N,B}(::UndefInitializer, dims::Integer...) where {T,N,B} =
131-
CuArray{T,N,B}(undef, dims)
131+
CuArray{T,N,B}(undef, convert(Tuple{Vararg{Int}}, dims))
132132
CuArray{T,N}(::UndefInitializer, dims::Integer...) where {T,N} =
133-
CuArray{T,N}(undef, dims)
133+
CuArray{T,N}(undef, convert(Tuple{Vararg{Int}}, dims))
134134

135135
# type but not dimensionality specified
136136
CuArray{T}(::UndefInitializer, dims::Dims{N}) where {T,N} =

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ if !has_cutensor() || first(picks).cap < v"6.0"
179179
end
180180
if do_sanitize
181181
# XXX: some library tests fail under compute-sanitizer
182-
append!(skip_tests, ["cutensor", "cusparse"])
182+
append!(skip_tests, ["cutensor"])
183183
# XXX: others take absurdly long
184184
push!(skip_tests, "cusolver")
185185
# XXX: these hang for some reason

0 commit comments

Comments
 (0)