From 5665a44f7ded392f444a34c63395685e5812fbe9 Mon Sep 17 00:00:00 2001 From: pjanevski Date: Fri, 22 Nov 2024 17:22:35 +0000 Subject: [PATCH] Optimize coord translation --- .../blackhole_coordinate_manager.cpp | 79 ++-- .../blackhole/blackhole_coordinate_manager.h | 7 +- device/coordinate_manager.cpp | 377 ++++++------------ device/coordinate_manager.h | 65 ++- .../grayskull_coordinate_manager.cpp | 20 +- .../grayskull/grayskull_coordinate_manager.h | 5 +- .../wormhole/wormhole_coordinate_manager.cpp | 28 +- device/wormhole/wormhole_coordinate_manager.h | 7 +- tests/api/test_core_coord_translation_bh.cpp | 44 +- tests/api/test_core_coord_translation_gs.cpp | 17 +- tests/api/test_core_coord_translation_wh.cpp | 35 +- 11 files changed, 269 insertions(+), 415 deletions(-) diff --git a/device/blackhole/blackhole_coordinate_manager.cpp b/device/blackhole/blackhole_coordinate_manager.cpp index d2f61e77..62fbbc74 100644 --- a/device/blackhole/blackhole_coordinate_manager.cpp +++ b/device/blackhole/blackhole_coordinate_manager.cpp @@ -4,38 +4,70 @@ * SPDX-License-Identifier: Apache-2.0 */ #include "blackhole_coordinate_manager.h" +#include +void BlackholeCoordinateManager::tensix_harvesting(const std::size_t tensix_harvesting_mask) { + CoordinateManager::tensix_harvesting_mask = tensix_harvesting_mask; + CoordinateManager::clear_tensix_harvesting_structures(); + + std::size_t num_harvested_x = __builtin_popcount(tensix_harvesting_mask); + std::size_t grid_size_x = CoordinateManager::tensix_grid_size.x; + std::size_t grid_size_y = CoordinateManager::tensix_grid_size.y; -std::set BlackholeCoordinateManager::get_x_coordinates_to_harvest(std::size_t harvesting_mask) { - std::set x_to_harvest; std::size_t logical_x = 0; - while (harvesting_mask > 0) { - if (harvesting_mask & 1) { - x_to_harvest.insert(logical_x); + for (std::size_t x = 0; x < grid_size_x; x++) { + if (!(tensix_harvesting_mask & (1 << x))) { + for (std::size_t y = 0; y < grid_size_y; y++) { + const tt_xy_pair& tensix_core = CoordinateManager::tensix_cores[x + y * grid_size_x]; + tensix_logical_to_physical[{logical_x, y}] = CoreCoord(tensix_core.x, tensix_core.y, CoreType::TENSIX, CoordSystem::PHYSICAL); + tensix_physical_to_logical[tensix_core] = CoreCoord(logical_x, y, CoreType::TENSIX, CoordSystem::LOGICAL); + } + logical_x++; + } + } + // std::cout << "tensix harvesting mask: " << tensix_harvesting_mask << std::endl; + // std::cout << "num harvested x: " << num_harvested_x << std::endl; + for (std::size_t x = 0; x < grid_size_x - num_harvested_x; x++) { + for (std::size_t y = 0; y < grid_size_y; y++) { + const tt_xy_pair& tensix_core = CoordinateManager::tensix_cores[x + y * grid_size_x]; + tensix_logical_to_virtual[{x, y}] = CoreCoord(tensix_core.x, tensix_core.y, CoreType::TENSIX, CoordSystem::VIRTUAL); + tensix_virtual_to_logical[tensix_core] = CoreCoord(x, y, CoreType::TENSIX, CoordSystem::LOGICAL); } - logical_x++; - harvesting_mask >>= 1; } - return x_to_harvest; -} -CoreCoord BlackholeCoordinateManager::translated_to_logical_tensix(const CoreCoord core_coord) { - const CoreCoord virtual_coord = CoreCoord(core_coord.x, core_coord.y, CoreType::TENSIX, CoordSystem::VIRTUAL); - return CoordinateManager::to_logical(virtual_coord); + BlackholeCoordinateManager::fill_tensix_logical_to_translated(); } -CoreCoord BlackholeCoordinateManager::logical_to_translated_tensix(const CoreCoord core_coord) { - const CoreCoord virtual_coord = CoordinateManager::to_virtual(core_coord); - return CoreCoord(virtual_coord.x, virtual_coord.y, CoreType::TENSIX, CoordSystem::TRANSLATED); +void BlackholeCoordinateManager::fill_tensix_logical_to_translated() { + const std::size_t num_harvested_x = __builtin_popcount(CoordinateManager::tensix_harvesting_mask); + const std::size_t grid_size_x = CoordinateManager::tensix_grid_size.x; + const std::size_t grid_size_y = CoordinateManager::tensix_grid_size.y; + + // std::cout << "tensix harvesting mask: " << CoordinateManager::tensix_harvesting_mask << std::endl; + + // std::cout << "num harvested x translated: " << num_harvested_x << std::endl; + + for (std::size_t x = 0; x < grid_size_x - num_harvested_x; x++) { + for (std::size_t y = 0; y < grid_size_y; y++) { + const CoreCoord virtual_coord = CoordinateManager::tensix_logical_to_virtual[{x, y}]; + const std::size_t translated_x = virtual_coord.x; + const std::size_t translated_y = virtual_coord.y; + CoordinateManager::tensix_logical_to_translated[{x, y}] = CoreCoord(translated_x, translated_y, CoreType::TENSIX, CoordSystem::TRANSLATED); + CoordinateManager::tensix_translated_to_logical[tt_xy_pair(translated_x, translated_y)] = CoreCoord(x, y, CoreType::TENSIX, CoordSystem::LOGICAL); + } + } } void BlackholeCoordinateManager::dram_harvesting(const std::size_t dram_harvesting_mask) { - - std::size_t get_num_harvested_x = __builtin_popcount(dram_harvesting_mask); + CoordinateManager::dram_harvesting_mask = dram_harvesting_mask; + CoordinateManager::clear_dram_harvesting_structures(); + + std::size_t num_harvested_banks = __builtin_popcount(dram_harvesting_mask); - for (std::size_t x = 0; x < dram_grid_size.x - get_num_harvested_x; x++) { + for (std::size_t x = 0; x < dram_grid_size.x - num_harvested_banks; x++) { for (std::size_t y = 0; y < dram_grid_size.y; y++) { - CoordinateManager::dram_logical_to_virtual[{x, y}] = CoordinateManager::dram_cores[x * dram_grid_size.y + y]; - CoordinateManager::dram_virtual_to_logical[dram_cores[x * dram_grid_size.y + y]] = {x, y}; + const tt_xy_pair& dram_core = CoordinateManager::dram_cores[x * dram_grid_size.y + y]; + CoordinateManager::dram_logical_to_virtual[{x, y}] = CoreCoord(dram_core.x, dram_core.y, CoreType::DRAM, CoordSystem::VIRTUAL); + CoordinateManager::dram_virtual_to_logical[dram_core] = CoreCoord(x, y, CoreType::DRAM, CoordSystem::LOGICAL); } } @@ -43,10 +75,11 @@ void BlackholeCoordinateManager::dram_harvesting(const std::size_t dram_harvesti for (std::size_t x = 0; x < dram_grid_size.x; x++) { if (!(dram_harvesting_mask & (1 << x))) { for (std::size_t y = 0; y < dram_grid_size.y; y++) { - CoordinateManager::dram_logical_to_physical[{logical_x , y}] = CoordinateManager::dram_cores[x * dram_grid_size.y + y]; - CoordinateManager::dram_physical_to_logical[dram_cores[x * dram_grid_size.y + y]] = {logical_x, y}; + const tt_xy_pair& dram_core = CoordinateManager::dram_cores[x * dram_grid_size.y + y]; + CoordinateManager::dram_logical_to_physical[{logical_x, y}] = CoreCoord(dram_core.x, dram_core.y, CoreType::DRAM, CoordSystem::PHYSICAL); + CoordinateManager::dram_physical_to_logical[dram_core] = CoreCoord(logical_x, y, CoreType::DRAM, CoordSystem::LOGICAL); } logical_x++; } } -} \ No newline at end of file +} diff --git a/device/blackhole/blackhole_coordinate_manager.h b/device/blackhole/blackhole_coordinate_manager.h index bd50efe6..bbdbabe2 100644 --- a/device/blackhole/blackhole_coordinate_manager.h +++ b/device/blackhole/blackhole_coordinate_manager.h @@ -18,9 +18,8 @@ class BlackholeCoordinateManager : public CoordinateManager { void dram_harvesting(const std::size_t dram_harvesting_mask) override; -protected: - CoreCoord translated_to_logical_tensix(const CoreCoord core_coord) override; - CoreCoord logical_to_translated_tensix(const CoreCoord core_coord) override; + void tensix_harvesting(const std::size_t tensix_harvesting_mask) override; - std::set get_x_coordinates_to_harvest(std::size_t harvesting_mask) override; +protected: + void fill_tensix_logical_to_translated() override; }; diff --git a/device/coordinate_manager.cpp b/device/coordinate_manager.cpp index 8f25de26..647f3a52 100644 --- a/device/coordinate_manager.cpp +++ b/device/coordinate_manager.cpp @@ -12,192 +12,140 @@ #include "tt_core_coordinates.h" #include "device/tt_xy_pair.h" -CoreCoord CoordinateManager::to_tensix_physical(const CoreCoord core_coord) { - switch (core_coord.coord_system) { - case CoordSystem::LOGICAL: - return CoreCoord{logical_x_to_physical_x[core_coord.x], logical_y_to_physical_y[core_coord.y], CoreType::TENSIX, CoordSystem::PHYSICAL}; - case CoordSystem::PHYSICAL: - return core_coord; - case CoordSystem::VIRTUAL: - return CoreCoord{logical_x_to_physical_x[virtual_x_to_logical_x[core_coord.x]], logical_y_to_physical_y[virtual_y_to_logical_y[core_coord.y]], CoreType::TENSIX, CoordSystem::PHYSICAL}; - case CoordSystem::TRANSLATED: - return to_tensix_physical(translated_to_logical_tensix(core_coord)); +std::map& CoordinateManager::get_logical_to_translated(CoreType core_type) { + switch (core_type) { + case CoreType::TENSIX: + return tensix_logical_to_translated; + case CoreType::DRAM: + return dram_logical_to_translated; + default: + throw std::runtime_error("Core type is not supported for getting logical to translated mapping"); } } -CoreCoord CoordinateManager::to_tensix_virtual(const CoreCoord core_coord) { - switch (core_coord.coord_system) { - case CoordSystem::LOGICAL: - return CoreCoord{logical_x_to_virtual_x[core_coord.x], logical_y_to_virtual_y[core_coord.y], CoreType::TENSIX, CoordSystem::VIRTUAL}; - case CoordSystem::PHYSICAL: - return CoreCoord{virtual_x_to_logical_x[core_coord.x], virtual_y_to_logical_y[core_coord.y], CoreType::TENSIX, CoordSystem::VIRTUAL}; - case CoordSystem::VIRTUAL: - return core_coord; - case CoordSystem::TRANSLATED: - return to_tensix_virtual(to_tensix_logical(core_coord)); +std::map& CoordinateManager::get_logical_to_virtual(CoreType core_type) { + switch (core_type) { + case CoreType::TENSIX: + return tensix_logical_to_virtual; + case CoreType::DRAM: + return dram_logical_to_virtual; + default: + throw std::runtime_error("Core type is not supported for getting logical to virtual mapping"); } } -CoreCoord CoordinateManager::to_tensix_logical(const CoreCoord core_coord) { - switch (core_coord.coord_system) { - case CoordSystem::LOGICAL: - return core_coord; - case CoordSystem::PHYSICAL: - return CoreCoord{physical_x_to_logical_x[core_coord.x], physical_y_to_logical_y[core_coord.y], CoreType::TENSIX, CoordSystem::LOGICAL}; - case CoordSystem::VIRTUAL: - return CoreCoord{virtual_x_to_logical_x[core_coord.x], virtual_y_to_logical_y[core_coord.y], CoreType::TENSIX, CoordSystem::LOGICAL}; - case CoordSystem::TRANSLATED: - return translated_to_logical_tensix(core_coord); +std::map& CoordinateManager::get_logical_to_physical(CoreType core_type) { + switch (core_type) { + case CoreType::TENSIX: + return tensix_logical_to_physical; + case CoreType::DRAM: + return dram_logical_to_physical; + default: + throw std::runtime_error("Core type is not supported for getting logical to physical mapping"); } } -CoreCoord CoordinateManager::to_tensix_translated(const CoreCoord core_coord) { - switch (core_coord.coord_system) { - case CoordSystem::LOGICAL: - return logical_to_translated_tensix(core_coord); - case CoordSystem::PHYSICAL: - return to_translated(to_tensix_logical(core_coord)); - case CoordSystem::VIRTUAL: - return to_translated(to_tensix_logical(core_coord)); - case CoordSystem::TRANSLATED: - return core_coord; +std::map& CoordinateManager::get_physical_to_logical(CoreType core_type) { + switch (core_type) { + case CoreType::TENSIX: + return tensix_physical_to_logical; + case CoreType::DRAM: + return dram_physical_to_logical; + default: + throw std::runtime_error("Core type is not supported for getting physical to logical mapping"); } } -CoreCoord CoordinateManager::to_dram_physical(const CoreCoord core_coord) { - switch (core_coord.coord_system) { - case CoordSystem::LOGICAL: { - tt_xy_pair physical_pair = dram_logical_to_physical.at({core_coord.x, core_coord.y}); - return CoreCoord(physical_pair.x, physical_pair.y, CoreType::DRAM, CoordSystem::PHYSICAL); - } - case CoordSystem::VIRTUAL: - return to_dram_physical(to_logical(core_coord)); - case CoordSystem::PHYSICAL: - return core_coord; - case CoordSystem::TRANSLATED: { - CoreCoord physical_coord = core_coord; - physical_coord.coord_system = CoordSystem::PHYSICAL; - return physical_coord; - } +std::map& CoordinateManager::get_virtual_to_logical(CoreType core_type) { + switch (core_type) { + case CoreType::TENSIX: + return tensix_virtual_to_logical; + case CoreType::DRAM: + return dram_virtual_to_logical; + default: + throw std::runtime_error("Core type is not supported for getting virtual to logical mapping"); } } -CoreCoord CoordinateManager::to_dram_logical(const CoreCoord core_coord) { +std::map& CoordinateManager::get_translated_to_logical(CoreType core_type) { + switch (core_type) { + case CoreType::TENSIX: + return tensix_translated_to_logical; + case CoreType::DRAM: + return dram_translated_to_logical; + default: + throw std::runtime_error("Core type is not supported for getting translated to logical mapping"); + } +} + +CoreCoord CoordinateManager::to_physical(const CoreCoord core_coord) { switch (core_coord.coord_system) { - case CoordSystem::LOGICAL: + case CoordSystem::PHYSICAL: return core_coord; - case CoordSystem::PHYSICAL: { - tt_xy_pair logical_pair = dram_physical_to_logical.at({core_coord.x, core_coord.y}); - return CoreCoord(logical_pair.x, logical_pair.y, CoreType::DRAM, CoordSystem::LOGICAL); - } - case CoordSystem::VIRTUAL: { - tt_xy_pair virtual_pair = dram_virtual_to_logical.at({core_coord.x, core_coord.y}); - return CoreCoord(virtual_pair.x, virtual_pair.y, CoreType::DRAM, CoordSystem::LOGICAL); - } + case CoordSystem::VIRTUAL: case CoordSystem::TRANSLATED: - return to_logical(to_physical(core_coord)); + return to_physical(to_logical(core_coord)); } + + // Coord system is surely logical. + auto& logical_mapping = get_logical_to_physical(core_coord.core_type); + return logical_mapping[{core_coord.x, core_coord.y}]; } -CoreCoord CoordinateManager::to_dram_virtual(const CoreCoord core_coord) { +CoreCoord CoordinateManager::to_virtual(const CoreCoord core_coord) { switch (core_coord.coord_system) { - case CoordSystem::LOGICAL: { - tt_xy_pair virtual_pair = dram_logical_to_virtual.at({core_coord.x, core_coord.y}); - return CoreCoord(virtual_pair.x, virtual_pair.y, CoreType::DRAM, CoordSystem::VIRTUAL); - } case CoordSystem::TRANSLATED: - case CoordSystem::PHYSICAL: { + case CoordSystem::PHYSICAL: return to_virtual(to_logical(core_coord)); - } case CoordSystem::VIRTUAL: return core_coord; } + + // Coord system is surely logical. + auto& logical_mapping = get_logical_to_virtual(core_coord.core_type); + return logical_mapping[{core_coord.x,core_coord.y}]; } -CoreCoord CoordinateManager::to_dram_translated(const CoreCoord core_coord) { +CoreCoord CoordinateManager::to_logical(const CoreCoord core_coord) { switch (core_coord.coord_system) { case CoordSystem::LOGICAL: + return core_coord; + case CoordSystem::PHYSICAL: { + auto& physical_mapping = get_physical_to_logical(core_coord.core_type); + return physical_mapping[{core_coord.x, core_coord.y}]; + } case CoordSystem::VIRTUAL: { - return to_dram_translated(to_dram_physical(core_coord)); + auto& virtual_mapping = get_virtual_to_logical(core_coord.core_type); + return virtual_mapping[{core_coord.x, core_coord.y}]; } - case CoordSystem::PHYSICAL: { - return CoreCoord(core_coord.x, core_coord.y, CoreType::DRAM, CoordSystem::TRANSLATED); + case CoordSystem::TRANSLATED: { + auto& translated_mapping = get_translated_to_logical(core_coord.core_type); + return translated_mapping[{core_coord.x, core_coord.y}]; } - case CoordSystem::TRANSLATED: - return core_coord; - } -} - -CoreCoord CoordinateManager::to_physical(const CoreCoord core_coord) { - switch (core_coord.core_type) { - case CoreType::TENSIX: - return to_tensix_physical(core_coord); - case CoreType::DRAM: - return to_dram_physical(core_coord); - case CoreType::ARC: - case CoreType::ACTIVE_ETH: - case CoreType::IDLE_ETH: - case CoreType::PCIE: - case CoreType::ROUTER_ONLY: - throw std::runtime_error("Core type is not supported for conversion to physical coordinates"); - } - throw std::runtime_error("Invalid coordinate system"); -} - -CoreCoord CoordinateManager::to_virtual(const CoreCoord core_coord) { - switch (core_coord.core_type) { - case CoreType::TENSIX: - return to_tensix_virtual(core_coord); - case CoreType::DRAM: - return to_dram_virtual(core_coord); - case CoreType::ARC: - case CoreType::ACTIVE_ETH: - case CoreType::IDLE_ETH: - case CoreType::PCIE: - case CoreType::ROUTER_ONLY: - throw std::runtime_error("Core type is not supported for conversion to virtual coordinates"); - } -} - -CoreCoord CoordinateManager::to_logical(const CoreCoord core_coord) { - switch (core_coord.core_type) { - case CoreType::TENSIX: - return to_tensix_logical(core_coord); - case CoreType::DRAM: - return to_dram_logical(core_coord); - case CoreType::ARC: - case CoreType::ACTIVE_ETH: - case CoreType::IDLE_ETH: - case CoreType::PCIE: - case CoreType::ROUTER_ONLY: - throw std::runtime_error("Core type is not supported for conversion to logical coordinates"); } } CoreCoord CoordinateManager::to_translated(const CoreCoord core_coord) { - switch (core_coord.core_type) { - case CoreType::TENSIX: - return to_tensix_translated(core_coord); - case CoreType::DRAM: - return to_dram_translated(core_coord); - case CoreType::ARC: - case CoreType::ACTIVE_ETH: - case CoreType::IDLE_ETH: - case CoreType::PCIE: - case CoreType::ROUTER_ONLY: - throw std::runtime_error("Core type is not supported for conversion to translated coordinates"); + switch (core_coord.coord_system) { + case CoordSystem::PHYSICAL: + case CoordSystem::VIRTUAL: + return to_translated(to_logical(core_coord)); + case CoordSystem::TRANSLATED: + return core_coord; } + + // Coord system is surely logical. + auto& logical_mapping = get_logical_to_translated(core_coord.core_type); + return logical_mapping[{core_coord.x, core_coord.y}]; } void CoordinateManager::clear_tensix_harvesting_structures() { - logical_x_to_physical_x.clear(); - logical_y_to_physical_y.clear(); - logical_x_to_virtual_x.clear(); - logical_y_to_virtual_y.clear(); - physical_x_to_logical_x.clear(); - physical_y_to_logical_y.clear(); - virtual_x_to_logical_x.clear(); - virtual_y_to_logical_y.clear(); + tensix_logical_to_physical.clear(); + tensix_logical_to_virtual.clear(); + tensix_physical_to_logical.clear(); + tensix_virtual_to_logical.clear(); + tensix_logical_to_translated.clear(); + tensix_translated_to_logical.clear(); } void CoordinateManager::clear_dram_harvesting_structures() { @@ -205,114 +153,55 @@ void CoordinateManager::clear_dram_harvesting_structures() { dram_logical_to_physical.clear(); dram_virtual_to_logical.clear(); dram_physical_to_logical.clear(); -} - -std::set CoordinateManager::get_x_coordinates_to_harvest(std::size_t harvesting_mask) { - return {}; -} - -std::set CoordinateManager::get_y_coordinates_to_harvest(std::size_t harvesting_mask) { - return {}; + dram_logical_to_translated.clear(); + dram_translated_to_logical.clear(); } void CoordinateManager::tensix_harvesting(const std::size_t harvesting_mask) { + this->tensix_harvesting_mask = harvesting_mask; clear_tensix_harvesting_structures(); - std::set physical_x_unharvested; - std::set physical_y_unharvested; - for (auto core : workers) { - physical_x_unharvested.insert(core.x); - physical_y_unharvested.insert(core.y); - } - - std::set x_coordinates_to_harvest = get_x_coordinates_to_harvest(harvesting_mask); - std::set y_coordinates_to_harvest = get_y_coordinates_to_harvest(harvesting_mask); - - std::size_t num_harvested_y = y_coordinates_to_harvest.size(); - std::size_t num_harvested_x = x_coordinates_to_harvest.size(); - - std::size_t grid_size_x = worker_grid_size.x; - std::size_t grid_size_y = worker_grid_size.y; - - logical_x_to_physical_x.resize(grid_size_x - num_harvested_x); - logical_y_to_physical_y.resize(grid_size_y - num_harvested_y); - - logical_x_to_virtual_x.resize(grid_size_x - num_harvested_x); - logical_y_to_virtual_y.resize(grid_size_y - num_harvested_y); - - fill_logical_to_physical_mapping(x_coordinates_to_harvest, y_coordinates_to_harvest, physical_x_unharvested, physical_y_unharvested); - fill_logical_to_virtual_mapping(physical_x_unharvested, physical_y_unharvested); -} - -void CoordinateManager::dram_harvesting(const std::size_t dram_harvesting_mask) { - - for (std::size_t x = 0; x < dram_grid_size.x; x++) { - for (std::size_t y = 0; y < dram_grid_size.y; y++) { - dram_logical_to_virtual[{x, y}] = dram_cores[x * dram_grid_size.y + y]; - dram_virtual_to_logical[dram_cores[x * dram_grid_size.y + y]] = {x, y}; - - dram_logical_to_physical[{x, y}] = dram_cores[x * dram_grid_size.y + y]; - dram_physical_to_logical[dram_cores[x * dram_grid_size.y + y]] = {x, y}; - } - } -} + std::size_t num_harvested_y = __builtin_popcount(harvesting_mask); + std::size_t grid_size_x = tensix_grid_size.x; + std::size_t grid_size_y = tensix_grid_size.y; -void CoordinateManager::fill_logical_to_physical_mapping( - const std::set& x_to_harvest, const std::set& y_to_harvest, - const std::set& physical_x_unharvested, const std::set& physical_y_unharvested) { - - auto physical_y_it = physical_y_unharvested.begin(); std::size_t logical_y = 0; - for (size_t y = 0; y < worker_grid_size.y; y++) { - if (y_to_harvest.find(y) == y_to_harvest.end()) { - logical_y_to_physical_y[logical_y] = *physical_y_it; - if (physical_y_to_logical_y.find(*physical_y_it) != physical_y_to_logical_y.end()) { - throw std::runtime_error("Duplicate physical y coordinate found in the worker cores"); + for (std::size_t y = 0; y < grid_size_y; y++) { + if (!(harvesting_mask & (1 << y))) { + for (std::size_t x = 0; x < grid_size_x; x++) { + const tt_xy_pair& tensix_core = tensix_cores[y * grid_size_x + x]; + tensix_logical_to_physical[{x, logical_y}] = CoreCoord(tensix_core.x, tensix_core.y, CoreType::TENSIX, CoordSystem::PHYSICAL); + tensix_physical_to_logical[tensix_core] = CoreCoord(x, logical_y, CoreType::TENSIX, CoordSystem::LOGICAL); } - physical_y_to_logical_y[*physical_y_it] = logical_y; logical_y++; - physical_y_it++; - } else { - physical_y_it++; } } - auto physical_x_it = physical_x_unharvested.begin(); - std::size_t logical_x = 0; - for(std::size_t x = 0; x < worker_grid_size.x; x++) { - if (x_to_harvest.find(x) == x_to_harvest.end()) { - logical_x_to_physical_x[logical_x] = *physical_x_it; - if (physical_x_to_logical_x.find(*physical_x_it) != physical_x_to_logical_x.end()) { - throw std::runtime_error("Duplicate physical x coordinate found in the worker cores"); - } - physical_x_to_logical_x[*physical_x_it] = logical_x; - logical_x++; - physical_x_it++; - } else { - physical_x_it++; + for (std::size_t y = 0; y < grid_size_y - num_harvested_y; y++) { + for (std::size_t x = 0; x < grid_size_x; x++) { + const tt_xy_pair& tensix_core = tensix_cores[y * grid_size_x + x]; + tensix_logical_to_virtual[{x, y}] = CoreCoord(tensix_core.x, tensix_core.y, CoreType::TENSIX, CoordSystem::VIRTUAL); + tensix_virtual_to_logical[tensix_core] = CoreCoord(x, y, CoreType::TENSIX, CoordSystem::LOGICAL); } } + + fill_tensix_logical_to_translated(); } -void CoordinateManager::fill_logical_to_virtual_mapping(const std::set& physical_x_unharvested, const std::set& physical_y_unharvested) { - auto physical_y_it = physical_y_unharvested.begin(); - for (std::size_t y = 0; y < logical_y_to_virtual_y.size(); y++) { - logical_y_to_virtual_y[y] = *physical_y_it; - if (virtual_y_to_logical_y.find(*physical_y_it) != virtual_y_to_logical_y.end()) { - throw std::runtime_error("Duplicate virtual y coordinate found in the worker cores"); - } - virtual_y_to_logical_y[*physical_y_it] = y; - physical_y_it++; - } +void CoordinateManager::fill_tensix_logical_to_translated() {} - auto physical_x_it = physical_x_unharvested.begin(); - for (std::size_t x = 0; x < logical_x_to_virtual_x.size(); x++) { - logical_x_to_virtual_x[x] = *physical_x_it; - if (virtual_x_to_logical_x.find(*physical_x_it) != virtual_x_to_logical_x.end()) { - throw std::runtime_error("Duplicate virtual x coordinate found in the worker cores"); +void CoordinateManager::dram_harvesting(const std::size_t dram_harvesting_mask) { + this->dram_harvesting_mask = dram_harvesting_mask; + clear_dram_harvesting_structures(); + + for (std::size_t x = 0; x < dram_grid_size.x; x++) { + for (std::size_t y = 0; y < dram_grid_size.y; y++) { + dram_logical_to_virtual[{x, y}] = CoreCoord(dram_cores[x * dram_grid_size.y + y].x, dram_cores[x * dram_grid_size.y + y].y, CoreType::DRAM, CoordSystem::VIRTUAL); + dram_virtual_to_logical[dram_cores[x * dram_grid_size.y + y]] = CoreCoord(x, y, CoreType::DRAM, CoordSystem::LOGICAL); + + dram_logical_to_physical[{x, y}] = CoreCoord(dram_cores[x * dram_grid_size.y + y].x, dram_cores[x * dram_grid_size.y + y].y, CoreType::DRAM, CoordSystem::PHYSICAL); + dram_physical_to_logical[dram_cores[x * dram_grid_size.y + y]] = CoreCoord(x, y, CoreType::DRAM, CoordSystem::LOGICAL); } - virtual_x_to_logical_x[*physical_x_it] = x; - physical_x_it++; } } @@ -322,31 +211,21 @@ void CoordinateManager::fill_logical_to_virtual_mapping(const std::set& std::unique_ptr CoordinateManager::get_coordinate_manager( tt::ARCH arch, - const tt_xy_pair& worker_grid_size, - const std::vector& workers, + const tt_xy_pair& tensix_grid_size, + const std::vector& tensix_cores, const std::size_t tensix_harvesting_mask, const std::size_t dram_harvesting_mask) { switch (arch) { case tt::ARCH::GRAYSKULL: - return std::make_unique(worker_grid_size, workers, tensix_harvesting_mask, dram_harvesting_mask); + return std::make_unique(tensix_grid_size, tensix_cores, tensix_harvesting_mask, dram_harvesting_mask); case tt::ARCH::WORMHOLE_B0: - return std::make_unique(worker_grid_size, workers, tensix_harvesting_mask, dram_harvesting_mask); + return std::make_unique(tensix_grid_size, tensix_cores, tensix_harvesting_mask, dram_harvesting_mask); case tt::ARCH::BLACKHOLE: - return std::make_unique(worker_grid_size, workers, tensix_harvesting_mask, dram_harvesting_mask); + return std::make_unique(tensix_grid_size, tensix_cores, tensix_harvesting_mask, dram_harvesting_mask); case tt::ARCH::Invalid: throw std::runtime_error("Invalid architecture for creating coordinate manager"); } throw std::runtime_error("Invalid architecture for creating coordinate manager"); } - -// TODO(pjanevski): these functions should be deleted once -// deep copy of CoordinateManager for SocDescriptor is implemented -CoreCoord CoordinateManager::translated_to_logical_tensix(const CoreCoord core_coord) { - return core_coord; -} - -CoreCoord CoordinateManager::logical_to_translated_tensix(const CoreCoord core_coord) { - return core_coord; -} \ No newline at end of file diff --git a/device/coordinate_manager.h b/device/coordinate_manager.h index 126a3847..60bfc168 100644 --- a/device/coordinate_manager.h +++ b/device/coordinate_manager.h @@ -18,9 +18,9 @@ class CoordinateManager { public: CoordinateManager( - const tt_xy_pair& worker_grid_size, const std::vector& workers, const std::size_t tensix_harvesting_mask, + const tt_xy_pair& tensix_grid_size, const std::vector& tensix_cores, const std::size_t tensix_harvesting_mask, const tt_xy_pair& dram_grid_size, const std::vector& dram_cores, const std::size_t dram_harvesting_mask) - : worker_grid_size(worker_grid_size), workers(workers), tensix_harvesting_mask(tensix_harvesting_mask), + : tensix_grid_size(tensix_grid_size), tensix_cores(tensix_cores), tensix_harvesting_mask(tensix_harvesting_mask), dram_grid_size(dram_grid_size), dram_cores(dram_cores), dram_harvesting_mask(dram_harvesting_mask) {} @@ -30,8 +30,8 @@ class CoordinateManager { static std::unique_ptr get_coordinate_manager( tt::ARCH arch, - const tt_xy_pair& worker_grid_size, - const std::vector& workers, + const tt_xy_pair& tensix_grid_size, + const std::vector& tensix_cores, const std::size_t tensix_harvesting_mask, const std::size_t dram_harvesting_mask); @@ -48,28 +48,7 @@ class CoordinateManager { void clear_tensix_harvesting_structures(); void clear_dram_harvesting_structures(); - virtual std::set get_x_coordinates_to_harvest(std::size_t harvesting_mask); - virtual std::set get_y_coordinates_to_harvest(std::size_t harvesting_mask); - - virtual void fill_logical_to_physical_mapping( - const std::set& x_to_harvest, const std::set& y_to_harvest, - const std::set& physical_x_unharvested, const std::set& physical_y_unharvested); - virtual void fill_logical_to_virtual_mapping(const std::set& physical_x_unharvested, const std::set& physical_y_unharvested); - - CoreCoord to_tensix_physical(const CoreCoord core_coord); - CoreCoord to_tensix_logical(const CoreCoord core_coord); - CoreCoord to_tensix_virtual(const CoreCoord core_coord); - CoreCoord to_tensix_translated(const CoreCoord core_coord); - - CoreCoord to_dram_physical(const CoreCoord core_coord); - CoreCoord to_dram_logical(const CoreCoord core_coord); - CoreCoord to_dram_virtual(const CoreCoord core_coord); - CoreCoord to_dram_translated(const CoreCoord core_coord); - - // TODO(pjanevski): this should be abstract functions - // Making deep copy of SocDescriptor is harded if these are abstract - virtual CoreCoord translated_to_logical_tensix(const CoreCoord core_coord); - virtual CoreCoord logical_to_translated_tensix(const CoreCoord core_coord); + virtual void fill_tensix_logical_to_translated(); std::map physical_y_to_logical_y; std::map physical_x_to_logical_x; @@ -83,18 +62,36 @@ class CoordinateManager { std::map virtual_y_to_logical_y; std::map virtual_x_to_logical_x; - std::map dram_logical_to_virtual; - std::map dram_logical_to_physical; + std::map tensix_logical_to_translated; + std::map tensix_logical_to_virtual; + std::map tensix_logical_to_physical; + + std::map tensix_physical_to_logical; + std::map tensix_virtual_to_logical; + std::map tensix_translated_to_logical; + + std::map dram_logical_to_translated; + std::map dram_logical_to_virtual; + std::map dram_logical_to_physical; + + std::map dram_physical_to_logical; + std::map dram_virtual_to_logical; + std::map dram_translated_to_logical; + + std::map& get_logical_to_translated(CoreType core_type); + std::map& get_logical_to_virtual(CoreType core_type); + std::map& get_logical_to_physical(CoreType core_type); - std::map dram_virtual_to_logical; - std::map dram_physical_to_logical; + std::map& get_physical_to_logical(CoreType core_type); + std::map& get_virtual_to_logical(CoreType core_type); + std::map& get_translated_to_logical(CoreType core_type); - const tt_xy_pair worker_grid_size; - const std::vector& workers; - const std::size_t tensix_harvesting_mask; + const tt_xy_pair tensix_grid_size; + const std::vector& tensix_cores; + std::size_t tensix_harvesting_mask; // TODO(pjanevski): put const for this attributes const tt_xy_pair dram_grid_size; const std::vector dram_cores; - const std::size_t dram_harvesting_mask; + std::size_t dram_harvesting_mask; }; diff --git a/device/grayskull/grayskull_coordinate_manager.cpp b/device/grayskull/grayskull_coordinate_manager.cpp index e61685c4..9c201684 100644 --- a/device/grayskull/grayskull_coordinate_manager.cpp +++ b/device/grayskull/grayskull_coordinate_manager.cpp @@ -5,12 +5,16 @@ */ #include "grayskull_coordinate_manager.h" -CoreCoord GrayskullCoordinateManager::translated_to_logical_tensix(const CoreCoord core_coord) { - const CoreCoord physical_coord = CoreCoord(core_coord.x, core_coord.y, CoreType::TENSIX, CoordSystem::PHYSICAL); - return CoordinateManager::to_logical(physical_coord); -} +void GrayskullCoordinateManager::fill_tensix_logical_to_translated() { + std::size_t num_harvested_y = __builtin_popcount(CoordinateManager::tensix_harvesting_mask); -CoreCoord GrayskullCoordinateManager::logical_to_translated_tensix(const CoreCoord core_coord) { - const CoreCoord physical_coord = CoordinateManager::to_physical(core_coord); - return CoreCoord(physical_coord.x, physical_coord.y, CoreType::TENSIX, CoordSystem::TRANSLATED); -} \ No newline at end of file + for (std::size_t x = 0; x < CoordinateManager::tensix_grid_size.x; x++) { + for (std::size_t y = 0; y < CoordinateManager::tensix_grid_size.y - num_harvested_y; y++) { + const CoreCoord physical_coord = CoordinateManager::tensix_logical_to_physical[{x, y}]; + const std::size_t translated_x = physical_coord.x; + const std::size_t translated_y = physical_coord.y; + CoordinateManager::tensix_logical_to_translated[{x, y}] = CoreCoord(translated_x, translated_y, CoreType::TENSIX, CoordSystem::TRANSLATED); + CoordinateManager::tensix_translated_to_logical[tt_xy_pair(translated_x, translated_y)] = CoreCoord(x, y, CoreType::TENSIX, CoordSystem::LOGICAL); + } + } +} diff --git a/device/grayskull/grayskull_coordinate_manager.h b/device/grayskull/grayskull_coordinate_manager.h index 3c92393e..e5a50012 100644 --- a/device/grayskull/grayskull_coordinate_manager.h +++ b/device/grayskull/grayskull_coordinate_manager.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc. + * SPDX-FileCopyrightText: (c) 2024 Tenstorrent Inc. * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,5 @@ class GrayskullCoordinateManager : public CoordinateManager { {tt::umd::grayskull::NUM_DRAM_BANKS, tt::umd::grayskull::NUM_NOC_PORTS_PER_DRAM_BANK}, tt::umd::grayskull::DRAM_CORES, dram_harvesting_mask) {} protected: - CoreCoord translated_to_logical_tensix(const CoreCoord core_coord) override; - CoreCoord logical_to_translated_tensix(const CoreCoord core_coord) override; + void fill_tensix_logical_to_translated() override; }; diff --git a/device/wormhole/wormhole_coordinate_manager.cpp b/device/wormhole/wormhole_coordinate_manager.cpp index e163f48d..64f3c17f 100644 --- a/device/wormhole/wormhole_coordinate_manager.cpp +++ b/device/wormhole/wormhole_coordinate_manager.cpp @@ -1,27 +1,19 @@ /* - * SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc. + * SPDX-FileCopyrightText: (c) 2024 Tenstorrent Inc. * * SPDX-License-Identifier: Apache-2.0 */ #include "wormhole_coordinate_manager.h" -std::set WormholeCoordinateManager::get_y_coordinates_to_harvest(std::size_t harvesting_mask) { - std::set y_to_harvest; - std::size_t logical_y = 0; - while (harvesting_mask > 0) { - if (harvesting_mask & 1) { - y_to_harvest.insert(logical_y); +void WormholeCoordinateManager::fill_tensix_logical_to_translated() { + std::size_t num_harvested_y = __builtin_popcount(CoordinateManager::tensix_harvesting_mask); + + for (std::size_t y = 0; y < CoordinateManager::tensix_grid_size.y - num_harvested_y; y++) { + for (std::size_t x = 0; x < CoordinateManager::tensix_grid_size.x; x++) { + const std::size_t translated_x = x + translated_coordinate_start_x; + const std::size_t translated_y = y + translated_coordinate_start_y; + CoordinateManager::tensix_logical_to_translated[{x, y}] = CoreCoord(translated_x, translated_y, CoreType::TENSIX, CoordSystem::TRANSLATED); + CoordinateManager::tensix_translated_to_logical[tt_xy_pair(translated_x, translated_y)] = CoreCoord(x, y, CoreType::TENSIX, CoordSystem::LOGICAL); } - logical_y++; - harvesting_mask >>= 1; } - return y_to_harvest; -} - -CoreCoord WormholeCoordinateManager::translated_to_logical_tensix(const CoreCoord core_coord) { - return CoreCoord{core_coord.x - translated_coordinate_start_x, core_coord.y - translated_coordinate_start_y, CoreType::TENSIX, CoordSystem::LOGICAL}; } - -CoreCoord WormholeCoordinateManager::logical_to_translated_tensix(const CoreCoord core_coord) { - return CoreCoord{core_coord.x + translated_coordinate_start_x, core_coord.y + translated_coordinate_start_y, CoreType::TENSIX, CoordSystem::TRANSLATED}; -} \ No newline at end of file diff --git a/device/wormhole/wormhole_coordinate_manager.h b/device/wormhole/wormhole_coordinate_manager.h index d546ce71..64fd8d40 100644 --- a/device/wormhole/wormhole_coordinate_manager.h +++ b/device/wormhole/wormhole_coordinate_manager.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc. + * SPDX-FileCopyrightText: (c) 2024 Tenstorrent Inc. * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,10 +16,7 @@ class WormholeCoordinateManager : public CoordinateManager { : CoordinateManager(worker_grid_size, workers, tensix_harvesting_mask, {tt::umd::wormhole::NUM_DRAM_BANKS, tt::umd::wormhole::NUM_NOC_PORTS_PER_DRAM_BANK}, tt::umd::wormhole::DRAM_CORES, dram_harvesting_mask) {} protected: - CoreCoord translated_to_logical_tensix(const CoreCoord core_coord) override; - CoreCoord logical_to_translated_tensix(const CoreCoord core_coord) override; - - std::set get_y_coordinates_to_harvest(std::size_t harvesting_mask) override; + virtual void fill_tensix_logical_to_translated(); private: static const std::size_t translated_coordinate_start_x = 18; diff --git a/tests/api/test_core_coord_translation_bh.cpp b/tests/api/test_core_coord_translation_bh.cpp index 95fa6ed0..ec7c2834 100644 --- a/tests/api/test_core_coord_translation_bh.cpp +++ b/tests/api/test_core_coord_translation_bh.cpp @@ -10,21 +10,6 @@ #include "tests/test_utils/soc_desc_test_utils.hpp" #include "device/blackhole/blackhole_implementation.h" -// Blackhole workers - x-y annotation -// functional_workers: -// [ -// 1-2, 2-2, 3-2, 4-2, 5-2, 6-2, 7-2, 10-2, 11-2, 12-2, 13-2, 14-2, 15-2, 16-2, -// 1-3, 2-3, 3-3, 4-3, 5-3, 6-3, 7-3, 10-3, 11-3, 12-3, 13-3, 14-3, 15-3, 16-3, -// 1-4, 2-4, 3-4, 4-4, 5-4, 6-4, 7-4, 10-4, 11-4, 12-4, 13-4, 14-4, 15-4, 16-4, -// 1-5, 2-5, 3-5, 4-5, 5-5, 6-5, 7-5, 10-5, 11-5, 12-5, 13-5, 14-5, 15-5, 16-5, -// 1-6, 2-6, 3-6, 4-6, 5-6, 6-6, 7-6, 10-6, 11-6, 12-6, 13-6, 14-6, 15-6, 16-6, -// 1-7, 2-7, 3-7, 4-7, 5-7, 6-7, 7-7, 10-7, 11-7, 12-7, 13-7, 14-7, 15-7, 16-7, -// 1-8, 2-8, 3-8, 4-8, 5-8, 6-8, 7-8, 10-8, 11-8, 12-8, 13-8, 14-8, 15-8, 16-8, -// 1-9, 2-9, 3-9, 4-9, 5-9, 6-9, 7-9, 10-9, 11-9, 12-9, 13-9, 14-9, 15-9, 16-9, -// 1-10, 2-10, 3-10, 4-10, 5-10, 6-10, 7-10, 10-10, 11-10, 12-10, 13-10, 14-10, 15-10, 16-10, -// 1-11, 2-11, 3-11, 4-11, 5-11, 6-11, 7-11, 10-11, 11-11, 12-11, 13-11, 14-11, 15-11, 16-11, -// ] - // Tests that all physical coordinates are same as all virtual coordinates // when there is no harvesting. TEST(SocDescriptor, SocDescriptorBHNoHarvesting) { @@ -46,9 +31,9 @@ TEST(SocDescriptor, SocDescriptorBHNoHarvesting) { } } -// // Test basic translation to virtual and physical noc coordinates. -// // We expect that the top left core will have virtual and physical coordinates (1, 2) and (2, 2) for -// // the logical coordinates if the first row is harvested. +// Test basic translation to virtual and physical noc coordinates. +// We expect that the top left core will have virtual and physical coordinates (1, 2) and (2, 2) for +// the logical coordinates if the first row is harvested. TEST(SocDescriptor, SocDescriptorBHTopLeftCore) { tt_SocDescriptor soc_desc = tt_SocDescriptor(test_utils::GetAbsPath("tests/soc_descs/blackhole_140_arch_no_eth.yaml"), 1); tt_xy_pair worker_grid_size = soc_desc.worker_grid_size; @@ -64,15 +49,14 @@ TEST(SocDescriptor, SocDescriptorBHTopLeftCore) { EXPECT_EQ(physical_cords, CoreCoord(2, 2, CoreType::TENSIX, CoordSystem::PHYSICAL)); } -// // Test logical to physical coordinate translation. -// // For the full grid of logical coordinates we expect that there are no duplicates of physical coordinates. -// // For the reverse mapping back of physical to logical coordinates we expect that same logical coordinates are returned as from original mapping. +// Test logical to physical coordinate translation. +// For the full grid of logical coordinates we expect that there are no duplicates of physical coordinates. +// For the reverse mapping back of physical to logical coordinates we expect that same logical coordinates are returned as from original mapping. TEST(SocDescriptor, SocDescriptorBHLogicalPhysicalMapping) { const std::size_t max_num_harvested_x = 14; tt_SocDescriptor soc_desc = tt_SocDescriptor(test_utils::GetAbsPath("tests/soc_descs/blackhole_140_arch.yaml")); for (std::size_t harvesting_mask = 0; harvesting_mask < (1 << max_num_harvested_x); harvesting_mask++) { - soc_desc.tensix_harvesting(harvesting_mask); std::map logical_to_physical; @@ -106,9 +90,9 @@ TEST(SocDescriptor, SocDescriptorBHLogicalPhysicalMapping) { } } -// // Test logical to virtual coordinate translation. -// // For the full grid of logical coordinates we expect that there are no duplicates of virtual coordinates. -// // For the reverse mapping back of virtual to logical coordinates we expect that same logical coordinates are returned as from original mapping. +// Test logical to virtual coordinate translation. +// For the full grid of logical coordinates we expect that there are no duplicates of virtual coordinates. +// For the reverse mapping back of virtual to logical coordinates we expect that same logical coordinates are returned as from original mapping. TEST(SocDescriptor, SocDescriptorBHLogicalVirtualMapping) { const std::size_t max_num_harvested_x = 14; @@ -148,9 +132,9 @@ TEST(SocDescriptor, SocDescriptorBHLogicalVirtualMapping) { } } -// // Test logical to translated coordinate translation. -// // For the full grid of logical coordinates we expect that there are no duplicates of translated coordinates. -// // For the reverse mapping back of translated to logical coordinates we expect that same logical coordinates are returned as from original mapping. +// Test logical to translated coordinate translation. +// For the full grid of logical coordinates we expect that there are no duplicates of translated coordinates. +// For the reverse mapping back of translated to logical coordinates we expect that same logical coordinates are returned as from original mapping. TEST(SocDescriptor, SocDescriptorBHLogicalTranslatedMapping) { const std::size_t max_num_harvested_x = 14; @@ -190,8 +174,8 @@ TEST(SocDescriptor, SocDescriptorBHLogicalTranslatedMapping) { } } -// // Test that virtual and translated coordinates are same for all logical coordinates. -// // This is expected for Blackhole way of harvesting. +// Test that virtual and translated coordinates are same for all logical coordinates. +// This is expected for Blackhole way of harvesting. TEST(SocDescriptor, SocDescriptorBHVirtualEqualTranslated) { const std::size_t max_num_harvested_x = 14; tt_SocDescriptor soc_desc = tt_SocDescriptor(test_utils::GetAbsPath("tests/soc_descs/blackhole_140_arch.yaml")); diff --git a/tests/api/test_core_coord_translation_gs.cpp b/tests/api/test_core_coord_translation_gs.cpp index c2b54b0e..86b6e1dc 100644 --- a/tests/api/test_core_coord_translation_gs.cpp +++ b/tests/api/test_core_coord_translation_gs.cpp @@ -10,21 +10,6 @@ #include "tests/test_utils/soc_desc_test_utils.hpp" #include "device/grayskull/grayskull_implementation.h" -// Grayskull workers - x-y annotation -// functional_workers: -// [ -// 1-1, 2-1, 3-1, 4-1, 5-1, 6-1, 7-1, 8-1, 9-1, 10-1, 11-1, 12-1, -// 1-2, 2-2, 3-2, 4-2, 5-2, 6-2, 7-2, 8-2, 9-2, 10-2, 11-2, 12-2, -// 1-3, 2-3, 3-3, 4-3, 5-3, 6-3, 7-3, 8-3, 9-3, 10-3, 11-3, 12-3, -// 1-4, 2-4, 3-4, 4-4, 5-4, 6-4, 7-4, 8-4, 9-4, 10-4, 11-4, 12-4, -// 1-5, 2-5, 3-5, 4-5, 5-5, 6-5, 7-5, 8-5, 9-5, 10-5, 11-5, 12-5, -// 1-7, 2-7, 3-7, 4-7, 5-7, 6-7, 7-7, 8-7, 9-7, 10-7, 11-7, 12-7, -// 1-8, 2-8, 3-8, 4-8, 5-8, 6-8, 7-8, 8-8, 9-8, 10-8, 11-8, 12-8, -// 1-9, 2-9, 3-9, 4-9, 5-9, 6-9, 7-9, 8-9, 9-9, 10-9, 11-9, 12-9, -// 1-10, 2-10, 3-10, 4-10, 5-10, 6-10, 7-10, 8-10, 9-10, 10-10, 11-10, 12-10, -// 1-11, 2-11, 3-11, 4-11, 5-11, 6-11, 7-11, 8-11, 9-11, 10-11, 11-11, 12-11 -// ] - // Tests that all physical coordinates are same as all virtual coordinates // when there is no harvesting. TEST(SocDescriptor, SocDescriptorGSNoHarvesting) { @@ -172,4 +157,4 @@ TEST(CoordinateManager, CoordinateManagerGSDRAMNoHarvesting) { EXPECT_EQ(dram_physical, expected_physical); } -} \ No newline at end of file +} diff --git a/tests/api/test_core_coord_translation_wh.cpp b/tests/api/test_core_coord_translation_wh.cpp index 657662bd..085c32b7 100644 --- a/tests/api/test_core_coord_translation_wh.cpp +++ b/tests/api/test_core_coord_translation_wh.cpp @@ -10,21 +10,6 @@ #include "tests/test_utils/soc_desc_test_utils.hpp" #include "device/wormhole/wormhole_implementation.h" -// Wormhole workers - x-y annotation -// functional_workers: -// [ -// 1-1, 2-1, 3-1, 4-1, 6-1, 7-1, 8-1, 9-1, -// 1-2, 2-2, 3-2, 4-2, 6-2, 7-2, 8-2, 9-2, -// 1-3, 2-3, 3-3, 4-3, 6-3, 7-3, 8-3, 9-3, -// 1-4, 2-4, 3-4, 4-4, 6-4, 7-4, 8-4, 9-4, -// 1-5, 2-5, 3-5, 4-5, 6-5, 7-5, 8-5, 9-5, -// 1-7, 2-7, 3-7, 4-7, 6-7, 7-7, 8-7, 9-7, -// 1-8, 2-8, 3-8, 4-8, 6-8, 7-8, 8-8, 9-8, -// 1-9, 2-9, 3-9, 4-9, 6-9, 7-9, 8-9, 9-9, -// 1-10, 2-10, 3-10, 4-10, 6-10, 7-10, 8-10, 9-10, -// 1-11, 2-11, 3-11, 4-11, 6-11, 7-11, 8-11, 9-11, -// ] - // Tests that all physical coordinates are same as all virtual coordinates // when there is no harvesting. TEST(SocDescriptor, SocDescriptorWHNoHarvesting) { @@ -48,9 +33,9 @@ TEST(SocDescriptor, SocDescriptorWHNoHarvesting) { } } -// // Test basic translation to virtual and physical noc coordinates. -// // We expect that the top left core will have virtual and physical coordinates (1, 1) and (1, 2) for -// // the logical coordinates if the first row is harvested. +// Test basic translation to virtual and physical noc coordinates. +// We expect that the top left core will have virtual and physical coordinates (1, 1) and (1, 2) for +// the logical coordinates if the first row is harvested. TEST(SocDescriptor, SocDescriptorWHTopLeftCore) { const std::size_t harvesting_mask = 1; @@ -69,9 +54,9 @@ TEST(SocDescriptor, SocDescriptorWHTopLeftCore) { EXPECT_EQ(physical_cords, CoreCoord(1, 2, CoreType::TENSIX, CoordSystem::PHYSICAL)); } -// // Test logical to physical coordinate translation. -// // For the full grid of logical coordinates we expect that there are no duplicates of physical coordinates. -// // For the reverse mapping back of physical to logical coordinates we expect that same logical coordinates are returned as from original mapping. +// Test logical to physical coordinate translation. +// For the full grid of logical coordinates we expect that there are no duplicates of physical coordinates. +// For the reverse mapping back of physical to logical coordinates we expect that same logical coordinates are returned as from original mapping. TEST(SocDescriptor, SocDescriptorWHLogicalPhysicalMapping) { const std::size_t max_num_harvested_y = 10; @@ -112,9 +97,9 @@ TEST(SocDescriptor, SocDescriptorWHLogicalPhysicalMapping) { } } -// // Test logical to virtual coordinate translation. -// // For the full grid of logical coordinates we expect that there are no duplicates of virtual coordinates. -// // For the reverse mapping back of virtual to logical coordinates we expect that same logical coordinates are returned as from original mapping. +// Test logical to virtual coordinate translation. +// For the full grid of logical coordinates we expect that there are no duplicates of virtual coordinates. +// For the reverse mapping back of virtual to logical coordinates we expect that same logical coordinates are returned as from original mapping. TEST(SocDescriptor, SocDescriptorWHLogicalVirtualMapping) { const std::size_t max_num_harvested_y = 10; @@ -152,7 +137,7 @@ TEST(SocDescriptor, SocDescriptorWHLogicalVirtualMapping) { } } -// // Test top left corner translation from logical to translated coordinates. +// Test top left corner translation from logical to translated coordinates. TEST(SocDescriptor, SocDescriptorWHLogicalTranslatedTopLeft) { const std::size_t translated_x_start = 18;