Introduce ModEM getrusage module to record high-water memory mark#44
Open
MiCurry wants to merge 1 commit intomagnetotellurics:mainfrom
Open
Introduce ModEM getrusage module to record high-water memory mark#44MiCurry wants to merge 1 commit intomagnetotellurics:mainfrom
MiCurry wants to merge 1 commit intomagnetotellurics:mainfrom
Conversation
Currently, the ModEM_memory module is not used anywhere in ModEM. This commit adds two new files to ModEM, ModEM_memory.f90 and ModEM_getrusage.c. ModEM_getrusage.c is a C file that calls the getrusage system call (see `man 2 getrusage`) and returns `ru_maxrss`, the maximum resident set size, or a max used memory high-water mark. ModEM_memory.f90 contains routines to either log or print `ru_maxrss`, when it does so it conveniently prints the maxrss in bytes, KB, MB and GB and allows the developer to specify a unique message with the output. It also contains a subroutine for the main task to calculate the total maxrss across tasks by using MPI_reduce. Of course, all tasks have to coordinate and call this routine at the same time. Only the main task writes out the result. Because this commit contains C code, I have coded it in a way that it can only be compiled by CMake and if `-DMODEM_MEMORY=on` is specified in the CMake build command. If this module is used in ModEM, and the user builds with the `./configure` build system, `ModEM_memory_get_maxrss` will throw an error telling the user that the C code is not compiled and how to compile it.
MiCurry
commented
Apr 3, 2026
| conversion = 1000.0; | ||
| #else | ||
| conversion = 1.0; | ||
| #endif |
Member
Author
There was a problem hiding this comment.
I need to double check this conversion is right...
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.
Currently, the ModEM_memory module is not used anywhere in ModEM.
This pull requests adds two new files to ModEM, ModEM_memory.f90 and ModEM_getrusage.c. ModEM_getrusage.c is a C file that calls the getrusage system call (see
man 2 getrusage) and returnsru_maxrss, the maximum resident set size, or a max used memory high-water mark in bytes.ModEM_memory.f90 contains routines to either log or print
ru_maxrss. The report conveniently prints the maxrss in bytes, KB, MB and GB and along with a developer specified message.It also contains a subroutine for the main task to calculate the total maxrss across tasks by using MPI_reduce. Of course, all tasks have to coordinate and call this routine at the same time. Only the main task writes out the result.
Because this commit contains C code, I have coded it in a way that it can only be compiled by CMake and if
-DMODEM_MEMORY=onis specified in the CMake build command.If this module is used in ModEM, and the user builds with the
./configurebuild system,ModEM_memory_get_maxrsswill throw an error telling the user that the C code is not compiled and how to compile it. If we use this module in ModEM we might want to include calls to it to be wraped around#ifdef MODEM_MEMORYpreprocessing statements.I have been using this module to record high water mark when developing the ESolnManager project, it has been quite useful and @akelbert has suggest it be included in.