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

New scalar indexing issue in JLArrays v0.2 #571

Open
mtfishman opened this issue Nov 19, 2024 · 0 comments
Open

New scalar indexing issue in JLArrays v0.2 #571

mtfishman opened this issue Nov 19, 2024 · 0 comments

Comments

@mtfishman
Copy link
Contributor

julia> versioninfo()
Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

julia> using JLArrays

julia> pkgversion(JLArrays)
v"0.2.0"

julia> a = jl(randn(2, 2))
2×2 JLArray{Float64, 2}:
  1.6783     0.918722
 -0.553115  -1.21098

julia> b = jl(randn(2, 2))
2×2 JLArray{Float64, 2}:
  0.240744  -1.6904
 -2.07826   -1.04436

julia> map!(identity, @view(b[1:2, 1:2]), @view(PermutedDimsArray(a, (2, 1))[1: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] scalar_getindex
    @ ~/.julia/packages/GPUArrays/sBzM5/src/host/indexing.jl:36 [inlined]
  [7] _getindex
    @ ~/.julia/packages/GPUArrays/sBzM5/src/host/indexing.jl:19 [inlined]
  [8] getindex
    @ ~/.julia/packages/GPUArrays/sBzM5/src/host/indexing.jl:17 [inlined]
  [9] getindex
    @ ./permuteddimsarray.jl:70 [inlined]
 [10] getindex
    @ ./subarray.jl:320 [inlined]
 [11] _getindex
    @ ./abstractarray.jl:1358 [inlined]
 [12] getindex
    @ ./abstractarray.jl:1312 [inlined]
 [13] map!(f::typeof(identity), dest::SubArray{Float64, 2, JLArray{…}, Tuple{…}, false}, A::SubArray{Float64, 2, PermutedDimsArray{…}, Tuple{…}, false})
    @ Base ./abstractarray.jl:3364
 [14] top-level scope
    @ REPL[24]:1
Some type information was truncated. Use `show(err)` to see complete types.

while:

julia> using JLArrays

julia> pkgversion(JLArrays)
v"0.1.6"

julia> a = jl(randn(2, 2))
2×2 JLArray{Float64, 2}:
 -0.640055   0.807964
 -0.656825  -0.442847

julia> b = jl(randn(2, 2))
2×2 JLArray{Float64, 2}:
  0.385222  0.903029
 -0.446148  0.758472

julia> map!(identity, @view(b[1:2, 1:2]), @view(PermutedDimsArray(a, (2, 1))[1:2, 1:2]))
2×2 view(::JLArray{Float64, 2}, 1:2, 1:2) with eltype Float64:
 -0.640055  -0.656825
  0.807964  -0.442847
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

No branches or pull requests

1 participant