The best compiler for chess, Intel or gcc or something else?

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

Has GCC caught up with Intel with respect to performance?

Poll ended at Sun Oct 14, 2012 4:32 pm

Yes
15
60%
No
10
40%
 
Total votes: 25

diep
Posts: 1822
Joined: Thu Mar 09, 2006 11:54 pm
Location: The Netherlands

Re: The best compiler for chess, Intel or gcc or something e

Post by diep »

Tom Likens wrote:
Don wrote:This issue has come up in another thread - I have heard conflicting reports over the past few years.

Some say that gcc as of version 4.6 and 4.7 is now at least the equal of Intel with respect to producing binaries that perform well - particularly due to improved link time optimization and a massive improvement in PGO.

Traditionally however Intel has always had the edge. What is the truth?

Both compilers are available for Windows and Linux - are there any platform differences? For instance is the Intel compiler crippled on Linux?
Don,

My experience is that the GCC has caught up with Intel when you use GCC 4.6+ (I'm currently using the default 64-bit version 4.6.3 that comes with Linux Mint vs. icpc (ICC) 13.0.0 20120731). This wasn't true for earlier versions of the Gnu compiler; then Intel had a substantial lead, especially when PGO was selected. At that time ICC was roughly 30% faster after PGO optimization.

I do have one question for you, previously you said that you were able to run PGO on a GCC compiled linux version and use it for optimizing a MingW version (same gcc version for both of course). I've tried this but it doesn't seem to work for me. I get a lot of messages that the optimizer can't find a large number of the functions (the name C++ name-mangling algorithm seems different) and the final Windows executable doesn't seem any faster than a straight MingW compile.

Could you elaborate a bit more on exactly how you got that to work, as it would be nice not to leave a 10-15% performance boost on the table. Is Komodo a C or C++ program? That might be the difference as my engine is written in C++.

regards,
--tom
Specify the directory explicitly to GCC, that should solve your problem.

GCC stil is roughly 10% slower here than intel c++. That's a huge difference.
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: The best compiler for chess, Intel or gcc or something e

Post by Don »

Tom Likens wrote:
Don wrote:This issue has come up in another thread - I have heard conflicting reports over the past few years.

Some say that gcc as of version 4.6 and 4.7 is now at least the equal of Intel with respect to producing binaries that perform well - particularly due to improved link time optimization and a massive improvement in PGO.

Traditionally however Intel has always had the edge. What is the truth?

Both compilers are available for Windows and Linux - are there any platform differences? For instance is the Intel compiler crippled on Linux?
Don,

My experience is that the GCC has caught up with Intel when you use GCC 4.6+ (I'm currently using the default 64-bit version 4.6.3 that comes with Linux Mint vs. icpc (ICC) 13.0.0 20120731). This wasn't true for earlier versions of the Gnu compiler; then Intel had a substantial lead, especially when PGO was selected. At that time ICC was roughly 30% faster after PGO optimization.

I do have one question for you, previously you said that you were able to run PGO on a GCC compiled linux version and use it for optimizing a MingW version (same gcc version for both of course). I've tried this but it doesn't seem to work for me. I get a lot of messages that the optimizer can't find a large number of the functions (the name C++ name-mangling algorithm seems different) and the final Windows executable doesn't seem any faster than a straight MingW compile.

Could you elaborate a bit more on exactly how you got that to work, as it would be nice not to leave a 10-15% performance boost on the table. Is Komodo a C or C++ program? That might be the difference as my engine is written in C++.

Komodo is written in C. I simply do the PGO in linux, then I cross compile it using mingw making sure the compiler sees the profile file. The windows version is much faster when doing that.

The slowdown I'm getting for windows is separate from this though. I get the slowdown from linux to windows even when I do not PGO either of them.


regards,
--tom
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.
Joost Buijs
Posts: 1562
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: The best compiler for chess, Intel or gcc or something e

Post by Joost Buijs »

Don wrote:In another thread someone reports that "MSVC version without PGO was 10% faster then the GCC version with the PGO."

But Dragan, who reports this, does not say what compiler options are used.
In the past I've noticed that MSVC without PGO was slightly faster than Intel C++ without PGO, but with PGO enabled Intel C++ was still on top.

Today I've made a short comparison with my program between MSVC 10.0, MSVC 11.0 and Intel C++ 13.0 using a single thread on a core i7:

MSVC 10.0 (-O2) 2627007 nps.
MSVC 11.0 (-O2) 2615285 nps.
Intel C++ 13.0 (-O2) 2629834 nps.
Intel C++ 13.0 (-O3) 2630472 nps.
Intel C++ 13.0 (PGO) 2707104 nps.
MSVC 11.0 (PGO) 2825527 nps.

It seems MSVC 11.0 with PGO has a slight edge here.

I never tried with GCC because (in the past) it had a bad reputation, and I'll probably have to make a lot of changes to my source to get it compiled without errors.

I also found that the use of 64 bit ints instead of 32 bit ints gives a very slight improvement on both Intel and MSVC. Under Linux both compilers seem to default to 64 bit ints while under Windows this is 32 bit.
stevenaaus
Posts: 608
Joined: Wed Oct 13, 2010 9:44 am
Location: Australia

Re: The best compiler for chess, Intel or gcc or something e

Post by stevenaaus »

rbarreira wrote:ICC used to have an edge even when PGO was not used. In my experience this is not the case anymore since gcc 4.5.

When PGO is used, it's possible that ICC still has an edge. Probably a small one, if anything (something like 5-10%).

GCC has an edge in being able to generate hardware-agnostic binaries, whereas ICC creates executables that either don't run on AMD at all, or run with a crappy codepath which deliberately cripples performance. This is well documented and was proven in court:

http://www.agner.org/optimize/blog/read.php?i=49
On this web page is noted
In my tests, the Gnu compiler for Linux has an optimizing performance similar to the Intel compiler, but the Gnu function library (glibc) is inferior.
Is this correct ? Here's an old post by Linus http://ecos.sourceware.org/ml/libc-alph ... 00079.html
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: The best compiler for chess, Intel or gcc or something e

Post by Don »

stevenaaus wrote:
rbarreira wrote:ICC used to have an edge even when PGO was not used. In my experience this is not the case anymore since gcc 4.5.

When PGO is used, it's possible that ICC still has an edge. Probably a small one, if anything (something like 5-10%).

GCC has an edge in being able to generate hardware-agnostic binaries, whereas ICC creates executables that either don't run on AMD at all, or run with a crappy codepath which deliberately cripples performance. This is well documented and was proven in court:

http://www.agner.org/optimize/blog/read.php?i=49
On this web page is noted
In my tests, the Gnu compiler for Linux has an optimizing performance similar to the Intel compiler, but the Gnu function library (glibc) is inferior.
Is this correct ? Here's an old post by Linus http://ecos.sourceware.org/ml/libc-alph ... 00079.html
This goes back to early 2002 and the point was not that it was inferior, but Linus felt it was bloated - too many functions.

In either case, I don't think this applies to execution speed of a chess program.
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.
Modern Times
Posts: 3517
Joined: Thu Jun 07, 2012 11:02 pm

Re: The best compiler for chess, Intel or gcc or something e

Post by Modern Times »

Jim Ablett would surely have something to say on this. Someone should make him aware of the thread.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: The best compiler for chess, Intel or gcc or something e

Post by lucasart »

In my experience, nothing beats GCC 4.7. As for PGO, I have never found that to be faster: maybe it used to in earlier versions, but with -O4 -flto, it's as fast w/o PGO

Who needs ICC or Mickeysoft VC++ anymore :wink:
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: The best compiler for chess, Intel or gcc or something e

Post by Don »

Modern Times wrote:Jim Ablett would surely have something to say on this. Someone should make him aware of the thread.
I don't know about MSVC but let's compare to the Intel compiler. When Jim Ablett was making binaries for me, they were faster that anything I could produce but they were nothing like what is being reported here. To believe some of these posts gcc is a completely worthless compiler and huge numbers are being bandied about that do not have the ring of truth. Jim Ablett used the Intel compiler and could get about 5% more than I could get with GCC, but this was before gcc 4.6 which has improved a lot.

So I'm asking people here not be compiler advocates, this thread is not about what your favorite compiler is but to get some objective facts based on recent data. That may be asking too much however because it's easy to use the "wrong" compiler options, the wrong compiler versions and so on. So anytime I hear anything too much over 5% (comparing gcc to Intel or MSVC) I start to believe something is being exaggerated or made up. In fact my experience says that 5% is a rough upper bound on what is credible in either direction. I do think it's likely one compiler may be 2-5 percent better. The other possibility is that this is highly dependent on how you write code. I have heard people claim that llvm or other compilers compile their code to run faster than gcc does, but each time I try it is around 5% weaker.
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: The best compiler for chess, Intel or gcc or something e

Post by bob »

Don wrote:This issue has come up in another thread - I have heard conflicting reports over the past few years.

Some say that gcc as of version 4.6 and 4.7 is now at least the equal of Intel with respect to producing binaries that perform well - particularly due to improved link time optimization and a massive improvement in PGO.

Traditionally however Intel has always had the edge. What is the truth?

Both compilers are available for Windows and Linux - are there any platform differences? For instance is the Intel compiler crippled on Linux?
The only known issue I am aware of is that intel binarys can really blow on AMD processors. Otherwise, I have found nothing better than the Intel compiler. GCC has had so many PGO-related bugs I quit using it because it would crash when I tried to PGO a threaded program...
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: The best compiler for chess, Intel or gcc or something e

Post by Don »

lucasart wrote:In my experience, nothing beats GCC 4.7. As for PGO, I have never found that to be faster: maybe it used to in earlier versions, but with -O4 -flto, it's as fast w/o PGO

Who needs ICC or Mickeysoft VC++ anymore :wink:
That is pretty odd, I found major benefit's for PGO with Komodo. Maybe it is very program specific then.
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.