Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Significantly slower code when compiling with G++ instead of LLVM

I am experimenting with an algorithm I programmed in C++ using XCode 7.0. When I compare the performance of the standard LLVM compiler in XCode to the binary created when compiling using G++ (5.2.0) the binary created using LLVM is an order of magnitude (>10x) faster than the code created using the g++ compiler.

I am using the -o3 code optimisation flag for the g++ compiler as follows:

/usr/local/Cellar/gcc/5.2.0/bin/g++-5 -o3 -fopenmp -DNDEBUG main.cpp \
PattersonInstance.cpp \
... \
-o RROTprog

The g++ compilation is needed because the algorithm has to be compiled and run on a high performance computer where I cannot use the LLVM compiler. Plus I would like to use Open MP to make the code faster.

All ideas on the reason what is causing these speed differences and how they could be resolved is more than welcome.

Thanks in advance for the help!

L

like image 711
Louis-Philippe Avatar asked Dec 18 '22 23:12

Louis-Philippe


1 Answers

I can bet that what happens is the following: you pass -o3 to the compiler, instead of -O3 (i.e. with CAPITAL O) and for this reason -o3 just instructs the compiler to output the executable to a file called "3". However you use -o RROTprog later in the same command line, and the last -o is the one that's considered by the compiler when outputting the executable.

The net effect: the -O3 is not present, hence no optimization is being done.

like image 113
vsoftco Avatar answered Dec 21 '22 13:12

vsoftco