Skip to main content

Module op_profile

Module op_profile 

Source
Expand description

Opt-in per-(OpKind, BackendId) host-time accounting for kernel launches (execute_compiled_with_wait_hint). Off by default (one relaxed atomic load per launch). What it measures: wall time of the kernel call on the HOST. A kernel that only enqueues work (Vulkan batches into a command buffer, CUDA launches on a stream) is charged its enqueue cost, NOT its device time; a kernel that blocks (CPU math, a host-to-device upload, a forced flush) is charged all of it. Device time lands wherever the realize finally waits, so compare the per-op sum with the caller’s own wall clock around a step.

Structs§

LaunchRow
One kernel launch, in launch order (see set_trace).
PhaseTimer
Times a named phase of a realize from start until it is dropped, when accounting is on (a no-op otherwise: one relaxed atomic load). Phases are hierarchical by NAME only: an outer phase’s time includes the inner ones nested inside it, so rows of take_phases are not additive.

Functions§

enabled
Whether accounting (or tracing) is on.
set_enabled
Turn accounting on or off. Does not clear what was recorded.
set_trace
Also keep every launch as a LaunchRow, in order (implies the accounting path). For a one-step anatomy, not for long runs: one row per launch. Does not clear what was recorded.
take
Drain the totals: (op, backend, launches, total host time), longest first.
take_phases
Drain the phase totals: (phase, entries, total time), longest first.
take_trace
Drain the launch trace.