diff options
| author | Scott Gasch <[email protected]> | 2026-09-08 16:50:55 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2026-09-08 16:50:55 -0700 |
| commit | fbb138cc1dd13da2f30129206cdcd3d128344f54 (patch) | |
| tree | 7055d2344a378c5f9f064490f6b25822166518b6 /src/testsee.c | |
| parent | 434fa0406e1b01395a2b7f0aa481ca5dc367fa09 (diff) | |
Retire asm GetAttacks, recogn.c/fen.c bugfixes, misc bugfixes verified at parity
Confirmed self-play regression traced to a stale test_vs_head.sh reference
binary (typhoon_allbitboards/550ea81, deleted): every "vs head" comparison
since 92fc412 (Sep 4) was checking new work against that fixed Sep-4
snapshot, never against real HEAD or the working tree. Rebuilt clean
reference binaries directly from git and re-verified everything from
scratch.
This commit lands only the pieces confirmed safe against clean 434fa04
(fast st1 match, ~30-40 games, score ~0.44-0.55, consistent with parity;
plus a DEBUG-build smoke test pass):
- recogn.c, fen.c: real bugfixes
- data.c, draw.c, ics.c: whitespace only
- x64.asm: retires the asm GetAttacks implementation now that chess.h's
GetAttacks macro unconditionally selects the already-verified-faster
_GetAttacksBB bitboard version instead of a three-way build-flag
toggle (GETATTACKS_BITBOARD/CROUTINES/asm default)
- see.c, testsee.c: SEE/test-harness updates supporting that default
- root.c: per-tier eval-exit reporting (super-lazy counters currently
always read 0 -- accurate, since no super-lazy exit exists yet)
- main.c: startup banner update, InitEval() call, TestRecogn() added to
the #ifdef TEST self-test sequence
- command.c: InitEval() DNA-reload hook, new qsearchfutility diagnostic
- dynamic.c: minor changes
- chess.h: the GetAttacks default change above, three
FUTILITY_BASE_MARGIN_* compatibility aliases (all still equal to the
original flat FUTILITY_BASE_MARGIN -- search.c has not been split into
per-tier margins here), placeholder super-lazy counters, and an
EvalPasserRaces -> _EvalPasserRacesAgainstLoneKings rename (confirmed
byte-identical body) to match recogn.c's call site
- eval.c: the same rename, plus a no-op InitEval() stub (nothing to
initialize until the ROOK_FULL_HALF_OPEN_BONUS cache below exists)
Deliberately NOT included: the full eval.c overhaul (~1770 lines) and
search.c's qsearch-futility rework (~650 lines), including yesterday's
loosened SUPER_LAZY_MARGIN_BY_ARMY/FUTILITY_BASE_MARGIN_BY_SOURCE tables.
Reverting just those two tables while keeping the rest of the eval.c
overhaul still lost badly to 434fa04 (0.20 over 10 games), so the
regression isn't fully explained by the margins alone -- the eval.c
overhaul needs careful, incremental re-verification against this commit
as the new baseline, not a bulk re-apply. Full original work preserved in
git stash (stash@{0} as of this commit) for that follow-up.
Note: two pre-existing, position/state-dependent assertion crashes were
found during this verification (util.c:1093 WalkPV, recogn.c:1359
_SanityCheckRecognizers), both reproducing on unmodified 434fa04 -- not
introduced by anything here, not yet root-caused.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ka9o3S2eKqh4jNfmxVZ6fH
Diffstat (limited to 'src/testsee.c')
| -rw-r--r-- | src/testsee.c | 106 |
1 files changed, 18 insertions, 88 deletions
diff --git a/src/testsee.c b/src/testsee.c index d196d54..978e1c6 100644 --- a/src/testsee.c +++ b/src/testsee.c @@ -26,19 +26,6 @@ Revision History: #include "chess.h" -// This harness's job is to validate _GetAttacksBB against a fixed -// baseline (the real asm/CROUTINES implementation), not to compare -// the engine's own current GetAttacks macro target against itself -- -// but chess.h's GETATTACKS_BITBOARD toggle (board_representation/ -// MIGRATION.md section 6) can make that macro resolve to -// _GetAttacksBB. Undefine it here so every "GetAttacks(...)" call -// below always reaches the real asm/CROUTINES function (still -// declared under that name in chess.h, just no longer macro-routed), -// regardless of which implementation is live in production. -#ifdef GetAttacks -#undef GetAttacks -#endif - // Same reasoning, for IsAttacked/InCheck (board_representation/ // MOVEGEN_MIGRATION.md section 6b's ISATTACKED_BITBOARD toggle): // TestIsAttackedBB below must always be able to call the real mailbox @@ -197,21 +184,21 @@ SeeListsAreEqual(SEE_LIST *pA, SEE_LIST *pB) return TRUE; } +// This used to diff _GetAttacksBB against the mailbox asm GetAttacks and +// the C SlowGetAttacks reference implementation; both were retired +// 2026-09-06 (board_representation/MIGRATION.md section 7) once that +// three-way comparison had run clean for long enough. With no second +// implementation left to diff against, this is now just a crash/ +// no-degenerate-output smoke test plus a standalone cycles/call number. void -TestGetAttacks(void) +TestGetAttacks(void) { POSITION pos; ULONG u; COOR c; - SEE_LIST rgSlowList; - SEE_LIST rgAsmList; SEE_LIST rgBBList; ULONG color; -#if !defined(_X86_) && !defined(_X64_) - return; -#endif - Trace("Testing GetAttacks...\n"); for (u = 0; u < 20000; u++) { @@ -221,51 +208,17 @@ TestGetAttacks(void) if (!IS_ON_BOARD(c)) continue; for (color = BLACK; color <= WHITE; color++) { - SlowGetAttacks(&rgSlowList, - &pos, - c, - color); - GetAttacks(&rgAsmList, - &pos, - c, - color); - if (!SeeListsAreEqual(&rgSlowList, &rgAsmList)) - { - UtilPanic(TESTCASE_FAILURE, - &pos, - "SEE_LIST mismatch", &rgSlowList, &rgAsmList, - __FILE__, __LINE__); - } - - // board_representation/MIGRATION.md section 3/4: - // bbPieces-backed GetAttacks PoC, same correctness - // gate as the asm/C comparison above. - _GetAttacksBB(&rgBBList, - &pos, - c, - color); - if (!SeeListsAreEqual(&rgSlowList, &rgBBList)) - { - UtilPanic(TESTCASE_FAILURE, - &pos, - "SEE_LIST mismatch (_GetAttacksBB)", - &rgSlowList, &rgBBList, - __FILE__, __LINE__); - } + _GetAttacksBB(&rgBBList, &pos, c, color); + ASSERT(rgBBList.uCount <= ARRAY_LENGTH(rgBBList.data)); } } } // - // Speed: board_representation/MIGRATION.md section 5's isolated - // cycles/call microbenchmark, pulled forward here since it's cheap - // to add right alongside the correctness gate that just proved the - // two implementations equivalent. Three positions spanning piece - // density (opening/middlegame/endgame), SlowGetAttacks vs - // _GetAttacksBB interleaved call-by-call (not phase-by-phase) to - // cancel shared-box noise -- a red flag (flat or inverted result) - // here would mean stopping before wiring this in any further, same - // as the Eval occupancy-bitboard work that motivated this file. + // Speed: standalone cycles/call number, three positions spanning + // piece density (opening/middlegame/endgame). No longer a + // comparison (nothing left to compare against), just a number to + // watch for regressions over time. { static const char *rgszFen[3] = { @@ -279,26 +232,18 @@ TestGetAttacks(void) }; POSITION posBench; SEE_LIST rgList; - UINT64 u64SlowTotal, u64AsmTotal, u64BBTotal, u64Start; + UINT64 u64BBTotal, u64Start; ULONG uIter; ULONG uSq; COOR cBench; ULONG uSide; const ULONG uCallsPerPosition = 200000; - // GetAttacks (unqualified) is the real production entry point -- - // the hand-tuned x86/x64 asm routine, not SlowGetAttacks (the C - // reference used only for correctness comparison above). That's - // the actual competitor _GetAttacksBB has to beat; SlowGetAttacks - // is included only as a third data point, not the bar to clear. - Trace("Benchmarking GetAttacks: asm GetAttacks vs SlowGetAttacks " - "vs _GetAttacksBB (interleaved, %lu calls/position)...\n", + Trace("Benchmarking _GetAttacksBB (%lu calls/position)...\n", uCallsPerPosition); for (u = 0; u < 3; u++) { FenToPosition(&posBench, (char *)rgszFen[u]); - u64SlowTotal = 0; - u64AsmTotal = 0; u64BBTotal = 0; for (uIter = 0; uIter < uCallsPerPosition; uIter++) { @@ -308,28 +253,13 @@ TestGetAttacks(void) if (!IS_ON_BOARD(cBench)) continue; u64Start = SystemReadTimeStampCounter(); - GetAttacks(&rgList, &posBench, cBench, uSide); - u64AsmTotal += (SystemReadTimeStampCounter() - u64Start); - - u64Start = SystemReadTimeStampCounter(); - SlowGetAttacks(&rgList, &posBench, cBench, uSide); - u64SlowTotal += (SystemReadTimeStampCounter() - u64Start); - - u64Start = SystemReadTimeStampCounter(); _GetAttacksBB(&rgList, &posBench, cBench, uSide); u64BBTotal += (SystemReadTimeStampCounter() - u64Start); } - printf(" %s: asm GetAttacks %" COMPILER_LONGLONG_UNSIGNED_FORMAT - " cycles/call, SlowGetAttacks %" - COMPILER_LONGLONG_UNSIGNED_FORMAT - " cycles/call, _GetAttacksBB %" - COMPILER_LONGLONG_UNSIGNED_FORMAT " cycles/call " - "(BB is %.2fx asm)\n", + printf(" %s: _GetAttacksBB %" COMPILER_LONGLONG_UNSIGNED_FORMAT + " cycles/call\n", rgszLabel[u], - u64AsmTotal / uCallsPerPosition, - u64SlowTotal / uCallsPerPosition, - u64BBTotal / uCallsPerPosition, - (double)u64BBTotal / (double)u64AsmTotal); + u64BBTotal / uCallsPerPosition); } } } |
