Repository navigation
GCN: spell out the host's i128 alignment in the datalayout - #983
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #983 +/- ##
=======================================
Coverage 88.42% 88.43%
=======================================
Files 30 30
Lines 6395 6400 +5
=======================================
+ Hits 5655 5660 +5
Misses 740 740 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
CI was all green, I just now trimmed the inline comments. if it looks good, happy to have it merged 🙏 |
simeonschaub
left a comment
There was a problem hiding this comment.
Changes look good, I wonder whether we can add an @filecheck regression test to check the backend actually does the right thing, i.e. something that fails with the current AMDGPU_LLVM_Backend_jll, but won't after JuliaPackaging/Yggdrasil#15010
Good point. I'll see to add that |
Better use |
|
Ah yeah right |
Since AMDGPU_LLVM_Backend_jll 23.1.1+3, the external back-end aligns i128 to 16 bytes, while Julia before 1.12 aligns Int128 to 8 bytes on the host, so kernel arguments after an Int128 were read at the wrong offset (JuliaGPU/AMDGPU.jl#1002). The back-end replaces the module's datalayout with its own, but since 23.1.1+4 keeps a 64-bit i128 alignment when the module asks for one. Append the host's alignment for the external back-end; on 1.12+ this also makes the middle end agree with the back-end's i128:128. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Tim Besard <tim.besard@gmail.com>
53d79e0 to
948ac96
Compare
|
Added a test. |
|
Can this be merged and a released so we can finalise JuliaGPU/AMDGPU.jl#1139 🙏 |
|
Thanks! Would it be possible to tag and release a patch? |
Since
AMDGPU_LLVM_Backend_jll23.1.1+3, the external back-end alignsi128to 16 bytes. Julia before 1.12 alignsInt128to 8 bytes on the host. Any kernel argument at or after anInt128therefore ends up at a different offset on the device than on the host, which makes kernels fault or read garbage (JuliaGPU/AMDGPU.jl#1002). libamdgpu replaces the module's datalayout with its own. Since 23.1.1+4 (JuliaPackaging/Yggdrasil#15010), it keeps a 64-biti128alignment if the module asks for one.For the external back-end, this PR therefore appends the host's
i128alignment to the GCN datalayout. On Julia 1.12+, that isi128:128. The kernel argument layout doesn't change there, but the middle end's datalayout now matches the back-end's instead of inheriting the 64-bit default of Julia's LLVM. The in-process back-end is unchanged, because its datalayout comes from Julia's LLVM.The new test compares the kernel argument offsets and sizes in the
amdhsa.kernelsmetadata with the host layout of the argument types. On Julia 1.11 it fails without the source change, and with JLL 23.1.1+3. It passes with this change and 23.1.1+4:kernel(::Int32, ::Int128, ::Tuple{Int32,Int128}, ::Int64)Int128offsetOn 1.12 and 1.13 the layout matches the host with or without this PR (16 and 32).