I am not sure why adding CUDA.@atomic
in the below code causes an error?
# works fine without CUDA.@atomic
function f(test)
broadcast(CuVector(1:2), transpose(CuVector(1:3))) do i,j
v::Float32 = j
test[i] += v
end
end
f(CUDA.zeros(Float32,2))
# ERROR with CUDA.@atomic
function g(test)
broadcast(CuVector(1:2), transpose(CuVector(1:3))) do i,j
v::Float32 = j
CUDA.@atomic test[i] += v
end
end
g(CUDA.zeros(Float32,2))
ERROR: LoadError: GPU broadcast resulted in non-concrete element type Union{}.
This probably means that the function you are broadcasting contains an error or type instability.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] copy
@ ~/.julia/packages/GPUArrays/3sW6s/src/host/broadcast.jl:44 [inlined]
[3] materialize
@ ./broadcast.jl:883 [inlined]
[4] broadcast(::var"#45#46"{CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}, ::CuArray{Int64, 1, CUDA.Mem.DeviceBuffer}, ::LinearAlgebra.Transpose{Int64, CuArray{Int64, 1, CUDA.Mem.DeviceBuffer}})
@ Base.Broadcast ./broadcast.jl:821
[5] g(test::CuArray{Float32, 1, CUDA.Mem.DeviceBuffer})