* Re: [RFA] choosing __platform_wait_t on targets without lock-free 64 atomics
[not found] <CAMmuTO9F_RuHaP6cot5=b59uhH+-C8N7TdoZJBapSHsmvZqXdw@mail.gmail.com>
@ 2023-01-06 0:22 ` Jonathan Wakely
2023-01-12 1:27 ` Thomas Rodgers
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2023-01-06 0:22 UTC (permalink / raw)
To: Iain Sandoe; +Cc: libstdc++, gcc-patches, Thomas Rodgers
How about this?
I don't think we should worry about targets without atomic int, so don't
bother using types smaller than int.
-- >8 --
For non-futex targets the __platform_wait_t type is currently uint64_t,
but that requires a lock in libatomic for some 32-bit targets. We don't
really need a 64-bit type, so use unsigned long if that is lock-free,
and int otherwise. This should mean it's lock-free on a wider set of
targets.
libstdc++-v3/ChangeLog:
* include/bits/atomic_wait.h (__detail::__platform_wait_t):
Define as unsigned long if always lock-free, and unsigned int
otherwise.
---
libstdc++-v3/include/bits/atomic_wait.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h
index bd1ed56d157..46f39f10cbc 100644
--- a/libstdc++-v3/include/bits/atomic_wait.h
+++ b/libstdc++-v3/include/bits/atomic_wait.h
@@ -64,7 +64,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// and __platform_notify() if there is a more efficient primitive supported
// by the platform (e.g. __ulock_wait()/__ulock_wake()) which is better than
// a mutex/condvar based wait.
- using __platform_wait_t = uint64_t;
+# if ATOMIC_LONG_LOCK_FREE == 2
+ using __platform_wait_t = unsigned long;
+# else
+ using __platform_wait_t = unsigned int;
+# endif
inline constexpr size_t __platform_wait_alignment
= __alignof__(__platform_wait_t);
#endif
--
2.39.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] choosing __platform_wait_t on targets without lock-free 64 atomics
2023-01-06 0:22 ` [RFA] choosing __platform_wait_t on targets without lock-free 64 atomics Jonathan Wakely
@ 2023-01-12 1:27 ` Thomas Rodgers
2023-01-12 11:01 ` Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Rodgers @ 2023-01-12 1:27 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Iain Sandoe, libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1670 bytes --]
I agree with this change.
On Thu, Jan 5, 2023 at 4:22 PM Jonathan Wakely <jwakely@redhat.com> wrote:
> How about this?
>
> I don't think we should worry about targets without atomic int, so don't
> bother using types smaller than int.
>
>
> -- >8 --
>
> For non-futex targets the __platform_wait_t type is currently uint64_t,
> but that requires a lock in libatomic for some 32-bit targets. We don't
> really need a 64-bit type, so use unsigned long if that is lock-free,
> and int otherwise. This should mean it's lock-free on a wider set of
> targets.
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/atomic_wait.h (__detail::__platform_wait_t):
> Define as unsigned long if always lock-free, and unsigned int
> otherwise.
> ---
> libstdc++-v3/include/bits/atomic_wait.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/include/bits/atomic_wait.h
> b/libstdc++-v3/include/bits/atomic_wait.h
> index bd1ed56d157..46f39f10cbc 100644
> --- a/libstdc++-v3/include/bits/atomic_wait.h
> +++ b/libstdc++-v3/include/bits/atomic_wait.h
> @@ -64,7 +64,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> // and __platform_notify() if there is a more efficient primitive
> supported
> // by the platform (e.g. __ulock_wait()/__ulock_wake()) which is better
> than
> // a mutex/condvar based wait.
> - using __platform_wait_t = uint64_t;
> +# if ATOMIC_LONG_LOCK_FREE == 2
> + using __platform_wait_t = unsigned long;
> +# else
> + using __platform_wait_t = unsigned int;
> +# endif
> inline constexpr size_t __platform_wait_alignment
> = __alignof__(__platform_wait_t);
> #endif
> --
> 2.39.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] choosing __platform_wait_t on targets without lock-free 64 atomics
2023-01-12 1:27 ` Thomas Rodgers
@ 2023-01-12 11:01 ` Jonathan Wakely
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2023-01-12 11:01 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: Iain Sandoe, libstdc++, gcc-patches
On Thu, 12 Jan 2023 at 01:27, Thomas Rodgers wrote:
>
> I agree with this change.
Thanks, pushed to trunk.
>
> On Thu, Jan 5, 2023 at 4:22 PM Jonathan Wakely <jwakely@redhat.com> wrote:
>>
>> How about this?
>>
>> I don't think we should worry about targets without atomic int, so don't
>> bother using types smaller than int.
>>
>>
>> -- >8 --
>>
>> For non-futex targets the __platform_wait_t type is currently uint64_t,
>> but that requires a lock in libatomic for some 32-bit targets. We don't
>> really need a 64-bit type, so use unsigned long if that is lock-free,
>> and int otherwise. This should mean it's lock-free on a wider set of
>> targets.
>>
>> libstdc++-v3/ChangeLog:
>>
>> * include/bits/atomic_wait.h (__detail::__platform_wait_t):
>> Define as unsigned long if always lock-free, and unsigned int
>> otherwise.
>> ---
>> libstdc++-v3/include/bits/atomic_wait.h | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h
>> index bd1ed56d157..46f39f10cbc 100644
>> --- a/libstdc++-v3/include/bits/atomic_wait.h
>> +++ b/libstdc++-v3/include/bits/atomic_wait.h
>> @@ -64,7 +64,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>> // and __platform_notify() if there is a more efficient primitive supported
>> // by the platform (e.g. __ulock_wait()/__ulock_wake()) which is better than
>> // a mutex/condvar based wait.
>> - using __platform_wait_t = uint64_t;
>> +# if ATOMIC_LONG_LOCK_FREE == 2
>> + using __platform_wait_t = unsigned long;
>> +# else
>> + using __platform_wait_t = unsigned int;
>> +# endif
>> inline constexpr size_t __platform_wait_alignment
>> = __alignof__(__platform_wait_t);
>> #endif
>> --
>> 2.39.0
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-12 11:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAMmuTO9F_RuHaP6cot5=b59uhH+-C8N7TdoZJBapSHsmvZqXdw@mail.gmail.com>
2023-01-06 0:22 ` [RFA] choosing __platform_wait_t on targets without lock-free 64 atomics Jonathan Wakely
2023-01-12 1:27 ` Thomas Rodgers
2023-01-12 11:01 ` Jonathan Wakely
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).