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

User avatar
velmarin
Posts: 1600
Joined: Mon Feb 21, 2011 9:48 am

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

Post by velmarin »

You can download a free evaluation of Intel Compiler 30 days,
Download Visual Studio 90-day trial, albeit installed in a virtual machine and perform their own tests.

There would have to compare two compilers.
Nothing like making yourself.
ZirconiumX
Posts: 1334
Joined: Sun Jul 17, 2011 11:14 am

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

Post by ZirconiumX »

velmarin wrote:You can download a free evaluation of Intel Compiler 30 days,
Download Visual Studio 90-day trial, albeit installed in a virtual machine and perform their own tests.

There would have to compare two compilers.
Nothing like making yourself.
Jose, ICC is free for non-commercial use - do a bit of digging and you should get a free license key for unlimited use - providing you don't make ANY money out of your executables.

MSVC is also free - I can't remember the name of the stripped down version though.

GCC is free for all uses - big plus for Don.

Matthew:out
Some believe in the almighty dollar.

I believe in the almighty printf statement.
User avatar
velmarin
Posts: 1600
Joined: Mon Feb 21, 2011 9:48 am

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

Post by velmarin »

Matew,
There is a question,
I suggested test, 30 day trial version.
Visual studio full 90 days trial.
No fees, totally legal.

Then if there are results, buy something else.
Komodo is also commercial.
This is a survey.

Code: Select all

http://software.intel.com/en-us/intel-parallel-studio-xe-evaluation/
You are here
Home » Intel® Parallel Studio XE 2013 for Windows* - Evaluation
INTEL® DEVELOPER ZONE:
Intel® Parallel Studio XE 2013 for Windows* - Evaluation
In order to install and use the Intel® Parallel Studio XE 2013 for Windows* product, you must have already installed a supported Microsoft development product. Please see the System Requirements for more information. If you do not already have a supported Microsoft development product installed, you may download a free 90-day trial version of Microsoft Visual Studio 2010* from Microsoft. This will allow for full functionality of the product during your evaluation. If, at the end of evaluation, you choose to purchase Intel Parallel Studio XE 2013 for Windows, the purchased product includes Visual Studio 2010 Shell and Libraries, enabling use of Intel® Visual Fortran Composer XE 2013, Intel VTune Amplifier XE 2013, Intel® Inspector XE 2013, and  Intel® Advisor XE 2013 without requiring a separate purchase of Microsoft Visual Studio, but the use of Intel C++ Composer XE 2013 requires a separate Visual Studio purchase.

If you understand and accept this requirement, click on the Accept button to proceed with your evaluation.
Last edited by velmarin on Mon Oct 08, 2012 10:20 pm, edited 1 time in total.
syzygy
Posts: 5554
Joined: Tue Feb 28, 2012 11:56 pm

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

Post by syzygy »

Joost Buijs wrote: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.
On 64-bit Linux, ints (i.e. type "int" in C) are 32 bits. On Windows I'm reasonably sure this is not different, but maybe it is a compiler flag (which would easily lead to problems though when mixing object code and libraries compiled with different flags...).
syzygy
Posts: 5554
Joined: Tue Feb 28, 2012 11:56 pm

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

Post by syzygy »

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 ?
If you read the whole page you'll see that he is talking about the math library. Apparently, at least at that time, the implementation of the GNU math library functions was not state of the art. That might still be true, but it won't affect chess engines.

Afaik the Intel compiler on Linux also links to glibc. It doesn't make a lot of sense to have two different C-library implementations on a single system. This might be different for statically linked math library functions.

The 10-year old post by Linus has nothing to do with this.
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 »

bob wrote: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...
Has anyone tried spoofing the CPU vendor ID on AMD CPUs. I guess this is the way to do it.
http://www.agner.org/optimize/blog/read.php?i=49#117
syzygy
Posts: 5554
Joined: Tue Feb 28, 2012 11:56 pm

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

Post by syzygy »

lucasart wrote:In my experience, nothing beats GCC 4.7.
For me gcc-4.7.0 was noticeably slower than gcc-4.6.2 or so, until I added the flag -fno-tree-vectorize.

This might be related to my use of -msse4.2 and/or -march=i7, because as far as I understand the vectorization attempts to use vector instructions for loops (so a vector instruction set must be enabled for "tree-vectorize" to kick in).

When I tried the Intel compiler, it did not beat gcc-4.6. And clang was just slower.
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 »

syzygy wrote:On 64-bit Linux, ints (i.e. type "int" in C) are 32 bits. On Windows I'm reasonably sure this is not different, but maybe it is a compiler flag (which would easily lead to problems though when mixing object code and libraries compiled with different flags...).
I've read somewhere that size_t of the 'int' type from ICC on Linux is 8 bytes, this seems to be wrong then. In ICC and MSVC there is no compiler flag to change the size of the 'int' type, thats why I defined int_t and uint_t and use this throughout my program, I don't use plain 'int' anywhere.
Strangely enough using 64 bit ints performs a little better with my engine.
rbarreira
Posts: 900
Joined: Tue Apr 27, 2010 3:48 pm

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

Post by rbarreira »

stevenaaus wrote:
bob wrote: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...
Has anyone tried spoofing the CPU vendor ID on AMD CPUs. I guess this is the way to do it.
http://www.agner.org/optimize/blog/read.php?i=49#117
That has one problem for some AMD CPUs, at least the Phenom II which has some SSE 4.2 instructions (including the most important one for chess, popcnt) but not all. So your program can crash if you spoof SSE 4.2, I guess Intel conveniently detected it that way instead of checking for individual instructions.
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 »

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:
Most experts seem to disagree with me, which should indicate that I am wrong. So that got me wondering and I did some tests.

First, let's all take the same source code so we don't compare apples and pears. I'm using Stockfish 2.3.1 compiling from source code
http://stockfishchess.org/download/
(don't use github because there were some commits since 2.3.1)

Note that I'm using GCC 4.7.2 (Lubuntu 12.10 x86_64)

PGO build

Code: Select all

$make profile-build ARCH=x86-64
$./stockfish bench > /dev/null
(...)
Total time (ms) : 5818
Nodes searched  : 5423738
Nodes/second    : 932234
Normal build

Code: Select all

$make build ARCH=x86-64
$./stockfish bench > /dev/null
(...)
Total time (ms) : 5244
Nodes searched  : 5423738
Nodes/second    : 1034274
Normal build -O4
instead of -O3, which is what the default Makefile uses (suboptimal).

Code: Select all

Total time (ms) : 5070
Nodes searched  : 5423738
Nodes/second    : 1069770
Jim Ablett's build
It still doesn't beat -O4 -flto

Code: Select all

Total time (ms) : 5155
Nodes searched  : 5423738
Nodes/second    : 1052131
So I maintain that -O4 -flto is at least equal (in this case clearly faster) to PGO. I noticed the same thing with my engine DiscoCheck (was actually about equal). As for ICC, I would like to see someone prove me that it performs that GCC 4.7, but I strongly doubt it... Please post your results, so we can rescale by the Jim Ablett compile for example to compare NPS.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.