Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanevskiTT committed Nov 8, 2024
1 parent 1137fc4 commit a49b2ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
28 changes: 14 additions & 14 deletions device/tt_cluster_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,22 +523,22 @@ void tt_ClusterDescriptor::load_ethernet_connections_from_connectivity_descripto
}

void tt_ClusterDescriptor::load_chips_from_connectivity_descriptor(YAML::Node &yaml, tt_ClusterDescriptor &desc) {
auto chip_coordinate_map = yaml["chips"].as<std::map<int, std::vector<int>>>();
desc.chips_have_coordinates = not chip_coordinate_map.empty();

for (YAML::const_iterator node = yaml["arch"].begin(); node != yaml["arch"].end(); ++node) {
chip_id_t chip_id = node->first.as<int>();
// Not all archs (e.g. Blackhole and Grayskull) have chip coordinates
if (chip_coordinate_map.find(chip_id) != chip_coordinate_map.end()) {
std::vector<int> chip_rack_coords = chip_coordinate_map[chip_id];
log_assert(chip_rack_coords.size() == 4, "Galaxy (x, y, rack, shelf) coords must be size 4");
eth_coord_t chip_location{
chip_rack_coords.at(0), chip_rack_coords.at(1), chip_rack_coords.at(2), chip_rack_coords.at(3)};
desc.chip_locations.insert({chip_id, chip_location});
desc.coords_to_chip_ids[std::get<2>(chip_location)][std::get<3>(chip_location)][std::get<1>(chip_location)][std::get<0>(chip_location)] = chip_id;
}
desc.all_chips.insert(chip_id);
}

for (YAML::const_iterator node = yaml["chips"].begin(); node != yaml["chips"].end(); ++node) {
chip_id_t chip_id = node->first.as<int>();
std::vector<int> chip_rack_coords = node->second.as<std::vector<int>>();
log_assert(chip_rack_coords.size() == 4, "Galaxy (x, y, rack, shelf) coords must be size 4");
eth_coord_t chip_location{
chip_rack_coords.at(0), chip_rack_coords.at(1), chip_rack_coords.at(2), chip_rack_coords.at(3)};

desc.chip_locations.insert({chip_id, chip_location});
desc.coords_to_chip_ids[std::get<2>(chip_location)][std::get<3>(chip_location)][std::get<1>(chip_location)][std::get<0>(chip_location)] = chip_id;
}

for(const auto& chip : yaml["chips_with_mmio"]) {
if(chip.IsMap()) {
Expand Down Expand Up @@ -633,7 +633,7 @@ const std::unordered_map<chip_id_t, std::unordered_map<ethernet_channel_t, std::

const std::unordered_map<chip_id_t, eth_coord_t>& tt_ClusterDescriptor::get_chip_locations() const {
static auto locations = std::unordered_map<chip_id_t, eth_coord_t>();
if (locations.empty() and this->chips_have_coordinates) {
if (locations.empty() and !this->chip_locations.empty()) {
for (auto chip_id : this->enabled_active_chips) {
locations[chip_id] = chip_locations.at(chip_id);
}
Expand All @@ -643,7 +643,7 @@ const std::unordered_map<chip_id_t, eth_coord_t>& tt_ClusterDescriptor::get_chip
}

chip_id_t tt_ClusterDescriptor::get_shelf_local_physical_chip_coords(chip_id_t virtual_coord) {
log_assert(this->chips_have_coordinates, "Getting physical chip coordinates is only valid for systems where chips have coordinates");
log_assert(!this->chip_locations.empty(), "Getting physical chip coordinates is only valid for systems where chips have coordinates");
// Physical cooridnates of chip inside a single rack. Calculated based on Galaxy topology.
// See: https://yyz-gitlab.local.tenstorrent.com/tenstorrent/budabackend/-/wikis/uploads/23e7a5168f38dfb706f9887fde78cb03/image.png
int x = std::get<0>(get_chip_locations().at(virtual_coord));
Expand Down Expand Up @@ -679,7 +679,7 @@ const std::unordered_map<chip_id_t, bool>& tt_ClusterDescriptor::get_noc_transla
std::size_t tt_ClusterDescriptor::get_number_of_chips() const { return this->enabled_active_chips.size(); }

int tt_ClusterDescriptor::get_ethernet_link_distance(chip_id_t chip_a, chip_id_t chip_b) const {
log_assert(this->chips_have_coordinates, "Getting physical chip coordinates is only valid for systems where chips have coordinates");
log_assert(!this->chip_locations.empty(), "Getting physical chip coordinates is only valid for systems where chips have coordinates");
return this->get_ethernet_link_coord_distance(chip_locations.at(chip_a), chip_locations.at(chip_b));
}

Expand Down
1 change: 0 additions & 1 deletion device/tt_cluster_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class tt_ClusterDescriptor {

protected:

bool chips_have_coordinates;
std::unordered_map<chip_id_t, std::unordered_map<ethernet_channel_t, std::tuple<chip_id_t, ethernet_channel_t> > > ethernet_connections;
std::unordered_map<chip_id_t, eth_coord_t> chip_locations;
// reverse map: rack/shelf/y/x -> chip_id
Expand Down

0 comments on commit a49b2ab

Please sign in to comment.