Skip to content

[libclc] Define 64-bit atomic compare_exchange for NVPTX#22750

Open
zjin-lcf wants to merge 1 commit into
intel:syclfrom
zjin-lcf:fix-nvptx-64bit-atomic-compare-exchange
Open

[libclc] Define 64-bit atomic compare_exchange for NVPTX#22750
zjin-lcf wants to merge 1 commit into
intel:syclfrom
zjin-lcf:fix-nvptx-64bit-atomic-compare-exchange

Conversation

@zjin-lcf

Copy link
Copy Markdown
Contributor

Summary

The compare_exchange definition guard in clc_atomic_compare_exchange.inc grouped __NVPTX__ together with __SPIR32__ and only emitted atomics for 32-bit types. As a result, the 64-bit integer __clc_atomic_compare_exchange was declared (via atomic_decl.inc) but never defined for CUDA, producing Unresolved 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-bit compare_exchange definitions.

Test plan

  • Rebuilt the NVPTX libspirv.bc/libclc.bc and confirmed the 64-bit __spirv_AtomicCompareExchange for int64 (...liiill) and uint64 (...miiimm) are now defined in both global (AS1) and local (AS3) address spaces (previously unresolved).
  • Built and ran the local-ht-sycl benchmark (HeCBench) with -fsycl-targets=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_80 on an NVIDIA A100 (CUDA 12.8): all four Kmer sizes (21, 33, 55, 77) PASSED.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants