Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always disallow scalar indexing. #359

Merged
merged 2 commits into from
Jun 10, 2021
Merged

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented May 21, 2021

@maleadt
Copy link
Member Author

maleadt commented May 27, 2021

Update:

julia> using CUDA
julia> cu([1])[1]
┌ Warning: Performing scalar indexing.
│ 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 are only permitted from the REPL for prototyping purposes.
│ If you did intend to index this array, annotate the caller with @allowscalar.
└ @ GPUArrays ~/Julia/pkg/GPUArrays/src/host/indexing.jl:57
1
                                                                                                                                                                                                                                  tim@taurus ~/Julia/pkg/GPUArrays$ jl -e 'using CUDA; cu([1])[1]'
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 are only permitted from the REPL for prototyping purposes.
If you did intend to index this array, annotate the caller with @allowscalar.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] assertscalar(op::String)
   @ GPUArrays ~/Julia/pkg/GPUArrays/src/host/indexing.jl:54
 [3] getindex(xs::CuArray{Int64, 1}, I::Int64)
   @ GPUArrays ~/Julia/pkg/GPUArrays/src/host/indexing.jl:87
 [4] top-level scope
   @ none:1

@vchuravy

@maleadt maleadt marked this pull request as ready for review May 27, 2021 11:59
@maleadt maleadt merged commit 25ce681 into master Jun 10, 2021
@bors bors bot deleted the tb/disallow_scalar_indexing branch June 10, 2021 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggestion - Disable AbstractArray indexing fallback by default
1 participant