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 1, 2024
1 parent c0d218f commit 3cb64ac
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 @@ -3300,6 +3301,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 @@ -3309,6 +3312,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 @@ -3325,6 +3330,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 @@ -3338,6 +3345,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 3cb64ac

Please sign in to comment.