Can anyone tell me what might cause the following:
My engine is written in ANSI C primarily on a Unix workstation. However, I have compiled it a few times on Windows 7 64-bit. Every perft test I have run on the unix version returns the right values at the right depths so far. However, when I run a specific test on the Windows version it gives a bad result for depth 6 on the following FEN:
r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1
The unix version returns 8031647685 for depth 6. The Windows one gave a very large negative number. At depth 5 it returned the right number of 193690690.
Any idea what can cause this difference?
Jeff
Curious Cross Platform Issue
Moderators: hgm, Rebel, chrisw
-
- Posts: 83
- Joined: Mon Mar 24, 2014 12:26 am
- Location: Glen Carbon, IL USA
-
- Posts: 793
- Joined: Sun Aug 03, 2014 4:48 am
- Location: London, UK
Re: Curious Cross Platform Issue
I would guess that's because you are assuming ints to be 64-bit.jsgroby wrote:Can anyone tell me what might cause the following:
My engine is written in ANSI C primarily on a Unix workstation. However, I have compiled it a few times on Windows 7 64-bit. Every perft test I have run on the unix version returns the right values at the right depths so far. However, when I run a specific test on the Windows version it gives a bad result for depth 6 on the following FEN:
r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1
The unix version returns 8031647685 for depth 6. The Windows one gave a very large negative number. At depth 5 it returned the right number of 193690690.
Any idea what can cause this difference?
Jeff
On Windows (even 64-bit Windows) ints are 32-bit for backward compatibility.
I always use uint64_t/int64_t/uint32_t/int32_t for portable code.
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.
-
- Posts: 83
- Joined: Mon Mar 24, 2014 12:26 am
- Location: Glen Carbon, IL USA
Re: Curious Cross Platform Issue
That is more than likely the issue. I am going to make the change and recompile and test in a bit.matthewlai wrote:I would guess that's because you are assuming ints to be 64-bit.jsgroby wrote:Can anyone tell me what might cause the following:
My engine is written in ANSI C primarily on a Unix workstation. However, I have compiled it a few times on Windows 7 64-bit. Every perft test I have run on the unix version returns the right values at the right depths so far. However, when I run a specific test on the Windows version it gives a bad result for depth 6 on the following FEN:
r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1
The unix version returns 8031647685 for depth 6. The Windows one gave a very large negative number. At depth 5 it returned the right number of 193690690.
Any idea what can cause this difference?
Jeff
On Windows (even 64-bit Windows) ints are 32-bit for backward compatibility.
I always use uint64_t/int64_t/uint32_t/int32_t for portable code.
Thanks for the suggestion.
jeff
-
- Posts: 83
- Joined: Mon Mar 24, 2014 12:26 am
- Location: Glen Carbon, IL USA
Re: Curious Cross Platform Issue
Indeed that was the issue. Fixed and tested on 64-bit Unix and Windows 7jsgroby wrote:That is more than likely the issue. I am going to make the change and recompile and test in a bit.matthewlai wrote:I would guess that's because you are assuming ints to be 64-bit.jsgroby wrote:Can anyone tell me what might cause the following:
My engine is written in ANSI C primarily on a Unix workstation. However, I have compiled it a few times on Windows 7 64-bit. Every perft test I have run on the unix version returns the right values at the right depths so far. However, when I run a specific test on the Windows version it gives a bad result for depth 6 on the following FEN:
r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1
The unix version returns 8031647685 for depth 6. The Windows one gave a very large negative number. At depth 5 it returned the right number of 193690690.
Any idea what can cause this difference?
Jeff
On Windows (even 64-bit Windows) ints are 32-bit for backward compatibility.
I always use uint64_t/int64_t/uint32_t/int32_t for portable code.
Thanks for the suggestion.
jeff
Thanks again. I learn something new every day while coding on this engine.
I am making a note of that particular FEN as it will be good to test with since it hits so many nodes at depth 6.
Jeff
-
- Posts: 793
- Joined: Sun Aug 03, 2014 4:48 am
- Location: London, UK
Re: Curious Cross Platform Issue
Glad to have helped .jsgroby wrote:Indeed that was the issue. Fixed and tested on 64-bit Unix and Windows 7jsgroby wrote:That is more than likely the issue. I am going to make the change and recompile and test in a bit.matthewlai wrote:I would guess that's because you are assuming ints to be 64-bit.jsgroby wrote:Can anyone tell me what might cause the following:
My engine is written in ANSI C primarily on a Unix workstation. However, I have compiled it a few times on Windows 7 64-bit. Every perft test I have run on the unix version returns the right values at the right depths so far. However, when I run a specific test on the Windows version it gives a bad result for depth 6 on the following FEN:
r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1
The unix version returns 8031647685 for depth 6. The Windows one gave a very large negative number. At depth 5 it returned the right number of 193690690.
Any idea what can cause this difference?
Jeff
On Windows (even 64-bit Windows) ints are 32-bit for backward compatibility.
I always use uint64_t/int64_t/uint32_t/int32_t for portable code.
Thanks for the suggestion.
jeff
Thanks again. I learn something new every day while coding on this engine.
I am making a note of that particular FEN as it will be good to test with since it hits so many nodes at depth 6.
Jeff
I got bitten by this before, too, going from a platform with 32-bit ints to a platform with 16-bit ints (microcontrollers).
C standard only says ints need to be 16-bits minimum.
So nowadays I only use int for very small values (few hundred), and only when I am lazy. Otherwise everything is fixed size types.
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.