-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement CoreCoord struct and translation
- Loading branch information
1 parent
71f8fd6
commit a179222
Showing
24 changed files
with
1,868 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,96 @@ | ||
/* | ||
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc. | ||
* SPDX-FileCopyrightText: (c) 2024 Tenstorrent Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include "blackhole_coordinate_manager.h" | ||
#include <iostream> | ||
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<std::size_t> BlackholeCoordinateManager::get_x_coordinates_to_harvest(std::size_t harvesting_mask) { | ||
std::set<std::size_t> 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++; | ||
} | ||
} | ||
|
||
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; | ||
|
||
BlackholeCoordinateManager::fill_tensix_logical_to_translated(); | ||
} | ||
|
||
tt_translated_coords BlackholeCoordinateManager::to_translated_coords(tt_logical_coords logical_coords) { | ||
tt_virtual_coords virtual_coords = to_virtual_coords(logical_coords); | ||
return tt_translated_coords(virtual_coords.x, virtual_coords.y); | ||
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; | ||
|
||
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[{translated_x, translated_y}] = CoreCoord(x, y, CoreType::TENSIX, CoordSystem::LOGICAL); | ||
} | ||
} | ||
} | ||
|
||
void BlackholeCoordinateManager::dram_harvesting(const std::size_t 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 - num_harvested_banks; x++) { | ||
for (std::size_t y = 0; y < dram_grid_size.y; 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); | ||
} | ||
} | ||
|
||
std::size_t logical_x = 0; | ||
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++) { | ||
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++; | ||
} | ||
} | ||
} | ||
|
||
void BlackholeCoordinateManager::fill_eth_logical_to_translated() { | ||
for (size_t x = 0; x < CoordinateManager::eth_grid_size.x; x++) { | ||
for (size_t y = 0; y < CoordinateManager::eth_grid_size.y; y++) { | ||
const size_t translated_x = x + eth_translated_coordinate_start_x; | ||
const size_t translated_y = y + eth_translated_coordinate_start_y; | ||
CoordinateManager::eth_logical_to_translated[{x, y}] = CoreCoord(translated_x, translated_y, CoreType::ETH, CoordSystem::TRANSLATED); | ||
CoordinateManager::eth_translated_to_logical[{translated_x, translated_y}] = CoreCoord(x, y, CoreType::ETH, CoordSystem::LOGICAL); | ||
} | ||
} | ||
} | ||
|
||
tt_logical_coords BlackholeCoordinateManager::to_logical_coords(tt_translated_coords translated_coords) { | ||
tt_virtual_coords virtual_coords = tt_virtual_coords(translated_coords.x, translated_coords.y); | ||
return CoordinateManager::to_logical_coords(virtual_coords); | ||
void BlackholeCoordinateManager::fill_pcie_logical_to_translated() { | ||
CoordinateManager::pcie_logical_to_translated[{0, 0}] = CoreCoord(pcie_translated_coordinate_start_x, pcie_translated_coordinate_start_y, CoreType::PCIE, CoordSystem::TRANSLATED); | ||
CoordinateManager::pcie_translated_to_logical[{pcie_translated_coordinate_start_x, pcie_translated_coordinate_start_y}] = CoreCoord(0, 0, CoreType::PCIE, CoordSystem::LOGICAL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,52 @@ | ||
/* | ||
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc. | ||
* SPDX-FileCopyrightText: (c) 2024 Tenstorrent Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "blackhole_implementation.h" | ||
#include "device/coordinate_manager.h" | ||
#include "device/blackhole/blackhole_implementation.h" | ||
|
||
class BlackholeCoordinateManager : public CoordinateManager { | ||
public: | ||
BlackholeCoordinateManager( | ||
const tt_xy_pair& worker_grid_size, const std::vector<tt_xy_pair>& workers, std::size_t harvesting_mask) : | ||
CoordinateManager(worker_grid_size, workers, harvesting_mask) {} | ||
const tt_xy_pair& tensix_grid_size, const std::vector<tt_xy_pair>& tensix_cores, const std::size_t tensix_harvesting_mask, | ||
const tt_xy_pair& dram_grid_size, const std::vector<tt_xy_pair>& dram_cores, const std::size_t dram_harvesting_mask, | ||
const tt_xy_pair& eth_grid_size, const std::vector<tt_xy_pair>& eth_cores, | ||
const tt_xy_pair& arc_grid_size, const std::vector<tt_xy_pair>& arc_cores, | ||
const tt_xy_pair& pcie_grid_size, const std::vector<tt_xy_pair>& pcie_cores) | ||
: CoordinateManager( | ||
tensix_grid_size, tensix_cores, tensix_harvesting_mask, | ||
dram_grid_size, dram_cores, dram_harvesting_mask, | ||
eth_grid_size, eth_cores, | ||
arc_grid_size, arc_cores, | ||
pcie_grid_size, pcie_cores) | ||
{ | ||
this->tensix_harvesting(tensix_harvesting_mask); | ||
this->dram_harvesting(dram_harvesting_mask); | ||
this->translate_eth_coords(); | ||
this->translate_arc_coords(); | ||
this->translate_pcie_coords(); | ||
} | ||
|
||
tt_translated_coords to_translated_coords(tt_logical_coords logical_coords) override; | ||
void dram_harvesting(const std::size_t dram_harvesting_mask) override; | ||
|
||
tt_logical_coords to_logical_coords(tt_translated_coords translated_coords) override; | ||
void tensix_harvesting(const std::size_t tensix_harvesting_mask) override; | ||
|
||
protected: | ||
std::set<std::size_t> get_x_coordinates_to_harvest(std::size_t harvesting_mask) override; | ||
void fill_tensix_logical_to_translated() override; | ||
|
||
void fill_eth_logical_to_translated() override; | ||
|
||
void fill_pcie_logical_to_translated() override; | ||
|
||
private: | ||
static const std::size_t eth_translated_coordinate_start_x = 20; | ||
static const std::size_t eth_translated_coordinate_start_y = 25; | ||
|
||
static const size_t pcie_translated_coordinate_start_x = 19; | ||
static const size_t pcie_translated_coordinate_start_y = 24; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.