Skip to content

Fix atomic ops for Apple clang/libc++ compatibility - #5

Open
alisterburt wants to merge 1 commit into
mainfrom
atomic-fix
Open

Fix atomic ops for Apple clang/libc++ compatibility#5
alisterburt wants to merge 1 commit into
mainfrom
atomic-fix

Conversation

@alisterburt

@alisterburt alisterburt commented Dec 20, 2025

Copy link
Copy Markdown
Contributor

LLM spiel:

  • Apple's libc++ doesn't support std::atomic<float/double>::fetch_add (C++20 floating-point atomics are incomplete)
  • Replace std::atomic-based implementation with OpenMP atomic pragmas, which compile to equivalent hardware instructions.
  • Add type trait to deduce real type from complex types, eliminating need for explicit template arguments at call sites.

@dtegunov I ran into issues building this on my work laptop - claude doesn't think there are perf implications to this but a review before merge would be good

Apple's libc++ doesn't support std::atomic<float/double>::fetch_add
(C++20 floating-point atomics are incomplete). Replace std::atomic-based
implementation with OpenMP atomic pragmas, which compile to equivalent
hardware instructions. Add type trait to deduce real type from complex types,
eliminating need for explicit template arguments at call sites.
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.

1 participant