From 53d468aab52117f0725eda376eaa100a46fca5a0 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 8 Oct 2026 00:55:34 +0300 Subject: [PATCH 1/2] stress-tests: guard x86intrin.h/rdtsc in bench.h for non-x86 builds bench.h included unconditionally for an unused rdtsc(), which breaks the ConvexHull stress test on ARM (e.g. Raspberry Pi). Only define rdtsc() on x86; tick() and timeit are unchanged. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_011rLUNgQTuqGH79WJWupFZK --- stress-tests/utilities/bench.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stress-tests/utilities/bench.h b/stress-tests/utilities/bench.h index e0b3f032e..887c9c098 100644 --- a/stress-tests/utilities/bench.h +++ b/stress-tests/utilities/bench.h @@ -1,8 +1,10 @@ #pragma once +#if defined(__x86_64__) || defined(__i386__) #include -// (avoid using this) +// (avoid using this) x86 only ll rdtsc() { return __rdtsc(); } +#endif ll tick() { struct timespec tp; From da7442f9e8aeea99f959d668d3b330d608098f6d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 8 Oct 2026 01:27:52 +0300 Subject: [PATCH 2/2] stress-tests: don't loop forever in ModMulLL on wider long double The expectSuccess=false tests loop until modmul gives a wrong answer, which relies on x87's 64-bit mantissa. With a wider long double (binary128 on aarch64) modmul stays correct up to ~2^63, so they never terminate. Only run them when LDBL_MANT_DIG == 64. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_011rLUNgQTuqGH79WJWupFZK --- stress-tests/number-theory/ModMulLL.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stress-tests/number-theory/ModMulLL.cpp b/stress-tests/number-theory/ModMulLL.cpp index 1871fe1ec..a55226a7b 100644 --- a/stress-tests/number-theory/ModMulLL.cpp +++ b/stress-tests/number-theory/ModMulLL.cpp @@ -68,10 +68,13 @@ int main() { const ull lim = 7268172458553106874ULL; // floor((sqrt(177) - 7) / 16 * 2**64) test(lim, true, false); - test((ull)(lim * 1.01L), false, false); + // The expected-failure tests below only make sense with x87 long double (64-bit mantissa). + // With a wider long double (e.g. binary128 on aarch64) modmul stays correct up to ~2^63, + // so they would never find a counterexample and loop forever. + if (LDBL_MANT_DIG == 64) test((ull)(lim * 1.01L), false, false); // test((ull)(lim * 1.001L), false, false); testSq(lim, true, false); - testSq(lim, false, false); + if (LDBL_MANT_DIG == 64) testSq(lim, false, false); cout << "Tests passed!" << endl; }