[Bug libstdc++/47433] New: libstdc++ parallel mode calls std::swap explicitely

2011-01-24 Thread manuel.holtgr...@fu-berlin.de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47433

   Summary: libstdc++ parallel mode calls std::swap explicitely
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: critical
  Priority: P3
 Component: libstdc++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: manuel.holtgr...@fu-berlin.de


The parallel libstdc++ calls std::swap explicitely. To my knowledge, this
disables the user to specify his own, possibly more efficient swap routine.
This is especially severe in parallel sorting and partitioning.

 libstdc++-v3-parallel-trunk $ ack 'std::swap'
balanced_quicksort.h
135:std::swap(*__pivot_pos, *(__end - 1));
147:  std::swap(*(__begin + __split_pos), *__pivot_pos);
287:std::swap(*__pivot_pos, *(__end - 1));
306:std::swap(*__split_pos1, *__pivot_pos);

losertree.h
237:std::swap(_M_losers[__pos]._M_sup, __sup);
238:std::swap(_M_losers[__pos]._M_source, __source);
239:std::swap(_M_losers[__pos]._M_key, __key);
333:std::swap(_M_losers[__pos]._M_sup, __sup);
334:std::swap(_M_losers[__pos]._M_source, __source);
335:std::swap(_M_losers[__pos]._M_key, __key);
464:std::swap(_M_losers[__pos]._M_sup, __sup);
465:std::swap(_M_losers[__pos]._M_source, __source);
466:std::swap(_M_losers[__pos]._M_keyp, __keyp);
541:std::swap(_M_losers[__pos]._M_sup, __sup);
542:std::swap(_M_losers[__pos]._M_source, __source);
543:std::swap(_M_losers[__pos]._M_keyp, __keyp);
697:std::swap(_M_losers[__pos]._M_source, __source);
698:std::swap(_M_losers[__pos]._M_key, __key);
788:std::swap(_M_losers[__pos]._M_source, __source);
789:std::swap(_M_losers[__pos]._M_key, __key);
937:std::swap(_M_losers[__pos]._M_source, __source);
938:std::swap(_M_losers[__pos]._M_keyp, __keyp);
1027:std::swap(_M_losers[__pos]._M_source, __source);
1028:std::swap(_M_losers[__pos]._M_keyp, __keyp);

partition.h
181:  std::swap(__begin[__thread_left],
241:  std::swap_ranges(__begin + __thread_left_border
264:  std::swap_ranges(__begin + __thread_right_border,
304:std::swap(__begin[__final_left], __begin[__final_right]);
357:std::swap(*__pivot_pos, *(__end - 1));
379:std::swap(*__split_pos1, *__pivot_pos);


[Bug libstdc++/47433] libstdc++ parallel mode calls std::swap explicitely

2011-01-24 Thread manuel.holtgr...@fu-berlin.de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47433

--- Comment #3 from Manuel Holtgrewe  2011-01-24 
12:56:16 UTC ---
I agree, that there are no obvious problems with std::swap_ranges.

Is anything specified in the standard in this direction?


[Bug tree-optimization/47460] New: Inconsistent behaviour of __sync_fetch_and_add builtin?

2011-01-25 Thread manuel.holtgr...@fu-berlin.de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47460

   Summary: Inconsistent behaviour of __sync_fetch_and_add
builtin?
   Product: gcc
   Version: 4.4.5
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: manuel.holtgr...@fu-berlin.de


I get the unexpected (for me) inconsistent behaviour of the
__sync_fetch_and_add builtin with the program below. My main confusion is
around the missing __sync_val_compare_and_swap_{1,2,4} when not explicitely
specifying the architecture in GCC 4.4.5, but availability in all other tried
variants.

Also, why is there a 64-bit variant when explicitely giving -march=i686 to g++
>=4.2 but missing one in g++-4.1?

Thanks!

Program gcc-atomic.cpp
--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<

template 
void test()
{
  T volatile x = 0;
  T y = 0;
  T z = 0;
  __sync_fetch_and_add(&x, y, z);
  __sync_fetch_and_or(&x, y, z);
  __sync_fetch_and_xor(&x, y, z);
  __sync_val_compare_and_swap(&x, y, z);
}

int main()
{
  test();
  test();
  test();
  test();
  test();
  test();
  test();
  test();
  test();
  test();
  return 0;
}


Output WITH -march=i686 switch
--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<


$ for i in 1 2 3 4 5; do g++-4.$i --version; g++-4.$i -dumpmachine; g++-4.$i
-march=i686 gcc-atomic.cpp; done
g++-4.1 (GCC) 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

i486-linux-gnu
/tmp/cce8mfQl.o: In function `void test()':
gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x46): undefined
reference to `__sync_fetch_and_add_8'
gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x5f): undefined
reference to `__sync_fetch_and_or_8'
gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x78): undefined
reference to `__sync_fetch_and_xor_8'
gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x9f): undefined
reference to `__sync_val_compare_and_swap_8'
/tmp/cce8mfQl.o: In function `void test()':
gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x45):
undefined reference to `__sync_fetch_and_add_8'
gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x5e):
undefined reference to `__sync_fetch_and_or_8'
gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x77):
undefined reference to `__sync_fetch_and_xor_8'
gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x9e):
undefined reference to `__sync_val_compare_and_swap_8'
collect2: ld returned 1 exit status
g++-4.2 (GCC) 4.2.4 (Debian 4.2.4-6)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

