1946 - Reduced memory usage option#2006
Open
icui wants to merge 2 commits into
Open
Conversation
icui
requested review from
Rohit-Kakodkar,
Copilot and
lsawade
and removed request for
Rohit-Kakodkar
July 22, 2026 03:09
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a configurable “reduced memory usage” mode for combined undo-attenuation by subdividing each disk-checkpoint replay window into smaller in-memory displacement buffers, trading extra forward replay for lower peak RAM.
Changes:
- Extend
wavefield_checkpointto compute a subdivided replay schedule (leaf size, internal full-state checkpoint count, replay split point, forward-step cost). - Rework combined undo-attenuation replay to use explicit checkpoint reader injection and the new subdivision schedule.
- Add YAML configuration and documentation for
solver.time-marching.checkpointing.subdivide-buffer, plus new unit tests for the schedule logic.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit-tests/periodic_tasks/wavefield_checkpoint.cpp | Adds unit tests covering subdivided replay schedule calculations and invalid subdivision handling. |
| core/specfem/solver/time_marching/combined_undoatt.tpp | Implements subdivided replay with optional in-memory full-state checkpoints and leaf buffering. |
| core/specfem/solver/time_marching.hpp | Adds a checkpoint_buffer_subdivisions parameter to combined undo-attenuation time marching. |
| core/specfem/runtime_configuration/solver.tpp | Passes configured buffer subdivision count into the combined solver instantiation. |
| core/specfem/runtime_configuration/solver.hpp | Parses optional checkpointing.subdivide-buffer from YAML and stores the configuration. |
| core/specfem/runtime_configuration/setup.cpp | Switches setup to construct the solver with the simulation type enum and time-marching YAML node. |
| core/specfem/periodic_tasks/wavefield_checkpoint.hpp | Extends the replay task to support subdivided buffering and internal checkpoint slot computations. |
| benchmarks/src/dim3/homogeneous_viscoelastic_kernel/README.md | Documents the new checkpointing.subdivide-buffer option and its semantics. |
| benchmarks/src/dim3/homogeneous_viscoelastic_kernel/CMakeFiles/adjoint_config.yaml.in | Adds default checkpointing.subdivide-buffer: 1 to adjoint benchmark config. |
| benchmarks/src/dim3/homogeneous_viscoelastic_kernel/CMakeFiles/adjoint_config_mpi.yaml.in | Adds default checkpointing.subdivide-buffer: 1 to MPI adjoint benchmark config. |
| architecture/core-components/io.md | Updates I/O architecture docs to mention subdivided replay windows. |
| architecture.md | Updates top-level architecture docs to mention subdivided replay windows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+490
to
+494
| std::function<void(int, int, int, int)> reverse_interval; | ||
| reverse_interval = [&](int start, int end, int available, int base_slot) { | ||
| const int length = end - start; | ||
| if (length <= 0) | ||
| return; |
Comment on lines
3
to
10
| #include "specfem/periodic_tasks/periodic_task.hpp" | ||
| #include "specfem/solver/solver.hpp" | ||
| #include "specfem/timescheme/timescheme.hpp" | ||
| #include "specfem/utilities.hpp" | ||
| #include <memory> | ||
| #include <string> | ||
| #include <yaml-cpp/yaml.h> | ||
|
|
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.
Overview
This PR improves undo-attenuation checkpoint replay and separates checkpoint
loading from ordinary periodic tasks.
wavefield_checkpoint.instead of discovering and filtering it from the periodic-task vector.
checkpointing.subdivide-buffer.displacement buffers in exchange for additional forward replay.
Benchmark results
The 3D homogeneous viscoelastic-kernel benchmark was run with an 800-step
simulation and a 400-step disk-checkpoint interval.
subdivide-bufferUsing three subdivisions reduced peak RSS by 24.6% (approximately
0.69 GiB) while increasing solver time by 25.2%. The previous run with
a 200-step checkpoint interval and
subdivide-buffer: 1took 94.08 seconds,so increasing the interval to 400 without subdivision had little timing
impact.
Each configuration was run once using the release/serial build on an Apple M4
with macOS 26.5.2, so timings should be treated as indicative.
Numerical validation
X,Y, andZare bitwise identical between replaystrategies.
1.04e-8.8.67e-19.These differences are consistent with floating-point ordering effects from the
alternative replay schedule.
Validation
WavefieldCheckpointunit tests pass.clang-formatandgit diff --checkpass.