Skip to content

Commit

Permalink
#9956: Support perf report for tracing runs
Browse files Browse the repository at this point in the history
  • Loading branch information
mo-tenstorrent committed Nov 5, 2024
1 parent 744b0e5 commit a0c2611
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 70 deletions.
9 changes: 9 additions & 0 deletions tt_metal/impl/device/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "noc/noc_parameters.h"
#include "tt_metal/impl/device/device_pool.hpp"
#include "tt_metal/detail/persistent_kernel_cache.hpp"
#include "tt_metal/tools/profiler/tt_metal_tracy.hpp"
#include "llrt/hal.hpp"

namespace tt {
Expand Down Expand Up @@ -3299,6 +3300,8 @@ bool Device::using_slow_dispatch() const {
}

void Device::begin_trace(const uint8_t cq_id, const uint32_t tid) {
ZoneScoped;
TracyTTMetalBeginTrace(this->id(), tid);
TT_FATAL(this->trace_buffer_pool_.count(tid) == 0, "Trace already exists for tid {} on device", tid);
TT_FATAL(!this->hw_command_queues_[cq_id]->tid.has_value(), "CQ {} is already being used for tracing tid {}", (uint32_t)cq_id, tid);
this->MarkAllocationsSafe();
Expand All @@ -3308,6 +3311,8 @@ void Device::begin_trace(const uint8_t cq_id, const uint32_t tid) {
}

void Device::end_trace(const uint8_t cq_id, const uint32_t tid) {
ZoneScoped;
TracyTTMetalEndTrace(this->id(), tid);
TT_FATAL(this->hw_command_queues_[cq_id]->tid == tid, "CQ {} is not being used for tracing tid {}", (uint32_t)cq_id, tid);
TT_FATAL(this->trace_buffer_pool_.count(tid) > 0, "Trace instance {} must exist on device", tid);
this->hw_command_queues_[cq_id]->record_end();
Expand All @@ -3324,6 +3329,8 @@ void Device::end_trace(const uint8_t cq_id, const uint32_t tid) {
}

void Device::replay_trace(const uint8_t cq_id, const uint32_t tid, const bool blocking) {
ZoneScoped;
TracyTTMetalReplayTrace(this->id(), tid);
constexpr bool check = false;
TT_FATAL(this->trace_buffer_pool_.count(tid) > 0, "Trace instance {} must exist on device" , tid);
if constexpr (check) {
Expand All @@ -3337,6 +3344,8 @@ void Device::replay_trace(const uint8_t cq_id, const uint32_t tid, const bool bl
}

void Device::release_trace(const uint32_t tid) {
ZoneScoped;
TracyTTMetalReleaseTrace(this->id(), tid);
uint32_t erased = this->trace_buffer_pool_.erase(tid);
// Only enable allocations once all captured traces are released
if (this->trace_buffer_pool_.empty()) {
Expand Down
Loading

0 comments on commit a0c2611

Please sign in to comment.