i486-linux-gnu
g++-4.3 (Debian 4.3.2-1.1) 4.3.2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

i486-linux-gnu
g++-4.4.5 (GCC) 4.4.5
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

i686-pc-linux-gnu
g++-4.5.1 (GCC) 4.5.1
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

i686-pc-linux-gnu


Output WITHOUT -march=i686 switch
--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<

$ for i in 1 2 3 4 5; do g++-4.$i --version; g++-4.$i -dumpmachine; g++-4.$i
gcc-atomic.cpp; done
g++-4.1 (GCC) 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

i486-linux-gnu
/tmp/ccGnLtMn.o: In function `void test()':
gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x46): undefined
reference to `__sync_fetch_and_add_8'
gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x5f): undefined
reference to `__sync_fetch_and_or_8'
gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x78): undefined
reference to `__sync_fetch_and_xor_8'
gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x9f): undefined
reference to `__sync_val_compare_and_swap_8'
/tmp/ccGnLtMn.o: In function `void test()':
gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x45):
undefined ref

[Bug tree-optimization/47460] Inconsistent behaviour of __sync_fetch_and_add builtin?

2011-01-25 Thread manuel.holtgr...@fu-berlin.de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47460

--- Comment #3 from Manuel Holtgrewe  2011-01-25 
16:53:23 UTC ---
Sorry for posting this here again, but could somebody clarify the following,
nevertheless and if this is expected behaviour, close the bug as invalid? In
the future, I'll first try to ask on the list.

Versions 4.4 and 4.5 were built with the same parameters (modulo some
libraries), so my question is: Why are the __sync_fetch* builtins not found in
4.4 by default? Is this related to the configure parameters?

  --with-cloog=/group/agabi/software/i686/gcc-4.4.5
--with-ppl=/group/agabi/software/i686/gcc-4.4.5


--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--

$ for i in 1 2 3 4 5; do g++-4.$i --version; g++-4.$i -v; done
g++-4.1 (GCC) 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1
--enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug
--with-tune=generic --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)
g++-4.2 (GCC) 4.2.4 (Debian 4.2.4-6)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2
--program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-mpfr --enable-targets=all --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.2.4 (Debian 4.2.4-6)
g++-4.3 (Debian 4.3.2-1.1) 4.3.2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.2-1.1'
--with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3
--program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-mpfr --enable-targets=all --enable-cld
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.3.2 (Debian 4.3.2-1.1) 
g++-4.4.5 (GCC) 4.4.5
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../../gcc-4.4.5/configure
--prefix=/group/agabi/software/i686/gcc-4.4.5
--with-mpfr=/group/agabi/software/i686/gcc-4.4.5
--with-mpfr-lib=/group/agabi/software/i686/gcc-4.4.5/lib
--with-gmp=/group/agabi/software/i686/gcc-4.4.5
--with-mpc=/group/agabi/software/i686/gcc-4.4.5
--with-cloog=/group/agabi/software/i686/gcc-4.4.5
--with-ppl=/group/agabi/software/i686/gcc-4.4.5 --enable-languages=c,c++
--program-suffix=-4.4.5
Thread model: posix
gcc version 4.4.5 (GCC) 
g++-4.5.1 (GCC) 4.5.1
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Using built-in specs.
COLLECT_GCC=/group/agabi/software/i686/gcc-4.5.1/bin/g++-4.5.1
COLLECT_LTO_WRAPPER=/group/agabi/software/i686/gcc-4.5.1/libexec/gcc/i686-pc-linux-gnu/4.5.1/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../configure --prefix=/group/agabi/software/i686/gcc-4.5.1
--with-mpfr=/group/agabi/software/i686/gcc-4.5.1
--with-mpfr-lib=/group/agabi/software/i686/gcc-4.5.1/lib
--with-gmp=/group/agabi/software/i686/gcc-4.5.1
--with-mpc=/group/agabi/software/i686/gcc-4.5.1 --enable-languages=c,c++
--program-suffix=-4.5.1
Thread model: posix
gcc version 4.5.1 (GCC)


[Bug tree-optimization/47460] Inconsistent behaviour of __sync_fetch_and_add builtin?

2011-01-25 Thread manuel.holtgr...@fu-berlin.de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47460

Manuel Holtgrewe  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID

--- Comment #5 from Manuel Holtgrewe  2011-01-25 
17:02:19 UTC ---
Thanks for clarifying, Jonathan. Sorry for preemptively adding this as a bug.