Skip to content

Commit

Permalink
fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
broskoTT committed Dec 5, 2024
1 parent cc3c180 commit 73d5507
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 56 deletions.
7 changes: 3 additions & 4 deletions device/api/umd/device/tt_cluster_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class tt_ClusterDescriptor {
std::unordered_map<chip_id_t, chip_id_t> closest_mmio_chip_cache = {};
std::unordered_map<chip_id_t, BoardType> chip_board_type = {};
std::unordered_map<chip_id_t, std::unordered_set<chip_id_t>> chips_grouped_by_closest_mmio;
std::unordered_map<chip_id_t, tt::ARCH> chip_arch = {};
std::unordered_map<chip_id_t, tt::Arch> chip_arch = {};

// one-to-many chip connections
struct Chip2ChipConnection {
Expand All @@ -78,7 +78,6 @@ class tt_ClusterDescriptor {
static void load_harvesting_information(YAML::Node &yaml, tt_ClusterDescriptor &desc);

void fill_chips_grouped_by_closest_mmio();
static tt::ARCH arch_from_string(std::string arch_str);

public:
/*
Expand All @@ -98,7 +97,7 @@ class tt_ClusterDescriptor {
static std::string get_cluster_descriptor_file_path();
static std::unique_ptr<tt_ClusterDescriptor> create_from_yaml(const std::string &cluster_descriptor_file_path);
static std::unique_ptr<tt_ClusterDescriptor> create();
static tt::ARCH detect_arch(const chip_id_t chip_id);
static tt::Arch detect_arch(const chip_id_t chip_id);

// This function is used to create mock cluster descriptor yaml files, for example for simulation.
static std::unique_ptr<tt_ClusterDescriptor> create_mock_cluster(
Expand All @@ -118,7 +117,7 @@ class tt_ClusterDescriptor {
int get_ethernet_link_distance(chip_id_t chip_a, chip_id_t chip_b) const;

BoardType get_board_type(chip_id_t chip_id) const;
tt::ARCH get_arch(chip_id_t chip_id) const;
tt::Arch get_arch(chip_id_t chip_id) const;

bool ethernet_core_has_active_ethernet_link(chip_id_t local_chip, ethernet_channel_t local_ethernet_channel) const;
std::tuple<chip_id_t, ethernet_channel_t> get_chip_and_channel_of_remote_ethernet_core(
Expand Down
19 changes: 3 additions & 16 deletions device/tt_cluster_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ void tt_ClusterDescriptor::load_chips_from_connectivity_descriptor(YAML::Node &y
chip_id_t chip_id = node->first.as<int>();
std::string arch_str = node->second.as<std::string>();
desc.all_chips.insert(chip_id);
desc.chip_arch.insert({chip_id, arch_from_string(arch_str)});
desc.chip_arch.insert({chip_id, tt::arch_from_str(arch_str)});
}

for (YAML::const_iterator node = yaml["chips"].begin(); node != yaml["chips"].end(); ++node) {
Expand Down Expand Up @@ -784,19 +784,6 @@ void tt_ClusterDescriptor::fill_chips_grouped_by_closest_mmio() {
}
}

tt::ARCH tt_ClusterDescriptor::arch_from_string(std::string arch_str) {
if (arch_str == "Grayskull") {
return tt::ARCH::GRAYSKULL;
}
if (arch_str == "Wormhole") {
return tt::ARCH::WORMHOLE_B0;
}
if (arch_str == "Blackhole") {
return tt::ARCH::BLACKHOLE;
}
return tt::ARCH::Invalid;
}

const std::unordered_map<chip_id_t, std::unordered_map<ethernet_channel_t, std::tuple<chip_id_t, ethernet_channel_t>>>
tt_ClusterDescriptor::get_ethernet_connections() const {
auto eth_connections = std::
Expand Down Expand Up @@ -879,15 +866,15 @@ BoardType tt_ClusterDescriptor::get_board_type(chip_id_t chip_id) const {
return chip_board_type.at(chip_id);
}

tt::ARCH tt_ClusterDescriptor::get_arch(chip_id_t chip_id) const {
tt::Arch tt_ClusterDescriptor::get_arch(chip_id_t chip_id) const {
log_assert(
chip_arch.find(chip_id) != chip_arch.end(),
"Chip {} does not have an architecture in the cluster descriptor",
chip_id);
return chip_arch.at(chip_id);
}

/* static */ tt::ARCH tt_ClusterDescriptor::detect_arch(chip_id_t chip_id) {
/* static */ tt::Arch tt_ClusterDescriptor::detect_arch(chip_id_t chip_id) {
return tt_ClusterDescriptor::create()->get_arch(chip_id);
}

Expand Down
30 changes: 15 additions & 15 deletions tests/api/test_core_coord_translation_bh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using namespace tt::umd;
// when there is no harvesting.
TEST(CoordinateManager, CoordinateManagerBlackholeNoHarvesting) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE);

// We expect full grid size since there is no harvesting.
tt_xy_pair tensix_grid_size = tt::umd::blackhole::TENSIX_GRID_SIZE;
Expand All @@ -35,7 +35,7 @@ TEST(CoordinateManager, CoordinateManagerBlackholeNoHarvesting) {
// the logical coordinates if the first row is harvested.
TEST(CoordinateManager, CoordinateManagerBlackholeTopLeftCore) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE, 1);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE, 1);
tt_xy_pair tensix_grid_size = tt::umd::blackhole::TENSIX_GRID_SIZE;

CoreCoord logical_coords = CoreCoord(0, 0, CoreType::TENSIX, CoordSystem::LOGICAL);
Expand All @@ -58,7 +58,7 @@ TEST(CoordinateManager, CoordinateManagerBlackholeLogicalPhysicalMapping) {

for (size_t harvesting_mask = 0; harvesting_mask < (1 << max_num_harvested_x); harvesting_mask++) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE, harvesting_mask);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE, harvesting_mask);

std::map<CoreCoord, CoreCoord> logical_to_physical;
std::set<CoreCoord> physical_coords_set;
Expand Down Expand Up @@ -100,7 +100,7 @@ TEST(CoordinateManager, CoordinateManagerBlackholeLogicalVirtualMapping) {

for (size_t harvesting_mask = 0; harvesting_mask < (1 << max_num_harvested_x); harvesting_mask++) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE, harvesting_mask);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE, harvesting_mask);

