Lambda is slower with g ++ 4.7 - faster with g ++ 4.6

I used g ++ 4.7 because it is one of the latest releases of g ++ and the first that adds real support for c++11 .

For testing purposes, I review the code made here .

Here you can find the full source code.

I call this source lambda.cpp and compile it with:

 g++-4.6 -std=c++0x lambda.cpp -o lambda46 g++-4.7 -std=c++11 lambda.cpp -o lambda47 

The lambda47 executable is about half a second slower than lambda46 when it comes to lambda execution, the surprise is that part of the iterator is usually faster than lambda46.

I also tried to use

 g++-4.7 -std=c++0x lambda.cpp -o lambda47-0x 

but basically g ++ - 4.6 always generates faster code than g ++ - 4.7.

Is this normal behavior or a mistake?

Is there a compiler that will work better with C ++ 11?


g ++ - 4.7 it was compiled with

Configurable with: ../ src / configure -v --with-pkgversion = 'Ubuntu / Linaro 4.7.2-4precise1' --with-bugurl = file: ///usr/share/doc/gcc-4.7/README .Bugs --enable-languages ​​= c, C ++, go, fortran, objc, obj-C ++ - -prefix = / usr --program-suffix = -4.7 --enable-shared -enable-linker -build-id --with-system-zlib --libexecdir = / usr / lib --without-included-gettext - -enable-threads = posix --with-gxx-include-dir = / usr / include / C + + / 4.7 --libdir = / usr / lib --enable-nls --with-sysroot = / - enable-clocale = gnu --enable-libstdcxx-debug --enable-libstdcxx-time = yes --enable- gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32 = i686 --with-tune = generic --enable-checking = release --build = x86_64 -linux-gnu -host = x86_64-linux-gnu --target = x86_64-linux-gnu

g ++ - 4.6 s

Configurable with: ../ src / configure -v --with-pkgversion = 'Ubuntu / Linaro 4.6.3-1ubuntu5' --with-bugurl = file: ///usr/share/doc/gcc-4.6/README .Bugs --enable-languages ​​= c, C ++, fortran, objc, obj-C ++ --prefix = / usr --program-suffix = -4.6 --enable-shared -enable-linker-build -id --with-system-zlib --libexecdir = / usr / lib --without-included-gettext --enable -threads = posix --with-gxx-include-dir = / usr / include / C ++ / 4.6 --libdir = / usr / lib --enable-nls --with-sysroot = / - enable-clocale = gnu - -enable-libstdcxx-debug --enable-libstdcxx-time = yes --enable-gnu- unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32 = i686 --with-tune = generic --enable-checking = release --build = x86_64-linux -gnu -host = x86_64-linux-gnu -target = x86_64-linux-gnu

+6
source share
1 answer

In my case, the lambda version is faster with g ++ 4.6 and 4.7 (and g ++ 4.7 is faster code than 4.6). The only difference is that I use the 32-bit version of compilers.

But if I compile the code with -O3, the iterator will be faster by about 2 seconds.

+1
source

All Articles