diff --git a/device/api/umd/device/blackhole_implementation.h b/device/api/umd/device/blackhole_implementation.h index 1e0884b8..73505e19 100644 --- a/device/api/umd/device/blackhole_implementation.h +++ b/device/api/umd/device/blackhole_implementation.h @@ -113,7 +113,7 @@ static const std::vector ETH_LOCATIONS = ETH_CORES; // Return to std::array instead of std::vector once we get std::span support in C++20 static const std::vector T6_X_LOCATIONS = {1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16}; static const std::vector T6_Y_LOCATIONS = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; -static const std::vector HARVESTING_NOC_LOCATIONS = {}; +static const std::vector HARVESTING_NOC_LOCATIONS = {1, 16, 2, 15, 3, 14, 4, 13, 5, 12, 6, 11, 7, 10}; static constexpr uint32_t STATIC_TLB_SIZE = 1024 * 1024; // TODO: Copied from wormhole. Need to verify. diff --git a/device/api/umd/device/coordinate_manager.h b/device/api/umd/device/coordinate_manager.h index 438cbd7a..7da28afa 100644 --- a/device/api/umd/device/coordinate_manager.h +++ b/device/api/umd/device/coordinate_manager.h @@ -68,6 +68,8 @@ class CoordinateManager { const tt::ARCH arch, const size_t tensix_harvesting_mask, const size_t dram_harvesting_mask); protected: + virtual void shuffle_tensix_harvesting_mask(const std::vector& harvesting_locations); + virtual void translate_tensix_coords(); virtual void translate_dram_coords(); virtual void translate_eth_coords(); diff --git a/device/blackhole/blackhole_coordinate_manager.cpp b/device/blackhole/blackhole_coordinate_manager.cpp index 6ff3de50..c331a49c 100644 --- a/device/blackhole/blackhole_coordinate_manager.cpp +++ b/device/blackhole/blackhole_coordinate_manager.cpp @@ -33,6 +33,7 @@ BlackholeCoordinateManager::BlackholeCoordinateManager( arc_cores, pcie_grid_size, pcie_cores) { + this->shuffle_tensix_harvesting_mask(blackhole::HARVESTING_NOC_LOCATIONS); this->translate_tensix_coords(); this->translate_dram_coords(); this->translate_eth_coords(); diff --git a/device/coordinate_manager.cpp b/device/coordinate_manager.cpp index 01bba5c6..26b48ae2 100644 --- a/device/coordinate_manager.cpp +++ b/device/coordinate_manager.cpp @@ -405,6 +405,26 @@ void CoordinateManager::assert_create_coordinate_manager( } } +void CoordinateManager::shuffle_tensix_harvesting_mask(const std::vector& harvesting_locations) { + std::vector sorted_harvesting_locations = harvesting_locations; + std::sort(sorted_harvesting_locations.begin(), sorted_harvesting_locations.end()); + size_t new_harvesting_mask = 0; + uint32_t pos = 0; + while (tensix_harvesting_mask > 0) { + if (tensix_harvesting_mask & 1) { + uint32_t sorted_position = + std::find( + sorted_harvesting_locations.begin(), sorted_harvesting_locations.end(), harvesting_locations[pos]) - + sorted_harvesting_locations.begin(); + new_harvesting_mask |= (1 << sorted_position); + } + tensix_harvesting_mask >>= 1; + pos++; + } + + tensix_harvesting_mask = new_harvesting_mask; +} + std::shared_ptr CoordinateManager::create_coordinate_manager( tt::ARCH arch, const size_t tensix_harvesting_mask, const size_t dram_harvesting_mask) { assert_create_coordinate_manager(arch, tensix_harvesting_mask, dram_harvesting_mask); diff --git a/device/grayskull/grayskull_coordinate_manager.cpp b/device/grayskull/grayskull_coordinate_manager.cpp index 3232717f..328d3718 100644 --- a/device/grayskull/grayskull_coordinate_manager.cpp +++ b/device/grayskull/grayskull_coordinate_manager.cpp @@ -33,6 +33,7 @@ GrayskullCoordinateManager::GrayskullCoordinateManager( arc_cores, pcie_grid_size, pcie_cores) { + this->shuffle_tensix_harvesting_mask(grayskull::HARVESTING_NOC_LOCATIONS); this->translate_tensix_coords(); this->translate_dram_coords(); this->translate_eth_coords(); diff --git a/device/wormhole/wormhole_coordinate_manager.cpp b/device/wormhole/wormhole_coordinate_manager.cpp index 4ba6dc52..b94c36fe 100644 --- a/device/wormhole/wormhole_coordinate_manager.cpp +++ b/device/wormhole/wormhole_coordinate_manager.cpp @@ -33,6 +33,7 @@ WormholeCoordinateManager::WormholeCoordinateManager( arc_cores, pcie_grid_size, pcie_cores) { + this->shuffle_tensix_harvesting_mask(wormhole::HARVESTING_NOC_LOCATIONS); this->translate_tensix_coords(); this->translate_dram_coords(); this->translate_eth_coords(); diff --git a/tests/api/test_core_coord_translation_bh.cpp b/tests/api/test_core_coord_translation_bh.cpp index 95cbe155..56d90b2d 100644 --- a/tests/api/test_core_coord_translation_bh.cpp +++ b/tests/api/test_core_coord_translation_bh.cpp @@ -34,8 +34,10 @@ TEST(CoordinateManager, CoordinateManagerBlackholeNoHarvesting) { // 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(CoordinateManager, CoordinateManagerBlackholeTopLeftCore) { + // This is targeting first row of Tensix cores on NOC layout. + const size_t harvesting_mask = (1 << 0); std::shared_ptr coordinate_manager = - CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE, 1); + CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE, harvesting_mask); tt_xy_pair tensix_grid_size = tt::umd::blackhole::TENSIX_GRID_SIZE; CoreCoord logical_coords = CoreCoord(0, 0, CoreType::TENSIX, CoordSystem::LOGICAL); diff --git a/tests/api/test_core_coord_translation_gs.cpp b/tests/api/test_core_coord_translation_gs.cpp index 233cb9e3..d2e804d7 100644 --- a/tests/api/test_core_coord_translation_gs.cpp +++ b/tests/api/test_core_coord_translation_gs.cpp @@ -52,8 +52,10 @@ TEST(CoordinateManager, CoordinateManagerGrayskullTopLeftCore) { // 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(CoordinateManager, CoordinateManagerGrayskullTopLeftCoreHarvesting) { + // This is targeting first row of Tensix cores on NOC layout. + const size_t harvesting_mask = (1 << 8); std::shared_ptr coordinate_manager = - CoordinateManager::create_coordinate_manager(tt::ARCH::GRAYSKULL, 1); + CoordinateManager::create_coordinate_manager(tt::ARCH::GRAYSKULL, harvesting_mask); CoreCoord logical_coords = CoreCoord(0, 0, CoreType::TENSIX, CoordSystem::LOGICAL); diff --git a/tests/api/test_core_coord_translation_wh.cpp b/tests/api/test_core_coord_translation_wh.cpp index d19539a8..2fa900de 100644 --- a/tests/api/test_core_coord_translation_wh.cpp +++ b/tests/api/test_core_coord_translation_wh.cpp @@ -36,7 +36,8 @@ TEST(CoordinateManager, CoordinateManagerWormholeNoHarvesting) { // 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(CoordinateManager, CoordinateManagerWormholeTopLeftCore) { - const size_t harvesting_mask = 1; + // This harvesting mask if targeting first row in NOC layout. + const size_t harvesting_mask = (1 << 1); std::shared_ptr coordinate_manager = CoordinateManager::create_coordinate_manager(tt::ARCH::WORMHOLE_B0, harvesting_mask);