I have a dual-boot on my computer since I prefer to code on linux. On windows, I use Intel Composer XE 2013, and to compare I installed the same version on linux (at first I used the intel compiler 17 on linux, but I went back to 2013 in order to compare properly with windows).
I have a program involving mostly computation (a fixed point algorithm). I compile it on windows with similar flags (-openmp -fast and link to boost library)... but the windows executable ends up being about 1.6 times faster.
More detail about the program: at the core of it I m using the boost library, with this kind of computations (that i m calling millions of time):
boost::math::lognormal distrib(mu, sigma); value = exp(boost::math::lgamma(N))*pow(cdf(distrib, x), 5);
I already noticed on linux (and I don t know why) that icpc tends to be faster for any call to boost function (like lgamma) than g++. However it's even faster overall on windows than on linux and I don't know why (and this is highly probably the reasons why windows is faster than linux).
(I also use openmp to parallelize loops but even without it the difference between OS stays).
What is the explanation? maybe some pre-build differences in compilation flags between the two platforms? Or is windows simply faster with ICC ? This would be weird because I never heard of such a thing (and for gcc for example, it tends to always be faster on linux with the same computer...).
Not sure it s relevant but on windows when I compile with the following .bat:
@call "C:\Program Files (x86)\Intel\Composer XE 2013\bin\iclvars.bat" ia32 icl /openmp /I "C:\boost_1_61_0" /fast program.cpp
and when I launch it, it says:
Intel(R) composer XE 2013 (package 089) Setting environment for using Microsoft Visual Studio 2010 x86 tools. Intel(R) C++ Compiler XE for applications running on IA-32. Version 13.0.0.089 Build 20120731 ... Microsoft (R) Incremental Linker Version 10.00.30319.01 -
Notice that I use ia32 while I'm being on an intel64 system (x86_64). But as a consequence on Linux I'm also using ia32 with:
source /media/usr/intel2013/bin/iccvars.sh intel64 icpc -o program program.cpp -std=c++11 -openmp -fast
Notice that on linux I have to impose -std=c++11 for it not to bug (while on windows I don't think it uses c++11 in fact when compiling.
I would like to definitely switch to linux but I would need my program to run at least as fast as on windows. It's been about 5 days that I'm looking for a solution to this, tweaking with flags and all, but I'm pretty new to compiler performance optimization and I was unable to find the reason why I have differences.
Any help would be greatly appreciated.
Edit: as for my hardware: Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz, 8 CPU, 4 cores, 2 threads per core, architecture x86_64. Windows is 8.1 and Linux 4.8.0-54-generic #57~16.04.1-Ubuntu