HipPrintf: Inline literal %s strings into format string#1123
Merged
Conversation
206083e to
bda9e71
Compare
1ee6ce8 to
235bb48
Compare
e377673 to
ad97083
Compare
Fix the format specifier parser to detect all %[flags][width][.precision]s patterns (e.g. %-8s, %8.5s, %*s), not just bare %s. This fixes crashes on PoCL/macOS where modified %s args remained in the wrong address space. Three strategies for string specifiers: 1. Bare %s with literal: inline content into format string 2. Modified %s with literal: clone string to constant address space 3. Dynamic strings: use _cl_print_str fallback Also: - Add null check to _cl_print_str to match AMD/nvidia behavior - Add TestPrintfStaticString compiler test - Exclude printf tests when CHIP_MALI_GPU_WORKAROUNDS is ON (Mali-G52 has non-functional OpenCL printf) - Remove now-passing printf tests from known_failures.yaml - Update HIP submodule with printf test fixes (flexible comparison, SPIR-V platform support, Catch2 compatibility) Fixes: #1122
…intfSpecifiers test
Mali GPUs require the cl_arm_printf vendor extension to receive kernel printf output. Register a callback via CL_PRINTF_CALLBACK_ARM context property when the extension is detected, forwarding output to stdout. Tested on Mali-G52: all 4 printf tests pass (Unit_printf_flags, Unit_printf_specifier, hipcc-TestPrintfLonePercent, cuda-simplePrintf).
The inlining of bare %s literals is not an IGC-specific workaround — it avoids the general OpenCL address space mismatch where HIP string literals are in UniformConstant (AS 0) but OpenCL printf expects Constant (AS 2). The IGC bug was fixed in driver 26.05.37020.3.
b1a1b80 to
2e07545
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.
IGC fails when SPIR-V printf has UniformConstant pointer as %s arg.
For literal strings, inline content directly into the format string.
Dynamic strings still use _cl_print_str char-by-char fallback.
Fixes #1122