Skip to content

hvncat triggers scalar iteration #820

Open

Description

@roflmaostc
gg = CUDA.rand(2,2)

# errors with
[gg;; gg]
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.

    error(::String)@error.jl:35
    assertscalar(::String)@GPUArraysCore.jl:103
    getindex(::CUDA.CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, ::Int64)@indexing.jl:9
    _typed_hvncat(::Type{Float32}, ::Val{2}, ::CUDA.CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, ::CUDA.CuArray{Float32, 2, CUDA.Mem.DeviceBuffer})@abstractarray.jl:2259
    _typed_hvncat(::Type, ::Int64, ::Bool, ::CUDA.CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, ::Vararg{CUDA.CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}})@abstractarray.jl:2215
    _hvncat@abstractarray.jl:2196[inlined]
    hvncat@abstractarray.jl:2189[inlined]
    top-level scope@[Local: 1](http://localhost:1234/edit?id=77e8e67e-c8bb-11ed-06aa-479b71d48037#)[inlined]


# works
[gg; gg]

CUDA runtime 11.8, artifact installation
CUDA driver 12.0
NVIDIA driver 525.85.5

Libraries:

  • CUBLAS: 11.11.3
  • CURAND: 10.3.0
  • CUFFT: 10.9.0
  • CUSOLVER: 11.4.1
  • CUSPARSE: 11.7.5
  • CUPTI: 18.0.0
  • NVML: 12.0.0+525.85.5

Toolchain:

  • Julia: 1.8.5
  • LLVM: 13.0.1
  • PTX ISA support: 3.2, 4.0, 4.1, 4.2, 4.3, 5.0, 6.0, 6.1, 6.3, 6.4, 6.5, 7.0, 7.1, 7.2
  • Device capability support: sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72, sm_75, sm_80, sm_86

1 device:
0: NVIDIA GeForce RTX 3060 (sm_86, 6.252 GiB / 12.000 GiB available)

❔

Julia Version 1.8.5
Commit 17cfb8e65ea (2023-01-08 06:45 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 24 × AMD Ryzen 9 5900X 12-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-13.0.1 (ORCJIT, znver3)
Threads: 12 on 24 virtual cores
Environment:
JULIA_NUM_THREADS = 12
JULIA_REVISE_WORKER_ONLY = 1

Activity

  1. changed the title [-];; is not working because of scalar indexing[/-] [+]hvncat triggers scalar iteration[/+] on Mar 22, 2023
  2. maleadt commented on Mar 22, 2023

    @maleadt
    Member

    ;; lowers to Base.hvncat

    julia> Meta.@lower [a ;; a]
    :($(Expr(:thunk, CodeInfo(
        @ none within `top-level scope`
    1 ─ %1 = Base.hvncat(2, a, a)
    └──      return %1
    ))))
    

    This can probably be implemented in GPUArrays.

  3. transferred this issue fromJuliaGPU/CUDA.jlon Oct 19, 2026
  4. added
    arraysThe array abstraction: broadcasting, mapreduce, indexing, views, generic linear algebra.
    and removed on Oct 19, 2026
  5. marked Concatenation #92 as a duplicate of this issue on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    arraysThe array abstraction: broadcasting, mapreduce, indexing, views, generic linear algebra.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions