Re:A collection of lock-free data structures written in stan...
by ot on Wednesday May 10, 2023 @07:22PM
(#35894940)
> Not sure if it has changed since.
It hasn't, Clang/GCC emit a cmpxchg16b only if you opt-in with `-mcx16`, which changes the ABI.
Re:A collection of lock-free data structures written in stan...
by moonchild on Wednesday May 10, 2023 @07:30PM
(#35895035)
128-bit aligned loads and stores are guaranteed to be atomic on all intel and amd cpus that support avx. And if your cpu doesn't support avx, it probably doesn't have enough cores that the performance of concurrent data structures matters that much.
So a 128 bit std::atomic on intel was not only suboptimal as the compiler had to use 2cas for load and stores as well, but actually wrong as an atomic load from readonly memory would fault. So at some point the ABI was changed to use the spinlock pool. Not sure if it has changed since.
If you do it "by hand", when you only need a 2cas, a 128 bit load that is not atomic is fine as any tearing will be detected by the CAS and 'fixed', but it is hard for the compiler to optimize generic code.
[1] which actually does full 128bit compare and swap, you are probably confusing it with the Itanium variant.