Repository navigation
fix(rocke): shift HIP vector lshr lanes in their own width - #14844
Conversation
The HIP lowering of vector.lshr read every lane as uint32_t before shifting. For an i8 or i16 lane that sign-extends a negative value first, so its sign bits were shifted into the result, where LLVM's lshr shifts in zeros. Both engines now read each lane through the unsigned type of its own width. An i32 lane still reads as uint32_t, so its source is unchanged. A new test checks that both engines emit the same HIP source with the unsigned read, compiles that source with hipcc for gfx942 and gfx950, and on a GPU compares the LLVM route and hipcc on that source with numpy, on negative and positive i8, i16 and i32 lanes. Co-Authored-By: Claude <noreply@anthropic.com>
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
|
Automated review: Model - qwen3.6:35b-a3b-coding-mtp-q4_K_M, effort: max PR #14844 — shift HIP vector lshr lanes in their own width (cgmillette, AICK-2902) — 🟡 First-round: verified; CI skips HIP cases
Utility: 🟢 Positive — HIP route now matches LLVM's lshr on i8/i16 lanes; nothing else changes. Legend: 🔴 blocking · 🟠 should-fix · 🟡 minor nit · 🟢 info/good · ⚪ retracted First-round review: first pass by a local qwen3.6 model, verified by the orchestrator (Claude Opus 5.5). Checks: merge with develop, build + ctest, byte identity, goldens, differential golden, the new test with the native engine on develop and the merge, its HIP source on a gfx1151 GPU, HIP output of the at-risk parity configs, CI at head. Flags whether a closer look is needed; not an approval or rejection. |
CongMa13
left a comment
There was a problem hiding this comment.
No new issues found. I agree with the following existing comments:
- HIP regression tests skip without
rocke_engine— cgmillette — #14844 (comment)
CongMa13
left a comment
There was a problem hiding this comment.
No new P0 or P1 issues were identified during this review. The changes are approved.
TheRock Submodule Bump ActivityNewest first
|
Motivation
On the HIP route,
vector.lshron i8 or i16 lanes gives wrong results for any lane with its top bit set: a lane holding -128 shifted right by 2 gives -32 instead of 32. The LLVM route gives the right result, so the two compile routes disagree on the same kernel.Technical Details
Both HIP lowerings (Python
_Lowerer._op_vector_lshr, C++rocke_h_op_vector_lshr) emittedres[i] = ((uint32_t)a[i]) >> b[i];for every element type. For an i8 or i16 lane the cast sign-extends a negative value to 32 bits first, so the shift moves sign bits into the result, where LLVM'slshr <N x iW>shifts in zeros at bit W-1.Both engines now read each lane through the unsigned type of its own width (
uint8_t,uint16_t,uint32_t), looked up in the existing unsigned-type table (_HIP_UNSIGNED_INT_TYPE/rocke_h_unsigned_int_type); an element with no entry is refused. An i32 lane still reads asuint32_t, so its source is unchanged. Only the HIP lowering changes; the LLVM IR of every kernel is unchanged.Test Plan
platform/tests/core/test_vector_lshr.py, for 4 x i8, 2 x i16 and 2 x i32 lanes:Test Result
platform/tests): 6232 passed, 769 skipped, 2 failed; develop in the same environment: 6221 passed, 769 skipped, the same 2 failed (test_arch_domain_lane.py::test_the_cpp_fallback_does_not_warn_twice,test_binding_compiler_selection.py::test_python_bindings_use_the_compiling_library). The 11 extra passes are the new test.ruff checkclean.ISSUE ID : AICK-2902
🤖 Generated with Claude Code