Page 1 of 4

gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Sun Nov 26, 2017 8:08 am
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...

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Sun Nov 26, 2017 8:32 am
by lucasart
I can confirm your results. GCC performance keeps getting worse with each release since 4.8.

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Sun Nov 26, 2017 9:52 am
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.

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Sun Nov 26, 2017 11:13 am
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.

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Sun Nov 26, 2017 1:27 pm
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).

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Sun Nov 26, 2017 4:10 pm
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.

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Sun Nov 26, 2017 4:19 pm
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).

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Sun Nov 26, 2017 7:13 pm
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.

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Sun Nov 26, 2017 7:28 pm
by AndrewGrant
Just tried using -std=c11. Results are about the same.

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Sun Nov 26, 2017 7:31 pm
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.)