std::map<CoreCoord, CoreCoord> logical_to_virtual;
std::set<CoreCoord> virtual_coords_set;
Expand Down Expand Up @@ -142,7 +142,7 @@ TEST(CoordinateManager, CoordinateManagerBlackholeLogicalTranslatedMapping) {

for (size_t harvesting_mask = 0; harvesting_mask < (1 << max_num_harvested_x); harvesting_mask++) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE, harvesting_mask);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE, harvesting_mask);

std::map<CoreCoord, CoreCoord> logical_to_translated;
std::set<CoreCoord> translated_coords_set;
Expand Down Expand Up @@ -183,7 +183,7 @@ TEST(CoordinateManager, CoordinateManagerBlackholeVirtualEqualTranslated) {

for (size_t harvesting_mask = 0; harvesting_mask < (1 << max_num_harvested_x); harvesting_mask++) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE, harvesting_mask);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE, harvesting_mask);

size_t num_harvested_x = CoordinateManager::get_num_harvested(harvesting_mask);

Expand All @@ -205,7 +205,7 @@ TEST(CoordinateManager, CoordinateManagerBlackholeVirtualEqualTranslated) {
// coordinates should cover all physical coordinates.
TEST(CoordinateManager, CoordinateManagerBlackholeDRAMNoHarvesting) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE);

const size_t num_dram_banks = tt::umd::blackhole::NUM_DRAM_BANKS;
const size_t num_noc_ports_per_bank = tt::umd::blackhole::NUM_NOC_PORTS_PER_DRAM_BANK;
Expand All @@ -231,7 +231,7 @@ TEST(CoordinateManager, CoordinateManagerBlackholeDRAMNoHarvesting) {
// Test top left corner translation from logical to physical coordinates.
TEST(CoordinateManager, CoordinateManagerBlackholeDRAMTopLeft) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE, 0, 1);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE, 0, 1);

const CoreCoord top_left_dram_logical = CoreCoord(0, 0, CoreType::DRAM, CoordSystem::LOGICAL);
const CoreCoord expected_top_left_physical = CoreCoord(0, 2, CoreType::DRAM, CoordSystem::PHYSICAL);
Expand All @@ -257,7 +257,7 @@ TEST(CoordinateManager, CoordinateManagerBlackholeDRAMLogicalPhysicalMapping) {
}

