fix: inline kernel arg promotion to avoid wrapper function pattern#1214
Merged
fix: inline kernel arg promotion to avoid wrapper function pattern#1214
Conversation
98e6508 to
83d9470
Compare
The previous promoteKernelArgs implementation created a two-level function pattern: a wrapper kernel (with i32 params) calling an internal "unpromoted" function (with the original narrow types). This caused subgroup shuffle operations (OpSubgroupShuffleINTEL) in the called function to return wrong results on Intel GPUs (IGC bug). Replace with in-place promotion: the kernel function is directly modified to use i32 params, with trunc instructions inserted at the entry block. This produces a flat kernel without function call indirection, which works correctly with Intel's subgroup shuffles. Fixes rocPRIM/hipCUB/rocThrust scan/sort/reduce failures caused by lookback_scan_kernel's bool parameters triggering the IGC bug.
83d9470 to
f867de1
Compare
Collaborator
Author
|
/run-aurora-ci |
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.
Summary
HipPromoteInts::promoteKernelArgscreated a wrapper entry point withi32params that called an inner.unpromotedfunction with the original narrow types (i1/i8/i16). Intel's GPU compiler (IGC) does not propagateOpExecutionMode SubgroupSizeto called functions, so subgroup shuffle operations inside the inner function executed with the wrong subgroup size, producing incorrect results.Changed
promoteKernelArgsto modify the kernel function in-place: the function body is spliced into a new function withi32params, andtruncinstructions convert back to the original narrow type at the entry block. This produces a flat kernel without function call indirection.Impact
Fixes ~50 library test failures across rocPRIM, hipCUB, and rocThrust. All multi-block parallel scan, sort, and reduce operations were broken because rocPRIM's
lookback_scan_kernelhasboolparameters (override_first_value,save_last_value).Verified:
thrust::inclusive_scannow passes at all sizes including N=4097, N=8192, N=65536 which were failing since the LLVM 22 native SPIR-V backend was first tested.Test plan
TestBoolParamShuffle— warp scan withintparam (passes) vsboolparam (was failing, now passes)thrust::inclusive_scanN=128..65536 all PASS