Skip to content

Commit 81b8c3d

Browse files
add some tests for sparsematrixcsc
1 parent b9bda11 commit 81b8c3d

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

test/base/kernelabstractions.jl

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1-
import KernelAbstractions
2-
include(joinpath(dirname(pathof(KernelAbstractions)), "..", "test", "testsuite.jl"))
1+
import KernelAbstractions as KA
2+
using SparseArrays
3+
using Adapt
4+
5+
include(joinpath(dirname(pathof(KA)), "..", "test", "testsuite.jl"))
36

47
Testsuite.testsuite(()->CUDABackend(false, false), "CUDA", CUDA, CuArray, CuDeviceArray)
58
for (PreferBlocks, AlwaysInline) in Iterators.product((true, false), (true, false))
69
Testsuite.unittest_testsuite(()->CUDABackend(PreferBlocks, AlwaysInline), "CUDA", CUDA, CuDeviceArray)
710
end
11+
12+
@testset "KA.functional" begin
13+
@test KA.functional(CUDABackend()) == CUDA.functional()
14+
end
15+
16+
@testset "CUDA Backend Adapt Tests" begin
17+
# CPU → GPU
18+
A = sprand(Float32, 10, 10, 0.5) #CSC
19+
A_d = adapt(CUDABackend(), A)
20+
@test A_d isa CUSPARSE.CuSparseMatrixCSC
21+
@test adapt(CUDABackend(), A_d) |> typeof == typeof(A_d)
22+
23+
# GPU → CPU
24+
B_d = A |> cu # CuCSC
25+
B = adapt(KA.CPU(), A_d)
26+
@test B isa SparseMatrixCSC
27+
@test adapt(KA.CPU(), B) |> typeof == typeof(B)
28+
end

0 commit comments

Comments
 (0)