Skip to content

Commit 1ee90f7

Browse files
committed
Test appropriate backend in examples
1 parent ccb0211 commit 1ee90f7

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

examples/memcopy.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ function mycopy!(A, B)
1616
return
1717
end
1818

19-
A = KernelAbstractions.zeros(backend, Float64, 128, 128)
20-
B = KernelAbstractions.ones(backend, Float64, 128, 128)
19+
A = KernelAbstractions.zeros(backend, f_type, 128, 128)
20+
B = KernelAbstractions.ones(backend, f_type, 128, 128)
2121
mycopy!(A, B)
2222
KernelAbstractions.synchronize(backend)
2323
@test A == B

examples/memcopy_static.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ function mycopy_static!(A, B)
1616
return
1717
end
1818

19-
A = KernelAbstractions.zeros(backend, Float64, 128, 128)
20-
B = KernelAbstractions.ones(backend, Float64, 128, 128)
19+
A = KernelAbstractions.zeros(backend, f_type, 128, 128)
20+
B = KernelAbstractions.ones(backend, f_type, 128, 128)
2121
mycopy_static!(A, B)
2222
KernelAbstractions.synchronize(backend)
2323
@test A == B

examples/performant_matmul.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Test
44
using Random
55
include(joinpath(dirname(pathof(KernelAbstractions)), "../examples/utils.jl")) # Load backend
66

7-
const TILE_DIM = 32
7+
const TILE_DIM = 16
88

99
@kernel function coalesced_matmul_kernel!(
1010
output, @Const(input1), @Const(input2), N, R, M,

examples/utils.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# EXCLUDE FROM TESTING
2+
if !(@isdefined backend)
23
if Base.find_package("CUDA") !== nothing
34
using CUDA
45
using CUDA.CUDAKernels
@@ -7,3 +8,8 @@ if Base.find_package("CUDA") !== nothing
78
else
89
const backend = CPU()
910
end
11+
end
12+
13+
@show backend, backend_str
14+
15+
const f_type = KernelAbstractions.supports_float64(backend) ? Float64 : Float32

test/examples.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function find_sources(path::String, sources = String[])
99
return sources
1010
end
1111

12-
function examples_testsuite(backend_str)
12+
function examples_testsuite(backend, backend_str)
1313
@testset "examples" begin
1414
examples_dir = joinpath(@__DIR__, "..", "examples")
1515
examples = find_sources(examples_dir)
@@ -21,6 +21,7 @@ function examples_testsuite(backend_str)
2121
@testset "$(basename(example))" for example in examples
2222
@eval module $(gensym())
2323
backend_str = $backend_str
24+
const backend = ($backend)()
2425
include($example)
2526
end
2627
@test true

test/testsuite.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function testsuite(backend, backend_str, backend_mod, AT, DAT; skip_tests = Set{
8989
end
9090

9191
@conditional_testset "Examples" skip_tests begin
92-
examples_testsuite(backend_str)
92+
examples_testsuite(backend, backend_str)
9393
end
9494

9595
return

0 commit comments

Comments
 (0)