Skip to content

Batch-threaded plane insertion for the gridding reconstructor

Status, 2026-11-29: run on dell2 done (rec_slabs, Phases 0 to 4, rulings R1 to R6); the Mac read of decision 12 made the same day and the change kept on the maintainer's ruling (Progress, "The Mac read"); in the working tree for him to commit. Decisions 1 to 15 ruled by Hans 2026-11-28, all as recommended. Report: batch_threaded_plane_insertion_report.md, beside this note. Base: 3de5b0295 (the commit that adds this plan sits on top; the launch copies the checkout at that commit and Phase 0 records the base it got). Phase 0 got 0267ace9e, which adds only this note to 3de5b0295 (rulings R3, applied here first): no re-pin; the code check's line numbers were re-read there and hold. Supersedes: none. Depends on: nothing unvalidated in SIMPLE; the loop's form comes from a standalone prototype (validated: bytes yes, speed on synthetic planes only, SIMPLE itself not measured). One run, rec_slabs, on dell2 under arun; a Mac read after it (decision 12) before anything is committed.

1. Why

reconstructor%insert_plane_oversamp threads inside one plane: a parallel region per plane and, per symmetry copy, one work-sharing loop per colour of h lines (6 colours), so a batch of 500 planes passes 3,000 barriers per symmetry copy. A standalone prototype of that loop (plain Fortran, synthetic planes with uniformly random orientations, box 160, batches of 500 planes, the arithmetic of mlx-fortran's toy reconstructor) was timed on 2026-11-28 against a loop that threads over the batch instead. Seconds per batch, median of 5 after a warm pass, all measured in the prototype:

Threads M5 Ultra, today's loop M5 Ultra, slab loop dell2, today's loop dell2, slab loop
1 0.215 0.334 0.416 0.579
4 0.121 0.089 0.137 0.153
8 0.225 0.046 0.115 0.105
10 0.240 0.039 0.100 0.093
16 not run not run 0.112 0.076
  • On the Mac today's loop does not scale past 4 threads and is slower at 10 than at 1; the slab loop is 6.2 times faster there at 10 threads. The cause on macOS is inferred (the cost of the OpenMP runtime's barriers), not measured; OMP_WAIT_POLICY changes nothing. SIMPLE's own stage behaves the same way on the M5 (measured 2026-11-28, the table under decision 15: fastest at four threads, slower at thirty than at one).
  • On Linux today's loop already scales (4.2 times at 10 threads of dell2). The slab loop takes 32 % less time at 16 threads, 7 % less at 10, 12 % more at 4 and 39 % more at 1.
  • Every form gave the bytes of today's loop at one thread, for the numerator and the density, at every thread count on both machines; a control that walks the planes in reverse differs in about 157,000 words.

mlx-fortran's run mlxf_insert_slabs then put the slab loop into the toy reconstructor's batch entry on the M5 Ultra and ended the same day (its report: mlxf_insert_host_slabs_report.md in that repository, read for this plan after the first draft). In the toy's class, all measured there and none of it SIMPLE's time: the stage at box 160, 6,000 planes and ten threads went from 2.888 s to 0.494 s (5.8 times); the bytes are the plane by plane loop's at 1, 2, 3, 10 and 30 threads; the fastest fixed thickness at ten threads was 8 layers, not the prototype's 6 (2.1 slabs per thread); with that fixed thickness slabs cost 1.68 times the plane by plane loop at one thread and 1.19 times at two, so the toy keeps the old loop under three threads.

The maintainer asked for the remedy in SIMPLE as an agent run on dell2 (2026-11-28: "I trust this will lead to acceleration also on the SIMPLE side"). His platform priorities: CPU-only machines and the new Macs first and equal. What is not known is the size of this plan: SIMPLE's own insertion has been timed on neither platform, and dell2 cannot show the Mac effect at all.

The prototype (insert_proto.f90, loop form_c with kclip, prep and the deposit helper) and its logs are outside version control: on the Mac in ~/src/mlx-fortran/build/insert_proto/, on dell2 in ~/tmp/mlxf_insert_proto (source and binary). Phase 0 copies them into the run's keep folder.

2. Contract

  1. A new entry of the gridding reconstructor inserts a batch of planes with its threads working across the batch: the expanded lattice is cut into slabs, each slab has one owning thread for the whole batch, and a thread adds only the voxels of its own slabs. No lock, no atomic, no barrier inside a batch.
  2. Its bytes are today's. For the same planes in the same order, the expanded numerator (cmat_exp) and the expanded density (rho_exp) equal, word for word, what insert_plane_oversamp called once per plane gives, at every team size, slab count and slab axis. Every voxel receives its additions from one thread in today's order: plane, symmetry copy, colour of h, h ascending within the colour, k ascending.
  3. insert_plane_oversamp is not edited, not by one character. It is the identity reference, the path of every other caller and the path a batch falls back to (decision 6). Off-state: a caller that does not call the batch entry runs no new line.
  4. No new command-line parameter, environment variable, compile flag or CMake target. No public name or dummy list of an existing routine changes (init_rec, prep_imgs4rec, write_state_half_partial and cleanup_rec_buffers are imported by the OpenMP-offload module).
  5. The partial reconstructions a worker writes are byte-identical to the base's wherever the base reproduces itself (Phase 0 decides where).
  6. Nothing of this run is committed before the Mac read of decision 12.

What the code check found (2026-11-28, at 3de5b0295)

