Repository navigation
Kernels: fixed HIP compilation-unit id, so code objects don't depend on the build folder - #6
Merged
Merged
Conversation
phantoslayer21
force-pushed
the
proposal/kernel-cuid
branch
from
November 13, 2026 15:01
7adff78 to
a29cb38
Compare
…ompile device_command in clean/runner/build.py now adds -cuid=wg_<output file name> to every HIP device compile (the id is the output file's base name, with characters outside [A-Za-z0-9_] replaced by "_", so it has no path in it). Without -cuid, clang derives the id itself; the id sets the __hip_cuid_... symbol name in the code object, and with a fixed id that name does not depend on the build folder. The gfx1201 and gfx1200 builds of one kernel get the same id. Measured (HIP SDK 7.2, BUILDING.md 3.3 command, code objects only: --extra-archs gfx1200 --no-model-k --no-runtime): - built in two different folders, all 54 code objects are byte-identical; - against release 0.6.0, which was built without -cuid, no file is byte-identical. All 54 have identical .text and .note sections and the same section list. .rodata is identical in 52; in post_w64__orig.co (both targets) it moves by 64 bytes, and its 93 kernel descriptors differ only in their code-entry offset, by that amount. Not measured: DXIL or kernels.json, model K code objects. The code objects were not run. BUILDING.md, "Comparing kernels with a release": builds made with -cuid compare file by file; for 0.6.0 compare the .text and .note sections, not .rodata or the whole file. The module docstring of build.py shows the flag. A CPU unit test, clean/tests/test_build_cuid.py, checks that the command carries -cuid=wg_<name>, the same for any output folder, with no path in it. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
phantoslayer21
marked this pull request as ready for review
November 13, 2026 15:31
phantoslayer21
force-pushed
the
proposal/kernel-cuid
branch
from
November 13, 2026 15:31
a29cb38 to
c0418dd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
clean/runner/build.pypasses a fixed compilation-unit id (-cuid=wg_<output name>) to every HIP device compile. The id is the output file's base name, with characters outside[A-Za-z0-9_]replaced by_, so it has no path in it. The module docstring now shows the flag, and a small CPU unit test (clean/tests/test_build_cuid.py) checks the command. BUILDING.md, "Comparing kernels with a release", says what to compare.The branch is one commit on top of
main(the two earlier commits are squashed, so the history carries only the corrected message).Why
Without
-cuid, clang derives each code object's compilation-unit id itself. That id sets the__hip_cuid_...symbol name in the code object, so a build without-cuidcan't be compared with another build by file hash. With a fixed id the symbol name doesn't depend on the build folder.Measured
Built from this change with the BUILDING.md 3.3 command, code objects only (
--extra-archs gfx1200 --no-model-k --no-runtime), HIP SDK 7.2:gfx1201.*files that the runtime step copies unchanged from them): all 54 have identical.textand.notesections and the same section list..rodatais identical in 52. Inpost_w64__orig.co(both targets),.rodatamoves by 64 bytes, and its 93 kernel descriptors differ only in their code-entry offset, by exactly that amount. No file is byte-identical to 0.6.0, because 0.6.0 was built without-cuid.Because of that last point, BUILDING.md tells you to compare 0.6.0 by
.textand.note, not by.rodataor the whole file. Builds made with-cuidcan be compared file by file.Not measured: DXIL,
kernels.jsonand the DX12 manifest (so BUILDING.md makes no new claim about them) and model K code objects (the build used--no-model-k).Testing
clean/tests/test_build_cuid.pyruns on the CPU, executes nothing and uses dummy compiler and ROCm paths. It asserts thatdevice_command(...)puts-cuid=wg_<name>in the command, that the id is the same for two different output folders and follows the output file's name, and that it contains no path. It passes locally with Python 3.12.main(Community setup #5).Checklist
Signed-off-by:line.SPDX-License-Identifier: MITand is this project's own; the other changed files are this project's own too (clean/runner/build.py,BUILDING.md).