std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE, 0, harvesting_mask);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE, 0, harvesting_mask);

std::map<CoreCoord, CoreCoord> logical_to_physical;
std::set<CoreCoord> physical_coords_set;
Expand Down Expand Up @@ -304,7 +304,7 @@ TEST(CoordinateManager, CoordinateManagerBlackholeDRAMLogicalVirtualMapping) {
}

std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE, 0, harvesting_mask);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE, 0, harvesting_mask);

std::map<CoreCoord, CoreCoord> logical_to_virtual;
std::set<CoreCoord> virtual_coords_set;
Expand Down Expand Up @@ -346,7 +346,7 @@ TEST(CoordinateManager, CoordinateManagerBlackholeDRAMTranslatedMapping) {
}

std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE, 0, harvesting_mask);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE, 0, harvesting_mask);

std::map<CoreCoord, CoreCoord> logical_to_translated;
std::set<CoreCoord> translated_coord_set;
Expand Down Expand Up @@ -393,14 +393,14 @@ TEST(CoordinateManager, CoordinateManagerBlackholeDRAMPMoreThanOneDRAMBankHarves
}

EXPECT_THROW(
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE, 0, harvesting_mask), std::runtime_error);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE, 0, harvesting_mask), std::runtime_error);
}
}

// Test that virtual, physical and translated coordinates are the same for all logical PCIE coordinates.
TEST(CoordinateManager, CoordinateManagerBlackholePCIETranslation) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE);
const tt_xy_pair pcie_grid_size = tt::umd::blackhole::PCIE_GRID_SIZE;

