Skip to content

MOM_cpu_clock_infra: emit NVTX ranges for MOM6 cpu clocks - #79

Open
JorgeG94 wants to merge 1 commit into
MOM6-GPU:dev/gpufrom
JorgeG94:feat/nvtx-markers
Open

MOM_cpu_clock_infra: emit NVTX ranges for MOM6 cpu clocks#79
JorgeG94 wants to merge 1 commit into
MOM6-GPU:dev/gpufrom
JorgeG94:feat/nvtx-markers

Conversation

@JorgeG94

Copy link
Copy Markdown

Record each clock's name as cpu_clock_id() registers it, then open an NVTX range in cpu_clock_begin() and close it in cpu_clock_end(). Every existing cpu_clock_id() name becomes a named range in an nsys timeline with no call-site changes.

The range is opened before, and closed after, the mpp clock so that it encloses it. Begin and end test the same condition, so starts and ends stay balanced for handles that were never named or that fall outside the table.

The code is guarded behind -DMOM_USE_NVTX, which is undefined by default: without it the preprocessed source is byte-identical to before and no extra library is linked. Profiling builds need -DMOM_USE_NVTX and -cudalib=nvtx.

Applied to both the FMS1 and FMS2 infra shims, which are byte-identical to each other. This also covers the halo and message-passing clocks, which MOM_domain_infra begins and ends through this module directly rather than through the MOM_cpu_clock framework wrapper.

Based on Ed's ae67665 ("add nvtx markers to clocks", branch benchmark_ALE_nvtx_clocks), which introduced the name-table approach and the range nesting; this adds the build guard so non-NVHPC builds are unaffected.

Mr. Claude helped a lot with the commit message because mine generally suck

Record each clock's name as cpu_clock_id() registers it, then open an NVTX
range in cpu_clock_begin() and close it in cpu_clock_end(). Every existing
cpu_clock_id() name becomes a named range in an nsys timeline with no
call-site changes.

The range is opened before, and closed after, the mpp clock so that it
encloses it. Begin and end test the same condition, so starts and ends stay
balanced for handles that were never named or that fall outside the table.

The code is guarded behind -DMOM_USE_NVTX, which is undefined by default:
without it the preprocessed source is byte-identical to before and no extra
library is linked. Profiling builds need -DMOM_USE_NVTX and -cudalib=nvtx.

Applied to both the FMS1 and FMS2 infra shims, which are byte-identical to
each other. This also covers the halo and message-passing clocks, which
MOM_domain_infra begins and ends through this module directly rather than
through the MOM_cpu_clock framework wrapper.

Based on Edward Yang's ae67665 ("add nvtx markers to clocks", branch
benchmark_ALE_nvtx_clocks), which introduced the name-table approach and the
range nesting; this adds the build guard so non-NVHPC builds are unaffected.

Co-authored-by: Edward Yang <edward.yang@anu.edu.au>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@edoyango

Copy link
Copy Markdown

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants