gcc4.8 outperforming gcc5, gcc6, gcc7

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
AndrewGrant
Posts: 319
Joined: Tue Apr 19, 2016 4:08 am
Contact:

gcc4.8 outperforming gcc5, gcc6, gcc7

Post by AndrewGrant » Sun Nov 26, 2017 7:08 am

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...

User avatar
lucasart
Posts: 2957
Joined: Mon May 31, 2010 11:29 am
Contact:

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by lucasart » Sun Nov 26, 2017 7:32 am

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: 131
Joined: Fri Dec 16, 2016 10:04 am
Contact:

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by abulmo2 » Sun Nov 26, 2017 8:52 am

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: 3578
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by Sven » Sun Nov 26, 2017 10:13 am

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: 1832
Joined: Fri Nov 26, 2010 1:00 pm

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by mar » Sun Nov 26, 2017 12:27 pm

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).

Look
Posts: 110
Joined: Thu Jun 05, 2014 12:14 pm
Location: Iran
Contact:

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by Look » Sun Nov 26, 2017 3:10 pm

[...]
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.
Mehdi Amini
www.my-c-codes.com/

Farewell.

syzygy
Posts: 4257
Joined: Tue Feb 28, 2012 10:56 pm

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by syzygy » Sun Nov 26, 2017 3:19 pm

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: 330
Joined: Mon Jul 20, 2015 3:06 pm
Contact:

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by D Sceviour » Sun Nov 26, 2017 6:13 pm

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: 319
Joined: Tue Apr 19, 2016 4:08 am
Contact:

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by AndrewGrant » Sun Nov 26, 2017 6:28 pm

Just tried using -std=c11. Results are about the same.

syzygy
Posts: 4257
Joined: Tue Feb 28, 2012 10:56 pm

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by syzygy » Sun Nov 26, 2017 6:31 pm

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.)

Post Reply