Skip to content

Commit c1e921d

Browse files
committed
Fixup tests
1 parent 42ea51b commit c1e921d

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

test/runtests.jl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,15 @@ const IS_CPU_BACKEND = BACKEND == get_backend([])
5858
global prefer_threads::Bool = !(IS_CPU_BACKEND && "--cpuKA" in ARGS)
5959

6060
array_from_host(h_arr::AbstractArray, dtype=nothing) = array_from_host(BACKEND, h_arr, dtype)
61-
@static if IS_CPU_BACKEND && prefer_threads
62-
function array_from_host(backend, h_arr::AbstractArray, dtype=nothing)
63-
d_arr = zeros(isnothing(dtype) ? eltype(h_arr) : dtype, size(h_arr))
64-
copyto!(d_arr, h_arr isa Array ? h_arr : Array(h_arr)) # Allow unmaterialised types, e.g. ranges
65-
d_arr
66-
end
67-
else
68-
function array_from_host(backend, h_arr::AbstractArray, dtype=nothing)
69-
d_arr = KernelAbstractions.zeros(backend, isnothing(dtype) ? eltype(h_arr) : dtype, size(h_arr))
70-
copyto!(d_arr, h_arr isa Array ? h_arr : Array(h_arr)) # Allow unmaterialised types, e.g. ranges
71-
d_arr
61+
62+
function array_from_host(backend, h_arr::AbstractArray, dtype=nothing)
63+
d_arr = if IS_CPU_BACKEND && prefer_threads # Don't use KA zeros if not using KA algorithms
64+
zeros(isnothing(dtype) ? eltype(h_arr) : dtype, size(h_arr))
65+
else
66+
KernelAbstractions.zeros(backend, isnothing(dtype) ? eltype(h_arr) : dtype, size(h_arr))
7267
end
68+
copyto!(d_arr, h_arr isa Array ? h_arr : Array(h_arr)) # Allow unmaterialised types, e.g. ranges
69+
d_arr
7370
end
7471

7572
@testset "Aqua" begin

0 commit comments

Comments
 (0)