GCC or Intel compiler for Linux ?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Canoike
Posts: 125
Joined: Tue Jan 17, 2012 8:08 pm

GCC or Intel compiler for Linux ?

Post by Canoike »

HI !

Which compiler produces the fastest executable for Linux ? GCC 5.x or Intel compiler?
My goal is to build a fast Stockfish. Currently, I use GCC 5.4.
I tried clang but is builds a too slow executable.

Thanks.
ZirconiumX
Posts: 1334
Joined: Sun Jul 17, 2011 11:14 am

Re: GCC or Intel compiler for Linux ?

Post by ZirconiumX »

Intel if you have an Intel CPU, GCC if you have an AMD CPU.

And Clang executables can be very fast if tuned correctly. You probably haven't set the right compile flags.
Some believe in the almighty dollar.

I believe in the almighty printf statement.
mar
Posts: 2559
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: GCC or Intel compiler for Linux ?

Post by mar »

ZirconiumX wrote:Intel if you have an Intel CPU, GCC if you have an AMD CPU.

And Clang executables can be very fast if tuned correctly. You probably haven't set the right compile flags.
Depends, sometimes msc is fastest, sometimes Intel and usually gcc. Clang is usually lousy in terms of performance but otherwise the compiler is pretty good.
Intel is only slower on AMD iff you make heavy use of memcpy - if you do then your program probably sucks anyway (speaking about chess engines of course)

The only "advice" is to try and pick the one that works best for you.
jdart
Posts: 4367
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: GCC or Intel compiler for Linux ?

Post by jdart »

Recent versions of gcc have a very good optimizer.

I have not had much if any performance gain from the Intel compiler.

--Jon
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: GCC or Intel compiler for Linux ?

Post by lucasart »

In my experience:
* gcc produces the fastest binaries.
* clang is useful, because it compiles quickly, and because it is more pedantic than gcc, sometimes issuing warnings that lead me to find subtle bugs.
* icc neither beats gcc at binary speed, nor clang at error/warning diagnostic and compilation speed. Plus it's not free, and Intel seems to lag behind and not update it, whereas clang and gcc keep moving forward. In other words, it's useless.

Of course:
* you need to understand what you're doing, and make sure you're using all the right compiler flags (eg. LTO and PGO). Many people don't understand what they're doing, and make erroneous conclusions due to sub-optimal use of compilers.
* you need to measure this yourself, instead of listening to what people tell you on talkchess or elsewhere. your mileage will vary, depending on your code.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
Dann Corbit
Posts: 12541
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: GCC or Intel compiler for Linux ?

Post by Dann Corbit »

Clang has such excellent diagnostics that it can be used as Lint.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
jdart
Posts: 4367
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: GCC or Intel compiler for Linux ?

Post by jdart »

icc is free for non-commercial use, on Linux only.

--Jon
abulmo
Posts: 151
Joined: Thu Nov 12, 2009 6:31 pm

Re: GCC or Intel compiler for Linux ?

Post by abulmo »

jdart wrote:icc is free for non-commercial use, on Linux only.
Well free is an ambiguous term in English. It can mean gratis as in "free beer" or libre as in "free speech". icc is gratis with restrictions. But it is not libre as gcc and clang are.
Richard
Dann Corbit
Posts: 12541
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: GCC or Intel compiler for Linux ?

Post by Dann Corbit »

Still, free beer is not so bad.
;-)
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
Canoike
Posts: 125
Joined: Tue Jan 17, 2012 8:08 pm

Re: GCC or Intel compiler for Linux ?

Post by Canoike »

Ubuntu 16.04 comes with gcc and g++ 5.4. Do you know if older or newer versions make executables faster ?

Thanks.