jonniedie / ComponentArrays.jl

Arrays with arbitrarily nested named components.
MIT License
286 stars 34 forks source link

`lmul!` fails with Component Array on GPU #232

Open vpuri3 opened 8 months ago

vpuri3 commented 8 months ago
julia> lmul!(false, ComponentArray((; x=CUDA.ones(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 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:35                                                     
 [2] assertscalar(op::String)                                                                                                                            
   @ GPUArraysCore ~/.julia/packages/GPUArraysCore/uOYfN/src/GPUArraysCore.jl:103                                                                        
 [3] getindex                                                                                                                                            
   @ LinearAlgebra ~/.julia/packages/GPUArrays/dAUOE/src/host/indexing.jl:48 [inlined]
 [4] getindex                                                                                                                                            
   @ LinearAlgebra ~/.julia/dev/ComponentArrays/src/array_interface.jl:94 [inlined]
 [5] macro expansion                                                                                                                                     
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:221 [inlined]
 [6] macro expansion
   @ LinearAlgebra ./simdloop.jl:77 [inlined]
 [7] lmul!(s::Bool, X::ComponentVector{Float32, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, Tuple{Axis{(x = 1:2,)}}})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:220
 [8] top-level scope
   @ REPL[16]:1
 [9] top-level scope
   @ ~/.julia/packages/CUDA/nbRJk/src/initialization.jl:205