@@ -58,18 +58,15 @@ const IS_CPU_BACKEND = BACKEND == get_backend([])
5858global prefer_threads:: Bool = ! (IS_CPU_BACKEND && " --cpuKA" in ARGS )
5959
6060array_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
7370end
7471
7572@testset " Aqua" begin
0 commit comments