[flang] [llvm] [flang-rt] Runtime implementation of extended intrinsic function SECNDS() (PR #152021)
Eugene Epshteyn via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 5 13:24:19 PDT 2025
eugeneepshteyn wrote:
> I think that you can replace that loop with just a single compare & swap if zero. Only the first thread to ever execute it would succeed, and all later ones would fail and return the first thread's value.
The other threads still need to wait for the initialization to happen, so I think the loop is unavoidable. (In early implementation, I didn't have a loop and threads came in quicker than the time value could be computed.) Also, I decided to put even `compare_exchange_strong()` inside the loop, because I read somewhere that even it can still fail under some conditions (for example, see section in https://dev.to/pauljlucas/advanced-thread-safety-in-c-3ap5).
https://github.com/llvm/llvm-project/pull/152021
More information about the llvm-commits
mailing list