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

implement Base.sum! #251

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

implement Base.sum! #251

wants to merge 1 commit into from

Conversation

vpuri3
Copy link
Contributor

@vpuri3 vpuri3 commented Mar 6, 2024

No description provided.

@vpuri3
Copy link
Contributor Author

vpuri3 commented Mar 6, 2024

On master

julia> x = (; x = zeros(4)) |> ComponentArray |> cu; y = ones(4,4) |> cu; sum!(x, y)
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/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       
    @ ~/.julia/packages/GPUArrays/Hd5Sk/src/host/indexing.jl:48 [inlined]
  [6] scalar_getindex(A::CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, Is::Int64)                                                                                                                                                                              

on this branch

julia> using CUDA, ComponentArrays; x = (; x = zeros(4)) |> ComponentArray |> cu; y = ones(4,4) |> cu; sum!(x, y)
Precompiling ComponentArrays
  2 dependencies successfully precompiled in 3 seconds. 99 already precompiled.
4×1 CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}:
 4.0
 4.0
 4.0
 4.0

@jonniedie
Copy link
Owner

Are we going to need this for all of the other ones as well?

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.

None yet

2 participants