mstar.utils.profiler#
Utilities for NVTX range annotations for profiling with nsys.
Functions
|
Emit an instant NVTX marker without CUDA synchronization. |
|
Enable NVTX only for a CUDA deployment or an explicitly CUDA device. |
|
Convenience context manager for range_push/range_pop. |
The shared sample buffer; |
|
|
Record wall time as |
|
|
Start stamp for |
|
|
Pop the current NVTX range, optionally syncing before the marker. |
|
Push an NVTX range, optionally syncing before the marker. |
Classes
|
Consecutive stage timings: each |
- class mstar.utils.profiler.PhaseLaps(prefix='')[source]#
Bases:
objectConsecutive stage timings: each
lap(stage)records the wall and CPU time since the previous lap (or construction) asprefix + stageandprefix + stage + ".cpu". A no-op unless MSTAR_PHASE_TIMING is set;skip()restarts the clock without recording, for a stretch timed elsewhere.- Parameters:
prefix (str)
- mstar.utils.profiler.mark(name)[source]#
Emit an instant NVTX marker without CUDA synchronization.
- Parameters:
name (str)
- Return type:
None
- mstar.utils.profiler.nvtx_enabled(requested, device=None)[source]#
Enable NVTX only for a CUDA deployment or an explicitly CUDA device.
- mstar.utils.profiler.nvtx_range(name, *, synchronize=False)[source]#
Convenience context manager for range_push/range_pop.
- mstar.utils.profiler.phase_buffer()[source]#
The shared sample buffer;
Worker.runreads and clears it.
- mstar.utils.profiler.phase_end(name, start)[source]#
Record wall time as
nameand this thread’s CPU time asname.cpu. Wall minus CPU is time the thread spent blocked – on the GIL, an event or a lock – which wall time alone cannot tell from work. Three threads share the GIL, so that gap is often large.
- mstar.utils.profiler.phase_start()[source]#
Start stamp for
phase_end: None unless MSTAR_PHASE_TIMING is set.
- mstar.utils.profiler.range_pop(*, synchronize=False)[source]#
Pop the current NVTX range, optionally syncing before the marker.
Same semantics as
range_push— default issynchronize=False.- Parameters:
synchronize (bool)
- Return type:
None
- mstar.utils.profiler.range_push(name, *, synchronize=False)[source]#
Push an NVTX range, optionally syncing before the marker.
Default is
synchronize=Falseso adding NVTX markers doesn’t serialize the execution. Setsynchronize=Trueonly when the caller specifically wants the range to extend over the GPU work it wraps (e.g. an ad-hoc benchmark of one kernel) — and remember that eachsynchronize=Truecall drains the entire default stream viatorch.cuda.synchronize(), not just the wrapped kernel.