JuliaGPU / JuliaGPU/GPUCompiler.jl

PTX: Demote GEP indices to 32 bits, if possible.

Open
#463 0 comments 0 reactions 0 assignees View on GitHub
ptx
Dominant language
Julia
Stars
187
Forks
68
Avg merge
1d 12h
Merged PRs (30d)
28

Description

In https://github.com/JuliaGPU/CUDA.jl/pull/1895, I made the size tuple of `CuDeviceArray` 32 bits so that we can emit better code (lowering register pressure, making it possible to execute compute & indexing instructions in parallel, etc) However, the NVPTX back-end defaults to using 64 bits for indexing pointers, resulting in 64-bits GEPs being introduced by the front-end and optimization. I tried to change that by specifying a 32-bit pointer index size in the data layout, https://github.com/JuliaGPU/GPUCompiler.jl/pull/444, but that breaks 64-bits indices which can still get reintroduced by optimization (see e.g. https://github.com/JuliaGPU/GPUCompiler.jl/issues/461).

Either we try this again on LLVM 17 (where a bug has been fixed that was introducing 64-bits GEP offsets), or we instead create an optimization pass that demotes GEP indices to 32 bits if possible (e.g., if they are constants, or come from the size field of a device array).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing GPUCompiler.jl PR 444 and issue 461, along with CUDA.jl PR 1895, to understand the data-layout and optimization behavior described. Compare the LLVM 17 behavior and the alternative GEP-demotion approach; done means safe 32-bit GEP indices where possible without breaking valid 64-bit indices.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.