Skip to content

tenzr::profiler

Classes

Name
struct tenzr::profiler::BottleneckReport
Heuristic analysis of the dominant performance bottleneck.
class tenzr::profiler::Profiler
Process-wide collector of profile events with Chrome Trace export.
struct tenzr::profiler::ProfileSummary
Aggregated profile statistics for a recorded trace.
class tenzr::profiler::ScopedTrace
RAII helper that records a duration for its enclosing scope.
class tenzr::profiler::StepMarker
RAII helper that marks the start and end of a training step.
struct tenzr::profiler::TopOp
Aggregated timing statistics for one operation in a profile.
struct tenzr::profiler::TraceEvent
One Chrome Trace Event entry recorded by the profiler.
class tenzr::profiler::TraceSession
RAII helper that starts profiling on construction and exports on destruction.

Functions

Name
bool IsEnabled()
void Start()
Begin recording on the global profiler.
void Stop()
Stop recording on the global profiler.
void Reset()
Clear all events on the global profiler.
void RecordCounter(std::string name, int64_t value, std::string cat ="memory")
void RecordInstant(std::string name, std::string cat ="general", char scope ='t')
bool ExportChromeTrace(const std::string & path)
ProfileSummary AnalyzeTrace()
void RecordStreamKernel(std::string name, int64_t stream_id, int64_t dur_us, std::string cat ="gpu_kernel", std::unordered_map< std::string, std::string > args ={})
void RecordMemoryTransfer(std::string name, size_t bytes, bool h2d, int64_t dur_us)
void RecordCollectiveComm(std::string name, size_t bytes, int64_t dur_us)
template <typename Fn ,typename... Args>
auto
Trace(const std::string & path, Fn && fn, Args &&... args)

Functions Documentation

function IsEnabled

inline bool IsEnabled()

Return: true while the global profiler is recording.

function Start

inline void Start()

Begin recording on the global profiler.

function Stop

inline void Stop()

Stop recording on the global profiler.

function Reset

inline void Reset()

Clear all events on the global profiler.

function RecordCounter

inline void RecordCounter(
    std::string name,
    int64_t value,
    std::string cat ="memory"
)

Parameters:

  • name Counter name.
  • value Counter value.
  • cat Event category.

Record a counter on the global profiler.

function RecordInstant

inline void RecordInstant(
    std::string name,
    std::string cat ="general",
    char scope ='t'
)

Parameters:

  • name Event name.
  • cat Event category.
  • scope Instant scope ('g', 'p', or 't').

Record an instant event on the global profiler.

function ExportChromeTrace

inline bool ExportChromeTrace(
    const std::string & path
)

Parameters:

  • path Output file path.

Return: true on success.

Export the global profiler's trace.

function AnalyzeTrace

inline ProfileSummary AnalyzeTrace()

Return: Aggregated statistics from the global profiler.

function RecordStreamKernel

inline void RecordStreamKernel(
    std::string name,
    int64_t stream_id,
    int64_t dur_us,
    std::string cat ="gpu_kernel",
    std::unordered_map< std::string, std::string > args ={}
)

Parameters:

  • name Kernel name.
  • stream_id Stream identifier.
  • dur_us Duration in microseconds.
  • cat Event category.
  • args Additional event arguments.

Record a device kernel on the global profiler.

function RecordMemoryTransfer

inline void RecordMemoryTransfer(
    std::string name,
    size_t bytes,
    bool h2d,
    int64_t dur_us
)

Parameters:

  • name Transfer name.
  • bytes Number of bytes transferred.
  • h2d true for host-to-device, false for device-to-host.
  • dur_us Duration in microseconds.

Record a memory transfer on the global profiler.

function RecordCollectiveComm

inline void RecordCollectiveComm(
    std::string name,
    size_t bytes,
    int64_t dur_us
)

Parameters:

  • name Operation name.
  • bytes Number of bytes communicated.
  • dur_us Duration in microseconds.

Record a collective operation on the global profiler.

function Trace

template <typename Fn ,
typename... Args>
auto Trace(
    const std::string & path,
    Fn && fn,
    Args &&... args
)

Parameters:

  • path Output path for the trace file.
  • fn Callable to invoke.
  • args Arguments forwarded to fn.

Return: fn's result.

Functional profiling wrapper analogous to jax.profiler.trace: records a trace over the span of one fn invocation.