Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add const to tt_ClusterDescriptor's methods returning maps #267

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions device/tt_cluster_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ void tt_ClusterDescriptor::fill_chips_grouped_by_closest_mmio() {
}
}

std::unordered_map<chip_id_t, std::unordered_map<ethernet_channel_t, std::tuple<chip_id_t, ethernet_channel_t> > > tt_ClusterDescriptor::get_ethernet_connections() const {
const std::unordered_map<chip_id_t, std::unordered_map<ethernet_channel_t, std::tuple<chip_id_t, ethernet_channel_t> > > tt_ClusterDescriptor::get_ethernet_connections() const {
auto eth_connections = std::unordered_map<chip_id_t, std::unordered_map<ethernet_channel_t, std::tuple<chip_id_t, ethernet_channel_t> > >();

for (const auto &[chip, channel_mapping] : this->ethernet_connections) {
Expand All @@ -620,7 +620,7 @@ std::unordered_map<chip_id_t, std::unordered_map<ethernet_channel_t, std::tuple<
return eth_connections;
}

std::unordered_map<chip_id_t, eth_coord_t> tt_ClusterDescriptor::get_chip_locations() const {
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()) {
for (auto chip_id : this->enabled_active_chips) {
Expand All @@ -640,7 +640,7 @@ chip_id_t tt_ClusterDescriptor::get_shelf_local_physical_chip_coords(chip_id_t v
}

// Return map, but filter by enabled active chips.
std::unordered_map<chip_id_t, chip_id_t> tt_ClusterDescriptor::get_chips_with_mmio() const {
const std::unordered_map<chip_id_t, chip_id_t> tt_ClusterDescriptor::get_chips_with_mmio() const {
auto chips_map = std::unordered_map<chip_id_t, chip_id_t>();
for (const auto &pair : chips_with_mmio) {
auto &chip_id = pair.first;
Expand All @@ -652,15 +652,15 @@ std::unordered_map<chip_id_t, chip_id_t> tt_ClusterDescriptor::get_chips_with_mm
return chips_map;
}

std::unordered_set<chip_id_t> tt_ClusterDescriptor::get_all_chips() const {
const std::unordered_set<chip_id_t>& tt_ClusterDescriptor::get_all_chips() const {
return this->enabled_active_chips;
}

std::unordered_map<chip_id_t, std::uint32_t> tt_ClusterDescriptor::get_harvesting_info() const {
const std::unordered_map<chip_id_t, std::uint32_t>& tt_ClusterDescriptor::get_harvesting_info() const {
return harvesting_masks;
}

std::unordered_map<chip_id_t, bool> tt_ClusterDescriptor::get_noc_translation_table_en() const {
const std::unordered_map<chip_id_t, bool>& tt_ClusterDescriptor::get_noc_translation_table_en() const {
return noc_translation_enabled;
}

Expand All @@ -675,6 +675,6 @@ BoardType tt_ClusterDescriptor::get_board_type(chip_id_t chip_id) const {
return board_type;
}

std::unordered_map<chip_id_t, std::unordered_set<chip_id_t>> tt_ClusterDescriptor::get_chips_grouped_by_closest_mmio() const {
const std::unordered_map<chip_id_t, std::unordered_set<chip_id_t>>& tt_ClusterDescriptor::get_chips_grouped_by_closest_mmio() const {
return chips_grouped_by_closest_mmio;
}
14 changes: 7 additions & 7 deletions device/tt_cluster_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ class tt_ClusterDescriptor {
const std::set<chip_id_t> &logical_mmio_device_ids,
const std::vector<chip_id_t> &physical_mmio_device_ids);

std::unordered_map<chip_id_t, std::uint32_t> get_harvesting_info() const;
std::unordered_map<chip_id_t, bool> get_noc_translation_table_en() const;
std::unordered_map<chip_id_t, eth_coord_t> get_chip_locations() const;
std::unordered_map<chip_id_t, std::unordered_map<ethernet_channel_t, std::tuple<chip_id_t, ethernet_channel_t> > > get_ethernet_connections() const;
std::unordered_map<chip_id_t, chip_id_t> get_chips_with_mmio() const;
std::unordered_set<chip_id_t> get_all_chips() const;
const std::unordered_map<chip_id_t, std::uint32_t>& get_harvesting_info() const;
const std::unordered_map<chip_id_t, bool>& get_noc_translation_table_en() const;
const std::unordered_map<chip_id_t, eth_coord_t>& get_chip_locations() const;
const std::unordered_map<chip_id_t, std::unordered_map<ethernet_channel_t, std::tuple<chip_id_t, ethernet_channel_t> > > get_ethernet_connections() const;
const std::unordered_map<chip_id_t, chip_id_t> get_chips_with_mmio() const;
const std::unordered_set<chip_id_t>& get_all_chips() const;
const std::unordered_map<chip_id_t, std::unordered_set<chip_id_t>>& get_chips_grouped_by_closest_mmio() const;
std::size_t get_number_of_chips() const;
std::unordered_map<chip_id_t, std::unordered_set<chip_id_t>> get_chips_grouped_by_closest_mmio() const;

int get_ethernet_link_distance(chip_id_t chip_a, chip_id_t chip_b) const;

Expand Down
Loading