Re: [PATCH 0/3] Uncontroversial improvements to C++20 wait-related implementation

2021-03-23 Thread Thiago Macieira via Gcc-patches
On Tuesday, 23 March 2021 08:39:43 PDT Thomas Rodgers wrote: > I will be submitting a new patch for the > atomic.wait/barrier/latch/semaphore functionality a bit later today that > subsumes the changes to atomic_wait and latch, and includes the changes > to barrier. Thanks, Thomas Is that meant

[PATCH 0/3] Uncontroversial improvements to C++20 wait-related implementation

2021-03-22 Thread Thiago Macieira via Gcc-patches
> Discussion at: > https://gcc.gnu.org/pipermail/libstdc++/2021-February/052043.html > > This patch set includes the uncontroversial parts that improve > performance but don't otherwise change ABI. > > Please note we still need to decide on how to deal with the future ABI > break. > > Thiago

[PATCH 2/3] std::latch: reduce internal implementation from ptrdiff_t to int

2021-03-05 Thread Thiago Macieira via Gcc-patches
ints can be used as futex on Linux. ptrdiff_t on 64-bit Linux can't. libstdc++-v3/ChangeLog: * include/std/latch: Use int instead of ptrdiff_t --- libstdc++-v3/include/std/latch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/latch

[PATCH 3/3] barrier: optimise by not having the hasher in a loop

2021-03-05 Thread Thiago Macieira via Gcc-patches
Our thread's ID does not change so we don't have to get it every time and hash it every time. libstdc++-v3/ChangeLog: * include/std/barrier(arrive): move hasher one level up in the stack. --- libstdc++-v3/include/std/barrier | 10 +- 1 file changed, 5 insertions(+), 5

[PATCH 0/3] Uncontroversial improvements to C++20 wait-related implementation

2021-03-05 Thread Thiago Macieira via Gcc-patches
Discussion at: https://gcc.gnu.org/pipermail/libstdc++/2021-February/052043.html This patch set includes the uncontroversial parts that improve performance but don't otherwise change ABI. Please note we still need to decide on how to deal with the future ABI break. Thiago Macieira (3): Atomic

[PATCH 1/3] Atomic __platform_wait: accept any 32-bit type, not just int

2021-03-05 Thread Thiago Macieira via Gcc-patches
The kernel doesn't care what we store in those 32 bits, only that they are comparable. This commit adds: * pointers and long on 32-bit architectures * unsigned * untyped enums and typed enums on int & unsigned int * float We're not using FUTEX_OP anywhere today. The kernel reserves 4 bits for

Re: [PATCH 2/5] Atomic __platform_wait: accept any 32-bit type, not just int

2021-03-03 Thread Thiago Macieira via Gcc-patches
On Wednesday, 3 March 2021 08:21:51 PST Jonathan Wakely wrote: > >>- = is_same_v, __platform_wait_t>; > >>+ = is_scalar_v> && sizeof(_Tp) == > >>sizeof(__platform_wait_t) > Oh, except that is_scalar is surprisingly expensive to instantiate > (its defined in a really expensive way) and

Re: [PATCH 1/5] std::latch: reduce internal implementation from ptrdiff_t to int

2021-03-03 Thread Thiago Macieira via Gcc-patches
On Wednesday, 3 March 2021 06:34:26 PST Jonathan Wakely wrote: > On 26/02/21 07:59 -0800, Thiago Macieira via Libstdc++ wrote: > >ints can be used as futex on Linux. ptrdiff_t on 64-bit Linux can't. > > Yes, we should do this for GCC 11. Want me to re-submit this one alone, with the "alignas(4)"

Re: [PATCH 4/5] barrier: use int instead of unsigned char for the phase state

2021-03-01 Thread Thiago Macieira via Gcc-patches
On Monday, 1 March 2021 14:31:09 PST Ville Voutilainen wrote: > On Tue, 2 Mar 2021 at 00:21, Thiago Macieira wrote: > > But the code I posted, if people are careful to use write like I did, > > would > > allow us to have the experimental "we're not sure this is right" > > implementation of

Re: [PATCH 4/5] barrier: use int instead of unsigned char for the phase state

2021-03-01 Thread Thiago Macieira via Gcc-patches
On Monday, 1 March 2021 14:04:34 PST Ville Voutilainen wrote: > Well, this would be different. What I'm suggesting is not quite that; > for any *new* facility, we'd make sure > that its draft macro and the final IS macro are different, but the > minimum value is the first draft version, > not

Re: [PATCH 4/5] barrier: use int instead of unsigned char for the phase state

