Skip to content

[AMDGPU] Validate scale_sel in v_cvt_scale_* - #227475

Merged
rampitec merged 1 commit into
mainfrom
users/rampitec/block16-validate-scale
Oct 1, 2026
Merged

rampitec merged 1 commit into
mainfrom
users/rampitec/block16-validate-scale

Conversation

@rampitec

Copy link
Copy Markdown
Contributor

These instructions can be block16 or block32 depending on the target
and scale_sel bits. Block16 is not supported in strict mode.

Re-enable the rest of the instructions in the strict mode but validate
the scale selector.

@rampitec

Copy link
Copy Markdown
Contributor Author

@rampitec
rampitec marked this pull request as ready for review September 29, 2026 21:16
@llvmorg-github-actions llvmorg-github-actions Bot added backend:AMDGPU clang:frontend Language frontend issues, e.g. anything involving "Sema" llvm:ir labels Sep 29, 2026
@llvmorg-github-actions

llvmorg-github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

@llvm/pr-subscribers-llvm-ir

@llvm/pr-subscribers-backend-amdgpu

Author: Stanislav Mekhanoshin (rampitec)

Changes

These instructions can be block16 or block32 depending on the target
and scale_sel bits. Block16 is not supported in strict mode.

Re-enable the rest of the instructions in the strict mode but validate
the scale selector.


Full diff: https://github.com/llvm/llvm-project/pull/227475.diff

