ThreadStore: guard AMDGCN inline asm with __HIP_PLATFORM_SPIRV__#1
Merged
ThreadStore: guard AMDGCN inline asm with __HIP_PLATFORM_SPIRV__#1
Conversation
The AMDGCN inline-asm specializations (flat_store_*, s_waitcnt) in HIPCUB_ASM_THREAD_STORE are meaningless on non-AMD targets. On SPIR-V targets (chipStar) they survive into the IR and crash SPIRV-LLVM-Translator at SPVWriter.cpp:5598 with a null-deref on InlineAsm call sites when SPV_INTEL_inline_assembly is not in the translator's extension allow-list. Gate the asm block on !defined(__HIP_PLATFORM_SPIRV__) so SPIR-V targets fall back to the existing __builtin_memcpy implementation of AsmThreadStore. AMD behavior is unchanged. Unblocks test_hipcub_thread under chipStar (all 100 gtest cases now pass on Arc A770 / Level Zero).
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
AMDGCN inline-asm specializations in
HIPCUB_ASM_THREAD_STORE(flat_store_*,s_waitcnt) are meaningless on non-AMD targets. On SPIR-V targets (chipStar) they survive into the IR and crash SPIRV-LLVM-Translator atSPVWriter.cpp:5598with a null-deref onInlineAsmcall sites whenSPV_INTEL_inline_assemblyis not in the translator's extension allow-list.One-line fix: gate the existing
#if HIPCUB_THREAD_STORE_USE_CACHE_MODIFIERS == 1block on!defined(__HIP_PLATFORM_SPIRV__)so SPIR-V falls back to the already-present__builtin_memcpy-basedAsmThreadStore.Behavior
AsmThreadStoreresolves to the generic__builtin_memcpyfallback instead of emittingflat_store_dword ... glcContext
This is the library-side fix that complements chipStar PR CHIP-SPV/chipStar#1236, which strips AMDGCN inline asm in a chipStar LLVM pass as a defense-in-depth backstop. This PR is the right long-term fix for hipCUB specifically.
Test plan
test_hipcub_threadbuilds and all 100 gtest cases PASS on Arc A770 / Level Zero (chipStar)