|
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")) |
3 | 6 |
|
4 | 7 | Testsuite.testsuite(()->CUDABackend(false, false), "CUDA", CUDA, CuArray, CuDeviceArray) |
5 | 8 | for (PreferBlocks, AlwaysInline) in Iterators.product((true, false), (true, false)) |
6 | 9 | Testsuite.unittest_testsuite(()->CUDABackend(PreferBlocks, AlwaysInline), "CUDA", CUDA, CuDeviceArray) |
7 | 10 | 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