View previous topic :: View next topic |
Author |
Message |
kfiaciarka Veteran
Joined: 20 May 2005 Posts: 1498 Location: Dobre Miasto, Poland
|
Posted: Wed Apr 09, 2008 9:16 pm Post subject: -d_glibcxx_parallel |
|
|
Does anyone tried this cflag combined with -fopenmp ? Code: | -D_GLIBCXX_PARALLEL -fopenmp | and experienced any speedup or compilaton issues? Here is some background |
|
Back to top |
|
|
MostAwesomeDude Guru
Joined: 12 Aug 2007 Posts: 373
|
Posted: Thu Apr 10, 2008 6:46 pm Post subject: |
|
|
Technically, you're supposed to set that flag along with -fopenmp for OpenMP support, but GCC appears to enable its builtin speedups even without it.
Yeah, I have a few things that use it, but the majority of code in Gentoo has not been altered to support OpenMP. Adding it to your CFLAGS would be pretty silly, since most code would end up linked with libgomp but not actually using it. _________________ Don't believe the "n00b" under my name. |
|
Back to top |
|
|
kfiaciarka Veteran
Joined: 20 May 2005 Posts: 1498 Location: Dobre Miasto, Poland
|
Posted: Thu Apr 10, 2008 6:56 pm Post subject: |
|
|
so what is the optimal solution to get some benefits from it ? Is just openmp USE enough for gcc to support it so additional -fopenmp c(xx)flag is not needed? Then -D_GLIBCXX_PARALLEL alone would be all you need to set ? |
|
Back to top |
|
|
loftwyr l33t
Joined: 29 Dec 2004 Posts: 970 Location: 43°38'23.62"N 79°27'8.60"W
|
Posted: Thu Apr 10, 2008 8:10 pm Post subject: |
|
|
The D_GLIBCXX_PARALLEL flag will only have a useful effect if the program makes use of OpenMP structures. Setting it as a default CFLAGS entry wouldn't be of any use. The programmer would set it if it would have any effect. _________________ My emerge --info
Have you run revdep-rebuild lately? It's in gentoolkit and it's worth a shot if things don't work well.
Celebrating 5 years of Gentoo-ing. |
|
Back to top |
|
|
MostAwesomeDude Guru
Joined: 12 Aug 2007 Posts: 373
|
Posted: Thu Apr 10, 2008 10:11 pm Post subject: |
|
|
kfiaciarka wrote: | so what is the optimal solution to get some benefits from it ? Is just openmp USE enough for gcc to support it so additional -fopenmp c(xx)flag is not needed? Then -D_GLIBCXX_PARALLEL alone would be all you need to set ? |
Setting -fopenmp will cause GCC to link against libgomp, and will enable OpenMP. The -D_GLIBCXX_PARALLEL will enable parallel STL code in libstdc++ for certain algorithms, which means that stuff in <algorithm> and <numeric> will automagically become parallelized.
GCC 4.2 and 4.3 will not enable OpenMP without -fopenmp. _________________ Don't believe the "n00b" under my name. |
|
Back to top |
|
|
kfiaciarka Veteran
Joined: 20 May 2005 Posts: 1498 Location: Dobre Miasto, Poland
|
Posted: Thu Apr 10, 2008 10:50 pm Post subject: |
|
|
@MostAwesomeDude
ok, maybe you have got some personal experience with it? Or you think that giving it a shot is just pointless? |
|
Back to top |
|
|
loftwyr l33t
Joined: 29 Dec 2004 Posts: 970 Location: 43°38'23.62"N 79°27'8.60"W
|
Posted: Fri Apr 11, 2008 12:41 am Post subject: |
|
|
MostAwesomeDude wrote: |
Setting -fopenmp will cause GCC to link against libgomp, and will enable OpenMP. The -D_GLIBCXX_PARALLEL will enable parallel STL code in libstdc++ for certain algorithms, which means that stuff in <algorithm> and <numeric> will automagically become parallelized.
GCC 4.2 and 4.3 will not enable OpenMP without -fopenmp. |
From the GOMP webpage:
Quote: |
When -fopenmp is used, the compiler will generate parallel code based on the OpenMP directives encountered.
|
What that means is, IF the programmer is using openMP code, then -fopenmp and _GLIBCXX_PARALLEL will have an affect. On normal code, -fopenmp has no effect. _________________ My emerge --info
Have you run revdep-rebuild lately? It's in gentoolkit and it's worth a shot if things don't work well.
Celebrating 5 years of Gentoo-ing. |
|
Back to top |
|
|
MostAwesomeDude Guru
Joined: 12 Aug 2007 Posts: 373
|
Posted: Fri Apr 11, 2008 5:41 am Post subject: |
|
|
kfiaciarka wrote: | @MostAwesomeDude
ok, maybe you have got some personal experience with it? Or you think that giving it a shot is just pointless? |
One of my side projects is a video game, and we have OpenMP support in some places in the code. So far, we're not seeing massive improvements; the biggest thing we're seeing is that we can peg one core with graphics and still have plenty of room on the second core for everything else, which is not exactly OpenMP-specific but is easier with it enabled.
Quote: |
What that means is, IF the programmer is using openMP code, then -fopenmp and _GLIBCXX_PARALLEL will have an affect. On normal code, -fopenmp has no effect. |
Half-right. The define is needed (I think?) to enable the parallel paths in the STL. So, using "-fopenmp -D_GLIBCXX_PARALLEL" should turn std::sort into a parallelized block of code upon compile. This allows unmodified code to experience OpenMP gains. However, I know that this is limited to the algorithms in <algorithm> and <numeric>, so if you don't use those you won't see anything. (And, before you ask, I have no idea about stuff like Boost or SWIG.) _________________ Don't believe the "n00b" under my name. |
|
Back to top |
|
|
|