feat(v4): Phase 7 Task 3b -- compudynamics on the 32 F18 opcodes as on the words, behind OPCODE_PHYSICS (#189)

Captain Bob, 2026-11-14: "we're supposed to be working on f18 opcode as well as our composed f18
dictionary"; ruled every loop on both, "and an easy revert if opcodes are too granular".

- The engine: a hook at retire (exec.h on_retire), as Part A's at call; NULL unless set. test_exec.c.
- The mesh: 32 opcode records per node, an opcode window, opcode transitions under L4; at every retired
  instruction decay at the opcodes' own slope, heat, temperature, the window, the transition; in each cycle
  all 32 cooled, the opcode window's service, inference on its heat. L8 scores from the words and its gates
  govern both; the tick stays paced by word calls. The window is now one type for words and opcodes.
- The revert: OPCODE_PHYSICS (Kconfig.physics, default y; the kernel's flags) -- 0 and the opcodes are
  counted and charged to the Stadium as in Phase 1. make -C v4 mesh-boot-noop builds and tests it.
- Tests first: test_mesh_boot.c 77 checks as built, 86 with pipelining on, 74 with the revert.
- Measured on amd64, back to back: 219 s on, 196 s off (+12% under TCG). Both boots' logs labelled.
Not pushed (held to the end of Phase 7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-14 00:29:08 +00:00
parent b5d99ba98b
commit e1b731f444
16 changed files with 296 additions and 57 deletions
+29
View File
@@ -622,6 +622,34 @@ static void test_call_hook_sees_every_call(void)
CHECK(es.on_call == 0, "v4_exec_reset leaves no hook");
}
/* the hook at retire (#189 Phase 7, ruling 7: compudynamics on the opcodes): every retired instruction, its opcode,
* in order, as HEAT-OP counts it */
static unsigned retired_seen, retire_bad, op_seen[32];
static void record_retire(void *ctx, v4_node *nd, unsigned op)
{
if (ctx != (void *)&retired_seen || nd != &n || op >= 32) { retire_bad++; return; }
retired_seen++;
op_seen[op]++;
}
static void test_retire_hook_sees_every_instruction(void)
{
unsigned i, retired = 0, k, same = 1;
v4_uheat_t before[32];
call_programme();
for (k = 0; k < 32; k++) { before[k] = h.op[k]; op_seen[k] = 0; }
es.on_retire = record_retire; es.on_retire_ctx = (void *)&retired_seen;
retired_seen = 0; retire_bad = 0;
for (i = 0; i < 9; i++) retired += v4_exec_step_word(&n, &es, &h);
for (k = 0; k < 32; k++) if (op_seen[k] != (unsigned)(h.op[k] - before[k])) same = 0;
CHECK(retire_bad == 0 && retired_seen == retired && retired > 0,
"the retire hook sees every retired instruction (%u of %u), with its context and node", retired_seen, retired);
CHECK(same, "and each opcode as often as HEAT-OP counts it");
es.on_retire = 0; es.on_retire_ctx = 0;
v4_exec_reset(&es);
CHECK(es.on_retire == 0, "v4_exec_reset leaves no retire hook");
}
int main(void)
{
printf("v4 exec tests: V4_CELL_BITS=%d\n", V4_CELL_BITS);
@@ -634,6 +662,7 @@ int main(void)
test_return_and_ex();
test_branches();
test_call_hook_sees_every_call();
test_retire_hook_sees_every_instruction();
test_unext();
test_retirement();
#if V4_CELL_BITS == 64