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

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by AndrewGrant »

That would be because of the patch I pushed yesterday... to allow indexing that array when in check (which means depth could be < 0).

I'm surprised I don't get these errors when I run my program through valgrind / gdb
#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 »

AndrewGrant wrote:I'm surprised I don't get these errors when I run my program through valgrind / gdb
Valgrind isn't really useful with local or global variables. gdb doesn't report an error because that access is still within valid memory. I think the access returns 8 because right before that, there is LateMovePruningDepth.

And for O3, I have seen GCC blowing up the program and becoming slower because the bigger program exceeded some CPU caches.
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 »

Testing the results of the fix for this mistake. The patch that introduced this bug was a good +10ELO

Seems like this bug was really holding the original patch back. I'll run a test with my normal TC 5+.05s and 20+.2s before I commit

depth_bug_fix
SPRT @ 2.0+0.02s with 1MB Hash
LLR: 2.96 (-2.94, 2.94) [0.00, 5.00]
Games: 5100 W: 1626 L: 1465 D: 2009
ELO: 10.97


This also has fixed my issue with PGO build differing from nonPGO.

Thank you for taking the time and tracking this down. I'll be sure to mention you when I commit the fix.

If you want actual contribution credits IE submit a PR, that can be done aswell
#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:Thank you for taking the time and tracking this down. I'll be sure to mention you when I commit the fix.

If you want actual contribution credits IE submit a PR, that can be done aswell
If you mean me, please don't bother! :-)

You were going to try -fsantize=undefined anyway as you posted 4 minutes before my post. When I saw that I felt a bit bad that I had not let you discover it yourself! It is quite amazing to have such a tool that easily saves you many hours of debugging.

So the credits should go to the developers of -fsanitize.
Dann Corbit
Posts: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by Dann Corbit »

AndrewGrant wrote:That would be because of the patch I pushed yesterday... to allow indexing that array when in check (which means depth could be < 0).

I'm surprised I don't get these errors when I run my program through valgrind / gdb
You can check array bounds manually:

Code: Select all

		assert&#40;index >= 0&#41;;
		assert&#40;index < 64&#41;;
		piece&#91;index&#93; = aPiece;
		color&#91;index&#93; = aColor;
I have macros that I use for array bounds checks. I can't seem to find my macro set right now, but this is the general idea:

Code: Select all

#include <assert.h>
#include <stdlib.h>

#define single_dim_check&#40; a, x ) ( &#40;assert&#40; &#40;x >= 0 ) && &#40;sizeof a / sizeof a&#91;0&#93; > x ) ) )

int main&#40;void&#41;
&#123;
    int a&#91;5&#93;;
    size_t index = 6;
    single_dim_check&#40;a,index&#41;;
    
    return 0;
&#125;
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.