summaryrefslogtreecommitdiff
path: root/src/testsee.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testsee.c')
-rw-r--r--src/testsee.c106
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);
}
}
}