[WIP] Tiny Profiler: default report to diags/performance.txt - #7077
Conversation
diags/performance.txt
| :pp:param:`warpx.reduced_diags_names`, or :pp:param:`diagnostics.enable` ``= 0``), the profiler | ||
| is turned off (``/dev/null``) so that no ``diags/`` folder is created. | ||
|
|
||
| Set this to a path to choose a specific file, to an empty string to print the report on the |
There was a problem hiding this comment.
To be more explicit, how about instead of an empty string, use tiny_profiler.output_file = stdout to write it to stdout.
There was a problem hiding this comment.
I think that will require an AMReX change. Let us also add stderr as a keyword, for completeness.
|
I'll have to update PR #6848 since there the profiles during the simulation would need to be in the context of the output to be meaningful. Maybe always write the additional profiles to stdout and only the final one controlled by |
## Summary `TinyProfiler::get_output_file()` cached `tiny_profiler.output_file` behind a process-lifetime function-local guard, so a process that cycles AMReX `initialize`/`finalize` more than once (e.g. a Jupyter notebook running several simulations) kept writing to the first cycle's report location and could fail to open it on a later cycle. Move the read-once guard to a namespace-scope flag (`output_file_read`) that `Initialize()` re-arms, and reset the cached output_file there. The value is still read at most once per cycle, so the timer and memory reports (both opened in append mode) continue to share one freshly-truncated file. ## Additional background Needed for BLAST codes that like to change defaults of the TP output file in the same process (e.g., Jupyter session) for subsequent simulation runs. - BLAST-ImpactX/impactx#1566 - BLAST-WarpX/warpx#7077 ## Checklist The proposed changes: - [x] fix a bug or incorrect behavior in AMReX - [ ] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
diags/performance.txtdiags/performance.txt
|
Flagging this as WIP until the to-do list in the PR description is finalized. |
By default, write the AMReX tiny profiler report to diags/performance.txt instead of stdout, for both executable- and Python-steered runs. If no diagnostics are configured (no full/BTD diagnostics and no reduced diagnostics), the profiler is turned off (/dev/null) so that no diags/ folder is created. A user-set tiny_profiler.output_file always takes precedence. The default is applied in WarpX::InitData() (after the diagnostics managers are constructed), which runs for both the executable and the Python paths. Requires the matching AMReX change to re-read tiny_profiler.output_file per init/finalize cycle. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
f00b685 to
211a32d
Compare
I am not sure, I would refrain from defaulting even more to stdout by default, for sake of interactive usage. Let us finish this PR here and then mirror in #6848 the options people might need? |
| // Determine the directory under which WarpX writes its diagnostics. | ||
| std::string diags_dir; | ||
| if (multi_diags->GetTotalDiags() > 0) { | ||
| // Full/back-transformed diagnostics: <diag>.file_prefix, e.g. "diags/diag1". | ||
| diags_dir = std::filesystem::path(multi_diags->GetDiag(0).GetFilePrefix()) | ||
| .parent_path().generic_string(); |
There was a problem hiding this comment.
Fun way to steal a custom diags path from the first available diags...
The tiny profiler output is nice but verbose for many workflows, and many of our Python users fully disable it by default because of the large "scrolling" it causes in many workflows. Change for both modes (exe + input) to keep consistent, so we can request from users their profile consistently when analyzing/helping.
Now, by default, write the AMReX tiny profiler report to
diags/performance.txtinstead of stdout, for both executable- and Python-steered runs. If no diagnostics are configured (no full/BTD diagnostics and no reduced diagnostics), the profiler is turned off (/dev/null) so that no diags/ folder is created. A user-settiny_profiler.output_filealways takes precedence.The default is applied in WarpX::InitData() (after the diagnostics managers are constructed), which runs for both the executable and the Python paths.
Requires the matching AMReX change to re-read
tiny_profiler.output_fileper init/finalize cycle.<diag_file_prefix>/performance.txtBLAST-ImpactX/impactx#1566) and keep logic in sync