Aarch64 does indeed have a proper atomic max, but even on x86-64 you can get a wait-free atomic max as long as you only need to support integers up to 64. In that case you can simply do a `lock or` with 1 In most cases it's even better to just store a maximum per thread separately and loop over all threads once to compute the current maximum if you really need it.
From Rust to reality: The hidden journey of fetch_max
11–20 of 62 posts
Re: From Rust to reality: The hidden journey of fetch_max
#12Re: From Rust to reality: The hidden journey of fetch_max
#13Re: From Rust to reality: The hidden journey of fetch_max
#14Re: From Rust to reality: The hidden journey of fetch_max
#15Was this compiled at O0? The generated code looks unnecessarily long-winded - at the very least I would expect the match jump table to get culled to only the Relaxed implementation.
RTFA
Re: From Rust to reality: The hidden journey of fetch_max
#16Re: From Rust to reality: The hidden journey of fetch_max
#17Re: From Rust to reality: The hidden journey of fetch_max
#18Hi, author here. My superpower is spending unreasonable amounts of time researching things with no practical purpose. Occasionally I blog about it - as a warning to others.
I liked the article. I saw your PS that we added it to the working draft for c++26, we also made it part of OpenMP as of 5.0 I think. It’s sometimes a hardware atomic like on arm, but what made the case was that it’s common to implement it sub-optimally even on x86 or LL-SC architectures. Often the generic cas loop gets used, like in your lambda example, but it lacks an early cutout since you can ignore any input val…
Re: From Rust to reality: The hidden journey of fetch_max
#19https://doi.org/10.1145/2486159.2486189 https://jshun.csail.mit.edu/contention.pdf
Re: From Rust to reality: The hidden journey of fetch_max
#20Did he get the job?