From fd2ad89e56870e173aa539c7d5f126815d8bca8a Mon Sep 17 00:00:00 2001 From: pjanevski Date: Wed, 11 Dec 2024 14:37:16 +0000 Subject: [PATCH] Address comments --- device/api/umd/device/coordinate_manager.h | 6 +++++ .../blackhole_coordinate_manager.cpp | 14 ++--------- device/coordinate_manager.cpp | 25 ++++++++++++++++--- .../grayskull_coordinate_manager.cpp | 9 +------ .../wormhole/wormhole_coordinate_manager.cpp | 9 +------ 5 files changed, 31 insertions(+), 32 deletions(-) diff --git a/device/api/umd/device/coordinate_manager.h b/device/api/umd/device/coordinate_manager.h index b961c7f8..6b8bd697 100644 --- a/device/api/umd/device/coordinate_manager.h +++ b/device/api/umd/device/coordinate_manager.h @@ -42,6 +42,12 @@ class CoordinateManager { tt::umd::CoreCoord to(const tt::umd::CoreCoord core_coord, const CoordSystem coord_system); + /* + * Initializes CoreCoord mappings for all core types. + * Must be called before using Coordinate Manager object. + */ + void initialize(); + virtual ~CoordinateManager() = default; private: diff --git a/device/blackhole/blackhole_coordinate_manager.cpp b/device/blackhole/blackhole_coordinate_manager.cpp index 4b1d5a23..a5af486c 100644 --- a/device/blackhole/blackhole_coordinate_manager.cpp +++ b/device/blackhole/blackhole_coordinate_manager.cpp @@ -32,14 +32,7 @@ BlackholeCoordinateManager::BlackholeCoordinateManager( arc_grid_size, arc_cores, pcie_grid_size, - pcie_cores) { - this->identity_map_physical_cores(); - this->translate_tensix_coords(); - this->translate_dram_coords(); - this->translate_eth_coords(); - this->translate_arc_coords(); - this->translate_pcie_coords(); -} + pcie_cores) {} void BlackholeCoordinateManager::translate_tensix_coords() { size_t num_harvested_x = CoordinateManager::get_num_harvested(tensix_harvesting_mask); @@ -50,17 +43,14 @@ void BlackholeCoordinateManager::translate_tensix_coords() { size_t x_index = grid_size_x - num_harvested_x; for (size_t x = 0; x < grid_size_x; x++) { if (tensix_harvesting_mask & (1 << x)) { - size_t y_index = 0; for (size_t y = 0; y < grid_size_y; y++) { const tt_xy_pair& physical_core = tensix_cores[x + y * grid_size_x]; - const tt_xy_pair& virtual_core = tensix_cores[x_index + y_index * grid_size_x]; + const tt_xy_pair& virtual_core = tensix_cores[x_index + y * grid_size_x]; CoreCoord virtual_coord = CoreCoord(virtual_core.x, virtual_core.y, CoreType::TENSIX, CoordSystem::VIRTUAL); add_core_translation(virtual_coord, physical_core); - - y_index++; } x_index++; } else { diff --git a/device/coordinate_manager.cpp b/device/coordinate_manager.cpp index 98129a96..1558452f 100644 --- a/device/coordinate_manager.cpp +++ b/device/coordinate_manager.cpp @@ -38,6 +38,15 @@ CoordinateManager::CoordinateManager( pcie_grid_size(pcie_grid_size), pcie_cores(pcie_cores) {} +void CoordinateManager::initialize() { + this->identity_map_physical_cores(); + this->translate_tensix_coords(); + this->translate_dram_coords(); + this->translate_eth_coords(); + this->translate_arc_coords(); + this->translate_pcie_coords(); +} + void CoordinateManager::add_core_translation(const CoreCoord& core_coord, const tt_xy_pair& physical_pair) { to_physical_map.insert({core_coord, physical_pair}); from_physical_map.insert({{{physical_pair.x, physical_pair.y}, core_coord.coord_system}, core_coord}); @@ -108,7 +117,7 @@ void CoordinateManager::translate_tensix_coords() { } } - fill_tensix_physical_translated_mapping(); + this->fill_tensix_physical_translated_mapping(); } void CoordinateManager::fill_tensix_physical_translated_mapping() { @@ -351,9 +360,11 @@ std::shared_ptr CoordinateManager::create_coordinate_manager( const std::vector& pcie_cores) { assert_create_coordinate_manager(arch, tensix_harvesting_mask, dram_harvesting_mask); + std::shared_ptr coord_manager; + switch (arch) { case tt::ARCH::GRAYSKULL: - return std::make_shared( + coord_manager = std::make_shared( tensix_grid_size, tensix_cores, tensix_harvesting_mask, @@ -366,8 +377,9 @@ std::shared_ptr CoordinateManager::create_coordinate_manager( arc_cores, pcie_grid_size, pcie_cores); + break; case tt::ARCH::WORMHOLE_B0: - return std::make_shared( + coord_manager = std::make_shared( tensix_grid_size, tensix_cores, tensix_harvesting_mask, @@ -380,8 +392,9 @@ std::shared_ptr CoordinateManager::create_coordinate_manager( arc_cores, pcie_grid_size, pcie_cores); + break; case tt::ARCH::BLACKHOLE: - return std::make_shared( + coord_manager = std::make_shared( tensix_grid_size, tensix_cores, tensix_harvesting_mask, @@ -394,11 +407,15 @@ std::shared_ptr CoordinateManager::create_coordinate_manager( arc_cores, pcie_grid_size, pcie_cores); + break; case tt::ARCH::Invalid: throw std::runtime_error("Invalid architecture for creating coordinate manager"); default: throw std::runtime_error("Unexpected ARCH value " + std::to_string((int)arch)); } + + coord_manager->initialize(); + return coord_manager; } size_t CoordinateManager::get_num_harvested(const size_t harvesting_mask) { diff --git a/device/grayskull/grayskull_coordinate_manager.cpp b/device/grayskull/grayskull_coordinate_manager.cpp index 9b1ab8da..aff1fe1e 100644 --- a/device/grayskull/grayskull_coordinate_manager.cpp +++ b/device/grayskull/grayskull_coordinate_manager.cpp @@ -32,14 +32,7 @@ GrayskullCoordinateManager::GrayskullCoordinateManager( arc_grid_size, arc_cores, pcie_grid_size, - pcie_cores) { - this->identity_map_physical_cores(); - this->translate_tensix_coords(); - this->translate_dram_coords(); - this->translate_eth_coords(); - this->translate_arc_coords(); - this->translate_pcie_coords(); -} + pcie_cores) {} void GrayskullCoordinateManager::fill_eth_physical_translated_mapping() { for (size_t x = 0; x < eth_grid_size.x; x++) { diff --git a/device/wormhole/wormhole_coordinate_manager.cpp b/device/wormhole/wormhole_coordinate_manager.cpp index d24fe624..3264c4ae 100644 --- a/device/wormhole/wormhole_coordinate_manager.cpp +++ b/device/wormhole/wormhole_coordinate_manager.cpp @@ -32,14 +32,7 @@ WormholeCoordinateManager::WormholeCoordinateManager( arc_grid_size, arc_cores, pcie_grid_size, - pcie_cores) { - this->identity_map_physical_cores(); - this->translate_tensix_coords(); - this->translate_dram_coords(); - this->translate_eth_coords(); - this->translate_arc_coords(); - this->translate_pcie_coords(); -} + pcie_cores) {} void WormholeCoordinateManager::fill_tensix_physical_translated_mapping() { size_t num_harvested_y = CoordinateManager::get_num_harvested(tensix_harvesting_mask);