tenzr::profiler::Profiler¶
Process-wide collector of profile events with Chrome Trace export.
#include <trace.h>
Public Functions¶
| Name | |
|---|---|
| Profiler & | Instance() |
| void | Start() Begin recording events. |
| void | Stop() Stop recording events. |
| void | Reset() Clear all recorded events and reset the clock. |
| bool | IsEnabled() const |
| void | RecordEvent(TraceEvent event) |
| void | RecordInstant(std::string name, std::string cat ="general", char scope ='t') |
| void | RecordCounter(std::string name, int64_t value, std::string cat ="memory") |
| void | RecordMetadata(std::string name, std::string value) |
| 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) |
| bool | ExportChromeTrace(const std::string & path) const |
| ProfileSummary | AnalyzeTrace() const |
| size_t | EventCount() const |
Public Functions Documentation¶
function Instance¶
Return:
- The process-wide profiler instance.
- Reference to the singleton Profiler.
Get the process-wide profiler.
function Start¶
Begin recording events.
Enable recording and emit the default process/thread metadata events.
function Stop¶
Stop recording events.
Disable recording; existing events are retained.
function Reset¶
Clear all recorded events and reset the clock.
Clear recorded events and restart the trace clock.
function IsEnabled¶
Return: true while recording is enabled.
function RecordEvent¶
Parameters:
- event Event to record.
- event Event to record.
Append a pre-built trace event. Append a raw trace event.
function RecordInstant¶
Parameters:
- name Event name.
- cat Event category.
- scope Instant scope ('g', 'p', or 't').
- name Event name.
- cat Event category.
- scope Instant scope (g, p, or t).
Record a zero-duration instant event. Record an instantaneous event.
function RecordCounter¶
Parameters:
- name Counter name.
- value Counter value.
- cat Event category.
- name Counter name.
- value Counter value.
- cat Event category.
Record a counter value. Record a numeric counter sample.
function RecordMetadata¶
Parameters:
- name Metadata key.
- value Metadata value.
- name Metadata key.
- value Metadata value.
Record a metadata name/value pair. Record a metadata event.
function RecordStreamKernel¶
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.
- name Kernel name.
- stream_id Source stream.
- dur_us Kernel duration in microseconds.
- cat Event category.
- args Additional event arguments.
Record a device-kernel execution. Record a device kernel duration on a stream.
function RecordMemoryTransfer¶
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.
- name Transfer name.
- bytes Number of bytes moved.
- h2d Direction: true for host-to-device.
- dur_us Transfer duration in microseconds.
Record a host/device memory transfer. Record a host-device transfer, including derived bandwidth when the duration is known.
function RecordCollectiveComm¶
Parameters:
- name Operation name.
- bytes Number of bytes communicated.
- dur_us Duration in microseconds.
- name Collective name.
- bytes Number of bytes communicated.
- dur_us Duration in microseconds.
Record a collective-communication operation. Record a collective communication operation.
function ExportChromeTrace¶
Parameters:
- path Output file path.
- path Destination file path.
Return:
- true on success.
- true on success.
Write recorded events as a Chrome Trace JSON file. Write recorded events to a Chrome/Perfetto trace JSON file.
function AnalyzeTrace¶
Return:
- Aggregated statistics for the recorded events.
- The computed profile summary.
Aggregate recorded events into a duration summary.
function EventCount¶
Return:
- Number of recorded events.
- Event count.
Number of recorded events.