Page 4 of 4

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Tue Nov 28, 2017 8:32 pm
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

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Tue Nov 28, 2017 8:36 pm
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.

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Wed Nov 29, 2017 12:21 am
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

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Wed Nov 29, 2017 1:09 am
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.

Re: gcc4.8 outperforming gcc5, gcc6, gcc7

Posted: Wed Nov 29, 2017 4:55 pm
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;