Read: src/main/volume/simple_reconstructor.f90 (insert_plane_oversamp at lines 454-605, insert_planes_multi at 1009-1190, alloc_rho at 161-204), src/main/strategies/search/simple_matcher_3Drec.f90, src/main/volume/simple_reconstructor_openmpoffload.f90, the flex callers, src/main/interp/simple_kbinterpol.f90, src/utils/math/simple_math_ft.f90 (fplane_shift), cmake/CompilerConfig.cmake, and the prototype. What the check changed against the brief this plan was asked from:

  1. The production batch already exists. calc_3Drec prepares up to MAXIMGBATCHSZ = 500 planes of one (state, half) and hands them to update_state_half_rec, which loops over the particles and calls insert_plane_oversamp once per plane. The batch entry replaces that loop; calc_3Drec keeps its shape.
  2. Under the probabilistic modes a particle enters at up to three poses. topk defaults to 3: insert_extra_poses re-shifts the committed plane into one scratch plane per extra pose (fplane_shift) and inserts it at once, interleaved with the committed planes. A batch therefore needs the extra planes kept until it is inserted, in today's order, or the bytes change (decision 3). The final reconstruction and reconstruct3D insert committed poses only.
  3. The flex callers are two different things. simple_flex_pca_mstep.f90 calls insert_planes_multi, not insert_plane_oversamp; simple_flex_pca_basis.f90 calls insert_plane_oversamp once per particle from a re-formed scratch plane. insert_planes_multi is not the same loop: K targets, a packed density, a transfer plane, a per-plane Nyquist cap and a bounds test that insert_plane_oversamp does not have.
  4. The offload module shares no insertion code. It has its own kernel (insert_all_slices), is compiled only with USE_OPENMP_OFFLOAD (off by default), its entry calc_3Drec_gpu has no caller at the base, and for several states it calls calc_3Drec.
  5. The arithmetic is not the prototype's. SIMPLE writes c + comp*ww and the Horner polynomial of apod_fast as plain expressions; whether they are fused is the compiler's choice (Release is -O3 -march=native on Linux and -O3 -mtune=generic on Apple silicon, no fast-math). The prototype fixed one ieee_fma per addition, so its byte identity says nothing about two loop bodies compiled by gfortran from SIMPLE's source. Identity is therefore measured in SIMPLE, between the two loops of one build (decision 8), with a stop if code generation separates them.
  6. A weight of one is the unweighted insertion bit for bit (the tester's header says so and the arithmetic agrees: the scale is pf*pf*w, the density term w*ctfsq). A batch can carry one weight per plane.
  7. The slab test must read the window the deposit uses. The window is nint(loc) plus and minus one; a second evaluation of loc for a filter could round the other way at a half and drop a tap. The clip of a line's k range is a superset; membership is decided on the window computed once per sample.
  8. The prototype's best slab thickness moves with the team. Its tuning log (dell2, box 160, 165 layers): best thickness 16 at 4 threads, 6 at 10, 4 at 16, which is 2.6 to 2.8 slabs per thread each time; at one thread 24 layers cost 10 % over today's loop and 6 layers 39 %. One slab for a team of one was not run. The toy's class agrees in kind: 8 layers best at ten threads (2.1 slabs per thread), and 1.68 times the old loop at one thread with 21 slabs. The one-thread loss grows with the slab count (samples prepared twice, and a line cut per line and slab), so a fixed thickness is its likely cause; that one slab brings one thread back to today's time is a hypothesis Phase 2 tests (decisions 4 and 7).
  9. The prototype's planes had uniformly random orientations. A batch of top views with slabs along the last index puts every sample into the central slab: one thread does all the work. Real projects have preferred orientations (decisions 5 and 6).
  10. The lattice. With dim = maxval(abs(lims)) + 2, cmat_exp and rho_exp are (lims(1,1)-wdim : dim, -dim : dim, -dim : dim): the first index is the Friedel half and the fastest in memory, so slabs along it would share cache lines. The prototype's lattice has the same shape.
  11. The stage is already timed. calc_3Drec writes rec3D accumulation (the time inside update_state_half_rec, the extras' re-shifts included) and rec3D poses inserted to the REC3D bench file of every pass (L_BENCH_GLOB is on).
  12. The prototype's loop bounds are SIMPLE's: stride = ceiling(sqrt(3)*wdim) = 6, the integer Nyquist disk nyq*(nyq+1), the k range per h, the TINY skip, the Friedel skip win(2,1) < lims(1,1), the stored half k <= 0 with the conjugate for k > 0.
  13. dell2's cores (read over ssh): CPUs 0-3 are P cores (4.8 GHz), 4-11 E cores (3.8 GHz), 12-15 low-power E cores (3.4 GHz). The real projects with 3D orientations under /data2 name stacks under /data, which does not exist there; the frozen inputs of the run nightly_triage (~/agent_runs/nightly_triage/scratch/keep/real/inputs) are the ones that were run on dell2.

The queue: f32_pcg (running on the dell) adds a benchmark entry to the same three registration files as decision 11 (simple_commanders_test_highlevel.f90, simple_test_exec_highlevel.f90, simple_test_ui_highlevel.f90), may add a suite row to the two _class files of the table, and edits simple_reconstructor_pcg.f90, which this plan does not touch. The two diffs add rows next to each other; the one applied second has its rows placed by hand. No other run edits the files of the table. Master is not frozen for the run and the run does not sync with it; it is expected to take under two days.

3. Decisions and rulings

Ruled 2026-11-28 by Hans in one sitting: decisions 1 to 15 as recommended ("Go" to the list of the fifteen with their recommendations), each with the origin of its numbers. Never renumbered. Where a decision names an alternative, the recommendation is what stands.

  1. Where the loop lives. A new type-bound procedure insert_planes_batch of reconstructor, in simple_reconstructor.f90, beside insert_plane_oversamp, which stays as it is (contract 3). Alternative: make insert_plane_oversamp a batch of one and retire the colours. Recommended: beside. The benchmark also times the batch entry called with one plane at a time; if that is within decision 9's no-loss bound of the coloured loop in every cell on both machines, the report recommends the retirement as a later change of its own.
  2. The batch unit is the batch update_state_half_rec already holds: the planes of one (state, half), at most 500 particles, in its order, each with its weight (one where today's call has none). Rotation matrices of every plane and symmetry copy are made serially before the parallel region, as insert_planes_multi does. Recommended.
  3. Extra poses (topk > 1) enter the same batch in today's order: a particle's committed plane, then its extras. The re-shifted planes are kept in a pool until the batch is inserted. The pool holds at most 500 planes and at most 512 MB (guessed); when it is full the records gathered so far are inserted and the pool is reused. Where a batch is cut changes no byte. Recommended. Alternative: particles with extras keep the per-plane path, which leaves the iterations of every probabilistic run on today's loop.
  4. Slab count follows the team. A team of one takes one slab (the whole lattice: today's work plus the clip tests). A team of T takes min(n/3, REC_SLABS_PER_THR*T) slabs of equal thickness along the chosen axis of n layers, never thinner than the window (3 layers), scheduled dynamic,1. REC_SLABS_PER_THR = 3 (derived: 2.6 to 2.8 in the prototype's tuning log, 2.1 in the toy's class at ten threads, code check 8). Phase 2 times 2, 3 and 4 in scratch builds at teams of 4, 8 and 16 and boxes 96, 160 and 256 and keeps the value with the smallest geometric mean of the batch times. Recommended. Alternative: mlx-fortran's fixed thickness of 8 with its rule that teams under three threads keep the old loop. Phase 2 (six passes, Progress): the rule picked 2, measured; the repository carries 2. Rulings R6 (2026-11-29, applied first in Phase 3) amends the layout: slab boundaries for equal estimated work, with 1 or 2 slabs per thread, against this equal-thickness layout; its rule and table are in Progress ("Ruling R6").
  5. The slab axis is chosen per batch between the second and the third index, never the first (code check 10). For each axis a the estimated share of the heaviest slab is f_a = mean over planes and symmetry copies of min(1, 2*t_a / (pi*R*s)), with t_a the slab thickness, R the Nyquist radius and s = sqrt(1 - n_a**2), n_a the plane normal's component along a (the third row of the rotation matrix). The axis with the smaller f_a is taken. The choice changes no byte (contract 2). Recommended. Alternative: the prototype's fixed last index, which serialises top views.
  6. A batch the slabs cannot balance takes today's loop. If f_a * T > REC_SLAB_MAX_LOAD for the chosen axis, the batch is inserted plane by plane with insert_plane_oversamp. REC_SLAB_MAX_LOAD = 2 (guessed: the heaviest slab would hold the team to half its size). Phase 2 first measures without the rule; it is built only if a fixture misses decision 9's no-loss bound without it, and its value is then the smallest of 1.5, 2 and 3 with which every fixture meets the bound. Recommended. Phase 2 (Progress): built, since cube missed; the rule picked 1.5, measured.
  7. Small teams. No team-size threshold is written in advance: with decision 4 a team of one runs one slab. If the batch entry misses decision 9's no-loss bound at small teams, a constant REC_SLAB_MIN_THR is added, set to the smallest team from which every larger measured team meets the bound, and smaller teams take today's loop. That bound is the only rule under which two paths stand. The toy's threshold of three threads was measured on the M5 with a fixed thickness and is not taken over: on Linux today's loop scales, so the crossing may lie higher, and it is measured here at 1, 2 and 4 threads. Recommended. Phase 2 (Progress): built, since a team of one missed every cell; REC_SLAB_MIN_THR = 2, measured.
  8. What identical means. The reference is SIMPLE's own insert_plane_oversamp, called once per plane in the same order, in the same build. Compared: every word of cmat_exp and of rho_exp. In the unit tester (fast gate): a team of one and a forced team of four, both axes, slab counts from one to n/3, symmetry c1 and d2, weights, extras, a batch cut in two. In the benchmark: teams of 1, 2, 3, 4, 8 and 16 for every fixture, box and symmetry of decision 11, and the per-plane loop at each team against itself at one thread. A planted control (the batch walked in reverse) must differ. In production: decision 9's identity cases. No tolerance: this is a change of logic, not of code generation. Recommended.
  9. Acceptance on Linux. (a) No loss, gated: in every cell of the benchmark (fixture, box, symmetry, core set of decision 10) the batch entry takes at most 1 + max(0.03, 2*spread) times the per-plane loop's time, spread being the per-plane loop's A-A spread in that cell from Phase 1 (0.03 guessed, the spread measured and frozen in Phase 1 before Phase 2's judged runs). (b) Gain, a verdict that is reported and not a stop: on the whole machine (16 threads), box 160, uniform orientations, c1, the batch entry takes at most 0.80 times the per-plane loop's time (derived: the prototype's 0.68 on this machine with a fixed thickness, 0.63 at its best thickness; the margin guessed because SIMPLE's loop is not the prototype's). Missing (b) with (a) met is the result "no Linux gain"; the run goes on, since the case for the change is then the Mac's. (c) Production identity, gated: simulated_workflow_6vxx at one thread, base against new, with test=identity; the partial reconstructions of reconstruct3D at 1 and at 16 threads, base against new, wherever Phase 0 shows that the base reproduces itself. (d) Production time, reported: rec3D accumulation per inserted pose, base against new, three runs each way, interleaved, at 16 threads. Recommended. The plan promises no Linux gain beyond (b), and none on teams of one kind of core: at 4 threads the prototype loses 12 % at a fixed thickness and gains 4 % at the best one, and its gain at 16 threads may owe part to the dynamic schedule on unequal cores, which a node of equal cores does not have.
  10. Timing protocol. Teams are pinned with taskset to sets of one kind of core where one exists: 1 thread on CPU 0; 2 threads on CPUs 0-1; 4 threads on the P cores (0-3); 8 threads on the E cores (4-11); 12 threads on 0-11; 16 threads on 0-15, the machine a user gets. The 8 E cores are the nearest thing dell2 has to a node of equal cores and are reported as such. Both arms are timed in one process, alternating, 7 rounds after a warm round (3 for one thread), the median with minimum and maximum, the one-minute load beside every row; a row taken at a load above 2 that is not the run's own is retaken. Phase 0 reads the core map from the machine and stops if it is not the one of code check 13. Recommended. Phase 2 deviation (Progress): a judged cell whose ratio lies within 5 % of its bound is measured in two more invocations and judged on the median of the three; the bounds are unchanged. Rulings R1 (applied first in Phase 0): the load is /proc/loadavg's one-minute value, written beside every timing; a row whose load above 2 is not the run's own is retaken after waiting up to 30 minutes, and a machine that stays loaded is the stop of section 7.
  11. The benchmark is a measure-only entry rec_insert_bench of simple_test_exec, registered like polar_matching_bench (no CTest entry, no thresholds, a row in section 1.3 of the test policy). It builds synthetic planes (random numerator, positive density term, weights) for a box, a plane count (500), a symmetry group and an orientation fixture, runs the arms on the same planes through the reconstructor's public calls, compares their bytes and appends rows to ./rec_insert_bench.tsv. Fixtures: uniform; top (normals within 10 degrees of the third lattice axis); side (normals within 10 degrees of the plane across it); tilt (a single-axis series); cube (three clusters along the lattice axes, the worst case for decision 5). Boxes 96, 160 and 256; symmetry c1, c4 and d2; with and without extra poses. Recommended.
  12. The Mac read precedes any commit. dell2 cannot show the effect this plan exists for. After the dell2 run's report, with the M5 Ultra idle (the run mlxf_insert_slabs ended on 2026-11-28), the run's diff is applied to a scratch copy of the base there, built in Release, and the unit suite and the benchmark are run at 1, 2, 4, 10 and 20 threads (boxes 160 and 256, every fixture, c1 and d2). Its keep rule is fixed now: bytes identical in every cell; no cell above decision 9 (a)'s bound; at 10 threads, box 160, uniform, c1, the batch entry at most 0.50 times the per-plane loop's time (derived: 0.16 in the prototype and 0.17 in the toy's class, with a threefold margin, the margin guessed). Decision 15's pre-read has shown that SIMPLE's own loop does not scale there; this read measures what the batch entry recovers. Proposed owner: the maintainer starts it as a one-phase arun run on local (rec_slabs_mac) or as a session, from the command list the dell2 report ends with. Until its table is in the report, the note stays in planned/ and nothing is committed. Recommended.
  13. Not changed here: insert_planes_multi (flex's M-step), the per-particle call of simple_flex_pca_basis.f90, the offload module, the PCG backend's accumulate_batch. Recommended. If the Mac read keeps the change, a plan of its own takes insert_planes_multi, whose loop is heavier per sample and has the same colours.
  14. Real data, reported and not gated. One solve3D on a copy of each of two frozen inputs of nightly_triage on dell2 (strep, d2, box 128; bgal, d2), with that run's command lines, makes the orientations; then reconstruct3D on base and new, three runs each way at 16 threads and one each at one thread: rec3D accumulation per pose and, at one thread, the bytes of the partial reconstructions. No map is judged. A set whose base run fails is recorded and left. Recommended: the orientation distribution of a real project is the one input the fixtures guess. Alternative, on the precedent of f32_pcg's ruling R8 of the same day: no experimental data in the run, the maintainer reads it himself.
  15. A Mac pre-read before launch (added 2026-11-28 after the toy's report; the M5 Ultra is free). That SIMPLE's own loop fails to scale on macOS is inferred from the toy that mirrors it, never measured. One reconstruct3D on a simulated project with the Mac's existing Release build, at 1, 4 and 10 threads, reads rec3D accumulation per pose from the REC3D bench file: about ten minutes, no code. If the stage scales there as on Linux (more than 3 times at 10 threads), the case for this plan is Linux's modest one and the maintainer decides whether the run is worth its machine time. Recommended: yes, before the go. It changes no decision above.

    Result, 2026-11-28: the premise holds in SIMPLE itself, the run goes ahead. M5 Ultra, the Release build of 8c4276822 (its simple_reconstructor.f90 is the base's; of simple_matcher_3Drec.f90 only the weighted route's membership test differs). reconstruct3D with pgrp=c3 mskdiam=180 on 3,000 particles simulated from the 6VXX test volume (simulate_particles, box 192, snr=0.1, uniform orientations, CTF on), so 9,000 plane insertions per run; three rounds, the thread counts interleaved. rec3D accumulation in seconds:

    Threads Median Lowest to highest Against one thread
    1 8.385 8.338 to 8.663 1.00
    2 4.925 4.913 to 4.974 1.70
    4 3.138 3.124 to 3.139 2.67
    10 4.951 4.950 to 4.974 1.69
    20 8.789 8.760 to 8.796 0.95
    30 13.394 13.259 to 13.410 0.63

    The stage is fastest at four threads, 1.69 times faster at ten (under the bound of 3) and slower at thirty than at one; rec3D particle preparation in the same runs falls from 2.13 s to 0.14 s. The accumulation is 78 % of the pass's time at one thread and 98 % at thirty. A one-thread job of the same session ran on the machine during the rounds (one core of thirty). No floor and no gate rests on this table; decision 12's keep rule is judged on the Mac read's own alternating measurement.

Defaults taken without a question: the names insert_planes_batch, rec_insert_bench, REC_SLABS_PER_THR, REC_SLAB_MAX_LOAD, REC_SLAB_MIN_THR and the run name rec_slabs; the constants are private parameters of simple_reconstructor.f90; the team is omp_get_max_threads() read before the region; no switch selects the old path; the report stays beside this note in planned/.

4. Not in this plan

A change of any byte of a reconstruction. A change of insert_plane_oversamp. A stored pre-pass of sample indices and weights (the prototype's form B: slower at every thread count) and ownership by tiles in two indices (form C2: no faster on uniform planes, and worse on one orientation because of the doubled boundaries). The preparation of the planes (prep_imgs4rec), compress_exp, volume assembly. The 2D class averager. GPU routes. OMP_WAIT_POLICY or any other runtime setting. mlx-fortran (read-only; its run reports on its own, and none of its numbers is a floor here). The dell.

5. Change types and gates

Phase Kind Gate
0 none builds, fast gate, the base's production cases twice, the machine and data preconditions
1 tests-only fast gate and registry check; the per-plane loop's table and its A-A spread, frozen
2 identical, new code beside the old decision 8 in the tester and the benchmark; Debug run; decision 9 (a), (b)
3 identical, production caller decision 9 (c), (d); decision 14; the unit suites and workflow checks of section 6
4 documents fast gate; the report

6. Acceptance

  • Bytes (decision 8): zero differing words in every tester case and every benchmark cell; the planted control differs; the per-plane loop's bytes do not depend on the team. 20 repeats at 16 threads of the largest cell, bit for bit.
  • git diff shows no changed line inside insert_plane_oversamp (contract 3).
  • Decision 9 (a) in every cell on dell2, with the frozen spreads; decision 9 (b) as a verdict.
  • Decision 9 (c): the identity cases Phase 0 found reproducible are byte-identical between base and new.
  • build/bin/simple_test_exec test=unit_reconstruction (Release and Debug), test=unit_heterogeneity (flex's callers), test=lib_reconstruction (its fractional reconstruction goes through calc_3Drec); the fast gate. Base failures recorded in Phase 0 are left and named.
  • Tagged numbers: 0.03 guessed; spreads measured in Phase 1; 0.80 derived (prototype, dell2); 0.50 derived (prototype and toy, M5); 3 times in decision 15 guessed; REC_SLABS_PER_THR 3 derived, then measured; REC_SLAB_MAX_LOAD 2 guessed, then measured; the pool's 500 planes and 512 MB guessed.
  • Reported, not gated: decision 9 (b) and (d); decision 14; the batch of one (decision 1); the homogeneous core sets; the per-plane loop's scaling on dell2. The Mac table (decision 12) is the maintainer's.

7. Common rules and stop conditions

The run builds in its own trees, commits nothing, edits only what the file table gives its phase and adds a row before editing a file the table lacks. No new parameter. No floor or tolerance moved. Experimental variants (the constants of decisions 4 and 6, a diagnostic compile flag) are patched copies of a source tree under the run's scratch and never enter the diff. One heavy job at a time. A missed verdict of decision 9 (b), a fixture that takes the fallback and a failed real-data base run are results, not stops.

Stops, each with a report and a recommendation:

  • A word differs between the batch entry and the per-plane loop and two attempts do not find a cause in the batch entry's logic. If the cause is code generation (the two loop bodies fused differently), the allowed remedy is to write the batch entry's deposit and weight statements as the per-plane loop writes them; if identity then needs an edit of insert_plane_oversamp or a compile flag, stop.
  • Decision 9 (a) cannot be met at the largest team even with decisions 6 and 7 applied: the slab loop then never wins on this machine, and whether it goes to the Mac at all is the maintainer's call.
  • Decision 9 (c) fails, or Phase 0 finds no production case in which the base reproduces itself.
  • The pool of decision 3 cannot hold one particle's extras within its bounds.
  • The core map is not the one of code check 13, or the machine cannot be made idle within 30 minutes.
  • A file outside the table, or a signature of contract 4, would have to change.

No ruling may waive: decision 8's byte identity; contract 3; decision 9 (c); the fast gate; the rule that no parameter is added.

8. Phases

Phase 0: the base

Build Release and Debug of the base, run the fast gate on both, record the machine (compiler, core map, load) and keep the base build. Copy the prototype into the keep folder and run it once at 1, 4, 8 and 16 threads (forms A and C) against its log of 2026-11-28. Run the unit and library entries of section 6 and record their failures. Check every command line against the base's UI. Production cases, each twice on the base: simulated_workflow_6vxx at one thread and seed offset 0, compared with test=identity; reconstruct3D inside that run's finished directory at 1 and at 16 threads, the partial reconstructions compared byte for byte, with rec3D accumulation and the poses inserted. The identity case must insert extra poses (a REC3D record with more poses than particle images); if the workflow's does not, a refine3D pass with refine=prob on its finished project at one thread, twice, is added as a second case. Decision 14's two solve3D runs and their base reconstruct3D runs, if decision 14 is ruled in.

Exit: the gate passes; Progress holds the core map, the prototype's check, which production outputs the base reproduces at 1 and at 16 threads, the base's rec3D accumulation per pose with its spread, and the state of the two real sets.

Phase 1: the benchmark and the per-plane loop's table

Add rec_insert_bench with the per-plane arm, the fixtures and the byte comparison of the per-plane loop against itself across teams. Measure the table of decision 10 for every fixture, box and symmetry, twice (A against A).

Exit: the entry runs from the installed build; the fast gate and its registry check pass; Progress holds the per-plane loop's seconds and scaling per core set, the spread per cell, and the frozen bounds of decision 9 (a).

Phase 2: the batch entry

Write insert_planes_batch (decisions 1, 2, 4 and 5) and its tester cases (decision 8), add the batch arm and the batch-of-one arm to the benchmark, run the Debug build's unit suite. Tune REC_SLABS_PER_THR in scratch builds. Judge decision 9 (a); build decision 6 and decision 7 only by their rules. Judge decision 9 (b).

Exit: section 6's bytes in full; decision 9 (a) met in every cell or a stop; Progress holds the table per core set, the tuned constants with their tables, whether decisions 6 and 7 were built, and the verdict of decision 9 (b).

Phase 3: the production caller

update_state_half_rec hands its batch to the batch entry, extras included (decision 3); the benchmark's extras arm goes through the same pool logic or a tester case covers it. Decision 9 (c) and (d), decision 14, the unit suites and library entries of section 6.

Exit: decision 9 (c) holds; Progress holds the production times base against new, the real sets' table and the memory of the pool at the largest box run.

Phase 4: documents and report

The batch insertion in doc/algorithms/reconstruction.md, the entry in the test policy's section 1.3 if Phase 1 left it incomplete, the README row, this note's status line. The report batch_threaded_plane_insertion_report.md by section 8 of doc/how2s/how2write_agent_plans.md: its first paragraph says that nothing is ready to commit before the Mac read; it carries the dell2 tables beside empty Apple-silicon columns, the exact commands of decision 12, the losers with their mechanisms, proposed lines for the skills simple-main-volume and simple-main-strategies-search, and a commit message.

Exit: the fast gate passes on the final tree; no job of the run is left; the report exists.

File table

File What Phases
doc/implementation_notes/planned/batch_threaded_plane_insertion.md this note: Progress, rulings applied, the status line each
src/main/commanders/test/simple_commanders_test_highlevel_recbench.f90 new: the benchmark entry, its fixtures and arms 1, 2, 3
src/main/commanders/test/simple_commanders_test_highlevel.f90 the entry's commander type and interface 1
src/main/exec/simple_test_exec_highlevel.f90 the entry's route 1
src/main/ui/simple_test/simple_test_ui_highlevel.f90 the entry's UI and help 1, 2
doc/policies/test_environment_policy.md section 1.3: the entry 1, 4
src/fileio/simple_bench_io.f90 added in Phase 1: load_average, the one-minute load beside a benchmark row, shared by both benchmarks instead of a second private copy 1
src/main/commanders/test/simple_commanders_test_highlevel_matchbench.f90 added in Phase 1: its private load_average replaced by the shared one 1
src/main/volume/simple_reconstructor.f90 the batch entry, its slab geometry and constants; the per-plane routine untouched; the tester's cases 2, 3
src/main/commanders/test/simple_commanders_test_class.f90 the suite row, if the tester's cases become a suite of their own 2
src/main/ui/simple_test/simple_test_ui_class.f90 the suite help, if a suite is added 2
src/main/strategies/search/simple_matcher_3Drec.f90 the batch handed to the batch entry; the extras' pool 3
doc/algorithms/reconstruction.md the batch insertion 4
doc/implementation_notes/README.md this note's row 4
doc/implementation_notes/planned/batch_threaded_plane_insertion_report.md new: the run's report 4

A listed x.f90 also covers x_tester.f90 (the fence's companion rule).

Progress

Phase 0, 2026-11-28 (dell2): the base

Files changed: this note only (rulings R1 and R3 recorded where they belong, and this entry); no source. Rulings R2 applied: the prototype and the real inputs were read only and run on copies. Logs and scripts are under /home/hael/agent_runs/rec_slabs/scratch (logs/, keep/scripts/, keep/tools/); the run's journal is state/journal_phase_0.md.

Base, machine, builds.

  • Base 0267ace9e (state/base_head): 3de5b0295 plus the commit that adds this note, nothing else (rulings R3; recorded at the Base line). Launch differences (state/launch_status.txt): none, the file is empty.
  • dell2: Ubuntu 26.04, kernel 7.0, GNU Fortran (Ubuntu 15.2.0-16ubuntu1) 15.2.0, CMake 4.2.3, 61 GB. lscpu: Intel Core Ultra 7 366H, 16 CPUs, one thread per core, one socket, one NUMA node, L2 24 MiB (7 instances), L3 18 MiB. Core map read from the machine (/sys/devices/cpu_core/cpus = 0-3, /sys/devices/cpu_atom/cpus = 4-15, cpuinfo_max_freq): CPUs 0-3 P cores at 4.8 GHz (CPU 2 at 4.9), 4-11 E cores at 3.8 GHz, 12-15 low-power E cores at 3.4 GHz. This is code check 13's map, so decision 10's core sets stand. No OMP_* or GOMP_* variable is set. Load at the start 0.02.
  • Configure line of every tree: cmake -S <src> -B <tree> -DCMAKE_BUILD_TYPE=<Release|Debug> -DBUILD_TESTS=ON -DNICE=OFF -DUSE_ARCHOPT=ON -DFORTLS=OFF, then make -j16, make install, scripts/run_fast_gate.sh <tree> (keep/tools/build_tree.sh; logs logs/<tree>.*.log). Every script takes its SIMPLE from keep/tools/env.sh <tree> (the recipe of ms_validate_4282d58 with the tree as its argument: that tree's bin/ and scripts/ first on PATH, every other SIMPLE build removed, SIMPLE_QSYS=local, SIMPLE_SEED unset); the first lines of every run's log name the simple_exec and simple_test_exec it used.
  • Trees: the frozen base, git archive 0267ace9e in scratch/keep/src_base, Release in scratch/keep/build_base (3 min; never rebuilt after this phase); the run's Release tree repo/build and Debug tree repo/build_debug, both built from the unchanged checkout.
  • The fast gate passed on all three: 15 of 15 suites each (Release base 11.5 s of wall time, Debug 47.3 s under the load of two running workflows, repo/build 13.5 s).
  • Command lines: every one in this entry ran as written on the base build. reconstruct3D's keys were read from simple_ui_reconstruct3D.f90 (projfile, pgrp, mskdiam, nthr, mkdir; nparts optional), and simple_test_exec test=unit_reconstruction suite=list lists weighted_insertion, the reconstructor's tester suite that Phase 2 extends.

The prototype (copied from ~/tmp/mlxf_insert_proto to scratch/keep/proto/, rulings R2; its binary ran as it was). ./proto 160 500 A,C 1,4,8,16 32 6 twice (proto/rec_slabs_phase0_run{1,2}.log), unpinned as in its own log, load 1.0 at the start (the decay of the run's own jobs) and up to 2.2 from the prototype itself. Seconds per batch of 500 planes, the two runs, against the log of 2026-11-28 the run notes quote:

Threads Form A (today's loop) Log Form C (slabs, 6 layers) Log
1 0.405, 0.416 0.416 0.578, 0.579 0.579
4 0.140, 0.140 0.137 0.153, 0.153 0.153
8 0.123, 0.125 0.115 0.104, 0.100 0.105
16 0.164, 0.159 0.112 0.065, 0.070 0.076

Zero differing words in every row. More than 10 % off the log: form A at 16 threads, 42 to 46 % slower (both runs), and form C at 16 threads in the first run, 14 % faster. The prototype runs unpinned, so at 16 threads its team lands on all three kinds of core; that the plane by plane form, which waits at a barrier per colour, suffers most from it is inferred, not measured. Context, not a gate: SIMPLE's own table comes in Phase 1.

Unit and library entries of section 6 on the base (from the installed build_base, scratch/keep/units_base_release/<entry>/run.log): unit_reconstruction 24 of 24 groups, 2092 assertions, 15.3 s; unit_heterogeneity 5 of 5, 179 assertions, 2.6 s; lib_reconstruction (eight threads, as CTest runs it) 11 of 11, 1994 assertions, 256 s under load. In Debug unit_reconstruction and unit_heterogeneity passed inside the fast gate. No base failure to carry.

Production identity case at one thread. simple_test_exec test=simulated_workflow suite=6vxx (the registry row: one thread, seed offset 0; OMP_NUM_THREADS=1), one execution in each of scratch/keep/entry/base_1 and base_2 (keep/scripts/run_wf6vxx.sh), 783 and 782 s, both passing (docking correlation 0.9874, whole-map correlation 0.9002, FSC=0.143 at 4.54 Å). simple_test_exec test=identity target=simulated_workflow_6vxx dir1=.../base_1 dir2=.../base_2 (entry/identity_base12/): 185 declared outputs the same, none differing or missing. The case inserts extra poses: of the 90 reconstruction passes in 7_solve3D/BENCH/REC3D_BENCH_PART1.txt (72 particle images each), 10 insert more poses than images (73 to 75, at crops of 100 to 128 pixels), the extras of the probabilistic search's weighted insertion (topk 3). The plan's second case (refine3D refine=prob on the finished project) is therefore not added. The coverage is thin, 13 extra poses among 6,480 insertions; Phase 3's pool needs its own tester case (as its run notes already ask). The workflow's project names its particle stacks by absolute paths into entry/base_1, so that directory is kept for Phase 3's runs.

reconstruct3D on the base (keep/scripts/run_rec3d.sh): inside a copy of a finished solve3D directory, simple_exec prg=reconstruct3D projfile=<project> pgrp=<group> mskdiam=<diameter> nthr=<n> mkdir=yes, with taskset -c 0 nthr=1 and taskset -c 0-15 nthr=16, each twice, in the order 1, 16, 1, 16. Compared byte for byte within each pair: every file the run writes (the partial reconstructions recvol_state01_part1_{even,odd}.mrc and their densities rho_recvol_state01_part1_{even,odd}.mrc, the even and odd volumes, filtered and unfiltered, the merged and postprocessed maps, the FSC, the sigma2 store). rec3D accumulation is the time inside the insertion loop of the pass (update_state_half_rec), read from the REC3D bench file; a pose is one particle plane at one orientation, which the loop inserts once per symmetry copy.

Project Threads Poses Accumulation (s) ms per pose Spread of the pair Bytes within the pair
6vxx (c3, box 192) 1 72 0.303, 0.304 4.215 0.3 % all the same
6vxx 16 72 0.069, 0.069 0.958 0 (timer step 1 ms = 1.4 %) all the same
bgal (d2, box 256) 1 2756 36.672, 35.963 13.18 2.0 % all the same
bgal 16 2756 7.113, 7.131 2.584 0.25 % all the same
strep (d2, box 128) 1 6821 17.922, 17.612, 17.780, 17.246 2.594 3.8 % over the four (1.7 % first pair) all the same
strep 16 6821 6.860, 6.719 0.995 2.1 % all the same

ms per pose is the median over the runs. strep has four one-thread runs: a slip in the run script started its first 16-thread pair at one thread (the command lines in rec3d_info.txt say so); they were kept as repeats and the 16-thread pair was run after them. Loads at the starts: 1.4 to 1.9 for 6vxx, 2.3 to 5.0 for bgal, 1.7 to 5.6 for strep, all the decay of the run's own preceding solve3D and runs (nothing else ran on the machine). Today's loop scales 4.4 times (6vxx, box 192), 5.1 times (bgal, box 256) and only 2.6 times (strep, box 128) from one P core to the whole machine. Between team sizes the partial reconstructions differ, as the test policy expects (section 1.5): the pass recomputes the noise spectra it whitens the planes with (calc_pspec), and sigma2_state.bin already differs between 1 and 16 threads, so the planes can differ before any insertion (inferred; Phase 1 tests the loop's own independence of the team). Identity is judged within a team size only.

Real data (decision 14, ruled in). One solve3D per set on the base, on a copy of the frozen input of nightly_triage under scratch/keep/real/<set>/ (keep/scripts/run_real.sh, that run's command lines, SIMPLE_SEED=1, nthr=16), one at a time:

  • bgal (nsample=1500 mskdiam=180 pgrp=d2 pgrp_start=c1): 842 s, status 0, FSC=0.143 at 4.03 Å and 0.5 at 5.02 Å, as nightly_triage's base run with the same seed. Its refine3D passes insert extra poses (1874 poses for 1519 images in the last one).
  • strep (nsample=5000 mskdiam=85 pgrp=d2 pgrp_start=c1): 1930 s, status 0, FSC=0.143 at 3.05 Å and 0.5 at 3.52 Å (nightly_triage's base, an older code base, gave 3.12 and 3.61 Å). Its refine3D passes insert many extra poses (13,465 poses for 5,004 images in the last one).

Both sets are usable: their finished 1_solve3D directories (the projects input.simple with 3D orientations and the sigma2 store) stay under scratch/keep/real/<set>/ for Phase 3, and their base reconstruct3D runs are in the table above. No map is judged.

Exit.

Exit item Met by
The gate passes fast gate 15/15 on build_base, repo/build (Release) and repo/build_debug (Debug)
The core map read from the machine, equal to code check 13
The prototype's check two runs, zero differing words, the table above
What the base reproduces at 1 and at 16 threads simulated_workflow_6vxx at one thread: all 185 declared outputs; reconstruct3D on 6vxx, bgal and strep: every output, at 1 and at 16 threads
rec3D accumulation per pose with its spread the table above
The state of the two real sets both ran on the base (bgal 842 s, strep 1930 s) and are kept for Phase 3

Decisions taken under delegation: the second identity case was not added (the first already inserts extra poses); the cross-team difference of reconstruct3D was traced to the sigma2 store and is not judged.

Kept for later phases under scratch/keep/: build_base and src_base; the two workflow executions entry/base_{1,2} (the identity case's base directories; base_1 holds the stacks the projects name); the base reconstruct3D outputs rec3d_{6vxx,bgal,strep}/base_t{1,16}_*/1_reconstruct3D; the real sets' finished directories real/{bgal,strep}/1_solve3D; the prototype proto/.

In short: the base builds and passes its gate in Release and Debug; every production output the plan gates on reproduces itself at one thread and at sixteen, so decision 9 (c) has its cases. Today's stage scales about five times on the whole machine at boxes 192 and 256, and only 2.6 times at box 128. The prototype's slab form is still faster than its plane by plane form at 16 threads here.

Phase 1, 2026-11-29 (dell2): the benchmark and the per-plane loop's table

Files changed in this phase:

  • new src/main/commanders/test/simple_commanders_test_highlevel_recbench.f90: the body of rec_insert_bench (fixtures, synthetic planes, the per-plane arm, the word-for-word comparison, the TSV row);
  • src/main/commanders/test/simple_commanders_test_highlevel.f90 (its commander type and interface), src/main/exec/simple_test_exec_highlevel.f90 (its route), src/main/ui/simple_test/simple_test_ui_highlevel.f90 (its program and keys), doc/policies/test_environment_policy.md (its row in section 1.3);
  • src/fileio/simple_bench_io.f90 and src/main/commanders/test/simple_commanders_test_highlevel_matchbench.f90, added to the file table first: the one-minute load reader load_average existed only as a private function of the polar matching benchmark; it now lives in simple_bench_io and both benchmarks import it, instead of a second copy (the repository rule: extend the owner, never copy a helper);
  • this note (the two file-table rows and this entry). insert_plane_oversamp and every production file are unchanged.

The entry. simple_test_exec test=rec_insert_bench builds a gridding reconstructor (the expanded lattice of new_accumulator with expand=.true.) and synthetic planes laid out as gen_fplane4rec leaves them (the native lattice with k <= 0, padded limits): a random numerator, a density term in [0.01, 1.01), one weight per plane in [0.5, 1.5), a fixed seed per fixture and box (so c1, c4 and d2 see the same planes). Fixtures of plane normals (the normal is the third row of the rotation matrix; the code checks each pose against its drawn normal): uniform; top (within 10 degrees of the third lattice axis); side (within 10 degrees of the plane across it); tilt (one axis, tilts evenly from -60 to 60 degrees, one in-plane angle); cube (thirds within 10 degrees of each lattice axis). Per cell (fixture, box, point group) it inserts the batch once at one thread as the reference, then runs a warm round and niter timed rounds (7; 3 at one thread) at the team nthr, compares every round's numerator and density word for word with the reference, and appends a row per arm to ./rec_insert_bench.tsv: fixture, box, planes, point group, symmetry copies, team, processors available (which names the taskset core set), arm, slab count and axis (zero until Phase 2), rounds, median, minimum and maximum seconds of the batch, the most differing words of the numerator and of the density over the rounds, and the load before the cell. Keys, all existing parameters (none added): suite (the fixture; list), box, pgrp, nptcls (planes, 500), niter, nthr; without them it runs every fixture, boxes 96, 160 and 256 and c1, c4 and d2. No registry row and no CTest entry; the fast gate passes on the build with it (15 of 15, registry and command-line checks included; scratch/logs/p1_fastgate.log).

Dry runs before the table: the entry's first smoke run showed words differing between teams; the cause was the entry's own planes (an expression assigned to an unallocated array starts at index 1, so the loop read the planes out of bounds and the bytes depended on the memory layout: identical with address randomisation switched off, varying with it). After explicit bounds: zero differing words at box 32 for every fixture and group at 1, 2, 3, 4, 8 and 16 threads; the bounds-checked Debug build (-fcheck=all) runs the entry clean at 1 and 4 threads (scripts and Python checks in scratch/keep/diag/; one of them replays the loop's colouring and finds no voxel that two lines of one colour share).

The table (decision 10). The install was frozen first (scratch/keep/frozen/p1_plane). Two sweeps, A then B, each one invocation per core set: taskset -c 0 nthr=1, 0-1 with 2, 0-3 (the P cores) with 4, 4-11 (the E cores) with 8, 0-11 with 12, 0-15 with 16; every fixture, box and point group per invocation; 45 cells per team (scratch/keep/scripts/p1_table.sh; results scratch/keep/bench/p1/{A,B}/t<n>/rec_insert_bench.tsv, loads and times in bench/p1/table_info.txt). 1 h 20 min of wall time (00:15 to 01:35 on 2026-11-29; the retake and the check at three threads below ran to 01:50).

Load. From about 00:20 a job outside this run was on the machine (~/mlxf_ci_repro, an mlx-fortran build). It runs at the lowest priority on E cores 4-7 under a guard that stops its whole process group while any process named simple_* exists and resumes it otherwise; during every invocation its processes were stopped (seen in ps, state T). It ran only in the seconds between invocations, which the one-minute load beside the rows partly holds; the rows at teams of 4 and more carry their own load above 2. Sweep B's one-thread invocation started right after sweep A's 16-thread one, at a load of 5.8 and a package temperature near 80 C, and its first six cells ran 4 to 9 % slower than sweep A's (which started on an idle machine); under rulings R1 it was retaken (bench/p1/B/t1_retake, the original kept) after a cool-down to 44 C and a load of 0.95, with the foreign job held stopped by a simple_-named sleep (scratch/keep/tools/simple_bench_hold, scripts/cool_then.sh); the retake equals sweep A within 0.5 %. Every other invocation followed the same predecessor in both sweeps.

Bytes. Zero differing words of the numerator and of the density, in every round of every cell, at teams 1, 2, 4, 8, 12 and 16 in both sweeps, and at a team of 3 (decision 8 names it; taskset -c 0-2, one timed round, all 45 cells, bench/p1/bytes_t3): the per-plane loop's bytes do not depend on the team.

Today's loop in SIMPLE, never timed before: seconds per batch of 500 planes, the mean of the two sweeps, geometric mean over the five fixtures and three point groups (core set in brackets):

Box 1 (0) 2 (0-1) 4 (0-3) 8 (4-11) 12 (0-11) 16 (0-15)
96 0.4204 0.2733 0.1809 0.1538 0.1368 0.2553
160 1.1852 0.7014 0.4408 0.3331 0.2513 0.4291
256 3.6539 2.0528 1.1881 0.8288 0.6073 0.8450

Scaling against one thread (the cell at one thread over the cell at the team), geometric mean over fixtures and point groups, lowest and highest cell in brackets:

Box 2 (0-1) 4 (0-3) 8 (4-11) 12 (0-11) 16 (0-15)
96 1.54 [1.49, 1.72] 2.32 [2.10, 2.71] 2.73 [2.23, 3.14] 3.07 [2.59, 3.53] 1.65 [1.33, 2.03]
160 1.69 [1.59, 1.81] 2.69 [2.39, 2.95] 3.56 [2.91, 4.26] 4.72 [3.86, 5.53] 2.76 [2.19, 3.43]
256 1.78 [1.59, 1.90] 3.08 [2.49, 3.57] 4.41 [3.37, 5.47] 6.02 [4.51, 7.67] 4.32 [2.99, 5.93]
  • The loop scales on one kind of core (2.3 to 3.1 times on the four P cores, 2.7 to 4.4 on the eight E cores) and best on twelve (3.1 to 6.0 times), and it is slower on all sixteen cores than on twelve: adding the four low-power E cores costs 1.9 times at box 96, 1.7 at 160 and 1.4 at 256. Each colour of h lines ends at a barrier and the lines are dealt out in a fixed order, so every colour waits for its slowest core (the mechanism is inferred, not measured). Decision 9 (b)'s cell (uniform, box 160, c1) takes 0.486 s at one thread, 0.095 s at 12 and 0.165 s at 16.
  • Small boxes scale worst (box 96: 1.5 times at two threads), as reconstruct3D on strep (box 128) did in Phase 0.
  • At one thread the top views at box 256 are about 30 % faster than the uniform planes (their deposits stay in a few layers of the lattice; inferred).

Spread and frozen bounds (decision 9 (a)). The spread of a cell is max(A, B) / min(A, B) - 1 of its two medians; its bound is 1 + max(0.03, 2 x spread), the most the batch entry may take relative to the per-plane loop in that cell in Phase 2. Frozen before any slab code exists in scratch/keep/bounds/p1_bounds.tsv (read-only, sha256 9a886af2a821654e...), made by scratch/keep/scripts/p1_bounds.py:

Team (CPUs) Spread, median Spread, highest Its cell Cells at 1.03 Cells above Highest bound
1 (0) 0.0034 0.0127 tilt 96 d2 45 0 1.030
2 (0-1) 0.0011 0.0040 top 96 c1 45 0 1.030
4 (0-3) 0.0017 0.0059 tilt 160 c1 45 0 1.030
8 (4-11) 0.0081 0.0564 top 256 c1 34 11 1.113
12 (0-11) 0.0131 0.1605 top 96 c4 24 21 1.321
16 (0-15) 0.0161 0.1684 side 160 c1 20 25 1.337

On the P cores (one, two and four threads) the spreads are small (at most 1.3 %, so every bound is 1.03); on the eight E cores and the mixed sets they are larger and scattered (at 12 and 16 threads sweep A was the slower in 47 cells and B in 43), and the rounds inside one invocation vary as much (one cell at 12 threads: 0.234 to 0.315 s), so they are the loop's own variation on mixed cores. Every cell, spread in % / bound:

Fixture, box, group 1 2 4 8 12 16
uniform 96 c1 0.1 / 1.030 0.2 / 1.030 0.6 / 1.030 2.9 / 1.058 1.3 / 1.030 3.4 / 1.068
uniform 96 c4 0.1 / 1.030 0.2 / 1.030 0.3 / 1.030 1.4 / 1.030 1.7 / 1.034 1.4 / 1.030
uniform 96 d2 0.1 / 1.030 0.2 / 1.030 0.4 / 1.030 1.3 / 1.030 0.3 / 1.030 2.7 / 1.053
uniform 160 c1 0.5 / 1.030 0.1 / 1.030 0.4 / 1.030 0.5 / 1.030 0.3 / 1.030 1.5 / 1.030
uniform 160 c4 0.1 / 1.030 0.1 / 1.030 0.0 / 1.030 0.4 / 1.030 0.6 / 1.030 1.6 / 1.032
uniform 160 d2 0.2 / 1.030 0.1 / 1.030 0.1 / 1.030 0.1 / 1.030 1.5 / 1.031 5.3 / 1.105
uniform 256 c1 0.2 / 1.030 0.3 / 1.030 0.2 / 1.030 0.3 / 1.030 0.1 / 1.030 2.0 / 1.040
uniform 256 c4 0.0 / 1.030 0.3 / 1.030 0.3 / 1.030 0.4 / 1.030 0.4 / 1.030 2.0 / 1.040
uniform 256 d2 0.1 / 1.030 0.1 / 1.030 0.1 / 1.030 1.2 / 1.030 0.0 / 1.030 1.1 / 1.030
top 96 c1 0.0 / 1.030 0.4 / 1.030 0.1 / 1.030 4.2 / 1.085 2.8 / 1.057 2.5 / 1.051
top 96 c4 0.1 / 1.030 0.1 / 1.030 0.1 / 1.030 2.9 / 1.059 16.1 / 1.321 0.4 / 1.030
top 96 d2 0.0 / 1.030 0.3 / 1.030 0.0 / 1.030 1.1 / 1.030 1.9 / 1.039 2.4 / 1.048
top 160 c1 0.0 / 1.030 0.1 / 1.030 0.2 / 1.030 0.8 / 1.030 2.7 / 1.054 3.4 / 1.067
top 160 c4 0.3 / 1.030 0.0 / 1.030 0.2 / 1.030 0.1 / 1.030 2.5 / 1.050 3.9 / 1.078
top 160 d2 0.2 / 1.030 0.1 / 1.030 0.3 / 1.030 0.6 / 1.030 2.0 / 1.040 2.5 / 1.050
top 256 c1 0.2 / 1.030 0.1 / 1.030 0.1 / 1.030 5.6 / 1.113 1.5 / 1.030 4.4 / 1.089
top 256 c4 0.3 / 1.030 0.0 / 1.030 0.1 / 1.030 1.0 / 1.030 0.5 / 1.030 0.9 / 1.030
top 256 d2 0.6 / 1.030 0.1 / 1.030 0.3 / 1.030 0.5 / 1.030 1.9 / 1.039 0.3 / 1.030
side 96 c1 0.5 / 1.030 0.1 / 1.030 0.6 / 1.030 0.2 / 1.030 2.8 / 1.056 1.0 / 1.030
side 96 c4 0.5 / 1.030 0.1 / 1.030 0.2 / 1.030 0.5 / 1.030 0.3 / 1.030 3.7 / 1.073
side 96 d2 0.6 / 1.030 0.1 / 1.030 0.2 / 1.030 2.1 / 1.042 1.2 / 1.030 0.4 / 1.030
side 160 c1 0.1 / 1.030 0.0 / 1.030 0.2 / 1.030 0.2 / 1.030 2.1 / 1.042 16.8 / 1.337
side 160 c4 0.3 / 1.030 0.2 / 1.030 0.2 / 1.030 0.3 / 1.030 1.0 / 1.030 2.4 / 1.047
side 160 d2 0.3 / 1.030 0.1 / 1.030 0.1 / 1.030 0.7 / 1.030 1.9 / 1.037 0.1 / 1.030
side 256 c1 0.1 / 1.030 0.2 / 1.030 0.1 / 1.030 2.1 / 1.041 1.0 / 1.030 0.2 / 1.030
side 256 c4 0.0 / 1.030 0.1 / 1.030 0.3 / 1.030 1.2 / 1.030 0.9 / 1.030 0.6 / 1.030
side 256 d2 0.5 / 1.030 0.0 / 1.030 0.1 / 1.030 0.0 / 1.030 0.9 / 1.030 0.2 / 1.030
tilt 96 c1 0.9 / 1.030 0.1 / 1.030 0.1 / 1.030 1.0 / 1.030 5.7 / 1.113 4.1 / 1.082
tilt 96 c4 1.2 / 1.030 0.1 / 1.030 0.2 / 1.030 3.3 / 1.066 0.6 / 1.030 0.0 / 1.030
tilt 96 d2 1.3 / 1.030 0.0 / 1.030 0.1 / 1.030 0.8 / 1.030 0.1 / 1.030 2.0 / 1.040
tilt 160 c1 1.3 / 1.030 0.1 / 1.030 0.6 / 1.030 2.1 / 1.041 6.8 / 1.135 1.9 / 1.038
tilt 160 c4 1.2 / 1.030 0.1 / 1.030 0.3 / 1.030 0.3 / 1.030 1.3 / 1.030 0.1 / 1.030
tilt 160 d2 1.0 / 1.030 0.1 / 1.030 0.5 / 1.030 0.5 / 1.030 6.2 / 1.125 0.6 / 1.030
tilt 256 c1 0.7 / 1.030 0.3 / 1.030 0.1 / 1.030 1.4 / 1.030 1.1 / 1.030 2.1 / 1.042
tilt 256 c4 0.7 / 1.030 0.1 / 1.030 0.1 / 1.030 0.3 / 1.030 0.4 / 1.030 0.7 / 1.030
tilt 256 d2 1.0 / 1.030 0.2 / 1.030 0.1 / 1.030 0.3 / 1.030 2.6 / 1.051 1.5 / 1.030
cube 96 c1 1.0 / 1.030 0.0 / 1.030 0.4 / 1.030 4.1 / 1.081 4.0 / 1.081 0.7 / 1.030
cube 96 c4 1.1 / 1.030 0.1 / 1.030 0.0 / 1.030 0.2 / 1.030 2.8 / 1.056 0.2 / 1.030
cube 96 d2 1.0 / 1.030 0.1 / 1.030 0.2 / 1.030 1.4 / 1.030 1.2 / 1.030 1.6 / 1.033
cube 160 c1 0.4 / 1.030 0.1 / 1.030 0.1 / 1.030 3.1 / 1.062 2.1 / 1.043 1.5 / 1.030
cube 160 c4 0.5 / 1.030 0.1 / 1.030 0.5 / 1.030 1.8 / 1.036 0.3 / 1.030 1.6 / 1.032
cube 160 d2 0.5 / 1.030 0.2 / 1.030 0.3 / 1.030 0.8 / 1.030 1.5 / 1.031 1.9 / 1.038
cube 256 c1 0.0 / 1.030 0.1 / 1.030 0.1 / 1.030 1.5 / 1.030 0.7 / 1.030 3.6 / 1.071
cube 256 c4 0.2 / 1.030 0.1 / 1.030 0.0 / 1.030 0.4 / 1.030 0.7 / 1.030 1.5 / 1.031
cube 256 d2 0.3 / 1.030 0.1 / 1.030 0.2 / 1.030 0.8 / 1.030 1.4 / 1.030 0.2 / 1.030

Exit.

Exit item Met by
The entry runs from the installed build every row above came from simple_test_exec of the installed tree (frozen copy)
The fast gate and its registry check pass 15 of 15; check_test_registry.py and the command-line chain check pass
The per-plane loop's seconds and scaling per core set the two tables above; every cell in the TSV files
The spread per cell and the frozen bounds the table above and scratch/keep/bounds/p1_bounds.tsv (read-only)
Whether the per-plane loop's bytes depend on the team they do not: zero differing words at 1, 2, 3, 4, 8, 12 and 16 threads

Decisions taken under delegation: the keys above (existing parameters only); the benchmark's constants stay in its submodule as the polar matching benchmark keeps its own; the shared load_average; the spread as a ratio of the two medians; the one-thread retake of sweep B under R1; the bytes-only check at three threads; no extras variant yet: for the per-plane loop extra poses are only more planes, and the variant belongs with the pool of decision 3 in Phase 3, whose file table row covers this entry.

In short: SIMPLE's per-plane insertion gives the same bytes at every team, scales to about five times on twelve cores, and loses a large part of that on all sixteen; the bounds the batch entry must meet are frozen, at 1.03 on one kind of core and looser on the mixed sets where the per-plane loop itself varies.

Phase 2, 2026-11-29 (dell2): the batch entry

(Written in two steps: the tuning of the slab constant below went into this note before the judged table was run.)

Tuning REC_SLABS_PER_THR (decision 4: the value of 2, 3 and 4 with the smallest geometric mean of the batch times at teams of 4, 8 and 16 and boxes 96, 160 and 256, uniform planes, c1). Three trees from one snapshot of this checkout, the constant patched (scratch/keep/src_spt{2,3,4}, patches scratch/keep/patches/spt{2,4}.patch, builds scratch/keep/build_spt{2,3,4}, fast gate passed on each); per pass and team one invocation per tree, taskset -c 0-3 with 4 threads, 4-11 with 8, 0-15 with 16, the machine cooled to below 55 C first; scripts scratch/keep/scripts/p2_tune.sh and p2_tune_more.sh, results scratch/keep/bench/p2_tune. The first two passes disagreed on the ranking (2 best by 7 % in the first, worst by 3.6 % in the second, where one invocation of value 2 on the E cores ran 30 % slow for the whole process and ten repeats of it did not show the slow state again; its cause is not known), so before more data the measurement was extended to six passes with the trees in alternating order, and the rule applied to all six. Seconds of the batch arm per batch of 500 planes, the mean of six passes; in brackets the batch over the per-plane loop timed in the same process, and the slab count:

Slabs per thread 4 thr, box 96 4 thr, box 160 4 thr, box 256 8 thr, box 96 8 thr, box 160 8 thr, box 256 16 thr, box 96 16 thr, box 160 16 thr, box 256 Geometric mean
2 0.0590 (0.84, 8 slabs) 0.1504 (0.88, 8 slabs) 0.4103 (0.85, 8 slabs) 0.0490 (0.85, 16 slabs) 0.1247 (1.00, 16 slabs) 0.3537 (1.04, 16 slabs) 0.0327 (0.31, 32 slabs) 0.0773 (0.45, 32 slabs) 0.1919 (0.56, 32 slabs) 0.1156
3 0.0668 (0.94, 12 slabs) 0.1689 (0.98, 12 slabs) 0.4193 (0.86, 12 slabs) 0.0518 (0.89, 24 slabs) 0.1301 (1.04, 24 slabs) 0.3271 (0.96, 24 slabs) 0.0324 (0.29, 33 slabs) 0.0847 (0.48, 48 slabs) 0.1991 (0.58, 48 slabs) 0.1213
4 0.0678 (0.96, 16 slabs) 0.1687 (0.98, 16 slabs) 0.4072 (0.83, 16 slabs) 0.0547 (0.97, 32 slabs) 0.1366 (1.11, 32 slabs) 0.3222 (0.95, 32 slabs) 0.0326 (0.31, 33 slabs) 0.0851 (0.49, 55 slabs) 0.2035 (0.61, 64 slabs) 0.1227

The rule picks 2 (geometric mean 0.1156 s; 3 takes 4.9 % longer, 4 takes 6.1 %; 2 is the smallest in five of the six passes). The plan's derived value 3 loses; the repository carries 2 (simple_reconstructor.f90). Two slabs per thread win on the P cores (0.84 to 0.88 of the per-plane time against 0.86 to 0.98) and on all sixteen cores; on the eight E cores three are slightly better at box 256 and two at boxes 96 and 160. Zero differing words in every tuning row.

Files changed in this phase: src/main/volume/simple_reconstructor.f90 (the batch entry, its worker and constants), src/main/volume/simple_reconstructor_tester.f90 (its cases), the benchmark's submodule src/main/commanders/test/simple_commanders_test_highlevel_recbench.f90 (the batch arms) and its help in src/main/ui/simple_test/simple_test_ui_highlevel.f90, and this note (decision 4's tuned value, this entry). No file outside the table.

The batch entry. reconstructor%insert_planes_batch(se, os, fpls, ws[, nslabs, axis]) inserts records in the order given: pose os(i), plane fpls(i), weight ws(i) (one for an unweighted call: code check 6, shown again by a tester case). It makes every record's rotations per symmetry copy serially, exactly as insert_plane_oversamp does, reads the team with omp_get_max_threads(), and then:

  • a team smaller than REC_SLAB_MIN_THR (2) takes the per-plane loop: insert_plane_oversamp once per record;
  • otherwise the lattice's second or third index is cut into min(n/3, REC_SLABS_PER_THR x team) slabs (REC_SLABS_PER_THR = 2; n the layers along the index, so a slab is never thinner than the 3-layer window), along the axis whose heaviest slab holds the smaller share of a plane on average (decision 5);
  • a batch whose heaviest slab would hold more than REC_SLAB_MAX_LOAD (1.5) times a thread's share of the work also takes the per-plane loop (decision 6);
  • else the private worker insert_planes_slabs (a type-bound procedure, so that the tester, a submodule, can force the axis and the slab count) runs one parallel do schedule(dynamic,1) over the slabs. The thread that owns a slab walks the whole batch in the per-plane loop's order (record, symmetry copy, colour of h lines, h, k), clips each line to a superset of the k whose window can reach its slab (double precision, a quarter layer of margin, one more k at each end, no cut when the line's coordinate barely changes), and for each sample computes the window's coordinate along the slab axis first, tests membership on that window, then does the rest exactly as the per-plane loop: the empty-sample skip, the window, the Friedel skip, the scale and density weight, the weights (an inline copy of the per-plane loop's contained weight routine, statement for statement) and the additions, restricted to the slab. No lock, atomic or barrier inside the batch; nothing allocated, no string and no module state inside the region.

The optional nslabs and axis report the geometry taken (0 for the per-plane loop) for the benchmark. insert_plane_oversamp is not changed by a character: git diff -U0 of the file has three hunks (the constants at 21-25, the two bindings at 101-102, the new routines at 614-876) and the routine's 152 lines, 454-605 at the base, are 461-612 now, identical (diff empty, same checksum).

Bytes first (decision 8), before any timing. Tester test_batch_insertion_identity in simple_reconstructor_tester.f90, run by simple_test_exec test=unit_reconstruction suite=weighted_insertion (the fast gate's suite): nine random planes laid out as gen_fplane4rec leaves them (a tenth of the samples empty, one top view and one side view among the poses, weights in [0.5, 1.5) with one weight of one), boxes 16 and 32, point groups c1 and d2, each compared word for word (transfer to integers, numerator and density) with insert_plane_oversamp called once per record on a second reconstructor at one thread:

  • the worker forced to both axes and to 1, 2, an intermediate number, n/3 and n slabs (n = 21 and 37: one-layer slabs included), at a team of one and a team forced to four (omp_set_num_threads, restored);
  • the public entry at both teams, with its own geometry (a team of one takes the per-plane loop; a team of four forms and takes min(n/3, 2 x 4) slabs); the batch cut in two; weight one against the unweighted per-plane call;
  • the axis rule: near-top views are cut along the second index, normals near the second index along the third; normals alternately near the second and the third index (f T about 2.5) take the per-plane loop; bytes unchanged in all three;
  • the planted control: the same batch in reverse order differs (the comparison can fail); it lives in the tester only.

Release and the bounds-checked Debug build (-fcheck=all): test=unit_reconstruction 24 of 24 groups, 2214 of 2214 assertions (the base had 2092), scratch/p2_unit/ur_release_final.log and debug/ur_debug_final.log. The benchmark's batch arms in Debug at box 32 (teams 1 and 4): zero differing words. In every benchmark row of this phase (tuning, both judged tables, the decision-6 trees, the re-measurements and the checks below: 3,429 rows, each the worst of its rounds) the numerator and the density of every arm equal the per-plane loop's at one thread, word for word.

The first judged table (decision 9 (a), before decisions 6 and 7; the batch with 2 slabs per thread against the per-plane loop in the same process, the three arms alternating; scratch/keep/scripts/p2_table.sh, frozen install scratch/keep/frozen/p2_batch, results scratch/keep/bench/p2_judged, judged by scripts/p2_judge.py against the frozen bounds; the machine cooled below 55 C and a load of 2 before each core set; 02:41 to 04:19):

Team (CPUs) Batch over per-plane: geometric mean [lowest, highest] Cells meeting the bound
1 (0) 1.061 [1.040, 1.072] 0 of 45
2 (0-1) 0.879 [0.770, 1.009] 45 of 45
4 (0-3) 0.857 [0.732, 1.012] 45 of 45
8 (4-11) 0.939 [0.716, 1.477] 36 of 45 (every cube cell missed, 1.13 to 1.48)
12 (0-11) 0.799 [0.551, 1.109] 40 of 45 (cube at boxes 160 and 256 missed, 1.05 to 1.11)
16 (0-15) 0.442 [0.276, 0.736] 45 of 45
  • One slab at one thread costs 4 to 7 % in every cell: the plan's hypothesis that a team of one on one slab is back at today's time is false (the extra per-sample tests and the variable tap ranges cost what the region per plane saved).
  • From two threads on the batch is faster than the per-plane loop on every kind of core, and on all sixteen cores it takes 0.28 to 0.74 of its time, where the per-plane loop collapses (Phase 1).
  • The cube fixture (thirds of the normals along each lattice axis) loads one slab of either axis: on the eight E cores it loses up to 48 %, as code check 9 and decision 6 expected.

Decision 6 (built, since cube missed): a batch whose heaviest slab holds more than REC_SLAB_MAX_LOAD times a thread's share takes the per-plane loop. Its constant: three trees from one snapshot with 1.5, 2 and 3 (scratch/keep/src_d6_*, patches scratch/keep/patches/d6_{15,3}.patch, fast gate passed on each), the cube fixture (every box and point group) at 2, 4, 8, 12 and 16 threads (scripts/p2_dec6.sh, bench/p2_dec6). A Python estimate of the load (scripts/p2_fload_estimate.py) put every other fixture below 1.0 and cube at 1.1, 1.8, 2.4, 2.6 and 2.7 at these teams, so only cube can take the fallback.

Single invocations decided nothing: under 1.5 a cube cell that took the per-plane loop, the same code in both arms, measured 1.042 against a bound of 1.03, because on the P cores at box 256 the per-plane loop's rounds fall into two levels within one process (2.05 and 2.20 s; heat, inferred), which a median of seven rounds cannot separate from a 3 % bound. Deviation, fixed before further data: a cell whose ratio lies within 5 % of its bound, met or missed, is measured in two more invocations of that cell alone (cooled first) and judged on the median of its three ratios (scripts/p2_remeasure.sh, scripts/p2_median3.py); the bounds themselves are unchanged. The rule applies alike to decision 6's choice and to the final judged table. Result (bench/p2_dec6/dec6_judge_median3.txt):

REC_SLAB_MAX_LOAD Cube cells taking the per-plane loop Cells re-measured Cells missing the bound
1.5 36 of 45 (teams 4 to 16) 29 0
2 27 of 45 (teams 8 to 16) 23 3 (box 160 at four threads, on slabs: medians 1.041 to 1.056)
3 0 not needed 15 (eight threads 1.12 to 1.46, twelve threads)

The rule (the smallest of 1.5, 2 and 3 with which every fixture meets the bound) picks 1.5, the only value that meets; the plan's guess of 2 loses at four threads.

Decision 7 (built, since a team of one missed every cell): every measured team from two on meets the bound with decision 6 (the judged table for the other fixtures, the 1.5 tree for cube), so REC_SLAB_MIN_THR = 2: a team of one takes the per-plane loop. The crossing lies between one and two threads on this machine; the toy's three threads (rulings R4) were measured on the M5 with a fixed thickness and are not taken over.

The final judged table (decisions 6 and 7 in place, the repository's build frozen as scratch/keep/frozen/p2_final; every cell of Phase 1's table, the three arms alternating in one process per core set, cooled before each; bench/p2_final, 06:43 to 08:21). The batch over the per-plane loop:

Team (CPUs) Batch: geometric mean [lowest, highest] Batch of one Cells meeting the bound Cells on the per-plane loop
1 (0) 1.001 [0.995, 1.013] 1.000 [0.995, 1.004] 45 of 45 45 (decision 7)
2 (0-1) 0.876 [0.762, 1.009] 0.902 [0.827, 1.012] 45 of 45 0
4 (0-3) 0.864 [0.731, 1.008] 0.895 [0.761, 1.069] 45 of 45 9, cube (decision 6)
8 (4-11) 0.891 [0.722, 1.027] 0.932 [0.753, 1.103] 45 of 45 9, cube
12 (0-11) 0.798 [0.521, 1.018] 0.823 [0.638, 1.006] 45 of 45 9, cube
16 (0-15) 0.485 [0.284, 1.030] 0.526 [0.377, 0.764] 45 of 45 9, cube

All 270 cells meet their frozen bounds on the single invocations; zero differing words in every arm and round. Under the re-measurement rule the 78 cells within 5 % of their bound (all 45 at one thread, where both arms run the same code, and 33 others) ran twice more (bench/p2_final/remeasure, 08:21 to 09:55): judged on the medians of three, every one of the 270 cells meets its bound (bench/p2_final/judge_median3.txt).

Decision 9 (b) (on all sixteen cores, box 160, uniform, c1, at most 0.80 of the per-plane loop's time): the batch takes 0.0773 s against 0.1779 s, 0.434: met (load 1.98, the run's own). The batch on sixteen cores is also faster than the per-plane loop's best team on this machine (twelve threads, 0.0954 s).

Decision 1, the batch of one (the batch entry called once per plane): within decision 9 (a)'s bound in 258 of 270 cells; it misses two cells at four threads (tilt, c4) and ten at eight E cores (side, uniform and tilt at boxes 160 and 256, up to 1.10). Since it has to hold in every cell on both machines, dell2 already rules out retiring the coloured loop in favour of batches of one.

Closing byte checks. The heaviest cell (side views, box 256, c4) at sixteen threads, 20 timed rounds of each arm (bench/p2_repeat20): zero differing words in every round, the batch at 0.784 s against 1.476 s. A team of three (taskset -c 0-2, every cell, bench/p2_bytes_t3): zero differing words; at three threads no batch takes the per-plane loop. With the tables above, the batch's bytes are the per-plane loop's at teams of 1, 2, 3, 4, 8, 12 and 16 for every fixture, box and point group.

Findings and losers, each with its mechanism:

  • One slab at one thread costs 4 to 7 %; teams of one keep today's loop (decision 7). The plan's three slabs per thread lose to two by 4.9 % in the geometric mean (more slabs mean more passes over the batch per thread); four lose by 6.1 %.
  • On batches with a third of their normals along each lattice axis (cube) one slab of either axis holds a third of every plane; the slabs lose there from four threads on, and decision 6 hands them to today's loop from a load of 1.5.
  • Today's loop on all sixteen cores is the weak point of the machine (Phase 1), and the batch recovers it: 0.28 to 0.74 of its time there, and faster than today's loop at its best team.
  • Two pitfalls of the measurement itself: single medians of seven rounds cannot separate 3 % where the per-plane loop's rounds split into two levels within one process (P cores at box 256, heat inferred), hence the re-measurement rule; and one invocation on the E cores ran a third slow for its whole life with no cause found (ten repeats did not show it again), which is why the tuning ran six passes.
  • A build-system trap: changing a private constant of simple_reconstructor did not recompile its tester submodule (the stale object still held the old value and failed two checks); touching the submodule fixed it.

Exit.

Exit item Met by
Section 6's bytes in full tester cases (both axes, slab counts 1 to n, teams 1 and 4, c1 and d2, weights, a cut batch, the unweighted call, the axis rule, the fallback) word for word; planted control differs; 3,429 benchmark rows with zero differing words at teams 1, 2, 3, 4, 8, 12 and 16; 20 rounds of the heaviest cell at sixteen threads bit for bit
Debug run unit_reconstruction 24/24, 2214/2214 under -fcheck=all; the benchmark's batch arms in Debug, zero differing words
Decision 9 (a) in every cell or a stop met in all 270 cells of the final table (78 on the median of three)
The table per core set the final table above; every cell in bench/p2_final/judge_first.tsv
The tuned constants with their tables REC_SLABS_PER_THR = 2 (six passes, table above); REC_SLAB_MAX_LOAD = 1.5 and its table; REC_SLAB_MIN_THR = 2
Whether decisions 6 and 7 were built both built, by their rules
The verdict of decision 9 (b) met, 0.434
insert_plane_oversamp untouched git diff -U0: no hunk inside it; old 454-605 equal to new 461-612
The fast gate 15 of 15 (scratch/logs/p2_fastgate_final.log)

Decisions taken under delegation: the tuning extended to six passes before deciding; the re-measurement rule for cells within 5 % of their bound (a deviation, fixed before the data it judged); the batch entry's dummy list (se, os, fpls, ws[, nslabs, axis]) and its private worker; the slabs' order in the schedule left natural; the tester's cases inside the existing weighted_insertion suite (no new suite, so no _class rows).

In short: the batch entry gives today's bytes in every case tried, is faster than today's loop from two threads on (about 12 to 14 % on the P cores, 11 % on the E cores, 20 % on twelve cores and about half the time on all sixteen), takes today's loop for a single thread and for batches that load one slab too heavily, and meets decision 9 (a) in every cell and decision 9 (b) by a wide margin. Whether it does more on Apple silicon is the Mac read's question.

Ruling R6, 2026-11-29 (dell2, done at the start of Phase 3): equal-work slab boundaries, not adopted

Rulings R6 (Hans, 2026-11-29, read first by this phase) asked to test slab boundaries placed for equal estimated work against the layout of Phase 2 (equal thickness, 2 slabs per thread), by a rule fixed in the ruling.

What was built. In the repository: the slab worker insert_planes_slabs now takes the slabs' first layers slab_lo(:) (and one past the last) instead of a count, so that any contiguous layout can be handed to it; insert_planes_batch passes the equal-thickness boundaries it took before, so the behaviour is unchanged. The tester gained two strongly unequal layouts on both axes, at teams of one and four, c1 and d2 (one-layer slabs at either end, and one-layer slabs in the dense middle), each word for word with the per-plane loop, and the batch in reverse on the unequal slabs as the planted control, which differs (weighted_insertion 144 to 192 checks). The candidate, only in scratch trees (scratch/keep/scripts/r6_make_candidate.py, patches scratch/keep/patches/r6_ew2.patch and r6_ew1.patch): between the axis choice and the slab loop, a histogram of the batch's samples per layer by the centre tap of their window (symmetry copies included, empty and Friedel-skipped samples left out, every third line and every third k), built in parallel over the records with one column per thread; a slab's cost is the samples whose window reaches it plus a third of the window layers they put inside it (kept in integers, three times over); the contiguous partition into at most the slab count with the smallest heaviest cost, by bisection on the bound and a greedy fill; decisions 5, 6 and 7 as built. Its bytes were the per-plane loop's in every tester case and every benchmark row.

The choice (the ruling's protocol: decision 4's as Phase 2 ran it, six passes with the trees in alternating order, teams 4 (P cores), 8 (E cores) and 16, boxes 96, 160 and 256, c1, the fixtures that take slabs in the reference: uniform, top, side and tilt; scratch/keep/scripts/r6_tune.sh, bench/r6_tune, 10:20 to 11:36, cooled first). Seconds of the batch per batch of 500 planes (geometric mean over the fixtures and the six passes; in brackets the batch over the per-plane loop in the same process):

Layout 4 thr, box 96 4 thr, box 160 4 thr, box 256 8 thr, box 96 8 thr, box 160 8 thr, box 256 16 thr, box 96 16 thr, box 160 16 thr, box 256 Geometric mean Cells
ref 0.0605 (0.85) 0.1541 (0.89) 0.3945 (0.85) 0.0487 (0.79) 0.1195 (0.90) 0.3058 (0.93) 0.0330 (0.29) 0.0759 (0.41) 0.1764 (0.48) 0.1125 216
ew2 0.0593 (0.83) 0.1491 (0.86) 0.3814 (0.82) 0.0473 (0.77) 0.1125 (0.84) 0.2919 (0.88) 0.0363 (0.33) 0.0788 (0.43) 0.1895 (0.52) 0.1123 216
ew1 0.0582 (0.82) 0.1493 (0.86) 0.4088 (0.88) 0.0450 (0.72) 0.1057 (0.78) 0.2834 (0.86) 0.0398 (0.36) 0.0846 (0.46) 0.1991 (0.56) 0.1138 216

Against the reference: equal work with 2 slabs per thread 0.2 % faster, with 1 slab per thread 1.2 % slower (per pass the first ranged from 1.5 % slower to 1.6 % faster). The rule adopts a candidate only at 3 % or more: not adopted; the repository keeps the equal-thickness layout, and both candidates are losers here. Their mechanism, inferred from the cells: equal work wins on the four P cores (2 to 3 % with two slabs per thread) and on the eight E cores (3 to 6 % with two, 7 to 12 % with one) and loses on all sixteen cores (4 to 10 % with two, 12 to 21 % with one), where equal work is not equal time on three kinds of core and the dynamic schedule over thinner, equal-thickness slabs absorbs the speed differences; the histogram's fixed cost also weighs most where the insertion is fastest. With one slab per thread, decision 6's unchanged estimate (thicker slabs) also sends the uniform batches to the per-plane loop (and the candidate tree's tester expectations of the slab geometry fail on that; its byte checks pass). The Mac read measures both layouts (the report's command list).

Reported, not gated and not adopted. (i) The reference layout with the slab count set so that a slab's voxels (numerator and density) take about 8 MB (13 slabs) and about 16 MB (7 slabs) at box 256, and a team of one allowed to take slabs (scratch trees, patches r6_sz8.patch, r6_sz16.patch; bench/r6_reported/size), the batch over the per-plane loop for uniform, top, side and tilt planes, c1:

Slabs One thread Four threads (P cores) Sixteen threads
about 8 MB (13) 0.818, 1.187, 0.760, 1.106 (geometric mean 0.950) 0.810, 0.781, 0.743, 0.852 (0.795) all on the per-plane loop (0.997)
about 16 MB (7) 0.802, 1.133, 0.735, 1.060 (0.917) 0.869, 0.867, 0.892, 0.945 (0.893) all on the per-plane loop (0.993)
reference (8 at four threads, 32 at sixteen) per-plane loop 0.839, 0.832, 0.831, 0.887 (0.847) 0.552, 0.418, 0.532, 0.420 (0.477)

Cache-sized slabs beat today's loop at one thread where a plane's samples spread across the lattice (uniform and side views: 18 to 26 % less time) and lose where they sit in a few layers anyway (top views and the tilt series); at four threads 13 slabs beat the reference's 8 by 6 %; at sixteen threads decision 6's estimate, computed for the thicker slabs, sends every batch to the per-plane loop. (ii) The cube fixture's load: decision 6's estimate f T against the heaviest slab's share times the team under the equal-work partition (r6_diag_on_ew2.patch, bench/r6_reported/diag): four threads 1.76 against 0.51 to 0.57; eight 2.36 to 2.41 against 0.53 to 0.59; twelve 2.55 to 2.61 against 0.55 to 0.86; sixteen 2.64 to 2.73 against 0.55 to 1.15 (box 96 the highest). A test on the partition itself would have let cube keep its slabs at every team; whether they would then beat today's loop was not measured. Both items feed a later plan.

Repeated on what the repository holds (the reference layout and Phase 3's code): contract 3's proof, the unit suite, the fast gate and the Debug build (in the Phase 3 entry below).

Phase 3, 2026-11-29 (dell2): the production caller

Files changed in this phase: src/main/volume/simple_reconstructor.f90 (the slab worker's boundaries for rulings R6; the record batch plane_batch and its pool), src/main/volume/simple_reconstructor_tester.f90 (R6's unequal slabs, the pool's case), src/main/strategies/search/simple_matcher_3Drec.f90 (the production caller) and this note (the R6 line under decision 4, the R6 entry above, this entry). No file outside the table; init_rec, prep_imgs4rec, write_state_half_partial and cleanup_rec_buffers keep their signatures.

The caller and the pool (decisions 2 and 3). update_state_half_rec (the routine calc_3Drec calls once per batch of at most 500 particles of one state and half) now gathers the batch's records in today's order into a plane_batch, a public type of the reconstructor module, and hands them to insert_planes_batch instead of calling insert_plane_oversamp per plane. The state and half checks stay serial and come first, as before. A particle's plane is moved into the batch (move_alloc, no copy) with its pose and its weight (one where today's call had none: bit for bit the unweighted call, code check 6); under the probabilistic modes' weighted insertion (topk > 1) each of its extra poses follows, its plane re-shifted from the particle's plane by the shift difference (fplane_shift, as today) into a pool slot, with the pose's angles and weight. The pool holds at most 500 planes and 512 MB (REC_POOL_MAXPLANES, REC_POOL_MAXBYTES, guessed); when a particle's extras do not fit, the records gathered so far are inserted first (a cut, which changes no byte) and the pool is reused; a particle whose extras could not fit an empty pool stops with an error (it cannot happen at topk 3). After an insert the particles' planes go back to the caller's array and the extra planes stay in the pool for reuse; the batch is released at the end of the routine, where today's scratch plane was. insert_extra_poses lost its only caller and is gone. Held as a type of the reconstructor (the plan left open how the pool is held) so that the reconstructor's tester can drive it with a small pool; the benchmark has no extras arm, since that tester case covers the pool's order.

Bytes in the tester. test_plane_batch_pool: nine planes with none, one or two extra poses each (shifts up to three pixels), inserted in today's interleaved order (insert_plane_oversamp per plane and per re-shifted extra) and through plane_batch with a pool of two planes, cut at least three times; c1 and d2, teams of one and four: word for word, and the caller's planes come back unchanged. test=unit_reconstruction: 24 of 24 groups, 2274 of 2274 assertions in Release and in the bounds-checked Debug build (Phase 0's base: 2092; the rest are this run's cases); unit_heterogeneity 179 of 179 (Release and Debug, the flex callers, unchanged code); lib_reconstruction (eight threads, its fractional reconstruction goes through calc_3Drec) 1994 of 1994 (scratch/keep/units_p3_new, scratch/p3_unit); the fast gate 15 of 15 (scratch/logs/p3_fastgate.log). Contract 3: insert_plane_oversamp is the base's, line for line (its lines 454-605 at the base are 484-635 now, diff empty), and no hunk of the file lies inside it.

Decision 9 (c), production identity (the frozen new build scratch/keep/frozen/p3_new against the base build):

  • simulated_workflow_6vxx at one thread (scratch/keep/entry/new_1, 844 s, passing with the base's numbers) against Phase 0's base_1: test=identity finds all 185 declared outputs the same (entry/identity_base1_new1). Ten of its reconstruction passes insert extra poses. At one thread the batch entry takes the per-plane loop (decision 7), so this case proves the record batch, the pool and the extras' order in production;
  • reconstruct3D on the workflow's finished project and on the two real sets, base and new interleaved (scratch/keep/scripts/p3_prod.sh, scratch/keep/p3_prod): every map the run writes (the partial reconstructions and their densities, the half maps filtered and unfiltered, the merged map, the FSC) is identical byte for byte, new against base, at one thread and at sixteen, on 6vxx, strep and bgal, against this phase's base runs and Phase 0's (18 comparisons, p3_prod/analysis.txt): the slab path in production;
  • not judged: a refine3D pass at sixteen threads does not reproduce itself on the base (two base runs already differ in their partial reconstructions), so its bytes are compared nowhere (test policy, section 1.5).

Decision 9 (d), production time (rec3D accumulation of the REC3D bench records, the time inside update_state_half_rec with the extras' re-shifts, per inserted pose; three runs each way interleaved at taskset -c 0-15 nthr=16, one each at taskset -c 0 nthr=1; loads at the starts 1.1 to 3.4, the run's own; the machine cooled before each pair):

Run Set Threads Base ms per pose New ms per pose New over base (median of the pairs) Poses
reconstruct3D 6vxx (simulated, c3, box 192) 16 0.986, 1.014, 0.986 0.611, 0.639, 0.611 0.620 72
reconstruct3D 6vxx 1 4.250 4.222 0.993 72
reconstruct3D strep (d2, box 128) 16 1.004, 1.054, 1.007 0.409, 0.405, 0.405 0.402 6821
reconstruct3D strep 1 2.383 2.401 1.008 6821
reconstruct3D bgal (d2, box 256) 16 2.566, 2.580, 2.554 1.373, 1.365, 1.353 0.530 2756
reconstruct3D bgal 1 12.722 12.724 1.000 2756
refine3D refine=prob, one iteration 6vxx 16 1.431, 1.014, 1.000 0.583, 0.583, 0.597 0.575 72
refine3D refine=prob, one iteration 6vxx 1 4.278 4.278 1.000 72
refine3D refine=prob, one iteration strep 16 1.084, 1.103, 1.111 0.504, 0.519, 0.509 0.465 6821
refine3D refine=prob, second of two iterations (extras) strep 16 1.142, 1.127, 1.183 0.578, 0.591, 0.587 0.506 about 14,200

A first refine3D iteration inserts no extras (no FSC yet for the insertion cone), so the extras path was timed on the second iteration of two-iteration passes (scratch/keep/scripts/p3_extras.sh, p3_prod/refine3d2): with about 2.1 poses per particle the batch entry takes half the base's time per pose. On the whole machine the reconstruction stage takes 0.40 to 0.62 of the base's time per pose; at one thread it is the base's (today's loop).

Decision 14, real data (reported, not gated; no map judged): on both real sets the same pairs, in the table above; at one thread the partial reconstructions and maps are the base's byte for byte (and at sixteen threads too).

Memory. The pool holds at most min(500, 512 MB / plane) planes: at box 128 (strep, the runs with extras) a plane is 99,840 bytes, so at most 500 planes, 50 MB; the peak resident memory of the REC3D records went from 1,786 to 1,787 MB (base) to 1,787 to 1,794 MB (new), within the runs' own spread. At box 256 (bgal, the largest box run) a plane is about 400 KB (at most 500, 200 MB), but reconstruct3D inserts no extras and the pool stays empty: peak resident memory 1,017.07 MB base, 1,017.38 MB new.

Exit.

Exit item Met by
Decision 9 (c) holds the workflow at one thread: 185 of 185 the same; reconstruct3D at 1 and 16 threads on 6vxx, strep and bgal: every map the same
The production times base against new the table above (decision 9 (d))
The real sets' table strep and bgal rows above, bytes the same at one thread
The memory of the pool at the largest box run box 256: no extras, pool empty (+0.3 MB); with extras at box 128: at most 50 MB, within the spread
The unit suites and library entries of section 6 unit_reconstruction (Release, Debug), unit_heterogeneity, lib_reconstruction: all pass, no base failure to compare

In short: every gridding reconstruction through calc_3Drec (refine3D's partial reconstructions, reconstruct3D, the final reconstruction) now goes through the batch entry; its bytes are today's wherever today's reproduce themselves, and on all sixteen cores of dell2 the stage takes about half its former time per pose (0.40 to 0.62), the extras' path included.

Phase 4, 2026-11-29 (dell2): documents and report

Files changed in this phase: doc/algorithms/reconstruction.md (a section "Batch insertion": the record batch and its order, slab ownership, why the order keeps the bytes, the line clip, the slab count and the axis rule, when a batch takes the per-plane loop, the pool; the weight paragraph, the complexity line and the implementation pointers brought up to date), doc/implementation_notes/README.md (this note's row), doc/policies/test_environment_policy.md (the benchmark's row of section 1.3 names its three arms), this note (the status line and this entry) and the new report batch_threaded_plane_insertion_report.md beside it. No source file changed; no file outside the table.

The report follows section 8 of doc/how2s/how2write_agent_plans.md: what was learned first (the per-plane loop's scaling per core set, the batch insertion's table per core set, the production times, which batches take the per-plane loop, the constants as tuned), what changed per phase with the review diffs, the decisions taken under delegation, the deviations, the evidence with its spreads, the losers with their mechanisms, what is left open (reported and not gated, data-dependent, follow-up runs), proposed skill lines (not applied: simple-main-volume's lifecycle and parallel-region rules, simple-main-strategies-search), the Mac read as commands and a commit message. Its tables carry dell2's numbers beside empty Apple-silicon columns. Every number in it was re-read against the Progress entries above and the files under scratch/keep/.

Decisions taken under delegation: - The Mac read takes the base from the run's archive of 0267ace9e (scratch/keep/src_base): the base commit is in the run's copy of the repository but not in dell2's ~/src/SIMPLE, and Phase 0 built the frozen base from that archive, so a tree without version history builds. - Of the equal-work layouts the command list measures the one with two slabs per thread (patches/r6_ew2_on_final.patch, the closer of the two and the one whose tree passes the fast gate); the patch with one slab per thread is named in the report (its tester checks of the slab geometry fail). Both patches apply cleanly to the final sources (patch --dry-run on copies). - The working tree's listing sits in the report's section on what changed, so that the report ends with the Mac read and the commit message.

Exit:

Exit item Met by
The fast gate passes on the final tree 15 of 15 after an incremental build and install (scratch/keep/logs/p4_fastgate.log)
No job of the run is left ps: no simple_*, build, hold or cool-down process of the run after the gate
The report exists batch_threaded_plane_insertion_report.md, beside this note; it points only to review/ and scratch/keep/

In short: the run on dell2 is done and documented; the batch insertion is described in the algorithm page, the report holds the dell2 tables beside empty Apple-silicon columns and the Mac read's commands, and nothing is committed before that read.

The Mac read, 2026-11-29 (M5 Ultra): decision 12

Made after the run by an interactive session on the maintainer's "Run the Mac read"; the detail is the report's section 8, the per-cell table doc/implementation_notes/data/rec_slabs_mac_read.tsv.

  • Tree: the base 0267ace9e with review/full.diff, Release, fast gate 15 of 15; unit_reconstruction 24 of 24 groups, 2,274 of 2,274 assertions.
  • Benchmark at 1, 2, 4, 10 and 20 threads, boxes 160 and 256, c1 and d2, every fixture, sweeps A and B, and one sweep of the equal-work patch: zero differing words in all 900 rows.
  • Keep rule. Gain verdict (ten threads, box 160, uniform, c1, at most 0.50): met, 0.186 and 0.176. No-loss bound: 99 of 100 cells within it in both sweeps; cube, box 256, d2 at one thread is at 1.040 against 1.030 in sweep B (0.998 in A), where both arms run the per-plane loop. Batch over the per-plane loop, geometric mean per team: 1.005, 0.905, 0.759, 0.305, 0.159 at 1, 2, 4, 10 and 20 threads.
  • Equal work with two slabs per thread: 0.99, 0.91, 0.95 and 1.00 of the diff layout's batch time at 2, 4, 10 and 20 threads (one sweep, reported).
  • Deviations: sweep B's two-thread invocations retaken (foreign load); a third sweep and the production comparison stopped when the run mlxf_match2d took the machine; the per-plane loop's time at four threads differs up to twofold between the sweeps, so those cells' bounds are wide.
  • Ruling. The keep rule read literally is not met in one cell of 100. Hans, 2026-11-29, on this evidence: "That is enough evidence for me that this will be useful on the Mac"; the next stages move to the Dell machines. On equal work: "even if the equal work approach is just matching it is nicer in a way because it is free of parameters"; it stays the candidate of the later slab-layout plan (the report's section 7).
  • Also on his approval ("Yes, apply them"): the report's three skill lines, in .github/skills/simple-main-volume/SKILL.md and .github/skills/simple-main-strategies-search/SKILL.md.
  • Not built in ~/src/SIMPLE itself: the machine was running another run's timings. The tree that was built and tested is the scratch copy, whose sources are the base's plus the same diff.