gcc4.8 outperforming gcc5, gcc6, gcc7

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

AndrewGrant
Posts: 1750
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

gcc4.8 outperforming gcc5, gcc6, gcc7

Post by AndrewGrant »

Make file found here: https://github.com/AndyGrant/Ethereal/b ... c/makefile

Looking at running times for my engine on my Threadripper1950x machine. (Running Ubuntu17 for now)

Ethereal does not use popcount / PEXT / all that other stuff

Code: Select all

Version | Bench Depth | Nodes Per Second | Time to completion (ms)
GCC 4.8       16            3,593,517             19807
GCC 5.4       16            3,354,796             21217
GCC 6.4       16            3,290,804             21629
GCC 7.2       16            3,239,579             21971
CLANG         16            2,921,272             24365
So whats the deal here? Am I missing compile flags? I tried march=native, mtune=native and got the same results as well...
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by lucasart »

I can confirm your results. GCC performance keeps getting worse with each release since 4.8.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
abulmo2
Posts: 433
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by abulmo2 »

Reading the release information about gcc 5 and above, optimization enhancement mostly concerns inter-procedural optimization and linker optimizations. You probably need to use the -flto flag and profile guided optimization to see some enhancements.
Also note that gcc changes it version numbering. The version 4.x were release about once a year with x incremented and now they increment the main version number once a year. So there are much more changes between say gcc 4.2 and gcc 4.8 than between gcc 5 and gcc 7.
Richard Delorme
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by Sven »

AndrewGrant wrote:Make file found here: https://github.com/AndyGrant/Ethereal/b ... c/makefile

Looking at running times for my engine on my Threadripper1950x machine. (Running Ubuntu17 for now)

Ethereal does not use popcount / PEXT / all that other stuff

Code: Select all

Version | Bench Depth | Nodes Per Second | Time to completion (ms)
GCC 4.8       16            3,593,517             19807
GCC 5.4       16            3,354,796             21217
GCC 6.4       16            3,290,804             21629
GCC 7.2       16            3,239,579             21971
CLANG         16            2,921,272             24365
So whats the deal here? Am I missing compile flags? I tried march=native, mtune=native and got the same results as well...
Have you tried g++ instead of gcc? Or at least "-std=c11" instead of "-std=c99"? It might require some code changes but I think the Gnu compiler might be able to create faster code when using the newer language standards.
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by mar »

Sven wrote:I think the Gnu compiler might be able to create faster code when using the newer language standards.
I very much doubt that. New language features are related to syntactic sugar (therefore frontend).
User avatar
Look
Posts: 364
Joined: Thu Jun 05, 2014 2:14 pm
Location: Iran
Full name: Mehdi Amini

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by Look »

[...]
AndrewGrant wrote:So whats the deal here? Am I missing compile flags? I tried march=native, mtune=native and got the same results as well...
Hi,

Which optimization flags did you use ?

With higher optimization, you can get a faster engine, but at times, a minor bug could cause your program, even to crash.
Farewell.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by syzygy »

Look wrote:[...]
AndrewGrant wrote:So whats the deal here? Am I missing compile flags? I tried march=native, mtune=native and got the same results as well...
Hi,

Which optimization flags did you use ?

With higher optimization, you can get a faster engine, but at times, a minor bug could cause your program, even to crash.
He posted a link to the Makefile (he compiles with -O3).

That higher optimisation levels can turn "minor bugs" into crashes is not a reason not to use optimisation. Such "minor bugs" simply need to be fixed. If use of an uninitialised variable does not crash the program, it will likely make it produce incorrect results (which can be almost impossible to notice in a chess engine, except for a measurable decrease in playing strength).
D Sceviour
Posts: 570
Joined: Mon Jul 20, 2015 5:06 pm

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by D Sceviour »

syzygy wrote:That higher optimisation levels can turn "minor bugs" into crashes is not a reason not to use optimisation. Such "minor bugs" simply need to be fixed. If use of an uninitialised variable does not crash the program, it will likely make it produce incorrect results (which can be almost impossible to notice in a chess engine, except for a measurable decrease in playing strength).
The gcc <variable> "may be used uninitialized" gives unpredictable bogus results. I visually inspect each element and then ignore the warnings if there is nothing wrong. Of course, something else may be triggering the warning.
AndrewGrant
Posts: 1750
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by AndrewGrant »

Just tried using -std=c11. Results are about the same.
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by syzygy »

AndrewGrant wrote:Just tried using -std=c11. Results are about the same.
What if you add -flto to CFLAGS?

(It does not do any miracles for me, and I just noticed that even regular Stockfish is faster on my PC if I disable link-time optimisation, but still it is worth a try.)