public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/38897]  New: Parallel mode example code does not compile
@ 2009-01-17 18:08 j dot s dot sebastian at gmail dot com
  2009-01-19 13:50 ` [Bug libstdc++/38897] " j dot s dot sebastian at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: j dot s dot sebastian at gmail dot com @ 2009-01-17 18:08 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4518 bytes --]

Compilation fails of the small code sample found at:

http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt12ch31s03.html

I am using the suggested compiler options.
This is the code (cut and pasted from your documentation):

#include <vector>
#include <parallel/algorithm>

int main()
{
  std::vector<int> v(100);

  // ...

  // Explicitly force a call to parallel sort.
  __gnu_parallel::sort(v.begin(), v.end());
  return 0;
}

If it is this code that is incorrect the docs should be fixed as there are not
many examples of  parallel libstdc++ usage to be found on the net at the
moment.

This is g++ output:

g++ -v -save-temps -fopenmp -march=i686 -o test parallelsort.cpp 
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.2-1ubuntu11'
--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-checking=release
--build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu11) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-fopenmp' '-march=i686' '-o' 'test'
'-shared-libgcc' '-pthread'
 /usr/lib/gcc/i486-linux-gnu/4.3.2/cc1plus -E -quiet -v -D_GNU_SOURCE
-D_REENTRANT parallelsort.cpp -D_FORTIFY_SOURCE=2 -march=i686 -fopenmp
-fpch-preprocess -o parallelsort.ii
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.3
 /usr/include/c++/4.3/i486-linux-gnu
 /usr/include/c++/4.3/backward
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.3.2/include
 /usr/lib/gcc/i486-linux-gnu/4.3.2/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-fopenmp' '-march=i686' '-o' 'test'
'-shared-libgcc' '-pthread'
 /usr/lib/gcc/i486-linux-gnu/4.3.2/cc1plus -fpreprocessed parallelsort.ii
-quiet -dumpbase parallelsort.cpp -march=i686 -auxbase parallelsort -version
-fopenmp -fstack-protector -o parallelsort.s
GNU C++ (Ubuntu 4.3.2-1ubuntu11) version 4.3.2 (i486-linux-gnu)
        compiled by GNU C version 4.3.2, GMP version 4.2.2, MPFR version 2.3.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: dc8f858cacda993dd8f70837f0d9565d
/usr/include/c++/4.3/parallel/algo.h: In function ‘void
std::__parallel::sort(_RAIter, _RAIter) [with _RAIter =
__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >]’:
parallelsort.cpp:11:   instantiated from here
/usr/include/c++/4.3/parallel/algo.h:1736: error: call of overloaded
‘sort(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> >
>&, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> >
>&, std::less<int>)’ is ambiguous
/usr/include/c++/4.3/parallel/algo.h:1741: note: candidates are: void
std::__parallel::sort(_RAIter, _RAIter, _Compare) [with _RAIter =
__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >,
_Compare = std::less<int>]
/usr/include/c++/4.3/bits/stl_algo.h:4806: note:                 void
std::sort(_RAIter, _RAIter, _Compare) [with _RAIter =
__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >,
_Compare = std::less<int>]

So it can't resolve the ambiguous overloading between a parallel and
non-parallel version of sort.

I am not sure which -march option i should be using, but i tried using none,
-march=i686, and -march=native, with identical results.

This is an up-to-date ubuntu 8.10, by the way.


-- 
           Summary: Parallel mode example code does not compile
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: j dot s dot sebastian at gmail dot com
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38897


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/38897] Parallel mode example code does not compile
  2009-01-17 18:08 [Bug libstdc++/38897] New: Parallel mode example code does not compile j dot s dot sebastian at gmail dot com
@ 2009-01-19 13:50 ` j dot s dot sebastian at gmail dot com
  2009-01-19 14:05 ` paolo dot carlini at oracle dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: j dot s dot sebastian at gmail dot com @ 2009-01-19 13:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from j dot s dot sebastian at gmail dot com  2009-01-19 13:50 -------
After some trial and error, I found it does compile (on same system) if I
modify the code as follows, to use the 3-argument version of sort:

#include <vector>
#include <parallel/algorithm>

int main()
{
  std::vector<int> v(100);

  // Explicitly force a call to parallel sort.
  //__gnu_parallel::sort(v.begin(), v.end());
  __gnu_parallel::sort(v.begin(), v.end(),std::less<int>());
  return 0;
}

Still I think it is a bug (not just documentation bug), as both versions should
work.

By the way this parallel STL stuff is just awesome ;-)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38897


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/38897] Parallel mode example code does not compile
  2009-01-17 18:08 [Bug libstdc++/38897] New: Parallel mode example code does not compile j dot s dot sebastian at gmail dot com
  2009-01-19 13:50 ` [Bug libstdc++/38897] " j dot s dot sebastian at gmail dot com
