perf(hydrology): keep flow_simulation state on the GPU across iterations - #442
Open
barrulus wants to merge 3 commits into
Open
perf(hydrology): keep flow_simulation state on the GPU across iterations#442barrulus wants to merge 3 commits into
barrulus wants to merge 3 commits into
Conversation
This was referenced Sep 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context: ottolink-dev/Hesiod#569. Depends on ottolink-dev/CLWrapper#8 (submodule bumped here; merge that first, or
git submodule updatewill not find the pinned commit).hmap::gpu::flow_simulationran two cheap stencil kernels per iteration but wrapped each with blocking image uploads, a queue finish and blocking downloads: 15 full-array transfers per step. The loop now keeps depth and the four fluxes as ping-pong image pairs on the device, shares one in-order queue between the flux, water and (new) rain kernels, and reads back once at the end. The public signature is unchanged; the two existing kernels are untouched.Output is bit-identical to the previous implementation: golden
.npydumps from the old code for nine parameter paths (rain map, uniform rain, evaporation, closed/outflow boundaries, velocity export, odd/zero/one iterations, non-square grid) compare equal to the bit after the rewrite. The rain increment moved from a host add into a smallhydraulic_vpipes_rain_passkernel compiled withFP_CONTRACT OFFso it stays exact.Tests: three characterization tests added (iteration parity + determinism, zero iterations, rain map of ones equals uniform rain); all FlowSimulation tests pass before and after.
Follow-ups (separate issues): the same pattern applies to
flow_simulation_viscous,snow_simulation,hydraulic_vpipesand the other solvers that read back inside their loops. Also observed, pre-existing and unchanged here: withoutflow_boundaries = falsethe clamp-to-edge sampling counts a boundary cell's own outgoing flux as inflow, so closed domains gain volume (about +40 % over 51 steps at 256² in my golden run).