[go: nahoru, domu]

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

Dispatching on ReshapedArrays is broken #1860

Closed
charleskawczynski opened this issue Jul 1, 2024 · 1 comment
Closed

Dispatching on ReshapedArrays is broken #1860

charleskawczynski opened this issue Jul 1, 2024 · 1 comment
Labels
bug Something isn't working GPU

Comments

@charleskawczynski
Copy link
Member

Dispatching on ReshapedArrays is broken, found in #1854:

julia> show(err)
1-element ExceptionStack:
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/GMsgk/src/GPUArraysCore.jl:155
  [3] _assertscalar(op::String, behavior::GPUArraysCore.ScalarIndexing)
    @ GPUArraysCore ~/.julia/packages/GPUArraysCore/GMsgk/src/GPUArraysCore.jl:128
  [4] assertscalar(op::String)
    @ GPUArraysCore ~/.julia/packages/GPUArraysCore/GMsgk/src/GPUArraysCore.jl:116
  [5] getindex(A::CUDA.CuArray{Float32, 5, CUDA.Mem.DeviceBuffer}, I::Int64)
    @ GPUArrays ~/.julia/packages/GPUArrays/OqrUV/src/host/indexing.jl:48
  [6] scalar_getindex(::CUDA.CuArray{Float32, 5, CUDA.Mem.DeviceBuffer}, ::Int64, ::Vararg{Int64})
    @ GPUArrays ~/.julia/packages/GPUArrays/OqrUV/src/host/indexing.jl:34
  [7] _getindex
    @ ~/.julia/packages/GPUArrays/OqrUV/src/host/indexing.jl:17 [inlined]
  [8] getindex
    @ ~/.julia/packages/GPUArrays/OqrUV/src/host/indexing.jl:15 [inlined]
  [9] getindex
    @ ./subarray.jl:290 [inlined]
 [10] _getindex
    @ ./abstractarray.jl:1341 [inlined]
 [11] getindex
    @ ./abstractarray.jl:1291 [inlined]
 [12] get_struct
    @ ~/CliMA/ClimaCore.jl/src/DataLayouts/struct.jl:218 [inlined]
 [13] macro expansion
    @ ~/CliMA/ClimaCore.jl/src/DataLayouts/struct.jl:200 [inlined]
 [14] macro expansion
    @ ./none:0 [inlined]
 [15] get_struct
    @ ./none:0 [inlined]
 [16] getindex
    @ ~/CliMA/ClimaCore.jl/src/DataLayouts/DataLayouts.jl:1026 [inlined]
 [17] getindex
    @ ~/CliMA/ClimaCore.jl/src/DataLayouts/DataLayouts.jl:1033 [inlined]
 [18] _broadcast_getindex
    @ ./broadcast.jl:662 [inlined]
 [19] _getindex
    @ ./broadcast.jl:706 [inlined]
 [20] _getindex
    @ ./broadcast.jl:705 [inlined]
 [21] _broadcast_getindex
    @ ./broadcast.jl:681 [inlined]
 [22] getindex
    @ ./broadcast.jl:636 [inlined]
 [23] copyto!(dest::ClimaCore.DataLayouts.VF{Float32, 70, SubArray{Float32, 2, Base.ReshapedArray{Float32, 5, SubArray{Float32, 2, CUDA.CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, Tuple{UnitRange{Int64}, Base.Slice{Base.OneTo{Int64}}}, false}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64, Int64, Base.Slice{Base.OneTo{Int64}}, Int64}, false}}, bc::Base.Broadcast.Broadcasted{ClimaCore.DataLayouts.VFStyle{70, CUDA.CuArray{Float32, N, CUDA.Mem.DeviceBuffer} where N}, Nothing, typeof(Thermodynamics.air_pressure), Tuple{Tuple{Thermodynamics.Parameters.ThermodynamicsParameters{Float32}}, ClimaCore.DataLayouts.VF{Thermodynamics.PhaseDry{Float32}, 70, SubArray{Float32, 2, CUDA.CuArray{Float32, 5, CUDA.Mem.DeviceBuffer}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64, Int64, Base.Slice{Base.OneTo{Int64}}, Int64}, false}}}})
    @ ClimaCore.DataLayouts ~/CliMA/ClimaCore.jl/src/DataLayouts/broadcast.jl:576
 [24] copyto!(dest::ClimaCore.DataLayouts.VIJFH{Float32, 70, 1, Base.ReshapedArray{Float32, 5, SubArray{Float32, 2, CUDA.CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, Tuple{UnitRange{Int64}, Base.Slice{Base.OneTo{Int64}}}, false}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}}}, bc::Base.Broadcast.Broadcasted{ClimaCore.DataLayouts.VIJFHStyle{70, 1, CUDA.CuArray{Float32, N, CUDA.Mem.DeviceBuffer} where N}, NTuple{5, Base.OneTo{Int64}}, typeof(Thermodynamics.air_pressure), Tuple{Tuple{Thermodynamics.Parameters.ThermodynamicsParameters{Float32}}, ClimaCore.DataLayouts.VIJFH{Thermodynamics.PhaseDry{Float32}, 70, 1, CUDA.CuArray{Float32, 5, CUDA.Mem.DeviceBuffer}}}})
    @ ClimaCore.DataLayouts ~/CliMA/ClimaCore.jl/src/DataLayouts/broadcast.jl:604
 [25] copyto!
    @ ~/CliMA/ClimaCore.jl/src/Fields/broadcast.jl:149 [inlined]
@charleskawczynski charleskawczynski added bug Something isn't working GPU labels Jul 1, 2024
@charleskawczynski
Copy link
Member Author

Closed by #1863

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GPU
Projects
None yet
Development

No branches or pull requests

1 participant