@ 2009-01-19 14:05 ` paolo dot carlini at oracle dot com
  2009-01-19 17:17 ` paolo dot carlini at oracle dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-01-19 14:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from paolo dot carlini at oracle dot com  2009-01-19 14:05 -------
Thanks for the additional info. Let's add Johannes in CC, I'm confident we can
fix this pretty soon.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo at gcc dot gnu dot
                   |                            |org, singler at ira dot uka
                   |                            |dot de
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-01-19 14:05:04
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38897


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/38897] Parallel mode example code does not compile
  2009-01-17 18:08 [Bug libstdc++/38897] New: Parallel mode example code does not compile j dot s dot sebastian at gmail dot com
  2009-01-19 13:50 ` [Bug libstdc++/38897] " j dot s dot sebastian at gmail dot com
  2009-01-19 14:05 ` paolo dot carlini at oracle dot com
@ 2009-01-19 17:17 ` paolo dot carlini at oracle dot com
  2009-01-19 17:20 ` paolo dot carlini at oracle dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-01-19 17:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from paolo dot carlini at oracle dot com  2009-01-19 17:17 -------
Hummm, actually, I can't reproduce with current mainline... Can you also try a
snapshot / SVN checkout of current mainline?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38897


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/38897] Parallel mode example code does not compile
  2009-01-17 18:08 [Bug libstdc++/38897] New: Parallel mode example code does not compile j dot s dot sebastian at gmail dot com
                   ` (2 preceding siblings ...)
  2009-01-19 17:17 ` paolo dot carlini at oracle dot com
@ 2009-01-19 17:20 ` paolo dot carlini at oracle dot com
  2009-01-19 17:36 ` paolo dot carlini at oracle dot com
  2009-01-20 15:13 ` j dot s dot sebastian at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-01-19 17:20 UTC (permalink / raw)
  To: gcc-bugs



-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38897


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/38897] Parallel mode example code does not compile
  2009-01-17 18:08 [Bug libstdc++/38897] New: Parallel mode example code does not compile j dot s dot sebastian at gmail dot com
                   ` (3 preceding siblings ...)
  2009-01-19 17:20 ` paolo dot carlini at oracle dot com
@ 2009-01-19 17:36 ` paolo dot carlini at oracle dot com
  2009-01-20 15:13 ` j dot s dot sebastian at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-01-19 17:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from paolo dot carlini at oracle dot com  2009-01-19 17:36 -------
By the way, I don't see any serious divergence between the 4_3 and the mainline
libraries in this area, therefore likely the issue is ultimately due to a C++
front-end issue... Since 4.3.3 is being released right now, and, I understand,
there are dim hopes of a 4.3.4 any time soon, unless we figure out something
really trivial for 4_3-branch, we are not going to do anything...


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38897


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/38897] Parallel mode example code does not compile
  2009-01-17 18:08 [Bug libstdc++/38897] New: Parallel mode example code does not compile j dot s dot sebastian at gmail dot com
                   ` (4 preceding siblings ...)
  2009-01-19 17:36 ` paolo dot carlini at oracle dot com
@ 2009-01-20 15:13 ` j dot s dot sebastian at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: j dot s dot sebastian at gmail dot com @ 2009-01-20 15:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from j dot s dot sebastian at gmail dot com  2009-01-20 15:13 -------
It seems with libstdc++ from svn trunk the bug disappears. 

Both   

__gnu_parallel::sort(v.begin(), v.end());

and

__gnu_parallel::sort(v.begin(), v.end(),std::less<int>());

now compile and run.

At the moment I only succeeded in making it compile with -march=native (in 64
bit mode), but I think that looks like a totally unrelated issue with the way
i've setup the code from SVN.

So I guess we can close this bug.


-- 

j dot s dot sebastian at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38897


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-01-20 15:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-17 18:08 [Bug libstdc++/38897] New: Parallel mode example code does not compile j dot s dot sebastian at gmail dot com
2009-01-19 13:50 ` [Bug libstdc++/38897] " j dot s dot sebastian at gmail dot com
2009-01-19 14:05 ` paolo dot carlini at oracle dot com
2009-01-19 17:17 ` paolo dot carlini at oracle dot com
2009-01-19 17:20 ` paolo dot carlini at oracle dot com
2009-01-19 17:36 ` paolo dot carlini at oracle dot com
2009-01-20 15:13 ` j dot s dot sebastian at gmail dot com

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).