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: 424
Joined: Tue Apr 19, 2016 4:08 am
Location: U.S.A
Full name: Andrew Grant
Contact:

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by AndrewGrant » Tue Nov 28, 2017 7:32 pm

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

Ras
Posts: 1018
Joined: Tue Aug 30, 2016 6:19 pm
Contact:

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by Ras » Tue Nov 28, 2017 7:36 pm

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: 424
Joined: Tue Apr 19, 2016 4:08 am
Location: U.S.A
Full name: Andrew Grant
Contact:

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by AndrewGrant » Tue Nov 28, 2017 11:21 pm

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

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

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by syzygy » Wed Nov 29, 2017 12:09 am

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: 9044
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Post by Dann Corbit » Wed Nov 29, 2017 3:55 pm

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.

Post Reply