From 15173cb6d3df57c9ef4e3fbc35d4de22c9a1ff7f Mon Sep 17 00:00:00 2001 From: Jackson Nie Date: Thu, 25 Jul 2024 11:01:53 -0400 Subject: [PATCH] #10671: API to get chip location (#10674) --- tt_metal/impl/device/device.hpp | 2 +- tt_metal/llrt/tt_cluster.cpp | 6 ++++++ tt_metal/llrt/tt_cluster.hpp | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tt_metal/impl/device/device.hpp b/tt_metal/impl/device/device.hpp index 2f1e9a8b0a63..1d7057102570 100644 --- a/tt_metal/impl/device/device.hpp +++ b/tt_metal/impl/device/device.hpp @@ -138,7 +138,7 @@ class Device { std::vector get_ethernet_sockets(chip_id_t connected_chip_id) const { return tt::Cluster::instance().get_ethernet_sockets(this->id_, connected_chip_id); } - + bool is_mmio_capable() const { return tt::Cluster::instance().get_associated_mmio_device(this->id_) == this->id_; } diff --git a/tt_metal/llrt/tt_cluster.cpp b/tt_metal/llrt/tt_cluster.cpp index 145077f683fd..d9af7c04f08d 100644 --- a/tt_metal/llrt/tt_cluster.cpp +++ b/tt_metal/llrt/tt_cluster.cpp @@ -341,6 +341,12 @@ uint32_t Cluster::get_harvested_rows(chip_id_t chip) const { } } +eth_coord_t Cluster::get_chip_location(chip_id_t chip) const { + const std::unordered_map &chip_locations = this->cluster_desc_->get_chip_locations(); + TT_FATAL(chip_locations.find(chip) != chip_locations.end(), "Cannot get chip location for chip {} that does not exist", chip); + return chip_locations.at(chip); +} + void Cluster::verify_eth_fw() const { for (const auto &[chip, mmio_device_id] : this->device_to_mmio_device_) { std::vector fw_versions; diff --git a/tt_metal/llrt/tt_cluster.hpp b/tt_metal/llrt/tt_cluster.hpp index 690d51340407..33beb10a7843 100644 --- a/tt_metal/llrt/tt_cluster.hpp +++ b/tt_metal/llrt/tt_cluster.hpp @@ -69,7 +69,8 @@ class Cluster { uint32_t get_harvesting_mask(chip_id_t chip) const { return this->get_driver(chip).get_harvesting_masks_for_soc_descriptors().at(chip); } - + eth_coord_t get_chip_location(chip_id_t chip) const; + //! device driver and misc apis void verify_eth_fw() const; void verify_sw_fw_versions(int device_id, std::uint32_t sw_version, std::vector &fw_versions) const;