Improve out of memory error message#4831
Merged
WeiqunZhang merged 6 commits intoAMReX-Codes:developmentfrom Dec 7, 2025
Merged
Improve out of memory error message#4831WeiqunZhang merged 6 commits intoAMReX-Codes:developmentfrom
WeiqunZhang merged 6 commits intoAMReX-Codes:developmentfrom
Conversation
Member
|
/run-hpsf-gitlab-ci |
|
GitLab CI 1336425 finished with status: failed. See details at https://gitlab.spack.io/amrex/amrex/-/pipelines/1336425. |
WeiqunZhang
approved these changes
Dec 7, 2025
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.
Summary
This PR adds extra information to the abort message if an AMReX Arena runs out of memory. This includes the type of memory, number of bytes asked, MPI rank, allocation function name and error code, TinyProfiler call stack, TinyProfiler profiled memory usage, and total usage of all memory arenas. The information is printed for all memory types, as this is easier and might be useful in case multiple arenas share the same memory type.
For this, a PrintMemoryUsage function is added to TinyProfiler, which can also be called externally. In case some memory is still currently allocated while the usage is printed, the number of frees and the currently used bytes are printed. If not, both metrics are omitted from the output. This also applies to the output when a program finishes normally, where previously the number of frees was always printed.
Example abort message (with syntax highlighting added):
Additional background
Technically, I think calling TinyProfiler::PrintCallStack from a non-master thread is not thread-safe, but this is hard to fix and should be unlikely to cause problems.
Should more information be added to the abort message? Maybe there is something from the "full" profiler?
Checklist
The proposed changes: