Skip to content

Commit 4d026f7

Browse files
authored
Merge pull request #520 from JuliaGPU/tb/test
Remove test reliance on high-level features
2 parents ae61e45 + ef742e5 commit 4d026f7

File tree

5 files changed

+31
-29
lines changed

5 files changed

+31
-29
lines changed

test/copyto.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ using KernelAbstractions, Test
22
import KernelAbstractions: allocate, copyto!
33
using Random
44

5-
function copyto_testsuite(Backend)
5+
function copyto_testsuite(Backend, ArrayT)
66
M = 1024
77
backend = Backend()
88
ET = KernelAbstractions.supports_float64(backend) ? Float64 : Float32
99

10-
A = rand!(allocate(backend, ET, M))
11-
B = rand!(allocate(backend, ET, M))
10+
A = ArrayT(rand(ET, M))
11+
B = ArrayT(rand(ET, M))
1212

1313
a = Array{ET}(undef, M)
1414
copyto!(backend, a, B)

test/localmem.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ function localmem_testsuite(backend, ArrayT)
4040
A = ArrayT{Int}(undef, 64)
4141
kernel!(A, ndrange = size(A))
4242
synchronize(backend())
43-
@test all(A[1:16] .== 16:-1:1)
44-
@test all(A[17:32] .== 16:-1:1)
45-
@test all(A[33:48] .== 16:-1:1)
46-
@test all(A[49:64] .== 16:-1:1)
43+
B = Array(A)
44+
@test all(B[1:16] .== 16:-1:1)
45+
@test all(B[17:32] .== 16:-1:1)
46+
@test all(B[33:48] .== 16:-1:1)
47+
@test all(B[49:64] .== 16:-1:1)
4748
end
4849
end
4950
end

test/private.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,29 @@ function private_testsuite(backend, ArrayT)
6565
A = ArrayT{Int}(undef, 64)
6666
private(backend(), 16)(A, ndrange = size(A))
6767
synchronize(backend())
68-
@test all(A[1:16] .== 16:-1:1)
69-
@test all(A[17:32] .== 16:-1:1)
70-
@test all(A[33:48] .== 16:-1:1)
71-
@test all(A[49:64] .== 16:-1:1)
68+
B = Array(A)
69+
@test all(B[1:16] .== 16:-1:1)
70+
@test all(B[17:32] .== 16:-1:1)
71+
@test all(B[33:48] .== 16:-1:1)
72+
@test all(B[49:64] .== 16:-1:1)
7273

7374
A = ArrayT{Int}(undef, 64, 64)
7475
A .= 1
7576
forloop(backend())(A, Val(size(A, 2)), ndrange = size(A, 1), workgroupsize = size(A, 1))
7677
synchronize(backend())
77-
@test all(A[:, 1] .== 64)
78-
@test all(A[:, 2:end] .== 1)
78+
@test all(Array(A)[:, 1] .== 64)
79+
@test all(Array(A)[:, 2:end] .== 1)
7980

8081
B = ArrayT{Bool}(undef, size(A)...)
8182
typetest(backend(), 16)(A, B, ndrange = size(A))
8283
synchronize(backend())
83-
@test all(B)
84+
@test all(Array(B))
8485

85-
A = ArrayT{Float32}(ones(64, 3));
86+
A = ArrayT(ones(Float32, 64, 3))
8687
out = ArrayT{Float32}(undef, 64)
8788
reduce_private(backend(), 8)(out, A, ndrange = size(out))
8889
synchronize(backend())
89-
@test all(out .== 3.0f0)
90+
@test all(Array(out) .== 3.0f0)
9091
end
9192

9293
if backend == CPU

test/test.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,45 +105,45 @@ function unittest_testsuite(Backend, backend_str, backend_mod, BackendArrayT; sk
105105
A = allocate(backend, Int, 16, 16)
106106
index_linear_global(backend, 8)(A, ndrange = length(A))
107107
synchronize(backend)
108-
@test all(A .== LinearIndices(A))
108+
@test all(Array(A) .== LinearIndices(A))
109109

110110
A = allocate(backend, Int, 8)
111111
index_linear_local(backend, 8)(A, ndrange = length(A))
112112
synchronize(backend)
113-
@test all(A .== 1:8)
113+
@test all(Array(A) .== 1:8)
114114

115115
A = allocate(backend, Int, 16)
116116
index_linear_local(backend, 8)(A, ndrange = length(A))
117117
synchronize(backend)
118-
@test all(A[1:8] .== 1:8)
119-
@test all(A[9:16] .== 1:8)
118+
@test all(Array(A)[1:8] .== 1:8)
119+
@test all(Array(A)[9:16] .== 1:8)
120120

121121
A = allocate(backend, Int, 8, 2)
122122
index_linear_local(backend, 8)(A, ndrange = length(A))
123123
synchronize(backend)
124-
@test all(A[1:8] .== 1:8)
125-
@test all(A[9:16] .== 1:8)
124+
@test all(Array(A)[1:8] .== 1:8)
125+
@test all(Array(A)[9:16] .== 1:8)
126126

127127
A = allocate(backend, CartesianIndex{2}, 16, 16)
128128
index_cartesian_global(backend, 8)(A, ndrange = size(A))
129129
synchronize(backend)
130-
@test all(A .== CartesianIndices(A))
130+
@test all(Array(A) .== CartesianIndices(A))
131131

132132
A = allocate(backend, CartesianIndex{1}, 16, 16)
133133
index_cartesian_global(backend, 8)(A, ndrange = length(A))
134134
synchronize(backend)
135-
@test all(A[:] .== CartesianIndices((length(A),)))
135+
@test all(Array(A)[:] .== CartesianIndices((length(A),)))
136136

137137
# Non-multiplies of the workgroupsize
138138
A = allocate(backend, Int, 7, 7)
139139
index_linear_global(backend, 8)(A, ndrange = length(A))
140140
synchronize(backend)
141-
@test all(A .== LinearIndices(A))
141+
@test all(Array(A) .== LinearIndices(A))
142142

143143
A = allocate(backend, Int, 5)
144144
index_linear_local(backend, 8)(A, ndrange = length(A))
145145
synchronize(backend)
146-
@test all(A .== 1:5)
146+
@test all(Array(A) .== 1:5)
147147
end
148148

149149
@kernel function constarg(A, @Const(B))
@@ -199,7 +199,7 @@ function unittest_testsuite(Backend, backend_str, backend_mod, BackendArrayT; sk
199199
A = KernelAbstractions.zeros(Backend(), Int64, 1024)
200200
kernel_val!(Backend())(A, Val(3), ndrange = size(A))
201201
synchronize(Backend())
202-
@test all((a) -> a == 3, A)
202+
@test all((a) -> a == 3, Array(A))
203203

204204
@kernel function kernel_empty()
205205
nothing
@@ -276,7 +276,7 @@ function unittest_testsuite(Backend, backend_str, backend_mod, BackendArrayT; sk
276276
A = KernelAbstractions.zeros(Backend(), Int64, 1024)
277277
context_kernel(Backend())(A, ndrange = size(A))
278278
synchronize(Backend())
279-
@test all((a) -> a == 1, A)
279+
@test all((a) -> a == 1, Array(A))
280280
else
281281
@test_throws ErrorException("This kernel is unavailable for backend CPU") context_kernel(Backend())
282282
end

test/testsuite.jl

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

6666
@conditional_testset "copyto!" skip_tests begin
67-
copyto_testsuite(backend)
67+
copyto_testsuite(backend, AT)
6868
end
6969

7070
@conditional_testset "Printing" skip_tests begin

0 commit comments

Comments
 (0)