* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. @ 2015-01-17 6:45 David Edelsohn 2015-01-17 7:24 ` pinskia 0 siblings, 1 reply; 16+ messages in thread From: David Edelsohn @ 2015-01-17 6:45 UTC (permalink / raw) To: Torvald Riegel; +Cc: GCC Patches, libstdc++, Jonathan Wakely This patch has broken bootstrap on AIX May I mention that this really should have been tested on systems other than x86 Linux. In file included from /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/ future:44:0, from /nasfarm/edelsohn/src/src/libstdc++-v3/src/c++11/compatibility-thread-c++0x.cc:30: /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:223:5: error: 'mutex' does not name a type mutex _M_mutex; ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:224:5: error: 'condition_variable' does not name a type condition_variable _M_condvar; ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h: In member function 'unsigned int std::__atomic_futex_unsigned<_Waiter_bit>::_M_load(std::memory_order)': /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:232:19: error: 'mutex' was not declared in this scope unique_lock<mutex> __lock(_M_mutex); ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:232:24: error: template argument 1 is invalid unique_lock<mutex> __lock(_M_mutex); ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:232:33: error: '_M_mutex' was not declared in this scope unique_lock<mutex> __lock(_M_mutex); /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h: In member function 'unsigned int std::__atomic_futex_unsigned<_Waiter_bit>::_M_load_when_not_equal(unsigned int, std::memory_order)': /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:239:19: error: 'mutex' was not declared in this scope unique_lock<mutex> __lock(_M_mutex); ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:239:24: error: template argument 1 is invalid unique_lock<mutex> __lock(_M_mutex); ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:239:33: error: '_M_mutex' was not declared in this scope unique_lock<mutex> __lock(_M_mutex); ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:241:2: error: '_M_condvar' was not declared in this scope _M_condvar.wait(__lock); ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h: In member function 'void std::__atomic_futex_unsigned<_Waiter_bit>::_M_load_when_equal(unsigned int, std::memory_order)': /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:248:19: error: 'mutex' was not declared in this scope unique_lock<mutex> __lock(_M_mutex); ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:248:24: error: template argument 1 is invalid unique_lock<mutex> __lock(_M_mutex); /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:248:33: error: '_M_mutex' was not declared in this scope unique_lock<mutex> __lock(_M_mutex); ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:250:2: error: '_M_condvar' was not declared in this scope _M_condvar.wait(__lock); ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h: In member function 'bool std::__atomic_futex_unsigned<_Waiter_bit>::_M_load_when_equal_for(unsigned int, std::memory_order, const std::chrono::duration<_Rep, _Period>&)': /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:258:19: error: 'mutex' was not declared in this scope unique_lock<mutex> __lock(_M_mutex); ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:258:24: error: template argument 1 is invalid unique_lock<mutex> __lock(_M_mutex); ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:258:33: error: '_M_mutex' was not declared in this scope unique_lock<mutex> __lock(_M_mutex); ^ /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:259:14: error: '_M_condvar' was not declared in this scope return _M_condvar.wait_for(__lock, __rtime, ^ etc. - David ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-17 6:45 [patch libstdc++] Optimize synchronization in std::future if futexes are available David Edelsohn @ 2015-01-17 7:24 ` pinskia 2015-01-17 8:06 ` Hans-Peter Nilsson 0 siblings, 1 reply; 16+ messages in thread From: pinskia @ 2015-01-17 7:24 UTC (permalink / raw) To: David Edelsohn; +Cc: Torvald Riegel, GCC Patches, libstdc++, Jonathan Wakely > On Jan 16, 2015, at 9:57 PM, David Edelsohn <dje.gcc@gmail.com> wrote: > > This patch has broken bootstrap on AIX > > May I mention that this really should have been tested on systems > other than x86 Linux. It also broke all newlib targets too. So you could have tested one listed in the sim-test web page. Thanks, Andrew > > In file included from /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/ > future:44:0, > from > /nasfarm/edelsohn/src/src/libstdc++-v3/src/c++11/compatibility-thread-c++0x.cc:30: > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:223:5: > error: 'mutex' does not name a type > mutex _M_mutex; > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:224:5: > error: 'condition_variable' does not name a type > condition_variable _M_condvar; > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h: > In member function 'unsigned int > std::__atomic_futex_unsigned<_Waiter_bit>::_M_load(std::memory_order)': > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:232:19: > error: 'mutex' was not declared in this scope > unique_lock<mutex> __lock(_M_mutex); > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:232:24: > error: template argument 1 is invalid > unique_lock<mutex> __lock(_M_mutex); > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:232:33: > error: '_M_mutex' was not declared in this scope > unique_lock<mutex> __lock(_M_mutex); > > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h: > In member function 'unsigned int > std::__atomic_futex_unsigned<_Waiter_bit>::_M_load_when_not_equal(unsigned > int, std::memory_order)': > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:239:19: > error: 'mutex' was not declared in this scope > unique_lock<mutex> __lock(_M_mutex); > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:239:24: > error: template argument 1 is invalid > unique_lock<mutex> __lock(_M_mutex); > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:239:33: > error: '_M_mutex' was not declared in this scope > unique_lock<mutex> __lock(_M_mutex); > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:241:2: > error: '_M_condvar' was not declared in this scope > _M_condvar.wait(__lock); > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h: > In member function 'void > std::__atomic_futex_unsigned<_Waiter_bit>::_M_load_when_equal(unsigned > int, std::memory_order)': > > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:248:19: > error: 'mutex' was not declared in this scope > unique_lock<mutex> __lock(_M_mutex); > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:248:24: > error: template argument 1 is invalid > unique_lock<mutex> __lock(_M_mutex); > > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:248:33: > error: '_M_mutex' was not declared in this scope > unique_lock<mutex> __lock(_M_mutex); > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:250:2: > error: '_M_condvar' was not declared in this scope > _M_condvar.wait(__lock); > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h: > In member function 'bool > std::__atomic_futex_unsigned<_Waiter_bit>::_M_load_when_equal_for(unsigned > int, std::memory_order, const std::chrono::duration<_Rep, _Period>&)': > > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:258:19: > error: 'mutex' was not declared in this scope > unique_lock<mutex> __lock(_M_mutex); > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:258:24: > error: template argument 1 is invalid > unique_lock<mutex> __lock(_M_mutex); > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:258:33: > error: '_M_mutex' was not declared in this scope > unique_lock<mutex> __lock(_M_mutex); > ^ > /tmp/20150117/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/bits/atomic_futex.h:259:14: > error: '_M_condvar' was not declared in this scope > return _M_condvar.wait_for(__lock, __rtime, > ^ > > etc. > > - David ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-17 7:24 ` pinskia @ 2015-01-17 8:06 ` Hans-Peter Nilsson 2015-01-17 11:00 ` Jonathan Wakely 2015-01-17 14:30 ` Jonathan Wakely 0 siblings, 2 replies; 16+ messages in thread From: Hans-Peter Nilsson @ 2015-01-17 8:06 UTC (permalink / raw) To: pinskia Cc: David Edelsohn, Torvald Riegel, GCC Patches, libstdc++, Jonathan Wakely On Fri, 16 Jan 2015, pinskia@gmail.com wrote: > > On Jan 16, 2015, at 9:57 PM, David Edelsohn <dje.gcc@gmail.com> wrote: > > > > This patch has broken bootstrap on AIX > > > > May I mention that this really should have been tested on systems > > other than x86 Linux. > > It also broke all newlib targets too. So you could have tested one listed in the sim-test web page. For those interested, PR64638. brgds, H-P ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-17 8:06 ` Hans-Peter Nilsson @ 2015-01-17 11:00 ` Jonathan Wakely 2015-01-17 14:30 ` Jonathan Wakely 1 sibling, 0 replies; 16+ messages in thread From: Jonathan Wakely @ 2015-01-17 11:00 UTC (permalink / raw) To: Hans-Peter Nilsson Cc: Andrew Pinski, David Edelsohn, Torvald Riegel, GCC Patches, libstdc++, Jonathan Wakely On 17 January 2015 at 06:45, Hans-Peter Nilsson <hp@bitrange.com> wrote: > On Fri, 16 Jan 2015, pinskia@gmail.com wrote: >> > On Jan 16, 2015, at 9:57 PM, David Edelsohn <dje.gcc@gmail.com> wrote: >> > >> > This patch has broken bootstrap on AIX >> > >> > May I mention that this really should have been tested on systems >> > other than x86 Linux. >> >> It also broke all newlib targets too. So you could have tested one listed in the sim-test web page. > > For those interested, PR64638. I'll fix it later today if Torvald doesn't beat me to it. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-17 8:06 ` Hans-Peter Nilsson 2015-01-17 11:00 ` Jonathan Wakely @ 2015-01-17 14:30 ` Jonathan Wakely 2015-01-17 20:55 ` Sandra Loosemore 1 sibling, 1 reply; 16+ messages in thread From: Jonathan Wakely @ 2015-01-17 14:30 UTC (permalink / raw) To: Hans-Peter Nilsson Cc: pinskia, David Edelsohn, Torvald Riegel, GCC Patches, libstdc++ [-- Attachment #1: Type: text/plain, Size: 513 bytes --] On 17/01/15 01:45 -0500, Hans-Peter Nilsson wrote: >On Fri, 16 Jan 2015, pinskia@gmail.com wrote: >> > On Jan 16, 2015, at 9:57 PM, David Edelsohn <dje.gcc@gmail.com> wrote: >> > >> > This patch has broken bootstrap on AIX >> > >> > May I mention that this really should have been tested on systems >> > other than x86 Linux. >> >> It also broke all newlib targets too. So you could have tested one listed in the sim-test web page. > >For those interested, PR64638. Should be fixed in trunk now, by this patch. [-- Attachment #2: patch.txt --] [-- Type: text/x-patch, Size: 1257 bytes --] commit a0fe2162e3b10f6d35e4ea73bae209081bf2e9c2 Author: Jonathan Wakely <jwakely@redhat.com> Date: Sat Jan 17 13:29:17 2015 +0000 PR libstdc++/64638 * include/bits/atomic_futex.h: Use appropriate config macros for availability of std::mutex, std::condition and std::chrono. diff --git a/libstdc++-v3/include/bits/atomic_futex.h b/libstdc++-v3/include/bits/atomic_futex.h index 9a418d8..2673604 100644 --- a/libstdc++-v3/include/bits/atomic_futex.h +++ b/libstdc++-v3/include/bits/atomic_futex.h @@ -48,6 +48,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) #if defined(_GLIBCXX_HAVE_LINUX_FUTEX) struct __atomic_futex_unsigned_base { @@ -209,7 +210,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; -#else +#else // !_GLIBCXX_HAVE_LINUX_FUTEX // If futexes are not available, use a mutex and a condvar to wait. // Because we access the data only within critical sections, all accesses @@ -280,7 +281,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; -#endif +#endif // _GLIBCXX_HAVE_LINUX_FUTEX +#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace std ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-17 14:30 ` Jonathan Wakely @ 2015-01-17 20:55 ` Sandra Loosemore 2015-01-17 21:13 ` Jonathan Wakely 0 siblings, 1 reply; 16+ messages in thread From: Sandra Loosemore @ 2015-01-17 20:55 UTC (permalink / raw) To: Jonathan Wakely Cc: Hans-Peter Nilsson, pinskia, David Edelsohn, Torvald Riegel, GCC Patches, libstdc++ Re: > On 17/01/15 01:45 -0500, Hans-Peter Nilsson wrote: >> On Fri, 16 Jan 2015, pinskia@gmail.com wrote: >>> > On Jan 16, 2015, at 9:57 PM, David Edelsohn <dje.gcc@gmail.com> wrote: >>> > >>> > This patch has broken bootstrap on AIX >>> > >>> > May I mention that this really should have been tested on systems >>> > other than x86 Linux. >>> >>> It also broke all newlib targets too. So you could have tested one listed in the sim-test web page. >> >> For those interested, PR64638. > > Should be fixed in trunk now, by this patch. I'm now getting this error in an arm-none-linux-gnueabi cross build: In file included from /scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/future:44:0, from /scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/functexcept.cc:34: /scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:71:3: error: #error We require lock-free atomic operations on int # error We require lock-free atomic operations on int ^ It used to work a few days ago.... nothing changed in my build environment except that I did "svn up" in my gcc source directory.... -Sandra ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-17 20:55 ` Sandra Loosemore @ 2015-01-17 21:13 ` Jonathan Wakely 2015-01-17 22:54 ` Sandra Loosemore 0 siblings, 1 reply; 16+ messages in thread From: Jonathan Wakely @ 2015-01-17 21:13 UTC (permalink / raw) To: Sandra Loosemore Cc: Hans-Peter Nilsson, pinskia, David Edelsohn, Torvald Riegel, GCC Patches, libstdc++ [-- Attachment #1: Type: text/plain, Size: 1654 bytes --] On 17/01/15 12:59 -0700, Sandra Loosemore wrote: >Re: > >>On 17/01/15 01:45 -0500, Hans-Peter Nilsson wrote: >>>On Fri, 16 Jan 2015, pinskia@gmail.com wrote: >>>>> On Jan 16, 2015, at 9:57 PM, David Edelsohn <dje.gcc@gmail.com> wrote: >>>>> >>>>> This patch has broken bootstrap on AIX >>>>> >>>>> May I mention that this really should have been tested on systems >>>>> other than x86 Linux. >>>> >>>>It also broke all newlib targets too. So you could have tested one listed in the sim-test web page. >>> >>>For those interested, PR64638. >> >>Should be fixed in trunk now, by this patch. > >I'm now getting this error in an arm-none-linux-gnueabi cross build: > > >In file included from /scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/future:44:0, > from /scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/functexcept.cc:34: >/scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:71:3: >error: #error We require lock-free atomic operations on int > # error We require lock-free atomic operations on int > ^ > >It used to work a few days ago.... nothing changed in my build >environment except that I did "svn up" in my gcc source directory.... Well that file didn't exist until yesterday :-) Does the attached patch fix it? The new __atomic_futex_unsigned type is only used in <future> when ATOMIC_LOCK_FREE > 1, so there's no point trying to define it and then failing if int is not lock-free, as the type isn't going to be used anyway. [-- Attachment #2: patch.txt --] [-- Type: text/x-patch, Size: 1277 bytes --] diff --git a/libstdc++-v3/include/bits/atomic_futex.h b/libstdc++-v3/include/bits/atomic_futex.h index 2673604..b4138ba 100644 --- a/libstdc++-v3/include/bits/atomic_futex.h +++ b/libstdc++-v3/include/bits/atomic_futex.h @@ -49,7 +49,7 @@ namespace std _GLIBCXX_VISIBILITY(default) _GLIBCXX_BEGIN_NAMESPACE_VERSION #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) -#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) +#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1 struct __atomic_futex_unsigned_base { // Returns false iff a timeout occurred. @@ -66,10 +66,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { typedef chrono::system_clock __clock_t; - // XXX We expect this to be lock-free, and having the payload at offset 0. -#if ATOMIC_INT_LOCK_FREE < 2 -# error We require lock-free atomic operations on int -#endif + // This must be lock-free and at offset 0. atomic<unsigned> _M_data; __atomic_futex_unsigned(unsigned __data) : _M_data(__data) @@ -281,7 +278,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; -#endif // _GLIBCXX_HAVE_LINUX_FUTEX +#endif // _GLIBCXX_HAVE_LINUX_FUTEX && ATOMIC_INT_LOCK_FREE > 1 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 _GLIBCXX_END_NAMESPACE_VERSION ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-17 21:13 ` Jonathan Wakely @ 2015-01-17 22:54 ` Sandra Loosemore 2015-01-17 22:58 ` Jonathan Wakely 0 siblings, 1 reply; 16+ messages in thread From: Sandra Loosemore @ 2015-01-17 22:54 UTC (permalink / raw) To: Jonathan Wakely Cc: Hans-Peter Nilsson, pinskia, David Edelsohn, Torvald Riegel, GCC Patches, libstdc++ On 01/17/2015 01:23 PM, Jonathan Wakely wrote: > On 17/01/15 12:59 -0700, Sandra Loosemore wrote: >> Re: >> >>> On 17/01/15 01:45 -0500, Hans-Peter Nilsson wrote: >>>> On Fri, 16 Jan 2015, pinskia@gmail.com wrote: >>>>>> On Jan 16, 2015, at 9:57 PM, David Edelsohn <dje.gcc@gmail.com> >>>>>> wrote: >>>>>> >>>>>> This patch has broken bootstrap on AIX >>>>>> >>>>>> May I mention that this really should have been tested on systems >>>>>> other than x86 Linux. >>>>> >>>>> It also broke all newlib targets too. So you could have tested one >>>>> listed in the sim-test web page. >>>> >>>> For those interested, PR64638. >>> >>> Should be fixed in trunk now, by this patch. >> >> I'm now getting this error in an arm-none-linux-gnueabi cross build: >> >> >> In file included from >> /scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/future:44:0, >> >> from >> /scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/functexcept.cc:34: >> >> /scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:71:3: >> error: #error We require lock-free atomic operations on int >> # error We require lock-free atomic operations on int >> ^ >> >> It used to work a few days ago.... nothing changed in my build >> environment except that I did "svn up" in my gcc source directory.... > > Well that file didn't exist until yesterday :-) > > Does the attached patch fix it? > > The new __atomic_futex_unsigned type is only used in <future> when > ATOMIC_LOCK_FREE > 1, so there's no point trying to define it and > then failing if int is not lock-free, as the type isn't going to be > used anyway. I'm getting a different series of build errors with this patch -- starting with In file included from /scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:27:0: /scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:221:5: error: 'mutex' does not name a type mutex _M_mutex; ^ /scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:222:5: error: 'condition_variable' does not name a type condition_variable _M_condvar; ^ /scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h: In member function 'unsigned int std::__atomic_futex_unsigned<_Waiter_bit>::_M_load(std::memory_ order)': /scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:230:7: error: 'unique_lock' was not declared in this scope unique_lock<mutex> __lock(_M_mutex); ^ and going on for several screenfuls. Maybe the patch(es) causing all these problems should be reverted until the breakage is tracked down and fixed and regression-tested on a variety of targets? It's not really blocking me at the moment, but it seems unfortunate that trunk is so unstable as we're entering Stage 4..... -Sandra ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-17 22:54 ` Sandra Loosemore @ 2015-01-17 22:58 ` Jonathan Wakely 2015-01-18 0:08 ` Sandra Loosemore 0 siblings, 1 reply; 16+ messages in thread From: Jonathan Wakely @ 2015-01-17 22:58 UTC (permalink / raw) To: Sandra Loosemore Cc: Hans-Peter Nilsson, pinskia, David Edelsohn, Torvald Riegel, GCC Patches, libstdc++ On 17/01/15 15:22 -0700, Sandra Loosemore wrote: >On 01/17/2015 01:23 PM, Jonathan Wakely wrote: >>On 17/01/15 12:59 -0700, Sandra Loosemore wrote: >>>Re: >>> >>>>On 17/01/15 01:45 -0500, Hans-Peter Nilsson wrote: >>>>>On Fri, 16 Jan 2015, pinskia@gmail.com wrote: >>>>>>>On Jan 16, 2015, at 9:57 PM, David Edelsohn <dje.gcc@gmail.com> >>>>>>>wrote: >>>>>>> >>>>>>>This patch has broken bootstrap on AIX >>>>>>> >>>>>>>May I mention that this really should have been tested on systems >>>>>>>other than x86 Linux. >>>>>> >>>>>>It also broke all newlib targets too. So you could have tested one >>>>>>listed in the sim-test web page. >>>>> >>>>>For those interested, PR64638. >>>> >>>>Should be fixed in trunk now, by this patch. >>> >>>I'm now getting this error in an arm-none-linux-gnueabi cross build: >>> >>> >>>In file included from >>>/scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/future:44:0, >>> >>> from >>>/scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/functexcept.cc:34: >>> >>>/scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:71:3: >>>error: #error We require lock-free atomic operations on int >>># error We require lock-free atomic operations on int >>> ^ >>> >>>It used to work a few days ago.... nothing changed in my build >>>environment except that I did "svn up" in my gcc source directory.... >> >>Well that file didn't exist until yesterday :-) >> >>Does the attached patch fix it? >> >>The new __atomic_futex_unsigned type is only used in <future> when >>ATOMIC_LOCK_FREE > 1, so there's no point trying to define it and >>then failing if int is not lock-free, as the type isn't going to be >>used anyway. > >I'm getting a different series of build errors with this patch -- >starting with > >In file included from /scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:27:0: >/scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:221:5: >error: 'mutex' does not name a type > mutex _M_mutex; > ^ >/scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:222:5: >error: 'condition_variable' does not name a type > condition_variable _M_condvar; > ^ >/scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h: >In member function 'unsigned int >std::__atomic_futex_unsigned<_Waiter_bit>::_M_load(std::memory_ >order)': >/scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:230:7: >error: 'unique_lock' was not declared in this scope > unique_lock<mutex> __lock(_M_mutex); > ^ >and going on for several screenfuls. Odd, that should already be fixed at rev 219799. Are you still at a revision older than that? >Maybe the patch(es) causing all these problems should be reverted >until the breakage is tracked down and fixed and regression-tested on >a variety of targets? It's not really blocking me at the moment, but >it seems unfortunate that trunk is so unstable as we're entering Stage >4..... ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-17 22:58 ` Jonathan Wakely @ 2015-01-18 0:08 ` Sandra Loosemore 2015-01-18 0:24 ` Jonathan Wakely 0 siblings, 1 reply; 16+ messages in thread From: Sandra Loosemore @ 2015-01-18 0:08 UTC (permalink / raw) To: Jonathan Wakely Cc: Hans-Peter Nilsson, pinskia, David Edelsohn, Torvald Riegel, GCC Patches, libstdc++ On 01/17/2015 03:36 PM, Jonathan Wakely wrote: > On 17/01/15 15:22 -0700, Sandra Loosemore wrote: > [snip snip] >> I'm getting a different series of build errors with this patch -- >> starting with >> >> In file included from >> /scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:27:0: >> >> /scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:221:5: >> error: 'mutex' does not name a type >> mutex _M_mutex; >> ^ >> /scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:222:5: >> error: 'condition_variable' does not name a type >> condition_variable _M_condvar; >> ^ >> /scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h: >> In member function 'unsigned int >> std::__atomic_futex_unsigned<_Waiter_bit>::_M_load(std::memory_ >> order)': >> /scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:230:7: >> error: 'unique_lock' was not declared in this scope >> unique_lock<mutex> __lock(_M_mutex); >> ^ >> and going on for several screenfuls. > > Odd, that should already be fixed at rev 219799. > > Are you still at a revision older than that? My source tree is at r219802 now. > >> Maybe the patch(es) causing all these problems should be reverted >> until the breakage is tracked down and fixed and regression-tested on >> a variety of targets? It's not really blocking me at the moment, but >> it seems unfortunate that trunk is so unstable as we're entering Stage >> 4..... -Sandra ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-18 0:08 ` Sandra Loosemore @ 2015-01-18 0:24 ` Jonathan Wakely 2015-01-18 8:37 ` Sandra Loosemore 0 siblings, 1 reply; 16+ messages in thread From: Jonathan Wakely @ 2015-01-18 0:24 UTC (permalink / raw) To: Sandra Loosemore Cc: Hans-Peter Nilsson, pinskia, David Edelsohn, Torvald Riegel, GCC Patches, libstdc++ On 17/01/15 15:54 -0700, Sandra Loosemore wrote: >On 01/17/2015 03:36 PM, Jonathan Wakely wrote: >>On 17/01/15 15:22 -0700, Sandra Loosemore wrote: >>[snip snip] >>>I'm getting a different series of build errors with this patch -- >>>starting with >>> >>>In file included from >>>/scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:27:0: >>> >>>/scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:221:5: >>>error: 'mutex' does not name a type >>> mutex _M_mutex; >>> ^ >>>/scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:222:5: >>>error: 'condition_variable' does not name a type >>> condition_variable _M_condvar; >>> ^ >>>/scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h: >>>In member function 'unsigned int >>>std::__atomic_futex_unsigned<_Waiter_bit>::_M_load(std::memory_ >>>order)': >>>/scratch/sandra/arm-fsf2/obj/gcc-mainline-0-arm-none-linux-gnueabi-i686-pc-linux-gnu/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_futex.h:230:7: >>>error: 'unique_lock' was not declared in this scope >>> unique_lock<mutex> __lock(_M_mutex); >>> ^ >>>and going on for several screenfuls. >> >>Odd, that should already be fixed at rev 219799. >> >>Are you still at a revision older than that? > >My source tree is at r219802 now. My fault, this additional chunk is needed alongside the patch I sent earlier: --- a/libstdc++-v3/include/bits/atomic_futex.h +++ b/libstdc++-v3/include/bits/atomic_futex.h @@ -35,7 +35,7 @@ #include <bits/c++config.h> #include <atomic> #include <chrono> -#if !defined(_GLIBCXX_HAVE_LINUX_FUTEX) +#if ! (defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1) #include <mutex> #include <condition_variable> #endif What I sent earlier causes your target to use std::mutex and std::condition_variable, but without the bit above the headers aren't included. >>>Maybe the patch(es) causing all these problems should be reverted >>>until the breakage is tracked down and fixed and regression-tested on >>>a variety of targets? It's not really blocking me at the moment, but >>>it seems unfortunate that trunk is so unstable as we're entering Stage >>>4..... Torvald, if the extra change above doesn't fix it (although it should do) then maybe it should be reverted until it can be tested more widely. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-18 0:24 ` Jonathan Wakely @ 2015-01-18 8:37 ` Sandra Loosemore 2015-01-18 15:32 ` Jonathan Wakely 0 siblings, 1 reply; 16+ messages in thread From: Sandra Loosemore @ 2015-01-18 8:37 UTC (permalink / raw) To: Jonathan Wakely Cc: Hans-Peter Nilsson, pinskia, David Edelsohn, Torvald Riegel, GCC Patches, libstdc++ On 01/17/2015 03:58 PM, Jonathan Wakely wrote: > > My fault, this additional chunk is needed alongside the patch I sent > earlier: > > --- a/libstdc++-v3/include/bits/atomic_futex.h > +++ b/libstdc++-v3/include/bits/atomic_futex.h > @@ -35,7 +35,7 @@ > #include <bits/c++config.h> > #include <atomic> > #include <chrono> > -#if !defined(_GLIBCXX_HAVE_LINUX_FUTEX) > +#if ! (defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1) > #include <mutex> > #include <condition_variable> > #endif > > What I sent earlier causes your target to use std::mutex and > std::condition_variable, but without the bit above the headers aren't > included. Still no joy: /scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:45:3: error: '__atomic_futex_unsigned_base' has not been declared __atomic_futex_unsigned_base::_M_futex_wait_until(unsigned *__addr, ^ /scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:88:3: error: '__atomic_futex_unsigned_base' has not been declared __atomic_futex_unsigned_base::_M_futex_notify_all(unsigned* __addr) ^ >>>> Maybe the patch(es) causing all these problems should be reverted >>>> until the breakage is tracked down and fixed and regression-tested on >>>> a variety of targets? It's not really blocking me at the moment, but >>>> it seems unfortunate that trunk is so unstable as we're entering Stage >>>> 4..... > > Torvald, if the extra change above doesn't fix it (although it should > do) then maybe it should be reverted until it can be tested more > widely. -Sandra ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-18 8:37 ` Sandra Loosemore @ 2015-01-18 15:32 ` Jonathan Wakely 2015-01-18 15:49 ` Jonathan Wakely 2015-01-29 3:35 ` Doug Gilmore 0 siblings, 2 replies; 16+ messages in thread From: Jonathan Wakely @ 2015-01-18 15:32 UTC (permalink / raw) To: Sandra Loosemore Cc: Hans-Peter Nilsson, pinskia, David Edelsohn, Torvald Riegel, GCC Patches, libstdc++ [-- Attachment #1: Type: text/plain, Size: 1195 bytes --] On 17/01/15 19:51 -0700, Sandra Loosemore wrote: >On 01/17/2015 03:58 PM, Jonathan Wakely wrote: >> >>My fault, this additional chunk is needed alongside the patch I sent >>earlier: >> >>--- a/libstdc++-v3/include/bits/atomic_futex.h >>+++ b/libstdc++-v3/include/bits/atomic_futex.h >>@@ -35,7 +35,7 @@ >>#include <bits/c++config.h> >>#include <atomic> >>#include <chrono> >>-#if !defined(_GLIBCXX_HAVE_LINUX_FUTEX) >>+#if ! (defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1) >>#include <mutex> >>#include <condition_variable> >>#endif >> >>What I sent earlier causes your target to use std::mutex and >>std::condition_variable, but without the bit above the headers aren't >>included. > >Still no joy: >/scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:45:3: >error: '__atomic_futex_unsigned_base' has not been declared > __atomic_futex_unsigned_base::_M_futex_wait_until(unsigned *__addr, > ^ >/scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:88:3: >error: '__atomic_futex_unsigned_base' has not been declared > __atomic_futex_unsigned_base::_M_futex_notify_all(unsigned* __addr) > ^ futex.cc needs the same change ... [-- Attachment #2: patch.txt --] [-- Type: text/x-patch, Size: 449 bytes --] diff --git a/libstdc++-v3/src/c++11/futex.cc b/libstdc++-v3/src/c++11/futex.cc index ad766c8..f24b44e 100644 --- a/libstdc++-v3/src/c++11/futex.cc +++ b/libstdc++-v3/src/c++11/futex.cc @@ -23,7 +23,7 @@ // <http://www.gnu.org/licenses/>. #include <bits/c++config.h> -#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) +#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1 #include <bits/atomic_futex.h> #include <chrono> #include <climits> ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-18 15:32 ` Jonathan Wakely @ 2015-01-18 15:49 ` Jonathan Wakely 2015-02-01 15:13 ` Jonathan Wakely 2015-01-29 3:35 ` Doug Gilmore 1 sibling, 1 reply; 16+ messages in thread From: Jonathan Wakely @ 2015-01-18 15:49 UTC (permalink / raw) To: Sandra Loosemore Cc: Hans-Peter Nilsson, pinskia, David Edelsohn, Torvald Riegel, GCC Patches, libstdc++ [-- Attachment #1: Type: text/plain, Size: 1947 bytes --] On 18/01/15 13:19 +0000, Jonathan Wakely wrote: >On 17/01/15 19:51 -0700, Sandra Loosemore wrote: >>On 01/17/2015 03:58 PM, Jonathan Wakely wrote: >>> >>>My fault, this additional chunk is needed alongside the patch I sent >>>earlier: >>> >>>--- a/libstdc++-v3/include/bits/atomic_futex.h >>>+++ b/libstdc++-v3/include/bits/atomic_futex.h >>>@@ -35,7 +35,7 @@ >>>#include <bits/c++config.h> >>>#include <atomic> >>>#include <chrono> >>>-#if !defined(_GLIBCXX_HAVE_LINUX_FUTEX) >>>+#if ! (defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1) >>>#include <mutex> >>>#include <condition_variable> >>>#endif >>> >>>What I sent earlier causes your target to use std::mutex and >>>std::condition_variable, but without the bit above the headers aren't >>>included. >> >>Still no joy: >>/scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:45:3: >>error: '__atomic_futex_unsigned_base' has not been declared >> __atomic_futex_unsigned_base::_M_futex_wait_until(unsigned *__addr, >> ^ >>/scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:88:3: >>error: '__atomic_futex_unsigned_base' has not been declared >> __atomic_futex_unsigned_base::_M_futex_notify_all(unsigned* __addr) >> ^ > >futex.cc needs the same change ... >diff --git a/libstdc++-v3/src/c++11/futex.cc b/libstdc++-v3/src/c++11/futex.cc >index ad766c8..f24b44e 100644 >--- a/libstdc++-v3/src/c++11/futex.cc >+++ b/libstdc++-v3/src/c++11/futex.cc >@@ -23,7 +23,7 @@ > // <http://www.gnu.org/licenses/>. > > #include <bits/c++config.h> >-#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) >+#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1 > #include <bits/atomic_futex.h> > #include <chrono> > #include <climits> I've committed the attached after succesfully building arm-none-linux-gnueabi with it and testing on x86_64-linux. (The other changes in the patch are just whitespace and making the member variables private.) [-- Attachment #2: patch.txt --] [-- Type: text/x-patch, Size: 7915 bytes --] commit 07fcc71b616a253ed34b8b6f83e7f8cf6ea08a7a Author: Jonathan Wakely <jwakely@redhat.com> Date: Sun Jan 18 14:34:52 2015 +0000 * src/c++11/futex.cc: Fix order of includes and preprocessor condition. diff --git a/libstdc++-v3/src/c++11/futex.cc b/libstdc++-v3/src/c++11/futex.cc index f24b44e..1336779 100644 --- a/libstdc++-v3/src/c++11/futex.cc +++ b/libstdc++-v3/src/c++11/futex.cc @@ -22,9 +22,8 @@ // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. -#include <bits/c++config.h> -#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1 #include <bits/atomic_futex.h> +#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1 #include <chrono> #include <climits> #include <syscall.h> commit c0b71ac062080887ae2bc072c9db21118155ae22 Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Sun Jan 18 14:25:22 2015 +0000 * include/bits/atomic_futex.h: Use mutex and condition_variable when atomic int is not lock-free. Make member variables private. * src/c++11/futex.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219815 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/libstdc++-v3/include/bits/atomic_futex.h b/libstdc++-v3/include/bits/atomic_futex.h index 2673604..51b9c7e 100644 --- a/libstdc++-v3/include/bits/atomic_futex.h +++ b/libstdc++-v3/include/bits/atomic_futex.h @@ -35,7 +35,7 @@ #include <bits/c++config.h> #include <atomic> #include <chrono> -#if !defined(_GLIBCXX_HAVE_LINUX_FUTEX) +#if ! (defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1) #include <mutex> #include <condition_variable> #endif @@ -49,7 +49,7 @@ namespace std _GLIBCXX_VISIBILITY(default) _GLIBCXX_BEGIN_NAMESPACE_VERSION #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) -#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) +#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1 struct __atomic_futex_unsigned_base { // Returns false iff a timeout occurred. @@ -62,16 +62,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; template <unsigned _Waiter_bit = 0x80000000> - struct __atomic_futex_unsigned : __atomic_futex_unsigned_base + class __atomic_futex_unsigned : __atomic_futex_unsigned_base { typedef chrono::system_clock __clock_t; - // XXX We expect this to be lock-free, and having the payload at offset 0. -#if ATOMIC_INT_LOCK_FREE < 2 -# error We require lock-free atomic operations on int -#endif + // This must be lock-free and at offset 0. atomic<unsigned> _M_data; + public: + explicit __atomic_futex_unsigned(unsigned __data) : _M_data(__data) { } @@ -82,7 +81,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } private: - // If a timeout occurs, returns a current value after the timeout; // otherwise, returns the operand's value if equal is true or a different // value if equal is false. @@ -165,26 +163,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Returns false iff a timeout occurred. template<typename _Rep, typename _Period> - _GLIBCXX_ALWAYS_INLINE bool - _M_load_when_equal_for(unsigned __val, memory_order __mo, - const chrono::duration<_Rep, _Period>& __rtime) - { - return _M_load_when_equal_until(__val, __mo, __clock_t::now() + __rtime); - } + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_for(unsigned __val, memory_order __mo, + const chrono::duration<_Rep, _Period>& __rtime) + { + return _M_load_when_equal_until(__val, __mo, + __clock_t::now() + __rtime); + } // Returns false iff a timeout occurred. template<typename _Clock, typename _Duration> - _GLIBCXX_ALWAYS_INLINE bool - _M_load_when_equal_until(unsigned __val, memory_order __mo, - const chrono::time_point<_Clock, _Duration>& __atime) - { - // DR 887 - Sync unknown clock to known clock. - const typename _Clock::time_point __c_entry = _Clock::now(); - const __clock_t::time_point __s_entry = __clock_t::now(); - const auto __delta = __atime - __c_entry; - const auto __s_atime = __s_entry + __delta; - return _M_load_when_equal_until(__val, __mo, __s_atime); - } + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_until(unsigned __val, memory_order __mo, + const chrono::time_point<_Clock, _Duration>& __atime) + { + // DR 887 - Sync unknown clock to known clock. + const typename _Clock::time_point __c_entry = _Clock::now(); + const __clock_t::time_point __s_entry = __clock_t::now(); + const auto __delta = __atime - __c_entry; + const auto __s_atime = __s_entry + __delta; + return _M_load_when_equal_until(__val, __mo, __s_atime); + } // Returns false iff a timeout occurred. template<typename _Duration> @@ -207,16 +206,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (_M_data.exchange(__val, __mo) & _Waiter_bit) _M_futex_notify_all(__futex); } - }; -#else // !_GLIBCXX_HAVE_LINUX_FUTEX +#else // ! (_GLIBCXX_HAVE_LINUX_FUTEX && ATOMIC_INT_LOCK_FREE > 1) // If futexes are not available, use a mutex and a condvar to wait. // Because we access the data only within critical sections, all accesses // are sequentially consistent; thus, we satisfy any provided memory_order. template <unsigned _Waiter_bit = 0x80000000> - struct __atomic_futex_unsigned + class __atomic_futex_unsigned { typedef chrono::system_clock __clock_t; @@ -224,6 +222,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION mutex _M_mutex; condition_variable _M_condvar; + public: + explicit __atomic_futex_unsigned(unsigned __data) : _M_data(__data) { } @@ -252,24 +252,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _Rep, typename _Period> - _GLIBCXX_ALWAYS_INLINE bool - _M_load_when_equal_for(unsigned __val, memory_order __mo, - const chrono::duration<_Rep, _Period>& __rtime) - { - unique_lock<mutex> __lock(_M_mutex); - return _M_condvar.wait_for(__lock, __rtime, - [&] { return _M_data == __val;}); - } + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_for(unsigned __val, memory_order __mo, + const chrono::duration<_Rep, _Period>& __rtime) + { + unique_lock<mutex> __lock(_M_mutex); + return _M_condvar.wait_for(__lock, __rtime, + [&] { return _M_data == __val;}); + } template<typename _Clock, typename _Duration> - _GLIBCXX_ALWAYS_INLINE bool - _M_load_when_equal_until(unsigned __val, memory_order __mo, - const chrono::time_point<_Clock, _Duration>& __atime) - { - unique_lock<mutex> __lock(_M_mutex); - return _M_condvar.wait_until(__lock, __atime, - [&] { return _M_data == __val;}); - } + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_until(unsigned __val, memory_order __mo, + const chrono::time_point<_Clock, _Duration>& __atime) + { + unique_lock<mutex> __lock(_M_mutex); + return _M_condvar.wait_until(__lock, __atime, + [&] { return _M_data == __val;}); + } _GLIBCXX_ALWAYS_INLINE void _M_store_notify_all(unsigned __val, memory_order __mo) @@ -278,10 +278,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_data = __val; _M_condvar.notify_all(); } - }; -#endif // _GLIBCXX_HAVE_LINUX_FUTEX +#endif // _GLIBCXX_HAVE_LINUX_FUTEX && ATOMIC_INT_LOCK_FREE > 1 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/src/c++11/futex.cc b/libstdc++-v3/src/c++11/futex.cc index ad766c8..f24b44e 100644 --- a/libstdc++-v3/src/c++11/futex.cc +++ b/libstdc++-v3/src/c++11/futex.cc @@ -23,7 +23,7 @@ // <http://www.gnu.org/licenses/>. #include <bits/c++config.h> -#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) +#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1 #include <bits/atomic_futex.h> #include <chrono> #include <climits> ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-18 15:49 ` Jonathan Wakely @ 2015-02-01 15:13 ` Jonathan Wakely 0 siblings, 0 replies; 16+ messages in thread From: Jonathan Wakely @ 2015-02-01 15:13 UTC (permalink / raw) To: libstdc++, gcc-patches; +Cc: Torvald Riegel [-- Attachment #1: Type: text/plain, Size: 136 bytes --] One more patch to fix the preprocessor conditions, this time to fix --disable-threads builds. Tested x86_64-linux, committed to trunk. [-- Attachment #2: patch.txt --] [-- Type: text/x-patch, Size: 730 bytes --] commit 911783907e5482c09d80fd8a5e3b5aa6d2b891d3 Author: Jonathan Wakely <jwakely@redhat.com> Date: Sat Jan 31 22:01:43 2015 +0000 * src/c++11/futex.cc: Do not define for gthr-single.h targets. diff --git a/libstdc++-v3/src/c++11/futex.cc b/libstdc++-v3/src/c++11/futex.cc index 1336779..a7f0200 100644 --- a/libstdc++-v3/src/c++11/futex.cc +++ b/libstdc++-v3/src/c++11/futex.cc @@ -23,6 +23,7 @@ // <http://www.gnu.org/licenses/>. #include <bits/atomic_futex.h> +#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) #if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1 #include <chrono> #include <climits> @@ -94,3 +95,4 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #endif +#endif ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch libstdc++] Optimize synchronization in std::future if futexes are available. 2015-01-18 15:32 ` Jonathan Wakely 2015-01-18 15:49 ` Jonathan Wakely @ 2015-01-29 3:35 ` Doug Gilmore 1 sibling, 0 replies; 16+ messages in thread From: Doug Gilmore @ 2015-01-29 3:35 UTC (permalink / raw) To: gcc-patches [-- Attachment #1: Type: text/plain, Size: 1531 bytes --] On 01/18/2015 05:19 AM, Jonathan Wakely wrote: > On 17/01/15 19:51 -0700, Sandra Loosemore wrote: >> On 01/17/2015 03:58 PM, Jonathan Wakely wrote: >>> >>> My fault, this additional chunk is needed alongside the patch I sent >>> earlier: >>> >>> --- a/libstdc++-v3/include/bits/atomic_futex.h >>> +++ b/libstdc++-v3/include/bits/atomic_futex.h >>> @@ -35,7 +35,7 @@ >>> #include <bits/c++config.h> >>> #include <atomic> >>> #include <chrono> >>> -#if !defined(_GLIBCXX_HAVE_LINUX_FUTEX) >>> +#if ! (defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1) >>> #include <mutex> >>> #include <condition_variable> >>> #endif >>> >>> What I sent earlier causes your target to use std::mutex and >>> std::condition_variable, but without the bit above the headers aren't >>> included. >> >> Still no joy: >> /scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:45:3: error: '__atomic_futex_unsigned_base' has not been declared >> __atomic_futex_unsigned_base::_M_futex_wait_until(unsigned *__addr, >> ^ >> /scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:88:3: error: '__atomic_futex_unsigned_base' has not been declared >> __atomic_futex_unsigned_base::_M_futex_notify_all(unsigned* __addr) >> ^ > > futex.cc needs the same change ... I am still noticing a problem building a native X86_64 ToT compiler on Ubuntu 12.04.5 LTS. Attached is a patch where the CPP guards in atomic_futex.h are reflected in futex.cc, which fixes my build problem. OK to commit? Thanks, Doug [-- Attachment #2: 0001-CPP-guards-in-futex.cc-should-match-guards-in-futex..patch --] [-- Type: text/x-patch, Size: 993 bytes --] From 1debe13da342ac30d905e12a9ca243e30cb61870 Mon Sep 17 00:00:00 2001 From: Doug Gilmore <doug.gilmore@imgtec.com> Date: Wed, 28 Jan 2015 14:29:14 -0800 Subject: [PATCH] CPP guards in futex.cc should match guards in futex.ii. --- libstdc++-v3/src/c++11/futex.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/src/c++11/futex.cc b/libstdc++-v3/src/c++11/futex.cc index 1336779..5087483 100644 --- a/libstdc++-v3/src/c++11/futex.cc +++ b/libstdc++-v3/src/c++11/futex.cc @@ -23,6 +23,7 @@ // <http://www.gnu.org/licenses/>. #include <bits/atomic_futex.h> +#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) #if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1 #include <chrono> #include <climits> @@ -93,4 +94,5 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } -#endif +#endif // _GLIBCXX_HAVE_LINUX_FUTEX && ATOMIC_INT_LOCK_FREE > 1 +#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 -- 1.7.9.5 ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2015-02-01 15:13 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-01-17 6:45 [patch libstdc++] Optimize synchronization in std::future if futexes are available David Edelsohn 2015-01-17 7:24 ` pinskia 2015-01-17 8:06 ` Hans-Peter Nilsson 2015-01-17 11:00 ` Jonathan Wakely 2015-01-17 14:30 ` Jonathan Wakely 2015-01-17 20:55 ` Sandra Loosemore 2015-01-17 21:13 ` Jonathan Wakely 2015-01-17 22:54 ` Sandra Loosemore 2015-01-17 22:58 ` Jonathan Wakely 2015-01-18 0:08 ` Sandra Loosemore 2015-01-18 0:24 ` Jonathan Wakely 2015-01-18 8:37 ` Sandra Loosemore 2015-01-18 15:32 ` Jonathan Wakely 2015-01-18 15:49 ` Jonathan Wakely 2015-02-01 15:13 ` Jonathan Wakely 2015-01-29 3:35 ` Doug Gilmore
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).