Skip to content

Commit

Permalink
Remove noc header file inclusion from watcher_device_reader.cpp (#16589)
Browse files Browse the repository at this point in the history
  • Loading branch information
blozano-tt authored Jan 10, 2025
1 parent 5cdf0fa commit 9c5a0b2
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tt_metal/impl/debug/watcher_device_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,26 @@
#include "hw/inc/debug/ring_buffer.h"
#include "impl/device/device.hpp"
#include "llrt/rtoptions.hpp"
#include "noc/noc_overlay_parameters.h"
#include "noc/noc_parameters.h"

#include "watcher_device_reader.hpp"

#include "llrt/hal.hpp"

using namespace tt::tt_metal;

using std::string;

#define NOC_MCAST_ADDR_START_X(addr) (hal.get_noc_mcast_addr_start_x(addr))
#define NOC_MCAST_ADDR_START_Y(addr) (hal.get_noc_mcast_addr_start_y(addr))
#define NOC_MCAST_ADDR_END_X(addr) (hal.get_noc_mcast_addr_end_x(addr))
#define NOC_MCAST_ADDR_END_Y(addr) (hal.get_noc_mcast_addr_end_y(addr))
#define NOC_UNICAST_ADDR_X(addr) (hal.get_noc_ucast_addr_x(addr))
#define NOC_UNICAST_ADDR_Y(addr) (hal.get_noc_ucast_addr_y(addr))
#define NOC_LOCAL_ADDR(addr) (hal.get_noc_local_addr(addr))
#define NOC_OVERLAY_START_ADDR (hal.get_noc_overlay_start_addr())
#define NOC_STREAM_REG_SPACE_SIZE (hal.get_noc_stream_reg_space_size())
#define STREAM_REMOTE_DEST_BUF_SIZE_REG_INDEX (hal.get_noc_stream_remote_dest_buf_size_reg_index())
#define STREAM_REMOTE_DEST_BUF_START_REG_INDEX (hal.get_noc_stream_remote_dest_buf_start_reg_index())

namespace { // Helper functions

// Helper function to get string rep of riscv type
Expand Down
11 changes: 11 additions & 0 deletions tt_metal/llrt/blackhole/bh_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ void Hal::initialize_bh() {
this->noc_multicast_encoding_func_ = [](uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end) {
return NOC_MULTICAST_ENCODING(x_start, y_start, x_end, y_end);
};
this->noc_mcast_addr_start_x_func_ = [](uint64_t addr) -> uint64_t { return NOC_MCAST_ADDR_START_X(addr); };
this->noc_mcast_addr_start_y_func_ = [](uint64_t addr) -> uint64_t { return NOC_MCAST_ADDR_START_Y(addr); };
this->noc_mcast_addr_end_x_func_ = [](uint64_t addr) -> uint64_t { return NOC_MCAST_ADDR_END_X(addr); };
this->noc_mcast_addr_end_y_func_ = [](uint64_t addr) -> uint64_t { return NOC_MCAST_ADDR_END_Y(addr); };
this->noc_ucast_addr_x_func_ = [](uint64_t addr) -> uint64_t { return NOC_UNICAST_ADDR_X(addr); };
this->noc_ucast_addr_y_func_ = [](uint64_t addr) -> uint64_t { return NOC_UNICAST_ADDR_Y(addr); };
this->noc_local_addr_func_ = [](uint64_t addr) -> uint64_t { return NOC_LOCAL_ADDR(addr); };

this->stack_size_func_ = [](uint32_t type) -> uint32_t {
switch (type) {
Expand All @@ -95,6 +102,10 @@ void Hal::initialize_bh() {
this->num_nocs_ = NUM_NOCS;
this->noc_addr_node_id_bits_ = NOC_ADDR_NODE_ID_BITS;
this->noc_coord_reg_offset_ = NOC_COORD_REG_OFFSET;
this->noc_overlay_start_addr_ = NOC_OVERLAY_START_ADDR;
this->noc_stream_reg_space_size_ = NOC_STREAM_REG_SPACE_SIZE;
this->noc_stream_remote_dest_buf_size_reg_index_ = STREAM_REMOTE_DEST_BUF_SIZE_REG_INDEX;
this->noc_stream_remote_dest_buf_start_reg_index_ = STREAM_REMOTE_DEST_BUF_START_REG_INDEX;
this->coordinate_virtualization_enabled_ = COORDINATE_VIRTUALIZATION_ENABLED;
this->virtual_worker_start_x_ = VIRTUAL_TENSIX_START_X;
this->virtual_worker_start_y_ = VIRTUAL_TENSIX_START_Y;
Expand Down
11 changes: 11 additions & 0 deletions tt_metal/llrt/grayskull/gs_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ void Hal::initialize_gs() {
this->noc_multicast_encoding_func_ = [](uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end) {
return NOC_MULTICAST_ENCODING(x_start, y_start, x_end, y_end);
};
this->noc_mcast_addr_start_x_func_ = [](uint64_t addr) -> uint64_t { return NOC_MCAST_ADDR_START_X(addr); };
this->noc_mcast_addr_start_y_func_ = [](uint64_t addr) -> uint64_t { return NOC_MCAST_ADDR_START_Y(addr); };
this->noc_mcast_addr_end_x_func_ = [](uint64_t addr) -> uint64_t { return NOC_MCAST_ADDR_END_X(addr); };
this->noc_mcast_addr_end_y_func_ = [](uint64_t addr) -> uint64_t { return NOC_MCAST_ADDR_END_Y(addr); };
this->noc_ucast_addr_x_func_ = [](uint64_t addr) -> uint64_t { return NOC_UNICAST_ADDR_X(addr); };
this->noc_ucast_addr_y_func_ = [](uint64_t addr) -> uint64_t { return NOC_UNICAST_ADDR_Y(addr); };
this->noc_local_addr_func_ = [](uint64_t addr) -> uint64_t { return NOC_LOCAL_ADDR(addr); };

this->stack_size_func_ = [](uint32_t type) -> uint32_t {
switch (type) {
Expand All @@ -178,6 +185,10 @@ void Hal::initialize_gs() {
this->num_nocs_ = NUM_NOCS;
this->noc_addr_node_id_bits_ = NOC_ADDR_NODE_ID_BITS;
this->noc_coord_reg_offset_ = NOC_COORD_REG_OFFSET;
this->noc_overlay_start_addr_ = NOC_OVERLAY_START_ADDR;
this->noc_stream_reg_space_size_ = NOC_STREAM_REG_SPACE_SIZE;
this->noc_stream_remote_dest_buf_size_reg_index_ = STREAM_REMOTE_DEST_BUF_SIZE_REG_INDEX;
this->noc_stream_remote_dest_buf_start_reg_index_ = STREAM_REMOTE_DEST_BUF_START_REG_INDEX;
this->coordinate_virtualization_enabled_ = COORDINATE_VIRTUALIZATION_ENABLED;
this->virtual_worker_start_x_ = VIRTUAL_TENSIX_START_X;
this->virtual_worker_start_y_ = VIRTUAL_TENSIX_START_Y;
Expand Down
29 changes: 29 additions & 0 deletions tt_metal/llrt/hal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class Hal {
using ValidRegAddrFunc = std::function<bool(uint32_t)>;
using NOCXYEncodingFunc = std::function<uint32_t(uint32_t, uint32_t)>;
using NOCMulticastEncodingFunc = std::function<uint32_t(uint32_t, uint32_t, uint32_t, uint32_t)>;
using NOCAddrFunc = std::function<uint64_t(uint64_t)>;
using StackSizeFunc = std::function<uint32_t(uint32_t)>;

private:
Expand All @@ -155,6 +156,10 @@ class Hal {
uint32_t num_nocs_;
uint32_t noc_addr_node_id_bits_;
uint32_t noc_coord_reg_offset_;
uint32_t noc_overlay_start_addr_;
uint32_t noc_stream_reg_space_size_;
uint32_t noc_stream_remote_dest_buf_size_reg_index_;
uint32_t noc_stream_remote_dest_buf_start_reg_index_;
bool coordinate_virtualization_enabled_;
uint32_t virtual_worker_start_x_;
uint32_t virtual_worker_start_y_;
Expand All @@ -168,6 +173,13 @@ class Hal {
ValidRegAddrFunc valid_reg_addr_func_;
NOCXYEncodingFunc noc_xy_encoding_func_;
NOCMulticastEncodingFunc noc_multicast_encoding_func_;
NOCAddrFunc noc_mcast_addr_start_x_func_;
NOCAddrFunc noc_mcast_addr_start_y_func_;
NOCAddrFunc noc_mcast_addr_end_x_func_;
NOCAddrFunc noc_mcast_addr_end_y_func_;
NOCAddrFunc noc_ucast_addr_x_func_;
NOCAddrFunc noc_ucast_addr_y_func_;
NOCAddrFunc noc_local_addr_func_;
StackSizeFunc stack_size_func_;

public:
Expand All @@ -179,6 +191,15 @@ class Hal {
uint32_t get_noc_addr_node_id_bits() const { return noc_addr_node_id_bits_; }
uint32_t get_noc_coord_reg_offset() const { return noc_coord_reg_offset_; }

uint32_t get_noc_overlay_start_addr() const { return noc_overlay_start_addr_; }
uint32_t get_noc_stream_reg_space_size() const { return noc_stream_reg_space_size_; }
uint32_t get_noc_stream_remote_dest_buf_size_reg_index() const {
return noc_stream_remote_dest_buf_size_reg_index_;
}
uint32_t get_noc_stream_remote_dest_buf_start_reg_index() const {
return noc_stream_remote_dest_buf_start_reg_index_;
}

template <typename IndexType, typename SizeType, typename CoordType>
auto noc_coordinate(IndexType noc_index, SizeType noc_size, CoordType coord) const
-> decltype(noc_size - 1 - coord) {
Expand All @@ -190,6 +211,14 @@ class Hal {
return noc_multicast_encoding_func_(x_start, y_start, x_end, y_end);
}

uint64_t get_noc_mcast_addr_start_x(uint64_t addr) const { return noc_mcast_addr_start_x_func_(addr); }
uint64_t get_noc_mcast_addr_start_y(uint64_t addr) const { return noc_mcast_addr_start_y_func_(addr); }
uint64_t get_noc_mcast_addr_end_x(uint64_t addr) const { return noc_mcast_addr_end_x_func_(addr); }
uint64_t get_noc_mcast_addr_end_y(uint64_t addr) const { return noc_mcast_addr_end_y_func_(addr); }
uint64_t get_noc_ucast_addr_x(uint64_t addr) const { return noc_ucast_addr_x_func_(addr); }
uint64_t get_noc_ucast_addr_y(uint64_t addr) const { return noc_ucast_addr_y_func_(addr); }
uint64_t get_noc_local_addr(uint64_t addr) const { return noc_local_addr_func_(addr); }

bool is_coordinate_virtualization_enabled() const { return this->coordinate_virtualization_enabled_; };
std::uint32_t get_virtual_worker_start_x() const { return this->virtual_worker_start_x_; }
std::uint32_t get_virtual_worker_start_y() const { return this->virtual_worker_start_y_; }
Expand Down
11 changes: 11 additions & 0 deletions tt_metal/llrt/wormhole/wh_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ void Hal::initialize_wh() {
this->noc_multicast_encoding_func_ = [](uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end) {
return NOC_MULTICAST_ENCODING(x_start, y_start, x_end, y_end);
};
this->noc_mcast_addr_start_x_func_ = [](uint64_t addr) -> uint64_t { return NOC_MCAST_ADDR_START_X(addr); };
this->noc_mcast_addr_start_y_func_ = [](uint64_t addr) -> uint64_t { return NOC_MCAST_ADDR_START_Y(addr); };
this->noc_mcast_addr_end_x_func_ = [](uint64_t addr) -> uint64_t { return NOC_MCAST_ADDR_END_X(addr); };
this->noc_mcast_addr_end_y_func_ = [](uint64_t addr) -> uint64_t { return NOC_MCAST_ADDR_END_Y(addr); };
this->noc_ucast_addr_x_func_ = [](uint64_t addr) -> uint64_t { return NOC_UNICAST_ADDR_X(addr); };
this->noc_ucast_addr_y_func_ = [](uint64_t addr) -> uint64_t { return NOC_UNICAST_ADDR_Y(addr); };
this->noc_local_addr_func_ = [](uint64_t addr) -> uint64_t { return NOC_LOCAL_ADDR(addr); };

this->stack_size_func_ = [](uint32_t type) -> uint32_t {
switch (type) {
Expand All @@ -96,6 +103,10 @@ void Hal::initialize_wh() {
this->num_nocs_ = NUM_NOCS;
this->noc_addr_node_id_bits_ = NOC_ADDR_NODE_ID_BITS;
this->noc_coord_reg_offset_ = NOC_COORD_REG_OFFSET;
this->noc_overlay_start_addr_ = NOC_OVERLAY_START_ADDR;
this->noc_stream_reg_space_size_ = NOC_STREAM_REG_SPACE_SIZE;
this->noc_stream_remote_dest_buf_size_reg_index_ = STREAM_REMOTE_DEST_BUF_SIZE_REG_INDEX;
this->noc_stream_remote_dest_buf_start_reg_index_ = STREAM_REMOTE_DEST_BUF_START_REG_INDEX;
this->coordinate_virtualization_enabled_ = COORDINATE_VIRTUALIZATION_ENABLED;
this->virtual_worker_start_x_ = VIRTUAL_TENSIX_START_X;
this->virtual_worker_start_y_ = VIRTUAL_TENSIX_START_Y;
Expand Down

0 comments on commit 9c5a0b2

Please sign in to comment.