Skip to content

Replace deprecated __hip_atomic_* builtins with __scoped_atomic_* equivalents#4902

Open
srinivamd wants to merge 1 commit into
developfrom
fix/replace-deprecated-hip-atomics
Open

Replace deprecated __hip_atomic_* builtins with __scoped_atomic_* equivalents#4902
srinivamd wants to merge 1 commit into
developfrom
fix/replace-deprecated-hip-atomics

Conversation

@srinivamd
Copy link
Copy Markdown
Contributor

@srinivamd srinivamd commented May 21, 2026

Summary

Replace deprecated __hip_atomic_load and __hip_atomic_compare_exchange_strong builtins in atomic.hpp with their non-deprecated equivalents __scoped_atomic_load_n and __scoped_atomic_compare_exchange, using __MEMORY_SCOPE_DEVICE instead of __HIP_MEMORY_SCOPE_AGENT.

Root cause: ROCm 7.14.0 HIP compiler deprecated the __hip_atomic_* builtins. Because MIGraphX JIT-compiles GPU kernels with -Werror,-Whip-deprecated-builtins, the deprecation warnings become hard errors, causing scatter_mul (and any other operation using atomic CAS) to fail at runtime. This is a regression from ROCm 7.13.0 (PASS) to 7.14.0 (FAIL).

Changes:

  • __hip_atomic_load__scoped_atomic_load_n
  • __hip_atomic_compare_exchange_strong__scoped_atomic_compare_exchange
  • __HIP_MEMORY_SCOPE_AGENT__MEMORY_SCOPE_DEVICE
  • Added #if __has_builtin(__scoped_atomic_load_n) / #else guard for backward compatibility with ROCm 7.13.x and earlier

Fixes: ROCM-24855test_verify_general abort on test_scatter_elements_mul_duplicate_index

Test plan

  • ctest -R test_verify_general passes on ROCm 7.14.0 (MI300/MI350)
  • ctest -R test_verify_general still passes on ROCm 7.13.0 (backward compat)
  • No new compiler warnings from atomic.hpp

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates MIGraphX GPU kernel atomics to avoid ROCm 7.14 HIP deprecation build failures by switching from deprecated __hip_atomic_* builtins to __scoped_atomic_* equivalents, with a fallback path for older toolchains.

Changes:

  • Replace __hip_atomic_load with __scoped_atomic_load_n (device scope) when available.
  • Replace __hip_atomic_compare_exchange_strong with __scoped_atomic_compare_exchange (device scope) when available.
  • Add a compile-time builtin-availability guard to preserve backward compatibility.

MIGRAPHX_ATOMIC_CAS_WARNING();
using storage = conditional_t<sizeof(T) == 4, uint32_t, uint64_t>;
storage* address = reinterpret_cast<storage*>(&x);
#if __has_builtin(__scoped_atomic_load_n)
Copy link
Copy Markdown
Collaborator

@CharlieL7 CharlieL7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine, where is the documentation for this deprecation and information about these macros?

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.

3 participants