diff options
| author | Scott Gasch <[email protected]> | 2026-09-04 09:37:45 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2026-09-04 09:37:45 -0700 |
| commit | 1f638f87d8afb0334bf05dda10dc13b4c7a60b62 (patch) | |
| tree | e82f547581d0582e188b4bda304b64f115de21de /src/chess.h | |
| parent | 1cfc6859fc0dfa9d3094213e2604f791513cc278 (diff) | |
Add GETATTACKS_BITBOARD toggle, wiring _GetAttacksBB into real search
Board-representation migration section 6: a GNUmakefile build flag
(-DGETATTACKS_BITBOARD) makes chess.h's GetAttacks macro resolve to
_GetAttacksBB instead of the real asm implementation (or SlowGetAttacks
under CROUTINES) -- a three-way choice at the same spot the existing
CROUTINES switch already lived. _GetAttacksBB is now reachable from
every real call site (generate.c's check-detection call, see.c's
SEE(), searchsup.c), not just the test/bench harness.
Found and fixed while verifying this: testsee.c's TestGetAttacks and
its benchmark call the identifier GetAttacks meaning "the real
asm/CROUTINES baseline" -- once the macro could resolve to
_GetAttacksBB, those calls would silently compare the new
implementation against itself, turning both the correctness sweep and
the benchmark into false-positive no-ops. Fixed with a local #undef
GetAttacks right after #include "chess.h" in testsee.c, so the harness
always validates against the true baseline regardless of which
implementation is live in production.
Verified: gmake TEST=1 GETATTACKS_BITBOARD=1 passes (self-test suite,
corrected benchmark still reporting real asm vs. _GetAttacksBB
correctly, and a real Search() call exercising _GetAttacksBB live).
precommit_check.sh GETATTACKS_BITBOARD=1 clean for both the TEST=1
self-test and DEBUG=1 smoke test. Default (no flag) build confirmed
unaffected -- GetAttacks still resolves to the real asm function.
See board_representation/MIGRATION.md section 6 for the full writeup.
Sections 4/5/7's remaining items (curated-suite sd10 comparison,
match_play.py gate) are now unblocked but not yet run.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Jntky4yGUTyQVaGCXms4F2
Diffstat (limited to 'src/chess.h')
| -rwxr-xr-x | src/chess.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/chess.h b/src/chess.h index 5c5bbf2..4bc3464 100755 --- a/src/chess.h +++ b/src/chess.h @@ -2894,18 +2894,29 @@ SlowGetAttacks(SEE_LIST *pList, POSITION *pos, COOR cSquare, ULONG uSide); -#ifdef CROUTINES -#define GetAttacks SlowGetAttacks -#endif -// board_representation/MIGRATION.md section 3: bbPieces-backed -// GetAttacks PoC -- not wired into the GetAttacks macro above yet. +// board_representation/MIGRATION.md section 3: bbPieces/bbPawns-backed +// GetAttacks primitive, verified correct (20,000-position sweep) and +// faster than asm GetAttacks (0.53-0.89x cycles/call across +// opening/middlegame/endgame -- see section 3's benchmark writeup). void CDECL _GetAttacksBB(SEE_LIST *pList, POSITION *pos, COOR cSquare, ULONG uSide); +// Three-way choice for which GetAttacks implementation is actually +// live -- see MIGRATION.md section 6: +// GETATTACKS_BITBOARD defined -> _GetAttacksBB (bitboard, new) +// else CROUTINES defined -> SlowGetAttacks (C mailbox) +// else (default) -> GetAttacks (asm x86/x64 mailbox, +// the literal function declared above) +#if defined(GETATTACKS_BITBOARD) +#define GetAttacks _GetAttacksBB +#elif defined(CROUTINES) +#define GetAttacks SlowGetAttacks +#endif + #ifdef _X86_ // // Note: this is most of the stuff that x86.asm assumes about the |
