Are relaxed threadgroup atomics (atomic_fetch_add) officially supported on the Metal 4.0 feature set, or only 4.1?

I'm writing GPU compute kernels (parallel prefix-sum and histogram) that rely on threadgroup-address-space atomics specifically atomic_fetch_add_explicit on a threadgroup atomic_uint, with memory_order_relaxed.

Setup:

  • Device: Apple M5, macOS 26.5
  • Toolchain reports MSL 4.0 / AIR 2.8 (i.e. the "Metal 4.0" feature level)
  • Note: I'm generating AIR (Apple IR) directly rather than emitting MSL source this is through a custom compute backend (Julia's Metal.jl), not the standard MSL front end.

What I observe: These threadgroup atomics compile and produce correct results, and give a meaningful speedup over a non-atomic (scan-based) fallback. I've validated correctness across a 256-bin histogram and a full multi-pass radix sort no mismatches.

The question:

Some capability checks gate threadgroup atomic support behind Metal 4.1, and my device reports 4.0 yet they clearly work. So:

  1. Are relaxed integer threadgroup atomics (atomic_fetch_add on threadgroup atomic_uint, relaxed ordering) officially supported on the Metal 4.0 feature set for current Apple Silicon, or is this unsupported behavior that happens to work?
  2. Is there a specific MSL version or GPU family that is the true minimum for these operations?
  3. Does the answer differ at the AIR / feature-set level (what I'm targeting) vs. the MSL front end, given I'm feeding AIR to the compiler directly?

I ask because a downstream library is (reasonably) hesitant to enable this path unless it's officially supported rather than relying on undefined behavior. Any authoritative guidance or a pointer to the relevant feature-set/GPU-family documentation would be hugely appreciated.

Thanks!

Answered by mahalis0 in 901172022

Threadgroup operations with memory_order_relaxed for atomic_uint values have been available for a very long time—nothing changed for those that I’m aware of in Metal 4.

What’s new in 4.1 in this area is additional memory-order options (see section 6.16.1 in the MSL spec) and threadgroup add/sub for atomic_float values (see the end of section 6.16.4, right before Table 6.27). If you’re not using either of those, which it sounds like you aren’t, then your min-spec for this stuff is probably somewhere around Metal 1.

Threadgroup operations with memory_order_relaxed for atomic_uint values have been available for a very long time—nothing changed for those that I’m aware of in Metal 4.

What’s new in 4.1 in this area is additional memory-order options (see section 6.16.1 in the MSL spec) and threadgroup add/sub for atomic_float values (see the end of section 6.16.4, right before Table 6.27). If you’re not using either of those, which it sounds like you aren’t, then your min-spec for this stuff is probably somewhere around Metal 1.

Are relaxed threadgroup atomics (atomic_fetch_add) officially supported on the Metal 4.0 feature set, or only 4.1?
 
 
Q