From 042dbfd98d664d67dcb006f1870984fc97bfebe1 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Thu, 8 Oct 2026 14:51:46 +0100 Subject: Batch plans, stage 1 of design 025: each batch loop's block read once at load (pure_batch_plans, after its instructions' plans are final): the locals it sets and whether it sets items, its sums into cells, and at each instruction a role (a sum's again, add or set) and how far on a LOCAL_LOAD's x = x op e is; batch_run, pass and local_load read the plan instead of scanning the block each batch; PURE_BATCH_LANES to build other lane counts; PURE_BATCH_CHECK (a build flag, while the stage is made) reads the block again each batch and stops if the plan differs; seeds 1 2 3 5 23 (default and PURE_SELECT=all), the fixed sources and the unit tests pass with it --- core/module.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'core/module.c') diff --git a/core/module.c b/core/module.c index 548a7c9..0aa51a4 100644 --- a/core/module.c +++ b/core/module.c @@ -1392,6 +1392,7 @@ void pure_module_release(PureModule *m) { free(m->reuse_from), free(m->reuse_length); m->reuse_from = m->reuse_length = NULL; m->reuses = false; + pure_batch_plans_free(m); free(m->storage); m->storage = NULL; m->code = NULL; @@ -1790,6 +1791,10 @@ PURE_COLD PureResult pure_module_load(const void *bytes, size_t size, PureModule /* The lists an index state refers to: their inserts tell where (move_indices). */ for (uint32_t i = 0; i < out->states; ++i) if (out->state_type[i] == PURE_STATE_INDEX) out->state_indexed[out->state_ref[i]] = true; + if (out->batches && !pure_batch_plans(out)) { + result = PURE_ALLOCATION; + REFUSE("out of memory", 0); + } out->jit = pure_jit_make(out); /* none: the executor runs it all */ return PURE_OK; refused: -- cgit v1.2.3