JuliaGPU / JuliaGPU/KernelAbstractions.jl

Usage of ::Int

Open
#685 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
523
Forks
88
Avg merge
1d 11h
Merged PRs (30d)
25

Description

I'm not sure if this is intentional, I assume it's to follow the general Julia default of Int, which is Int64 on most platforms. However, it also means I am unable to use Int32 when I specifically want to, and on GPUs it can actually make quite a difference especially for indexing or iterating.
As it stands, I cannot start a kernel with Int32 block sizes, for example:

  Expression: binning_vegas!(backend, bins_buffer, ndi_buffer, buffer, grid, normal_distribution)
  MethodError: no method matching KernelAbstractions.NDIteration.StaticSize(::Tuple{Int32, Int32, Int32})
  The type `KernelAbstractions.NDIteration.StaticSize` exists, but no method is defined for this combination of argument types when trying to construct it.
  
  Closest candidates are:
    KernelAbstractions.NDIteration.StaticSize(::Int64...)
     @ KernelAbstractions ~/.julia/packages/KernelAbstractions/aLmvZ/src/nditeration.jl:21
    KernelAbstractions.NDIteration.StaticSize(::Tuple{Vararg{Int64}})
     @ KernelAbstractions ~/.julia/packages/KernelAbstractions/aLmvZ/src/nditeration.jl:20
    KernelAbstractions.NDIteration.StaticSize(::Type{<:Tuple})
     @ KernelAbstractions ~/.julia/packages/KernelAbstractions/aLmvZ/src/nditeration.jl:22
  
  Stacktrace:
   [1] vegas_binning_kernel_batched!(dev::CPU, size::Tuple{Int32, Int32, Int32})
     @ Vegas ~/.julia/packages/KernelAbstractions/aLmvZ/src/macros.jl:68
   [2] binning_vegas!(backend::CPU, bins_buffer::Matrix{Float16}, ndi_buffer::Matrix{Int64}, buffer::VegasBatchBuffer{Float16, 4194304, 11, Matrix{Float16}, Vector{Float16}, Vector{Float16}}, grid::VegasGrid{Float16, 33, 11, Matrix{Float16}}, func::Function)
     @ Vegas ~/repos/Vegas.jl/src/binning.jl:169
   [3] macro expansion
     @ ~/repos/Vegas.jl/test/binning.jl:21 [inlined]
   [4] macro expansion
     @ ~/.julia/juliaup/julia-1.12.5+0.x64.linux.gnu/share/julia/stdlib/v1.12/Test/src/Test.jl:677 [inlined]
   [5] macro expansion
     @ ~/repos/Vegas.jl/test/binning.jl:21 [inlined]
   [6] macro expansion
     @ ~/.julia/juliaup/julia-1.12.5+0.x64.linux.gnu/share/julia/stdlib/v1.12/Test/src/Test.jl:1865 [inlined]
   [7] testsuite_binning(backend::CPU, el_type::Type{Float16}, nbins::Int64, dim::Int64)
     @ Main ~/repos/Vegas.jl/test/binning.jl:10

I think I could make a PR to make this more generic by using Integer instead of Int in most places.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/nditeration.jl around the StaticSize methods shown in the error, then inspect the related kernel entry points mentioned in the stack trace. Reproduce the Int32 block-size failure and verify that the affected construction paths accept it without breaking existing Int-based behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.