[libc-commits] [libc] [libc] add a simple TTAS spin lock (PR #98846)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Sun Jul 14 17:08:23 PDT 2024


https://github.com/jhuber6 commented:

I've found using `fetch_or` and `fetch_and` works better on the GPU targets. That is,
```
atomic<int32_t> lock{};

bool has_lock = !lock.fetch_or(1, cpp::MemoryOrder::Acquire);
...
lock.fetch_and(0, cpp::MemoryOrder::Release);
```
Any clue how this performs on non-GPU targets?

https://github.com/llvm/llvm-project/pull/98846


More information about the libc-commits mailing list