[10/10] libstdc++: Optimise std::latch::arrive_and_wait
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
fail
|
Test failed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
fail
|
Test failed
|
Commit Message
We don't need to wait if we know the counter has reached zero.
libstdc++-v3/ChangeLog:
* include/std/latch (latch::arrive_and_wait): Optimise.
---
This one's commented out for now, but sending for review anyway.
libstdc++-v3/include/std/latch | 12 ++++++++++++
1 file changed, 12 insertions(+)
@@ -101,8 +101,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_ALWAYS_INLINE void
arrive_and_wait(ptrdiff_t __update = 1) noexcept
{
+#if 0
+ __glibcxx_assert(__update >= 0 && __update <= max());
+ auto const __old = __atomic_impl::fetch_sub(&_M_a, __update,
+ memory_order::release);
+ if (std::cmp_equal(__old, __update))
+ __atomic_impl::notify_all(&_M_a);
+ else if (std::cmp_greater(__old, __update))
+ wait();
+ else
+ __glibcxx_assert(std::cmp_less_equal(__update, __old));
+#else
count_down(__update);
wait();
+#endif
}
private: