* libstdc++: Minor codegen improvement for atomic wait spinloop
@ 2022-07-06 1:04 Thomas Rodgers
2022-07-06 20:56 ` Jonathan Wakely
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Rodgers @ 2022-07-06 1:04 UTC (permalink / raw)
To: libstdc++, gcc Patches
[-- Attachment #1: Type: text/plain, Size: 203 bytes --]
This patch merges the spin loops in the atomic wait implementation which is
a
minor codegen improvement.
libstdc++-v3/ChangeLog:
* include/bits/atomic_wait.h (__atomic_spin): Merge spin loops.
[-- Attachment #2: 0001-libstdc-Minor-codegen-improvement-for-atomic-wait-sp.patch --]
[-- Type: application/octet-stream, Size: 1726 bytes --]
From 5bd6b6f0e7d630c597900e82fe04bb2bc7a1e3d4 Mon Sep 17 00:00:00 2001
From: Thomas Rodgers <trodgers@redhat.com>
Date: Tue, 5 Jul 2022 17:42:42 -0700
Subject: [PATCH] libstdc++: Minor codegen improvement for atomic wait spinloop
This patch merges the spin loops in the atomic wait implementation which is a
minor codegen improvement.
libstdc++-v3/ChangeLog:
* include/bits/atomic_wait.h (__atomic_spin): Merge spin loops.
---
libstdc++-v3/include/bits/atomic_wait.h | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h
index 125b1cad886..a6d55d3af8a 100644
--- a/libstdc++-v3/include/bits/atomic_wait.h
+++ b/libstdc++-v3/include/bits/atomic_wait.h
@@ -142,8 +142,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
}
- constexpr auto __atomic_spin_count_1 = 12;
- constexpr auto __atomic_spin_count_2 = 4;
+ constexpr auto __atomic_spin_count_relax = 12;
+ constexpr auto __atomic_spin_count = 16;
struct __default_spin_policy
{
@@ -157,18 +157,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool
__atomic_spin(_Pred& __pred, _Spin __spin = _Spin{ }) noexcept
{
- for (auto __i = 0; __i < __atomic_spin_count_1; ++__i)
+ for (auto __i = 0; __i < __atomic_spin_count; ++__i)
{
if (__pred())
return true;
- __detail::__thread_relax();
- }
- for (auto __i = 0; __i < __atomic_spin_count_2; ++__i)
- {
- if (__pred())
- return true;
- __detail::__thread_yield();
+ if (__i < __atomic_spin_count_relax)
+ __detail::__thread_relax();
+ else
+ __detail::__thread_yield();
}
while (__spin())
--
2.36.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: libstdc++: Minor codegen improvement for atomic wait spinloop
2022-07-06 1:04 libstdc++: Minor codegen improvement for atomic wait spinloop Thomas Rodgers
@ 2022-07-06 20:56 ` Jonathan Wakely
2022-07-06 21:41 ` Thomas Rodgers
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2022-07-06 20:56 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: libstdc++, gcc Patches
On Wed, 6 Jul 2022 at 02:05, Thomas Rodgers via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> This patch merges the spin loops in the atomic wait implementation which is
> a
> minor codegen improvement.
>
> libstdc++-v3/ChangeLog:
> * include/bits/atomic_wait.h (__atomic_spin): Merge spin loops.
OK, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: libstdc++: Minor codegen improvement for atomic wait spinloop
2022-07-06 20:56 ` Jonathan Wakely
@ 2022-07-06 21:41 ` Thomas Rodgers
2022-07-07 9:30 ` Jonathan Wakely
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Rodgers @ 2022-07-06 21:41 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: libstdc++, gcc Patches
Ok for trunk? backport?
On Wed, Jul 6, 2022 at 1:56 PM Jonathan Wakely <jwakely@redhat.com> wrote:
> On Wed, 6 Jul 2022 at 02:05, Thomas Rodgers via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
> >
> > This patch merges the spin loops in the atomic wait implementation which
> is
> > a
> > minor codegen improvement.
> >
> > libstdc++-v3/ChangeLog:
> > * include/bits/atomic_wait.h (__atomic_spin): Merge spin loops.
>
> OK, thanks.
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: libstdc++: Minor codegen improvement for atomic wait spinloop
2022-07-06 21:41 ` Thomas Rodgers
@ 2022-07-07 9:30 ` Jonathan Wakely
2022-07-26 22:42 ` Thomas Rodgers
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2022-07-07 9:30 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: libstdc++, gcc Patches
On Wed, 6 Jul 2022 at 22:42, Thomas Rodgers <trodgers@redhat.com> wrote:
>
> Ok for trunk? backport?
Yes, for all branches that have the atomic wait code.
>
> On Wed, Jul 6, 2022 at 1:56 PM Jonathan Wakely <jwakely@redhat.com> wrote:
>>
>> On Wed, 6 Jul 2022 at 02:05, Thomas Rodgers via Libstdc++
>> <libstdc++@gcc.gnu.org> wrote:
>> >
>> > This patch merges the spin loops in the atomic wait implementation which is
>> > a
>> > minor codegen improvement.
>> >
>> > libstdc++-v3/ChangeLog:
>> > * include/bits/atomic_wait.h (__atomic_spin): Merge spin loops.
>>
>> OK, thanks.
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: libstdc++: Minor codegen improvement for atomic wait spinloop
2022-07-07 9:30 ` Jonathan Wakely
@ 2022-07-26 22:42 ` Thomas Rodgers
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Rodgers @ 2022-07-26 22:42 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: libstdc++, gcc Patches
This is now committed to trunk, backported to releases/gcc-12 and
releases/gcc-11.
Apologies for the delay, it's been a wild couple of weeks.
Tom.
On Thu, Jul 7, 2022 at 2:31 AM Jonathan Wakely <jwakely@redhat.com> wrote:
> On Wed, 6 Jul 2022 at 22:42, Thomas Rodgers <trodgers@redhat.com> wrote:
> >
> > Ok for trunk? backport?
>
> Yes, for all branches that have the atomic wait code.
>
>
> >
> > On Wed, Jul 6, 2022 at 1:56 PM Jonathan Wakely <jwakely@redhat.com>
> wrote:
> >>
> >> On Wed, 6 Jul 2022 at 02:05, Thomas Rodgers via Libstdc++
> >> <libstdc++@gcc.gnu.org> wrote:
> >> >
> >> > This patch merges the spin loops in the atomic wait implementation
> which is
> >> > a
> >> > minor codegen improvement.
> >> >
> >> > libstdc++-v3/ChangeLog:
> >> > * include/bits/atomic_wait.h (__atomic_spin): Merge spin
> loops.
> >>
> >> OK, thanks.
> >>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-26 22:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-06 1:04 libstdc++: Minor codegen improvement for atomic wait spinloop Thomas Rodgers
2022-07-06 20:56 ` Jonathan Wakely
2022-07-06 21:41 ` Thomas Rodgers
2022-07-07 9:30 ` Jonathan Wakely
2022-07-26 22:42 ` Thomas Rodgers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).