Open
Description
On GPUArrays v10.3.1
, map((x,y)->x+y, CUDA.zeros(2), 1:2)
used to work without causing a scalar indexing issue. However, with the change in v11.1.0
, it now throws the following error:
julia> map((x,y)->x+y, CUDA.zeros(2), 1:2)
ERROR: Scalar indexing is disallowed.
Invocation of getindex resulted in scalar indexing of a GPU array.
This is typically caused by calling an iterating implementation of a method.
Such implementations *do not* execute on the GPU, but very slowly on the CPU,
and therefore should be avoided.
If you want to allow scalar iteration, use `allowscalar` or `@allowscalar`
to enable scalar iteration globally or for the operations in question.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] errorscalar(op::String)
@ GPUArraysCore ~/.julia/packages/GPUArraysCore/aNaXo/src/GPUArraysCore.jl:151
[3] _assertscalar(op::String, behavior::GPUArraysCore.ScalarIndexing)
@ GPUArraysCore ~/.julia/packages/GPUArraysCore/aNaXo/src/GPUArraysCore.jl:124
[4] assertscalar(op::String)
@ GPUArraysCore ~/.julia/packages/GPUArraysCore/aNaXo/src/GPUArraysCore.jl:112
[5] getindex
@ ~/.julia/packages/GPUArrays/sBzM5/src/host/indexing.jl:50 [inlined]
[6] iterate
@ ./abstractarray.jl:1209 [inlined]
[7] iterate
@ ./abstractarray.jl:1207 [inlined]
[8] _zip_iterate_some
@ ./iterators.jl:444 [inlined]
[9] _zip_iterate_all
@ ./iterators.jl:436 [inlined]
[10] iterate
@ ./iterators.jl:426 [inlined]
[11] iterate
@ ./generator.jl:45 [inlined]
[12] collect(itr::Base.Generator{Base.Iterators.Zip{Tuple{CuArray{Float32, 1, CUDA.DeviceMemory}, UnitRange{Int64}}}, Base.var"#4#5"{var"#3#4"}})
@ Base ./array.jl:791
[13] map(f::Function, it::CuArray{Float32, 1, CUDA.DeviceMemory}, iters::UnitRange{Int64})
@ Base ./abstractarray.jl:3495
[14] top-level scope
@ REPL[3]:1
I wonder if this was an intended change. CUDA.zeros(2) .+ (1:2)
still seems to work on CUDA v5.6
without causing a scalar indexing issue.