Skip to content

Commit

Permalink
#4756: Fix watcher gtest fixture log clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
tt-dma committed Jan 20, 2024
1 parent 580d588 commit c0f65e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <chrono>
#include <thread>
#include "common_fixture.hpp"
#include "llrt/watcher.hpp"

// A version of CommonFixture with watcher enabled
class WatcherFixture: public CommonFixture {
Expand Down Expand Up @@ -58,6 +59,6 @@ class WatcherFixture: public CommonFixture {
CommonFixture::RunTestOnDevice(run_function_no_args, device);
// Wait for a final watcher poll and then clear the log.
std::this_thread::sleep_for(std::chrono::milliseconds(interval_ms));
std::remove(log_file_name.c_str());
tt::llrt::watcher_clear_log();
}
};
6 changes: 6 additions & 0 deletions tt_metal/llrt/watcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ constexpr uint16_t DEBUG_SANITIZE_NOC_SENTINEL_OK_16 = 0xbada;
static bool enabled = false;
static std::mutex watch_mutex;
static std::unordered_map<void *, std::shared_ptr<WatcherDevice>> devices;
static string logfile_path = "";
static FILE *logfile = nullptr;
static std::chrono::time_point start_time = std::chrono::system_clock::now();
static std::vector<string> kernel_names;
Expand Down Expand Up @@ -611,6 +612,7 @@ void watcher_attach(void *dev,

if (!watcher::enabled && OptionsG.get_watcher_enabled()) {

watcher::logfile_path = log_path;
watcher::logfile = watcher::create_file(log_path);

int sleep_usecs = OptionsG.get_watcher_interval() * 1000;
Expand Down Expand Up @@ -665,5 +667,9 @@ int watcher_register_kernel(const string& name) {
return watcher::kernel_names.size() - 1;
}

void watcher_clear_log() {
watcher::logfile = watcher::create_file(watcher::logfile_path);
}

} // namespace llrt
} // namespace tt
3 changes: 3 additions & 0 deletions tt_metal/llrt/watcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ void watcher_sanitize_host_noc_write(const metal_SocDescriptor &soc_d, CoreCoord

int watcher_register_kernel(const string& name);

// Helper function to clear the watcher log file
void watcher_clear_log();

} // namespace llrt
} // namespace tt

0 comments on commit c0f65e6

Please sign in to comment.