SELAH
Stage-wise Evolution Library for Accelerators and HPC
- Documentation: SELAH (quick start, tutorial, schemes, performance, verification)
- GitHub: GitHub - szaghi/SELAH: Stage-wise Evolution Library for Accelerators and HPC: time integrators as stage-wise operators for block-structured field solvers, on CPUs and GPUs, in modern Fortran. · GitHub
SELAH is a modern Fortran library of time integrators for block-structured field solvers: finite-volume and finite-difference codes, AMR or not, whose state is a set of blocks with ghost cells and whose step is limited by memory bandwidth, not by arithmetic. It gives you the schemes’ coefficients, the kernels that do each stage’s arithmetic over your arrays, and a stepper that your solver drives one stage at a time. The same kernel source runs on the host, with OpenMP, and on a GPU through OpenACC. It is the successor of my FOODIE, and v0.5.1 is the first release I announce here (written with the help of an AI assistant).
Disclaimer: why SELAH takes no right-hand side. rklib, ODEPACK, the Fortran interface of SUNDIALS and my own FOODIE solve ordinary differential equations the classical way: you hand them the right-hand side, as a procedure, a callback or a class to extend, and they call it inside their step. SELAH accepts none of these, on purpose, and that choice is its HPC design:
- Between two stages, the step is yours. A PDE solver has work to do there that no right-hand-side interface can foresee: ghost-cell and halo exchanges over MPI, AMR seam filling and refluxing, boundary conditions, limiters, a sub-cycled source, a linear solve, diagnostics, whatever your PDE requires. SELAH never calls your code. Your solver calls
begin_stageandend_stage, and between them does anything it wants, in its own loops, on its own data, on the CPU or the GPU. A stage contract says what every buffer holds at that moment.- And no overhead for that freedom. A callback or a class to extend puts an interface between the integrator and your solver: an indirect call per stage, a signature your residual must fit, and in FOODIE’s case operator-overloaded integrands whose stage arithmetic runs through polymorphic type-bound operators and their temporaries. That is fine for a system of ODEs and too costly where the cells of a large field are swept. In SELAH the stage arithmetic is plain kernels over your arrays, with no polymorphism, procedure pointer or callback in or around them: a step costs its memory traffic and nothing more, and the stepper takes 0.999 of the time of the same kernels called by hand (below).
- What a state is. For them, a vector. For SELAH, a field of rank 1 to 5 with ghost cells, in two memory layouts, masked or not, of which the kernels write the interior box and nothing else.
- What a step costs. SELAH counts the field accesses of every step and measures them on the GPU (below), and offers the low-storage forms in 2 registers instead of s + 1.
- Choose an ODE solver for a system of ODEs with an adaptive step, a stiff problem that needs a Newton solve with a Jacobian, or implicit Runge–Kutta: SELAH gives an error estimate and a step-size rule but no control loop, and its implicit schemes are multistep ones (Adams–Moulton, BDF), solved by fixed-point stages or by your own Newton through
stage_gamma.- Choose SELAH when the state is a large field, when your PDE needs its own work between the stages, at full speed, or when the step must run on a GPU from Fortran.
SELAH looks young, with only five minor releases, but it is not new code: its kernels, its stepper and its catalogue are extracted from ADAM’s integrators and FOODIE’s schemes, with years of use and testing behind them, for accuracy and for performance on CPUs and GPUs. What is new (the schemes of the last releases, the Magnus integrators) is verified the same way (below). The API may still change before v1.0.
Whole SSP(5,4) and SSP(10,4) steps on an NVIDIA A30, 256 blocks of 16³ cells with 5 components (109 MB a field): time and field accesses per step, ADAM’s hand-written integrator in brown, SELAH’s stepper in blue.
Built for HPC
1. You drive the stages. One step, as your solver writes it:
call st%initialize(SCHEME_SSP_54, FORM_BUTCHER, lb=lbound(q), ub=ubound(q))
call st%begin_step(bx, q)
do k=1, st%stages()
call st%begin_stage(k, bx, dt, q) ! the stepper builds the state of stage k
u => st%stage_state()
r => st%rhs_register() ! where the residual of stage k goes
call fill_ghosts(u) ! yours: halo exchange, AMR seams, anything your PDE needs
call residual(u, r, dx) ! yours
call st%end_stage(k, bx, dt, q)
enddo
call st%finish_step(bx, dt, q) ! q^{n+1}
- No integrand type to extend, no callback, no procedure pointer: the time loop, the residual and whatever your PDE needs between the stages (halo exchange, AMR seams, boundary conditions, limiters, anything else) stay in your code, at your code’s speed. SELAH itself makes no MPI call.
stage_weight(k)gives stage k’s effective weight in the step, in every storage form, which is what a flux register needs to reflux an AMR level; the step’s residual can be fused into the update.- Companion states advance in the field’s stages: particles (Boris, Vay, Higuera–Cary pushers, with charge-conserving stage currents), PML auxiliary fields, a stiff linear decay integrated exactly.
The stage contract: the stepper’s calls, and the window of each stage where the solver acts.
2. Kernels over your arrays, on the GPU. The stage and update kernels are plain loops over contiguous arrays, with no polymorphism or procedure pointer in or around them, and one source for the host, OpenMP and OpenACC through FUNDAL’s macros. On a GPU the field and the stepper’s registers live in device memory, and nothing crosses the bus during a step. Measured on the A30 (performance):
- the stepper costs nothing: the same kernels called by hand take 0.999 of its time;
- a SELAH step costs 0.548 of ADAM FLUME’s, the integrator it was carved from, because it builds each stage state from the solution instead of copying it into every buffer, and lets you write the residual in place (field accesses: 0.528);
- per kernel, SELAH matches ADAM’s hand-written kernels to within 3 %.
The box: the kernels write the interior cells and nothing else; ghost cells and pool blocks are never touched.
3. Storage is bandwidth. Two-register, Williamson 2N and Ketcheson forms keep a scheme in 2 registers instead of s + 1, equal to its Butcher form to round-off. SSP(10,4) in Ketcheson’s two registers runs a step in 2.32 ms where its Butcher form takes 6.40 ms; at equal simulated time, with the step at the strong-stability limit, it costs 0.217 of SSP(5,4)'s integrator time and half its residual evaluations.
The registers of each storage form, stage by stage: what the stepper writes, where your residual goes, what is read again.
Every low-storage form against its Butcher form, over 40 steps: round-off.
4. Reproducible. Every kernel sums in a fixed order, so a run repeats bit for bit, and a golden file pins 10880 values on every compiler; double or single precision is chosen at build time.
The schemes
Seven families, each with its sources and its stability bounds in the schemes page:
- Explicit Runge–Kutta, 63 schemes: SSP (up to SSP(10,4) and the linear-SSP family), low storage (LSRK up to 14 stages, with optimised stability regions), the classical fixed-step ones, high order up to order 10, and embedded pairs from Heun–Euler 2(1) to Feagin 10(8), each from its paper.
- Splittings: Strang, Yoshida, Blanes–Moan S6 and S10, and Lie for an additive splitting with a flow of your own.
- Leapfrog, with and without the Robert–Asselin–Williams filter.
- Explicit multistep: Adams–Bashforth 1–16, SSP linear multistep (five of them for a varying step), SSP multistep-multistage.
- Implicit multistep: Adams–Moulton, Adams–Bashforth–Moulton, BDF 1–6, and the Nordsieck form with a step and an order that change between steps.
- Second-order systems y'' = f(t, y): Runge–Kutta–Nyström, Störmer and Cowell.
- Commutator-free Magnus for y' = A(t)\,y, orders 4 to 8, with a dense per-cell exponential or a Krylov one.
Every one of FOODIE’s 86 schemes is among them, and a porting page maps FOODIE’s calls to SELAH’s.
Stability regions, drawn from the library’s own tableaux.

