Skip to content

Base.issorted causes scalar indexing #635

@lkdvos

Description

@lkdvos

MWE:

julia> using CUDA

julia> issorted(cu(rand(10)))
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:44
  [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/w335n/src/host/indexing.jl:50 [inlined]
  [6] iterate
    @ ./abstractarray.jl:1235 [inlined]
  [7] iterate
    @ ./abstractarray.jl:1233 [inlined]
  [8] issorted(itr::CuArray{Float32, 1, CUDA.DeviceMemory}, order::Base.Order.ForwardOrdering)
    @ Base.Sort ./sort.jl:51
  [9] #issorted#1
    @ ./sort.jl:95 [inlined]
 [10] issorted(itr::CuArray{Float32, 1, CUDA.DeviceMemory})
    @ Base.Sort ./sort.jl:88

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions