Smaug: a new chess engine based on glaurung

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: The Intel C++ compiler

Post by bob »

sje wrote:
zullil wrote:
sje wrote:The Intel C++ compiler is available for a limited time free trial if you give them some marketing data, Otherwise it's US$599 plus US$240/year for support.

I tried the free version some time ago. I don't recall any earthshaking improvements over g++, but I do remember that the Intel compiler did supply a few more useful diagnostics about questionable coding.
The Intel C++ compiler for Mac OS X is available for 30 days at no charge, for evaluation. No submission of marketing data is required.

Chess engine binaries compiled with icc are almost twice as fast as those compiled with gcc, at least on my Mac. For example, I just compiled Smaug221 using both icpc and g++. In a middlegame position with 45 possible moves, the icpc binary examined 1.81M nps, while the g++ binary examined 0.92 M nps.

Your results may vary a bit, but the Intel compiler produces much faster binaries than gcc does.
As I wrote, I never saw any huge speed increase in spite of considerable experimentation with compiler options. The extra diagnostics were useful even if half of them were spurious to some extent.

Also: Apple is spending a lot of R&D budget on speeding up Mac OS/X and the various professional applications it sells. Yet all of these are built with the same gcc tools that Apple ships for free. If the Intel compiler were really that much better, then Apple would use it themselves.
Probably not, because there are restrictions on what you can do and then sell.

But it is definitely faster. by at _least_ 10%. I have it on every machine I use, as well as the latest gcc. On my laptop I just compared 4.3 against the intel 11.0 compiler, both using PGO (which is broken about 1/2 the time in gcc and causes it to crash, although this version seems to work pretty well). 11.0 is 18% faster than gcc 4.3, for Crafty. 64 bit on fedora 10, core-2 duo 2.0ghz. I could probably test it on our dual quad-core cluster as well, but I suspect it would be the same. BTW 11.0 is about 10% faster than the last 10.x version they released... again for Crafty
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: The Intel C++ compiler

Post by sje »

bob wrote:
sje wrote:Also: Apple is spending a lot of R&D budget on speeding up Mac OS/X and the various professional applications it sells. Yet all of these are built with the same gcc tools that Apple ships for free. If the Intel compiler were really that much better, then Apple would use it themselves.
Probably not, because there are restrictions on what you can do and then sell.
Maybe for you and I, but Apple is one of Intel's biggest customers and in better financial shape than most of the others. Spending billions of bucks a year on Intel chips must mean some leverage for Apple, and I'm sure they could negotiate terms for using the Intel compiler for both in-house and compiled application distribution.

Apple being able to give it away for free (as is the case with the gcc toolchain) might be a different story, though.

Perhaps Apple thinks it's got a better deal with gcc because they can inject their customizations and improvements with better flexibility than they could achieve with Intel's software. Also, a compiler that might perform marginally better with a chess engine might not shine as brightly with the compilation of typical consumer applications.
User avatar
AdminX
Posts: 6340
Joined: Mon Mar 13, 2006 2:34 pm
Location: Acworth, GA

Re: Smaug: a new chess engine based on glaurung

Post by AdminX »

Until something better comes along as I know it will. :wink:

Image
"Good decisions come from experience, and experience comes from bad decisions."
__________________________________________________________________
Ted Summers
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: The Intel C++ compiler

Post by Tord Romstad »

sje wrote:The Intel C++ compiler is available for a limited time free trial if you give them some marketing data,
Yes, but there are some very severe restrictions even during the limited time free trial: You are not allowed to distribute the binaries you compile, and you are not even allowed to use them on your own computer after the trial time runs out.
Otherwise it's US$599 plus US$240/year for support.
Is it really that expensive? I don't remember how much i payed a couple of years back, but it was nowhere near that much. Intel must have increased their prices a lot since then.
I tried the free version some time ago. I don't recall any earthshaking improvements over g++, but I do remember that the Intel compiler did supply a few more useful diagnostics about questionable coding.
I think the improvements depend a lot on the program. The Intel compiler (if you use the -ipo switch) is able to inline function calls across file boundaries, which GCC currently cannot (at least not version 4.2, I'm not sure about 4.3 and 4.4). I've also found that the Intel compiler is much faster at doing 64-bit arithmetics on 32-bit CPUs. For a bitboard program like Glaurung, this means that the Intel compiler gives a huge performance improvement on x86-32 CPUs, but a smaller improvement on x86-64.

Another advantage of the Intel compiler is that profiler guided optimization actually works. With GCC, I usually get executables that crash immediately at startup when I try to use PGO.

Tord
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: Smaug: a new chess engine based on glaurung

Post by Tord Romstad »

Tord Romstad wrote:
Tord Romstad wrote:The Intel compiler for OS X is not free, but I have it. I'll compile optimized x86-64 binaries of Smaug and Stockfish, and put them on my web site later tonight.
OK, here are PGO-optimized 64-bit OS X binaries compiled with the Intel compiler:

http://www.glaurungchess.com/smaug221.gz
http://www.glaurungchess.com/stockfish12-optimistic.gz

The binaries require a Core 2 Duo Mac running OS X 10.5 (Leopard).
And here is the binary for Stockfish 1.2 default:

http://www.glaurungchess.com/stockfish12-default.gz

Thanks for the link to the source code, Marco!

Tord
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Smaug: a new chess engine based on glaurung

Post by mcostalba »

Tord Romstad wrote:
Thanks for the link to the source code, Marco!
Thanks to you for the binary....and for many other things :-)

Anyhow, for the line "it was too good to be true" these are the almost final results with the second Joona patch applied, the one on beta correction in NULL move search.

After 890 games 1+0 Stockfish with patch vs Stockfish without patch results are:

+182 -250 =459 -27 ELO !!!!

So the second patch didn't work. Probably it is too aggressive in pruning nodes, expecially in mid game, on fixed depth tests I have measured a searched nodes count reduction of 25%-30% on a set of test positions.

It seems really too much. If we would really able to prune all that stuff WITHOUT missing interesting moves then we could directly jump in the Rybka planet...but this is not the case :-(
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Speaking of g++-v4.3

Post by sje »

Speaking of g++-v4.3, it turns out that the version has a big fat optimization bug that kicks in at -O2 or higher. It takes a combination of enumeration variables, inline functions (member and otherwise) that pass by reference, and maybe the phase of the moon.

Code: Select all

// Clear remaining squares along the current rank

while &#40;file < FileLen&#41; &#123;ClearSq&#40;file, rank&#41;; IncrFile&#40;file&#41;;&#125;;
As far as I can tell, g++-v4.3 optimized the conditional test into the twilight zone via decoupling the file variable into a register on one hand and a stack temporary on the other. The code works fine with other g++ flavors dating back to 2002.

Four hours shot to hell. <grumble>
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: Smaug: a new chess engine based on glaurung

Post by zamar »

mcostalba wrote:
+182 -250 =459 -27 ELO !!!!
Thanks for the results!! Here my own tests failed. Now I must figure out what went wrong...
Joona Kiiski
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: The Intel C++ compiler

Post by bob »

sje wrote:
bob wrote:
sje wrote:Also: Apple is spending a lot of R&D budget on speeding up Mac OS/X and the various professional applications it sells. Yet all of these are built with the same gcc tools that Apple ships for free. If the Intel compiler were really that much better, then Apple would use it themselves.
Probably not, because there are restrictions on what you can do and then sell.
Maybe for you and I, but Apple is one of Intel's biggest customers and in better financial shape than most of the others. Spending billions of bucks a year on Intel chips must mean some leverage for Apple, and I'm sure they could negotiate terms for using the Intel compiler for both in-house and compiled application distribution.

Apple being able to give it away for free (as is the case with the gcc toolchain) might be a different story, though.


We run all sorts of stuff on our cluster, and have compared speeds for both. From things like blast, to the 5 chess programs I run all the time, intel has been faster than gcc by at least 10%. And version 11.0 adds a 10% improvement to that...

And this is including trials with PGO which is the only way I compile apps that run a long time.
Perhaps Apple thinks it's got a better deal with gcc because they can inject their customizations and improvements with better flexibility than they could achieve with Intel's software. Also, a compiler that might perform marginally better with a chess engine might not shine as brightly with the compilation of typical consumer applications.
krazyken

Re: The Intel C++ compiler

Post by krazyken »

sje wrote:
bob wrote:
sje wrote:Also: Apple is spending a lot of R&D budget on speeding up Mac OS/X and the various professional applications it sells. Yet all of these are built with the same gcc tools that Apple ships for free. If the Intel compiler were really that much better, then Apple would use it themselves.
Probably not, because there are restrictions on what you can do and then sell.
Maybe for you and I, but Apple is one of Intel's biggest customers and in better financial shape than most of the others. Spending billions of bucks a year on Intel chips must mean some leverage for Apple, and I'm sure they could negotiate terms for using the Intel compiler for both in-house and compiled application distribution.

Apple being able to give it away for free (as is the case with the gcc toolchain) might be a different story, though.

Perhaps Apple thinks it's got a better deal with gcc because they can inject their customizations and improvements with better flexibility than they could achieve with Intel's software. Also, a compiler that might perform marginally better with a chess engine might not shine as brightly with the compilation of typical consumer applications.
Perhaps more important to Apple is that they are still compiling for non-intel chips, they haven't discontinued support for G4's and G5's yet.