for (size_t x = 0; x < pcie_grid_size.x; x++) {
Expand All @@ -418,7 +418,7 @@ TEST(CoordinateManager, CoordinateManagerBlackholePCIETranslation) {
// Test that virtual, physical and translated coordinates are the same for all logical ARC coordinates.
TEST(CoordinateManager, CoordinateManagerBlackholeARCTranslation) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE);
const tt_xy_pair arc_grid_size = tt::umd::blackhole::ARC_GRID_SIZE;

for (size_t x = 0; x < arc_grid_size.x; x++) {
Expand All @@ -440,7 +440,7 @@ TEST(CoordinateManager, CoordinateManagerBlackholeARCTranslation) {
// Test ethernet coordinate translation.
TEST(CoordinateManager, CoordinateManagerBlackholeETHTranslation) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::BLACKHOLE);
CoordinateManager::create_coordinate_manager(tt::Arch::BLACKHOLE);
const tt_xy_pair eth_grid_size = tt::umd::blackhole::ETH_GRID_SIZE;

const size_t eth_translated_coordinate_start_x = 20;
Expand Down
20 changes: 10 additions & 10 deletions tests/api/test_core_coord_translation_gs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using namespace tt::umd;
// when there is no harvesting.
TEST(CoordinateManager, CoordinateManagerGrayskullNoHarvesting) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::GRAYSKULL);
CoordinateManager::create_coordinate_manager(tt::Arch::GRAYSKULL);

// We expect full grid size since there is no harvesting.
tt_xy_pair tensix_grid_size = tt::umd::grayskull::TENSIX_GRID_SIZE;
Expand All @@ -35,7 +35,7 @@ TEST(CoordinateManager, CoordinateManagerGrayskullNoHarvesting) {
// the logical coordinates if the first row is harvested.
TEST(CoordinateManager, CoordinateManagerGrayskullTopLeftCore) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::GRAYSKULL);
CoordinateManager::create_coordinate_manager(tt::Arch::GRAYSKULL);

CoreCoord logical_coords = CoreCoord(0, 0, CoreType::TENSIX, CoordSystem::LOGICAL);

Expand All @@ -53,7 +53,7 @@ TEST(CoordinateManager, CoordinateManagerGrayskullTopLeftCore) {
// the logical coordinates if the first row is harvested.
TEST(CoordinateManager, CoordinateManagerGrayskullTopLeftCoreHarvesting) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::GRAYSKULL, 1);
CoordinateManager::create_coordinate_manager(tt::Arch::GRAYSKULL, 1);

CoreCoord logical_coords = CoreCoord(0, 0, CoreType::TENSIX, CoordSystem::LOGICAL);

Expand All @@ -70,7 +70,7 @@ TEST(CoordinateManager, CoordinateManagerGrayskullTopLeftCoreHarvesting) {
// We always expect that physical, virtual and translated coordinates are the same.
TEST(CoordinateManager, CoordinateManagerGrayskullTranslatingCoords) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::GRAYSKULL);
CoordinateManager::create_coordinate_manager(tt::Arch::GRAYSKULL);
tt_xy_pair tensix_grid_size = tt::umd::grayskull::TENSIX_GRID_SIZE;

for (size_t x = 0; x < tensix_grid_size.x; x++) {
Expand Down Expand Up @@ -100,7 +100,7 @@ TEST(CoordinateManager, CoordinateManagerGrayskullLogicalPhysicalMapping) {

for (size_t harvesting_mask = 0; harvesting_mask < (1 << max_num_harvested_y); harvesting_mask++) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::GRAYSKULL, harvesting_mask);
CoordinateManager::create_coordinate_manager(tt::Arch::GRAYSKULL, harvesting_mask);

std::map<CoreCoord, CoreCoord> logical_to_physical;
std::set<CoreCoord> physical_coords_set;
Expand Down Expand Up @@ -144,7 +144,7 @@ TEST(CoordinateManager, CoordinateManagerGrayskullLogicalVirtualMapping) {

for (size_t harvesting_mask = 0; harvesting_mask < (1 << max_num_harvested_y); harvesting_mask++) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::GRAYSKULL, harvesting_mask);
CoordinateManager::create_coordinate_manager(tt::Arch::GRAYSKULL, harvesting_mask);

std::map<CoreCoord, CoreCoord> logical_to_virtual;
std::set<CoreCoord> virtual_coords_set;
Expand Down Expand Up @@ -178,7 +178,7 @@ TEST(CoordinateManager, CoordinateManagerGrayskullLogicalVirtualMapping) {
// so logical coordinates should cover all physical coordinates.
TEST(CoordinateManager, CoordinateManagerGrayskullDRAMNoHarvesting) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::GRAYSKULL);
CoordinateManager::create_coordinate_manager(tt::Arch::GRAYSKULL);

const size_t num_dram_banks = tt::umd::grayskull::NUM_DRAM_BANKS;
const std::vector<tt_xy_pair>& dram_cores = tt::umd::grayskull::DRAM_CORES;
Expand All @@ -197,7 +197,7 @@ TEST(CoordinateManager, CoordinateManagerGrayskullDRAMNoHarvesting) {
// Test that virtual, physical and translated coordinates are the same for all logical PCIE coordinates.
TEST(CoordinateManager, CoordinateManagerGrayskullPCIETranslation) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::GRAYSKULL);
CoordinateManager::create_coordinate_manager(tt::Arch::GRAYSKULL);
const tt_xy_pair pcie_grid_size = tt::umd::grayskull::PCIE_GRID_SIZE;

for (size_t x = 0; x < pcie_grid_size.x; x++) {
Expand All @@ -219,7 +219,7 @@ TEST(CoordinateManager, CoordinateManagerGrayskullPCIETranslation) {
// Test that virtual, physical and translated coordinates are the same for all logical ARC coordinates.
TEST(CoordinateManager, CoordinateManagerGrayskullARCTranslation) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::GRAYSKULL);
CoordinateManager::create_coordinate_manager(tt::Arch::GRAYSKULL);
const tt_xy_pair arc_grid_size = tt::umd::grayskull::ARC_GRID_SIZE;

for (size_t x = 0; x < arc_grid_size.x; x++) {
Expand All @@ -240,5 +240,5 @@ TEST(CoordinateManager, CoordinateManagerGrayskullARCTranslation) {

// Test that we assert properly if DRAM harvesting mask is non-zero for Grayskull.
TEST(CoordinateManager, CoordinateManagerGrayskullDRAMHarvestingAssert) {
EXPECT_THROW(CoordinateManager::create_coordinate_manager(tt::ARCH::GRAYSKULL, 0, 1), std::runtime_error);
EXPECT_THROW(CoordinateManager::create_coordinate_manager(tt::Arch::GRAYSKULL, 0, 1), std::runtime_error);
}
Loading

0 comments on commit 73d5507

Please sign in to comment.