The same mathematical sequence is used for Serial, AVX, CUDA, and HIP:
setup maps are built once and made available in the selected memory space;
only boundary-adjacent volume elements are copied for curl–curl;
the flux is combined in one kernel before extraction, and contracted with the normal in one kernel after it;
work is batched by compatible source, curl–curl, boundary-region, and boundary-block layouts;
the restricted fields take the interleave width of the velocity, 1 or that of the execution space, so that the curl–curl reads and writes them without reshaping; the gather copies through index maps built on the host for the interleave widths of the source and the restricted block, the first time the pair is seen, and kept, and numbers its threads by restricted point, the element lane varying fastest, so that its writes are coalesced; it runs on the stream of each restricted block, which waits on an event recorded on the stream of its source block, so the host never waits; after that, every block of the restricted volume and of each region runs on its own stream;
the extraction orders itself after the streams of the restricted blocks it reads, and the streams of the region blocks after itself, with events (see §28.4.2);
the boundary coefficients of the regions are copied into one compact array on the streams of the region blocks, and gathered into the layout of each domain block on the stream of that block; the region and domain block streams wait on one another through the operator’s own stream before and after the gathers;
the final scatter separates unique coefficient targets from shared corner targets, avoiding atomics while retaining the correct sum; its target indices are built on the host, for the interleave width of a block of the pressure forcing, 1 or that of the execution space, the first time a block at that width is seen, so the forcing is updated in its own layout, never reshaped.
No solver-level backend-specific branch changes equations (30.7) or (30.16).