C3 Stage contract
| ID | Group | Type | Backends | Figure | Program |
|---|---|---|---|---|---|
| C3 | Contracts | C | CPU (gfortran, nvfortran, ifx; R8P and R4P); GPU (A30) | no | selah_test_stepper, selah_test_stepper_options, selah_test_stepper_ranks, selah_test_kernels, selah_test_xfail_* |
Case and scope
A solver programs against the stage contract. This case checks every clause, and the options around it, as a solver would use them:
- Between
begin_stage(k)andend_stage(k)the stage state holds stage: qwhenstage_state_is_q(k), elsestage_state(). - The stepper never writes a ghost cell.
- The caller may write the ghost cells of the stage state.
rhs_register()is distinct from the stage state, and null outside the window, asstage_state()is.- After
finish_stepthe registers are scratch.
Setup
| Clause or option | How it is checked | Program |
|---|---|---|
| no ghost cell written (2) | every register and q start with a sentinel in their ghost layers; the layers the caller never fills keep it bit for bit through whole steps, every scheme and form | selah_test_stepper |
| a kernel writes its box only | every kernel, both layouts, masked and unmasked, on a component range: every cell outside the box (ghosts, pool slots past the active blocks, other components, inactive cells) bitwise untouched | selah_test_kernels (348 checks) |
| residual register distinct (4) | associated(rhs_register(), stage_state) false at every stage | selah_test_stepper |
| no register outside a window (4) | rhs_register() and stage_state() not associated after begin_step and after every end_stage, every scheme and form | selah_test_stepper |
state_aliases_q, stage_state_is_q (1) | true exactly for the aliasing forms, and for the zero rows of A with stages_on_q; stage_state() null on such a stage | selah_test_stepper |
stages_on_q | the solution bitwise that of the plain Butcher form, every scheme | selah_test_stepper |
registers= | NaN-filled caller registers give the solution of the own registers bitwise, in the Butcher, two-register, 2N and Ketcheson forms: no form reads a register before writing it | selah_test_stepper_options |
| masks | solid blocks of q bitwise untouched through whole steps in four forms; mask_comp absent = the last component | selah_test_stepper_options, selah_test_kernels |
the mask policy (masked_q) | the solid cells of every stage state are stages_on_q, registers filled with NaN) and every other form; every stage state and the solution bitwise those of a caller that copies masked_q, both layouts, both mask components, 0 and 3 registers: inactive box cells | selah_test_stepper_options, selah_test_kernels |
stage_time, finish_step(dq=) | selah_test_stepper_options | |
| ADAM's forest | two steppers (realms) driven stage by stage together: begin_stage(k) on every realm, the seam fill of every stage state from the neighbours', the residuals, end_stage(k) on every realm; per-stage seams give the single-block solution bitwise; lagged seams (#113: the ghosts of stage_weight(k) finish_step) and per-stage reflux (on rhs_register() before end_stage) conserve the mass to round-off; the caller's registers written or NaN-filled between steps (ADAM's D_flux diagnostic) leave the solution bitwise | selah_test_forest |
| time-dependent residuals | through the stepper, every scheme and form: | selah_test_nonautonomous |
| fields of rank 1 to 4 | seven shapes, every scheme and form: bitwise the rank-5 run; ghost cells of q and of every register untouched; both views null outside every window, rhs_register_view associated inside it, stage_state_view exactly when the stage is not on q; the stage coefficients; masks of q's rank with their own components (solid cells untouched, fluid cells bitwise the unmasked run) | selah_test_stepper_ranks |
| stage coefficients | stage stage_time(k); with the residual the indicator of stage stage_weight(j) (64 ε), every scheme and form | selah_test_stepper |
| error stops | dq for a non-Butcher form; registers numbered from 0; rk4 in a two-register form: each program must stop with its message | selah_test_xfail_dq_form, _registers, _form |
Program
bash
./exe/selah_test_stepper ; ./exe/selah_test_stepper_options ; ./exe/selah_test_stepper_ranks ; ./exe/selah_test_kernels
bash scripts/run_tests.sh # runs the xfail programs and passes them when they exit with an errorResults
All checks pass on every compiler, in both precisions, and on the GPU: 314 in selah_test_stepper, 49 in selah_test_stepper_options, 848 in selah_test_stepper_ranks (694 in R4P), 348 in selah_test_kernels. The three expected failures stop with their messages. The A30 jobs of 2026-11-17 (C5) ran 248 checks of selah_test_stepper, before the stage window and the stage coefficients were added. Job 1368457 ran all of them on the A30.
Findings
- No form reads a register before writing it: the stepper accepts uninitialised registers. Before the documentation audit of 2026-11-17 the 2N form's first stage computed
, and a NaN in a caller's register poisoned the step. The 2N stage with now writes without reading it. initialize(registers=)now refuses registers whose slots are not numbered from 1 or whose bounds are not the field's. Such registers used to be indexed one slot off without a message.- Before 2026-11-18,
rhs_register()outside a stage window returned, in the Butcher form, the stage-state register (slotk_active + 1with no stage active), against clause 4, without a message. Both pointers are now null there. - Before 2026-11-18,
stage_timewas checked against the tableau it returns, in the Butcher form only: a stage of another form evaluated at another abscissa would have passed. The stage coefficients are now measured in every form. A swap of two abscissae (stages 5 and 6) fails the check in 8 scheme-form pairs,ssp-104 ketamong them. A swap of two weights fails it in every pair where the two weights differ. Where they are equal (ssp-22, ssp-33, ssp-104: SSP(10,4)'s ten weights are all 1/10) the swap changes nothing a caller can observe.