SPIR-V: declare native integer widths in the datalayout
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start with the SPIR-V datalayout variants in src/spirv.jl at the linked lines and compare them with upstream LLVM's SPIR-V datalayout change. Add the native integer widths to both spirv64 and spirv32, then validate with KernelAbstractions' and OpenCL.jl's PoCL tests, including the Khronos translator configuration.
Written by the indexing model from the issue text.
Description
GPUCompiler's SPIR-V datalayout doesn't declare native integer widths:
Upstream LLVM added n8:16:32:64 to its SPIR-V datalayouts in llvm/llvm-project#110695, because without it "optimisation passes, such as InstCombine, [get] ideas and e.g. [shrink] to non byte-multiple integer types, which is not desirable and can lead to breakage further down in the toolchain".
We hit this with Julia 1.13 (LLVM 20): in KernelAbstractions' PoCL exception path, a switch on a function returning 0, 1 or 2 gets narrowed to i2:
%trunc = trunc nuw i64 %0 to i2
switch i2 %trunc, label %L21 [
i2 1, label %L18.thread
i2 0, label %L23
]
LLVM's SPIR-V back end happens to cope, since it rounds integer widths up to 8/16/32/64/128 bits (SPIRVGlobalRegistry::adjustOpTypeIntWidth), but:
- other consumers may not: the Khronos translator presumably needs
SPV_INTEL_arbitrary_precision_integersfor such types (not verified); libspirvreplaces the module's datalayout with its target machine's, which does includen8:16:32:64, so we optimize under different assumptions than the back end compiles under;- odd-width arithmetic has to be masked again once widened.
The fix is to add n8:16:32:64 to both variants (spirv64 and spirv32), as upstream does. It only affects which integer widths the optimizer considers native, not type sizes, alignment or pointers. It should be validated with KernelAbstractions' PoCL tests and OpenCL.jl's PoCL tests, including the Khronos translator configuration.
- Dominant language
- Julia
- Stars
- 188
- Forks
- 71
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 60
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaGPU/GPUCompiler.jl
-
signature_type_by_tt allocates on every launch on Julia 1.14Possibly taken @maleadt claimed this today. Open
Difficulty 3/5 1-2 days Newbie friendliness 25/100
JuliaGPU/GPUCompiler.jl#1024 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
JuliaGPU/GPUCompiler.jl#1019 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
JuliaGPU/GPUCompiler.jl#1014 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 12/100
JuliaGPU/GPUCompiler.jl#1011 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
JuliaGPU/GPUCompiler.jl#970 ·
Maintainers usually reply within 1 day
All issues in JuliaGPU/GPUCompiler.jl
Similar issues
-
TSDAE's docstring implies a theta argument it does not takePossibly taken @singhharsh1708 claimed this today. Opendocumentation
Difficulty 1/5 Under an hour Newbie friendliness 74/100
SciML/PETScDiffEq.jl#282 ·
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 Half a day Newbie friendliness 82/100
-
SavedSubsystem with an integer save_idxs maps the index the wrong way roundPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
SciML/SciMLBase.jl#1643 ·
Maintainers usually reply within 2 days
-
authority-vechtstromen ready-for-agent
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Deltares/Ribasim-NL#890 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day