SSP(5,4) at its strong-stability limit (left) keeps the total variation from growing; above the threshold (right) it grows.

Δt = 0.6, 400 steps: the Strang splitting stays on a closed curve near the exact circle; rk4 spirals inwards.
A few more from the gallery
Observed orders of every scheme in every storage form, through the stepper.
Every Magnus scheme at its order, on non-commuting systems.
Long-time energy error of the splittings against Runge–Kutta: bounded.
Gauss’s law per step: the direct deposit against SELAH’s stage currents, kept to round-off.
The gallery has all of them, each opening the page that explains it.
How it is checked
- Tests: 58 programs (51 tests and 7 expected failures), also the verification suite, on every push with gfortran 16.2, nvfortran 26.9 and Intel ifx, in double and single precision, and with host OpenMP; the debug builds (all checks on) run by hand.
- Schemes: order conditions in quadruple precision; SSP coefficients computed, never typed in; observed orders in every storage form; stability regions; strong stability; long-time energy of the splittings.
- Golden file: 10880 values pinned.
- Mutation testing: 141 of 141 mutants killed on v0.5.1’s code.
- Device: the OpenACC builds pass on an NVIDIA A30 and on an RTX 4070, run by hand.
- Docs: every snippet and output in the documentation comes from a program the CI compiles and runs.
- Honest limits:
- no implicit Runge–Kutta or IMEX stages yet;
- the dense Magnus exponential is slow on the GPU (#12).
Where it comes from
SELAH is the time operator of ADAM, my AMR framework: FLUME, PRISM and RIPPLE step their fields with SELAH’s stepper on the CPU and on the GPU. SETH (WENO and TENO reconstructions) and GIDEON (finite-difference and finite-volume stencils) use it in their tests and examples. It keeps FOODIE’s catalogue and drops FOODIE’s operator-overloaded integrands, which are elegant but cost too much where the cells are swept.
git clone https://github.com/szaghi/SELAH && cd SELAH
fobis fetch && fobis build --mode static-gnu
or
curl -fsSL https://github.com/szaghi/SELAH/releases/latest/download/install.sh | bash
SELAH is also a FoBiS and an fpm dependency, and its only dependencies are my own PENF and FUNDAL. It is available under your choice of license: GPL-3.0-or-later, BSD-2-Clause, BSD-3-Clause or MIT.
Coming next: diagonally implicit and IMEX Runge–Kutta stages, under the same stage contract, and the dense Magnus exponential’s speed on the GPU (#12).
My best regards.
Stefano