9 Files Affected:

  • (modified) clang/include/clang/Basic/BuiltinsAMDGPU.td (+6-6)
  • (modified) clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1250-strict.cl (-6)
  • (modified) llvm/include/llvm/IR/IntrinsicsAMDGPU.td (+6-8)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPULowerIntrinsics.cpp (+62)
  • (modified) llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp (+47)
  • (modified) llvm/lib/Target/AMDGPU/VOP3Instructions.td (+7-9)
  • (added) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.scale.pk-scale-range.ll (+265)
  • (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.scale.pk.ll (+3-3)
  • (modified) llvm/test/MC/AMDGPU/gfx1250-strict_err.s (+132-16)
The server is unavailable at this time. Please wait a few minutes before you try again.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

✅ With the latest revision this PR passed the C/C++ code formatter.

@rampitec
rampitec force-pushed the users/rampitec/block16-validate-scale branch from 917a745 to d8a9087 Compare September 29, 2026 21:19
@rampitec

Copy link
Copy Markdown
Contributor Author

@scchan do you mind to double check actual OPSEL bit ranges used here?

@rampitec
rampitec force-pushed the users/rampitec/block16-cvt branch from 48bad19 to 32fdcc5 Compare September 30, 2026 20:05
@rampitec
rampitec force-pushed the users/rampitec/block16-validate-scale branch from d8a9087 to 58e3ec4 Compare September 30, 2026 20:05
Base automatically changed from users/rampitec/block16-cvt to main October 1, 2026 19:02
These instructions can be block16 or block32 depending on the target
and scale_sel bits. Block16 is not supported in strict mode.

Re-enable the rest of the instructions in the strict mode but validate
the scale selector.
@rampitec
rampitec force-pushed the users/rampitec/block16-validate-scale branch from 58e3ec4 to b7cf639 Compare October 1, 2026 19:08
@rampitec
rampitec enabled auto-merge (squash) October 1, 2026 19:15
@rampitec
rampitec merged commit 325224c into main Oct 1, 2026
8 of 10 checks passed
@rampitec
rampitec deleted the users/rampitec/block16-validate-scale branch October 1, 2026 20:11
@llvm-ci

llvm-ci commented Oct 1, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder sanitizer-aarch64-linux-bootstrap-msan running on sanitizer-buildbot9 while building clang,llvm at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/94/builds/21627

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using ld.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using ld.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
-- Testing: 104248 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.
FAIL: lld :: COFF/gfids-icf.s (101225 of 104248)
******************** TEST 'lld :: COFF/gfids-icf.s' FAILED ********************
Exit Code: -6

Command Output (stdout):
--
# RUN: at line 2
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llvm-mc -triple x86_64-windows-msvc /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/COFF/gfids-icf.s -filetype=obj -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/COFF/Output/gfids-icf.s.tmp.obj
# executed command: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llvm-mc -triple x86_64-windows-msvc /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/COFF/gfids-icf.s -filetype=obj -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/COFF/Output/gfids-icf.s.tmp.obj
# note: command had no output on stdout or stderr
# RUN: at line 3
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/COFF/Output/gfids-icf.s.tmp.obj -guard:cf,nolongjmp -out:/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/COFF/Output/gfids-icf.s.tmp.exe -opt:icf -entry:main
# executed command: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/COFF/Output/gfids-icf.s.tmp.obj -guard:cf,nolongjmp -out:/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/COFF/Output/gfids-icf.s.tmp.exe -opt:icf -entry:main
# .---command stderr------------
# | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
# | lld-link: warning: '_load_config_used' is misaligned (expected alignment to be 8 bytes, got 1 instead)
# |  #0 0x0000ace89aa9ec70 ___interceptor_backtrace /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/../sanitizer_common/sanitizer_common_interceptors.inc:4617:13
# |  #1 0x0000ace89acb53fc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:935:7
# |  #2 0x0000ace89acae380 llvm::sys::RunSignalHandlers() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Signals.cpp:109:18
# |  #3 0x0000ace89acb69a4 SignalHandler(int, siginfo_t*, void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:474:38
# |  #4 0x0000ace89aacf160 IsInInterceptorScope /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:78:10
# |  #5 0x0000ace89aacf160 SignalAction(int, void*, void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1167:3
# |  #6 0x0000f000173bba20 (linux-vdso.so.1+0xa20)
# |  #7 0x0000f00016e4a4c0 (/usr/lib/aarch64-linux-gnu/libc.so.6+0xaa4c0)
# |  #8 0x0000ace89aadc788 __msan::SetShadow(void const*, unsigned long, unsigned char) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_poisoning.cpp:217:12
# |  #9 0x0000ace89aadba90 __msan::MsanThread::ClearShadowForThreadStackAndTLS() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:31:7
# | #10 0x0000ace89aadbbc8 malloc_storage /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.h:45:59
# | #11 0x0000ace89aadbbc8 __msan::MsanThread::Init() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:45:3
# | #12 0x0000ace89aa8478c MsanThreadStartFunc(void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1186:22
# | #13 0x0000f00016e2c248 (/usr/lib/aarch64-linux-gnu/libc.so.6+0x8c248)
# | #14 0x0000f00016e96b9c (/usr/lib/aarch64-linux-gnu/libc.so.6+0xf6b9c)
# | MemorySanitizer:DEADLYSIGNAL
# | /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build0/bin/llvm-symbolizer: error: 'linux-vdso.so.1': No such file or directory
# `-----------------------------
# error: command failed with exit status: -6

--

********************
Step 11 (stage2/msan check) failure: stage2/msan check (failure)
...
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using ld.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using ld.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:572: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
-- Testing: 104248 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.
FAIL: lld :: COFF/gfids-icf.s (101225 of 104248)
******************** TEST 'lld :: COFF/gfids-icf.s' FAILED ********************
Exit Code: -6

Command Output (stdout):
--
# RUN: at line 2
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llvm-mc -triple x86_64-windows-msvc /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/COFF/gfids-icf.s -filetype=obj -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/COFF/Output/gfids-icf.s.tmp.obj
# executed command: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llvm-mc -triple x86_64-windows-msvc /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/COFF/gfids-icf.s -filetype=obj -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/COFF/Output/gfids-icf.s.tmp.obj
# note: command had no output on stdout or stderr
# RUN: at line 3
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/COFF/Output/gfids-icf.s.tmp.obj -guard:cf,nolongjmp -out:/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/COFF/Output/gfids-icf.s.tmp.exe -opt:icf -entry:main
# executed command: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/COFF/Output/gfids-icf.s.tmp.obj -guard:cf,nolongjmp -out:/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/COFF/Output/gfids-icf.s.tmp.exe -opt:icf -entry:main
# .---command stderr------------
# | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
# | lld-link: warning: '_load_config_used' is misaligned (expected alignment to be 8 bytes, got 1 instead)
# |  #0 0x0000ace89aa9ec70 ___interceptor_backtrace /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/../sanitizer_common/sanitizer_common_interceptors.inc:4617:13
# |  #1 0x0000ace89acb53fc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:935:7
# |  #2 0x0000ace89acae380 llvm::sys::RunSignalHandlers() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Signals.cpp:109:18
# |  #3 0x0000ace89acb69a4 SignalHandler(int, siginfo_t*, void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:474:38
# |  #4 0x0000ace89aacf160 IsInInterceptorScope /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:78:10
# |  #5 0x0000ace89aacf160 SignalAction(int, void*, void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1167:3
# |  #6 0x0000f000173bba20 (linux-vdso.so.1+0xa20)
# |  #7 0x0000f00016e4a4c0 (/usr/lib/aarch64-linux-gnu/libc.so.6+0xaa4c0)
# |  #8 0x0000ace89aadc788 __msan::SetShadow(void const*, unsigned long, unsigned char) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_poisoning.cpp:217:12
# |  #9 0x0000ace89aadba90 __msan::MsanThread::ClearShadowForThreadStackAndTLS() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:31:7
# | #10 0x0000ace89aadbbc8 malloc_storage /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.h:45:59
# | #11 0x0000ace89aadbbc8 __msan::MsanThread::Init() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:45:3
# | #12 0x0000ace89aa8478c MsanThreadStartFunc(void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1186:22
# | #13 0x0000f00016e2c248 (/usr/lib/aarch64-linux-gnu/libc.so.6+0x8c248)
# | #14 0x0000f00016e96b9c (/usr/lib/aarch64-linux-gnu/libc.so.6+0xf6b9c)
# | MemorySanitizer:DEADLYSIGNAL
# | /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build0/bin/llvm-symbolizer: error: 'linux-vdso.so.1': No such file or directory
# `-----------------------------
# error: command failed with exit status: -6

--

********************

Expertcoderz pushed a commit to Expertcoderz/llvm-project that referenced this pull request Oct 3, 2026
These instructions can be block16 or block32 depending on the target
and scale_sel bits. Block16 is not supported in strict mode.

Re-enable the rest of the instructions in the strict mode but validate
the scale selector.
sunhmy-amd added a commit to ROCm/rocm-systems that referenced this pull request Oct 4, 2026
LCOMPILER-2841 established that all six v_cvt_scale_pk16_*_{fp6,bf6}
opcodes execute on MI450-A0. What A0 lacks is the block16 half of the
scale_sel range, not the opcodes themselves.
llvm/llvm-project#227475 moves them off block16-cvt-scale-insts onto
gfx1250-insts, which gfx1250-strict has, and validates scale_sel instead:
0-3 on strict, 0-7 with block16.

Flip HIP_ENABLE_GFX1250_BLOCK16_BUILTINS to cover both targets so the six
pk16 sites use hardware on strict instead of the software fallback. All 28
pk16 call sites pass scale_sel 0, which is block32 and inside the valid
range on both targets, so the half of the range strict lacks is never
requested.

The macro guards nothing but those six opcodes: all 16 use sites across
amd_hip_ocp_fp.hpp and amd_hip_fp6.h reduce to cvt_scale_pk16_* calls,
with no block16-specific logic. Its name is now misleading, since it does
not gate block16 mode; renaming it to HIP_ENABLE_GFX1250_PK16_SCALE_BUILTINS
to mirror PK8_SCALE is left to a follow-up to keep this diff reviewable.

Depends on a compiler carrying #227475, which is itself stacked on
#227426. Until then gfx1250-strict fails to build with "needs target
feature block16-cvt-scale-insts", so the dependency is enforced at compile
time rather than degrading silently.

Both macro copies are updated. They cannot be merged into one:
amd_hip_ocp_fp.hpp must stay self-contained because hipRTC compiles it
without amd_hip_mx_common.h, which redefines hipRoundMode under RTC.
Verified by attempting the deduplication and observing hipRTC fail.

NOT YET MEASURED on hardware, unlike the pk8 flip in the previous commit.
#227475 is open, based on a branch rather than main, and its scale_sel
validation applies MaxSel=8 to all nine pk8 opcodes where LCOMPILER-2841
expects 0-3 for the three fp4 variants, so its scope may still change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
sunhmy-amd added a commit to ROCm/rocm-systems that referenced this pull request Oct 5, 2026
LCOMPILER-2841 established that all six v_cvt_scale_pk16_*_{fp6,bf6}
opcodes execute on MI450-A0. What A0 lacks is the block16 half of the
scale_sel range, not the opcodes themselves.
llvm/llvm-project#227475 moves them off block16-cvt-scale-insts onto
gfx1250-insts, which gfx1250-strict has, and validates scale_sel instead:
0-3 on strict, 0-7 with block16.

Flip HIP_ENABLE_GFX1250_BLOCK16_BUILTINS to cover both targets so the six
pk16 sites use hardware on strict instead of the software fallback. All 28
pk16 call sites pass scale_sel 0, which is block32 and inside the valid
range on both targets, so the half of the range strict lacks is never
requested.

The macro guards nothing but those six opcodes: all 16 use sites across
amd_hip_ocp_fp.hpp and amd_hip_fp6.h reduce to cvt_scale_pk16_* calls,
with no block16-specific logic. Its name is now misleading, since it does
not gate block16 mode; renaming it to HIP_ENABLE_GFX1250_PK16_SCALE_BUILTINS
to mirror PK8_SCALE is left to a follow-up to keep this diff reviewable.

Depends on a compiler carrying #227475, which is itself stacked on
#227426. Until then gfx1250-strict fails to build with "needs target
feature block16-cvt-scale-insts", so the dependency is enforced at compile
time rather than degrading silently.

Both macro copies are updated. They cannot be merged into one:
amd_hip_ocp_fp.hpp must stay self-contained because hipRTC compiles it
without amd_hip_mx_common.h, which redefines hipRoundMode under RTC.
Verified by attempting the deduplication and observing hipRTC fail.

NOT YET MEASURED on hardware, unlike the pk8 flip in the previous commit.
#227475 is open, based on a branch rather than main, and its scale_sel
validation applies MaxSel=8 to all nine pk8 opcodes where LCOMPILER-2841
expects 0-3 for the three fp4 variants, so its scope may still change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
jichangjichang pushed a commit to ROCm/rocm-libraries that referenced this pull request Oct 6, 2026
Follow-up to [#11777](#11777)
("hipblaslt: add support for gfx1250-strict build").

## Motivation

#11777 made eight source guards that tested only `__gfx1250__` accept
`__gfx1250_strict__` too, because compiling for gfx1250-strict
predefines only the latter. Two of those guards enable the hardware e5m3
conversion. That was valid with the compiler #11777 was tested on
(10.2.0a20260930), but the compiler has since changed.

The hipBLASLt client build for `gfx1250-strict` fails on ROCm nightlies
from 10.2.0a20261004:

```
error: '__builtin_amdgcn_cvt_pk_fp8_f32_e5m3' needs target feature fp8e5m3-insts
```

ROCm/llvm-project
[`7667f52dd687`](ROCm/llvm-project@7667f52dd687)
cherry-picks
[llvm/llvm-project#227861](llvm/llvm-project#227861)
("Disable e5m3 conversions on gfx1250-strict", LCOMPILER-2845). It moves
`FeatureFP8E5M3Insts` out of the common gfx1250 feature set, so
`gfx1250-strict` (v0) no longer has the e5m3 conversion instructions.
`hipblaslt_e5m3.h` and `DataTypes_E5M3.hpp` still enable the hardware
fast path for both `__gfx1250__` and `__gfx1250_strict__`, as #11777
left them.

This PR makes the strict build work again on current nightlies and keeps
it working on older ones.

## Technical Details

`HIP_E5M3_CVT_FAST_PATH` is now enabled for `__gfx1250__` only, in both
copies of the header:

- `projects/hipblaslt/library/include/hipblaslt/hipblaslt_e5m3.h`
- `projects/hipblaslt/tensilelite/include/Tensile/DataTypes_E5M3.hpp`

```diff
-#if (defined(__gfx1250__) || defined(__gfx1250_strict__)) && __HIP_DEVICE_COMPILE__
+// gfx1250-strict (v0) has no e5m3 conversion instructions; it takes the software path.
+#if defined(__gfx1250__) && __HIP_DEVICE_COMPILE__
 #define HIP_E5M3_CVT_FAST_PATH 1
```

- **gfx1250-strict:** takes the existing software conversion. This is
also correct on nightlies up to 20261003. Their compiler still accepted
the e5m3 builtins on strict, but v0 has no such instructions.
- **gfx1250 (v1):** unchanged. It keeps the hardware `v_cvt_pk_fp8_f32`,
and the condition evaluates the same for it as before.
- **The remaining guards from #11777** (`memory_gfx.h`, the
float4/bfloat6/float6 headers, mxDataGenerator) are unchanged. They
still accept both names, and the client and libraries build with them on
every nightly from 20260930 to 20261006.
- **Tensile kernels:** not affected. TensileLite emits no e5m3
conversion, and the strict library tree assembles on 20261004 to
20261006.
- **Not covered:** the other changes in the same cherry-pick
([#227426](llvm/llvm-project#227426),
[#227475](llvm/llvm-project#227475)) re-enable
`v_cvt_scale_pk8/pk16` on strict in their block32 forms. hipBLASLt and
hipSPARSELt do not use these instructions or the HIP FP4/FP6 headers, so
they need no change here.
- **Still not addressed, as listed in #11777:** on a v0 part with
`HSA_DISABLE_GFX12_STRICT` unset or `1`, the device reports `gfx1250`.
The HIP kernels compiled into libhipblaslt and the clients then load
their gfx1250 builds, which keep the hardware e5m3 path. This change
does not alter that. It covers only the `gfx1250-strict` builds.

## Test Plan

- Compile the real client TU (`hipblaslt_init_device.cpp`, flags from
`compile_commands.json`) for `gfx1250` and `gfx1250-strict`, with the
original and the new headers, on every nightly from 20260930 to
20261006.
- Clean builds of hipBLASLt and hipSPARSELt, clients included
(`install.sh -c -a "gfx1250;gfx1250-strict"`), on every nightly from
20260930 to 20261006, then verify the library layout.
- Full test pass on gfx1250 (v1), ROCm 10.2.0a20261005, following
`gfx1250-strict-testing.md`:
  - hipblaslt-test (all, and `*quick*`)
  - FP4 bench and mxf4 smoke
  - hipsparselt-test
  - TensileLite unit, arch-stepping and packaging tests
  - tox `Tests/common`
  - pre-commit (hipBLASLt and repo root configs)

## Test Result

- **Client TU compile:**
- Original headers fail on `gfx1250-strict` for 20261004, 20261005 and
20261006.
- With this change, both targets build on every nightly from 20260930 to
20261006.
- **Clean builds, 20260930 to 20261006:** rc=0 on every nightly.
- hipBLASLt: 400 / 397 / 400 files for `gfx1250` / `gfx1250v0` /
`gfx1250-strict`, layout OK.
  - hipSPARSELt: 131 files in each subtree.
- **gfx1250 (v1), ROCm 10.2.0a20261005:**

| Suite | Result |
|---|---|
| hipblaslt-test all | 67569 passed, 0 failed, 34 skipped |
| hipblaslt-test `*quick*` | 18043 passed |
| FP4 bench / mxf4 smoke | 345 solutions, no nan / passed |
| hipsparselt-test | 165405 / 165405 passed |
| TensileLite unit, arch-stepping, packaging | passed |
| tox `Tests/common` | 9642 passed, 1 failed |
| pre-commit, both configs | passed |

The one tox failure is `gsu_gfx1250` (BF16 GSU, size 512x512x1x32767,
Relu). It is flaky and unrelated to e5m3. Of three reruns on an idle
GPU, two passed and one failed, and the failing kernel differs between
runs.

The tests ran on develop `d116965bed9` plus this change. The branch is
rebased onto develop `9db04770489`. The 3 commits in between touch only
rocALUTION and rocSPARSE.

## Submission Checklist

- [ ] Look over the contributing guidelines at
https://github.com/ROCm/TheRock/blob/main/GOVERNANCE.md#pull-requests.
sunhmy-amd added a commit to ROCm/rocm-systems that referenced this pull request Oct 6, 2026
The macro gates the pk16 fp6/bf6 scaled converts, not block16 mode.
gfx1250-strict has those opcodes (LCOMPILER-2841, llvm/llvm-project#227475)
but not the block16 half of the scale_sel range, so a gate named BLOCK16
enabled under __gfx1250_strict__ reads as a contradiction and invites a
block16-mode call site that would silently alias to scale_sel 0-3 on A0.

Rename to HIP_ENABLE_GFX1250_PK16_SCALE_BUILTINS, matching the existing
HIP_ENABLE_GFX1250_PK8_SCALE_BUILTINS. Identifier rename only; no change
to gating conditions or generated code.

Addresses review feedback from Siu Chi Chan on #12070.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:AMDGPU clang:frontend Language frontend issues, e.g. anything involving "Sema" llvm:ir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants