Skip to content

Commit

Permalink
Harvesting mask NOC layout
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanevskiTT committed Dec 4, 2024
1 parent 1d8c9dd commit 7acb0a9
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion device/api/umd/device/blackhole_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static const std::vector<tt_xy_pair> 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<uint32_t> T6_X_LOCATIONS = {1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16};
static const std::vector<uint32_t> T6_Y_LOCATIONS = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
static const std::vector<uint32_t> HARVESTING_NOC_LOCATIONS = {};
static const std::vector<uint32_t> 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.

Expand Down
2 changes: 2 additions & 0 deletions device/api/umd/device/coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>& harvesting_locations);

virtual void translate_tensix_coords();
virtual void translate_dram_coords();
virtual void translate_eth_coords();
Expand Down
1 change: 1 addition & 0 deletions device/blackhole/blackhole_coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 20 additions & 0 deletions device/coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,26 @@ void CoordinateManager::assert_create_coordinate_manager(
}
}

void CoordinateManager::shuffle_tensix_harvesting_mask(const std::vector<uint32_t>& harvesting_locations) {
std::vector<uint32_t> 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> 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);
Expand Down
1 change: 1 addition & 0 deletions device/grayskull/grayskull_coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions device/wormhole/wormhole_coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion tests/api/test_core_coord_translation_bh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CoordinateManager> 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);
Expand Down
4 changes: 3 additions & 1 deletion tests/api/test_core_coord_translation_gs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CoordinateManager> 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);

Expand Down
3 changes: 2 additions & 1 deletion tests/api/test_core_coord_translation_wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::WORMHOLE_B0, harvesting_mask);
Expand Down

0 comments on commit 7acb0a9

Please sign in to comment.