Skip to content

Commit a0919f2

Browse files
committed
Even more sparse tests
1 parent b26030e commit a0919f2

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

test/libraries/cusparse.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ blockdim = 5
4444
@test size(d_x) == (m, 1)
4545
x = sprand(m,n,0.2)
4646
d_x = CuSparseMatrixCSC(x)
47+
d_tx = CuSparseMatrixCSC(transpose(x))
48+
d_ax = CuSparseMatrixCSC(adjoint(x))
49+
@test size(d_tx) == (n,m)
50+
@test size(d_ax) == (n,m)
4751
@test CuSparseMatrixCSC(d_x) === d_x
4852
@test length(d_x) == m*n
4953
@test size(d_x) == (m,n)
@@ -55,6 +59,8 @@ blockdim = 5
5559
@test sprint(show, MIME"text/plain"(), d_x) == replace(sprint(show, MIME"text/plain"(), x), "SparseMatrixCSC{Float64, Int64}"=>"CuSparseMatrixCSC{Float64, Int32}")
5660
@test Array(d_x[:]) == x[:]
5761
@test d_x[:, :] == x[:, :]
62+
@test d_tx[:, :] == transpose(x)[:, :]
63+
@test d_ax[:, :] == adjoint(x)[:, :]
5864
@test d_x[(1, 1)] == x[1, 1]
5965
@test d_x[firstindex(d_x)] == x[firstindex(x)]
6066
@test d_x[div(end, 2)] == x[div(end, 2)]
@@ -91,6 +97,8 @@ blockdim = 5
9197
@test_throws ArgumentError copyto!(d_y,d_x)
9298
x = sprand(m,n,0.2)
9399
d_x = CuSparseMatrixCOO(x)
100+
d_tx = CuSparseMatrixCOO(transpose(x))
101+
d_ax = CuSparseMatrixCOO(adjoint(x))
94102
@test CuSparseMatrixCOO(d_x) === d_x
95103
@test length(d_x) == m*n
96104
@test size(d_x) == (m,n)
@@ -107,6 +115,8 @@ blockdim = 5
107115
@test d_x[firstindex(d_x)] == x[firstindex(x)]
108116
@test d_x[div(end, 2)] == x[div(end, 2)]
109117
@test d_x[end] == x[end]
118+
@test d_tx[:, 1] == transpose(x)[:, 1]
119+
@test d_ax[1, :] == adjoint(x)[1, :]
110120
@test d_x[firstindex(d_x), firstindex(d_x)] == x[firstindex(x), firstindex(x)]
111121
@test d_x[div(end, 2), div(end, 2)] == x[div(end, 2), div(end, 2)]
112122
@test d_x[end, end] == x[end, end]

test/libraries/cusparse/reduce.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
using CUDA.CUSPARSE, SparseArrays
22

3-
# XXX: these tests cause GC corruption (see JuliaGPU/CUDA.jl#2027)
4-
if false
5-
63
m,n = 5,6
74
p = 0.5
85

@@ -25,7 +22,10 @@ for elty in [Int32, Int64, Float32, Float64]
2522
y = sum(x, dims=2)
2623
dy = sum(dx, dims=2)
2724
@test y Array(dy)
25+
if elty in (Float32, Float64)
26+
dy = mapreduce(abs, +, dx; init=zero(elty))
27+
y = mapreduce(abs, +, x; init=zero(elty))
28+
@test y dy
29+
end
2830
end
2931
end
30-
31-
end

0 commit comments

Comments
 (0)