gcc4.8 outperforming gcc5, gcc6, gcc7

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

syzygy
Posts: 5563
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: 1754
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: 5563
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.)
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by syzygy »

D Sceviour wrote:
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.
Yes, gcc sometimes produces bogus warnings (the most annoying being array out of bounds where no array is accessed out of bounds), but where it is right, the proper solution is to fix it and not to accept it as a "minor bug" and compile without optimisation hoping there is no harm ;-)

If there is a bug, a crash is the best thing that can happen since it ensures that the bug is detected. The problem with some of these bugs is that the crash (not the bug) goes away when compiling in debug mode. That makes it harder to locate them. But nowadays it is pretty easy to locate them using -fsanitize.
AndrewGrant
Posts: 1754
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 »

Code: Select all

// Using Linked makefile
BENCH DEPTH |  COMP  | NPS
     20     | GCC4.8 | 3592466
     20     | GCC5.4 | 3367175
     20     | GCC6.4 | 3366372
     20     | GCC7.2 | 3246964
     
// Using Linked makefile plus -flto
BENCH DEPTH |  COMP  | NPS
     20     | GCC4.8 | 3611056
     20     | GCC5.4 | 3498027
     20     | GCC6.4 | 3550826
     20     | GCC7.2 | 3323299
     
GCC4.8 with    -flto BENCH 22 NPS=3553729

GCC4.8 without -flto BENCH 22 NPS=3587155
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
AndrewGrant
Posts: 1754
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 »

Code: Select all

// Using Linked makefile
BENCH DEPTH |  COMP  | NPS
     20     | GCC4.8 | 3592466
     20     | GCC5.4 | 3367175
     20     | GCC6.4 | 3366372
     20     | GCC7.2 | 3246964
     
// Using Linked makefile plus -flto
BENCH DEPTH |  COMP  | NPS
     20     | GCC4.8 | 3611056
     20     | GCC5.4 | 3498027
     20     | GCC6.4 | 3550826
     20     | GCC7.2 | 3323299
     
GCC4.8 with    -flto BENCH 22 NPS=3553729

GCC4.8 without -flto BENCH 22 NPS=3587155
[/quote]
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by Ras »

syzygy wrote:He posted a link to the Makefile (he compiles with -O3).
It is well-known that -O3 can produce slower binaries. Should also be compared with what happens with -O2.
Dann Corbit
Posts: 12540
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by Dann Corbit »

I definitely get best performance with gcc 7.2. It beats all my other compilers handily.
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.
AndrewGrant
Posts: 1754
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 »

What OS?
What CPU?
What Flags?
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )