You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 12, 2021. It is now read-only.
julia> a =ones(2,2)
2×2 Array{Float64,2}:1.01.01.01.0
julia> da =CuArray(a)
2×2 CuArray{Float64,2}:1.01.01.01.0
julia> a = Base.mapreduce(identity, +, a, dims=2)
2×1 Array{Float64,2}:2.02.0
julia> da = Base.mapreduce(identity, +, da, dims=2)
blk =1
thr =2
f = identity
op =+
R = [0.0; 0.0]
A = [1.01.0; 1.01.0]
range = (nothing, Base.OneTo(2))
R = [0.0; 0.0]
2×1 CuArray{Float64,2}:0.00.0
Adding the following side effect-free statement (expanded from (I...)[1]) to the kernel "fixes" the issue:
--- a/src/mapreduce.jl+++ b/src/mapreduce.jl@@ -3,6 +3,7 @@ using CuArrays: @cuindex, cudims
function mapreducedim_kernel_serial(f, op, R, A, range)
I = @cuindex R
newrange = map((r, i) -> r === nothing ? i : r, range, I)
+ @inbounds ((Tuple(CartesianIndices(R)[(blockIdx().x-1) * blockDim().x + threadIdx().x]))...)[1]
for I′ in CartesianIndices(newrange)
@inbounds R[I...] = op(R[I...], f(A[I′]))
end