[libclc] Define 64-bit atomic compare_exchange for NVPTX#22750
Open
zjin-lcf wants to merge 1 commit into
Open
Conversation
The compare_exchange definition guard grouped __NVPTX__ with __SPIR32__ and only emitted atomics for 32-bit types, so 64-bit integer __clc_atomic_compare_exchange was declared (via atomic_decl.inc) but never defined for CUDA, causing "Unresolved extern function '_Z29__clc_atomic_compare_exchange...'" (ptxas fatal) for 64-bit CAS. Match the guard used by the sibling clc_atomic_def.inc (restrict only __SPIR32__ to 32-bit) so both CUDA (NVPTX) and HIP (AMDGPU) get 64-bit compare_exchange definitions. Co-authored-by: Cursor <cursoragent@cursor.com>
bratpiorka
approved these changes
Jul 24, 2026
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
The
compare_exchangedefinition guard inclc_atomic_compare_exchange.incgrouped__NVPTX__together with__SPIR32__and only emitted atomics for 32-bit types. As a result, the 64-bit integer__clc_atomic_compare_exchangewas declared (viaatomic_decl.inc) but never defined for CUDA, producingUnresolved extern function '_Z29__clc_atomic_compare_exchange...'(ptxas fatal) whenever a 64-bit compare-and-swap was used on NVPTX.This changes the guard to match the sibling
clc_atomic_def.inc(restrict only__SPIR32__to 32-bit), so both CUDA (NVPTX) and HIP (AMDGPU) get 64-bitcompare_exchangedefinitions.Test plan
libspirv.bc/libclc.bcand confirmed the 64-bit__spirv_AtomicCompareExchangeforint64(...liiill) anduint64(...miiimm) are now defined in both global (AS1) and local (AS3) address spaces (previously unresolved).local-ht-syclbenchmark (HeCBench) with-fsycl-targets=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_80on an NVIDIA A100 (CUDA 12.8): all four Kmer sizes (21, 33, 55, 77) PASSED.