2021-03-01 Thread Thiago Macieira via Gcc-patches
On Monday, 1 March 2021 12:35:05 PST Ville Voutilainen wrote: > I can't make the above code work, in any reasonable manner, because > it's doing feature detection incorrectly. :) > What I can imagine doing, however, is this: > > 1) a published IS always bumps feature-macro values (this won't help

Re: [PATCH 4/5] barrier: use int instead of unsigned char for the phase state

2021-03-01 Thread Thiago Macieira via Gcc-patches
On Monday, 1 March 2021 10:12:35 PST Ville Voutilainen wrote: > I do have a question about the intent/concern here, regardless of what > your patch technically > does. The ABI break _is_ your concern, and the "heisenbugs" you were > worried about would > in fact be caused by the ABI break? So if

Re: [PATCH 4/5] barrier: use int instead of unsigned char for the phase state

2021-03-01 Thread Thiago Macieira via Gcc-patches
On Monday, 1 March 2021 09:38:58 PST Thomas Rodgers wrote: > > And _M_phase, despite being non-atomic, is never accessed without the > > atomic_ref, aside from the constructor. Both arrive() and wait() start > > off by > > creating the atomic_ref. > > If it's non-atomic, then how is wait()

Re: [PATCH 4/5] barrier: use int instead of unsigned char for the phase state

2021-03-01 Thread Thiago Macieira via Gcc-patches
On Sunday, 28 February 2021 07:05:47 PST Hans-Peter Nilsson wrote: > On Fri, 26 Feb 2021, Thiago Macieira via Gcc-patches wrote: > > ints can be used in futexes. chars can't. > > Shouldn't that be an atomic type instead of a bare int then? There are a couple of atomic_ref

Re: [PATCH 1/5] std::latch: reduce internal implementation from ptrdiff_t to int

2021-02-26 Thread Thiago Macieira via Gcc-patches
On Friday, 26 February 2021 11:31:00 PST Andreas Schwab wrote: > On Feb 26 2021, Thiago Macieira wrote: > > On Friday, 26 February 2021 10:14:42 PST Andreas Schwab wrote: > >> On Feb 26 2021, Thiago Macieira via Gcc-patches wrote: > >> > -alignas(__aligno

Re: [PATCH 1/5] std::latch: reduce internal implementation from ptrdiff_t to int

2021-02-26 Thread Thiago Macieira via Gcc-patches
On Friday, 26 February 2021 10:14:42 PST Andreas Schwab wrote: > On Feb 26 2021, Thiago Macieira via Gcc-patches wrote: > > @@ -85,7 +85,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > } > > > > private: > > -alignas(__alignof__(ptrdiff_t)) ptrdiff_t _M_a; >

[PATCH 5/5] barrier: optimise by not having the hasher in a loop

2021-02-26 Thread Thiago Macieira via Gcc-patches
Our thread's ID does not change so we don't have to get it every time and hash it every time. --- libstdc++-v3/include/std/barrier | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/include/std/barrier b/libstdc++-v3/include/std/barrier index

[PATCH 4/5] barrier: use int instead of unsigned char for the phase state

2021-02-26 Thread Thiago Macieira via Gcc-patches
ints can be used in futexes. chars can't. --- libstdc++-v3/include/std/barrier | 21 - 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/libstdc++-v3/include/std/barrier b/libstdc++-v3/include/std/barrier index e09212dfcb9..ae058bd3dc3 100644 ---

[PATCH 3/5] std::__atomic_wait: don't use __detail::__waiter with futex

2021-02-26 Thread Thiago Macieira via Gcc-patches
That violates "don't pay for what you don't need" rule of C++. Users of std::atomic::wait will often have some bit in their atomic indicate whether the value is contended or not, so we don't need libstdc++ to do double book-keeping for us. --- libstdc++-v3/include/bits/atomic_wait.h | 22

[PATCH 2/5] Atomic __platform_wait: accept any 32-bit type, not just int

2021-02-26 Thread Thiago Macieira via Gcc-patches
The kernel doesn't care what we store in those 32 bits, only that they are comparable. This commit adds: * pointers and long on 32-bit architectures * unsigned * untyped enums and typed enums on int & unsigned int * float We're not using FUTEX_OP anywhere today. The kernel reserves 4 bits for

[PATCH 1/5] std::latch: reduce internal implementation from ptrdiff_t to int

2021-02-26 Thread Thiago Macieira via Gcc-patches
ints can be used as futex on Linux. ptrdiff_t on 64-bit Linux can't. --- libstdc++-v3/include/std/latch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/latch b/libstdc++-v3/include/std/latch index ef8c301e5e9..156aea5c5e5 100644 ---