feat(kernel-ab): C++ driver time mode, aa.sh A/A control (STRA-317)

kab time: monotonic ns + TSC slices with a dependent-add clock calibration before and
after each slice (tq_cpu_parity --bench method; slices whose clock moved >5 percent are
dropped, threshold from tq_cpu_parity.cpp:303), RESIDENT and STREAMED regimes, pinned
single-thread pool, 4096-aligned buffers, manifest and case input hashes, effective
environment. aa.sh: seeded schedule, N rounds of two fresh processes, per-round ratios
only. time_smoke.sh runs the acceptance commands. Only tools/kernel-ab/ is touched.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Pavlo Ratushnyi
2026-10-28 20:40:44 +01:00
co-authored by Claude Sonnet 5.5
parent 75254fb593
commit dcb2f3dbbd
6 changed files with 753 additions and 6 deletions
+11 -3
View File
@@ -5,6 +5,7 @@
// D/case-<id>.cpp-{avx512,avx2}.out, then manifest.json LAST
// kab run-tree --run-dir D --tree avx512|avx2 (internal) one tree's .out files; prints one JSON probe line
// kab poolcheck --run-dir D [--workers N] stage composition vs the real ExpertPool (bitwise), same process
// kab time --run-dir D --case ID --slices N --pin CPU --out F.json STRA-317: timing, resident + streamed regimes (cpp/kab_time.cpp)
//
// The kernels are engine/strata's, UNCHANGED, built by ../cpp/Makefile. Nothing here is kernel arithmetic: the driver only
// COMPOSES the stage entry points of include/strata/kernels/cpu/native_expert.hpp (+ the Q2_0 kernels of expert_layout.hpp)
@@ -18,6 +19,9 @@
#include <cpuid.h>
#include <dirent.h>
#include <fcntl.h>
#include <sched.h> // STRA-317 (time mode): sched_setaffinity / sched_getcpu
#include <time.h> // clock_gettime
#include <x86intrin.h> // __rdtsc, _mm_lfence
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
@@ -623,18 +627,22 @@ int cmd_gen(const Args& a, const std::string& exe) {
return 0;
}
// STRA-317 (S0.8a2): the `time` sub-command lives in kab_time.cpp, included here so it shares this file's reader and composition
#define KAB_TIME_INCLUDED_FROM_KAB 1
#include "kab_time.cpp"
} // namespace
int main(int argc, char** argv) {
if (argc < 2) die("usage: kab gen|run-tree|poolcheck ...");
if (argc < 2) die("usage: kab gen|run-tree|poolcheck|time ...");
const std::string cmd = argv[1];
const Args a = parse(argc, argv, 2);
if (cmd == "gen") {
if (cmd == "gen" || cmd == "time") {
char self[4096];
const ssize_t n = readlink("/proc/self/exe", self, sizeof self - 1);
if (n <= 0) die("cannot resolve /proc/self/exe");
self[n] = 0;
return cmd_gen(a, self);
return cmd == "gen" ? cmd_gen(a, self) : cmd_time(a, self);
}
if (cmd == "run-tree") return cmd_run_tree(a);
if (cmd == "poolcheck") return cmd_poolcheck(a);