From 1f638f87d8afb0334bf05dda10dc13b4c7a60b62 Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Fri, 4 Sep 2026 09:37:45 -0700 Subject: 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 Claude-Session: https://claude.ai/code/session_01Jntky4yGUTyQVaGCXms4F2 --- src/chess.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/chess.h') 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 -- cgit v1.3