Skip to content

Commit

Permalink
change remote to asic_location
Browse files Browse the repository at this point in the history
  • Loading branch information
broskoTT committed Feb 26, 2025
1 parent f5df1f8 commit a2c8cc0
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 19 deletions.
4 changes: 2 additions & 2 deletions device/api/umd/device/blackhole_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ static const size_t dram_translated_coordinate_start_y = 12;

/*
* Ge the PCIE core that can be used for communication with host
* based on the board type and whether the chip is remote or not.
* based on the board type and asic location of the chip.
* Information on remote chip is used only if the board type is P300.
*/
std::vector<tt_xy_pair> get_pcie_cores(const BoardType board_type, const bool is_chip_remote);
std::vector<tt_xy_pair> get_pcie_cores(const BoardType board_type, const uint8_t asic_location);

} // namespace blackhole

Expand Down
2 changes: 1 addition & 1 deletion device/api/umd/device/coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CoordinateManager {
const bool noc_translation_enabled,
const tt::umd::HarvestingMasks harvesting_masks = {0, 0, 0},
const BoardType board_type = BoardType::UNKNOWN,
const bool is_chip_remote = false);
const uint8_t asic_location = 0);

static size_t get_num_harvested(const size_t harvesting_mask);
static std::vector<size_t> get_harvested_indices(const size_t harvesting_mask);
Expand Down
3 changes: 3 additions & 0 deletions device/api/umd/device/tt_cluster_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class tt_ClusterDescriptor {
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::map<ChipUID, chip_id_t> chip_uid_to_chip_id = {};
std::map<chip_id_t, ChipUID> chip_id_to_chip_uid = {};

// one-to-many chip connections
struct Chip2ChipConnection {
Expand Down Expand Up @@ -115,7 +116,9 @@ class tt_ClusterDescriptor {
BoardType get_board_type(chip_id_t chip_id) const;
tt::ARCH get_arch(chip_id_t chip_id) const;

void add_chip_uid(const chip_id_t chip_id, const ChipUID &chip_uid);
chip_id_t get_chip_id(const ChipUID &chip_uid) const;
const ChipUID &get_chip_uid(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
4 changes: 2 additions & 2 deletions device/api/umd/device/tt_soc_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class tt_SocDescriptor {
const bool noc_translation_enabled,
const tt::umd::HarvestingMasks harvesting_masks = {0, 0, 0},
const BoardType board_type = BoardType::UNKNOWN,
const bool is_chip_remote = false);
const uint8_t asic_location = 0);

// CoreCoord conversions.
tt::umd::CoreCoord translate_coord_to(const tt::umd::CoreCoord core_coord, const CoordSystem coord_system) const;
Expand Down Expand Up @@ -130,7 +130,7 @@ class tt_SocDescriptor {
const bool noc_translation_enabled,
const tt::umd::HarvestingMasks harvesting_masks,
const BoardType board_type,
const bool is_chip_remote);
const uint8_t asic_location);
void load_core_descriptors_from_device_descriptor(YAML::Node &device_descriptor_yaml);
void load_soc_features_from_device_descriptor(YAML::Node &device_descriptor_yaml);
void get_cores_and_grid_size_from_coordinate_manager();
Expand Down
14 changes: 11 additions & 3 deletions device/api/umd/device/types/cluster_descriptor_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ enum BlackholeChipType : uint32_t {
Type2,
};

inline BlackholeChipType get_blackhole_chip_type(const BoardType board_type, const bool is_chip_remote) {
if (is_chip_remote) {
inline BlackholeChipType get_blackhole_chip_type(const BoardType board_type, const uint8_t asic_location) {
if (asic_location != 0) {
if (board_type != BoardType::P300) {
throw std::runtime_error("Remote chip is supported only for Blackhole P300 board.");
}
Expand All @@ -98,7 +98,15 @@ inline BlackholeChipType get_blackhole_chip_type(const BoardType board_type, con
case BoardType::P150:
return BlackholeChipType::Type2;
case BoardType::P300:
return is_chip_remote ? BlackholeChipType::Type1 : BlackholeChipType::Type2;
switch (asic_location) {
case 0:
return BlackholeChipType::Type2;
case 1:
return BlackholeChipType::Type1;
default:
throw std::runtime_error(
"Invalid asic location for Blackhole P300 board: " + std::to_string(asic_location));
}
default:
throw std::runtime_error("Invalid board type for Blackhole architecture.");
}
Expand Down
4 changes: 2 additions & 2 deletions device/blackhole/blackhole_implementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ tt_driver_noc_params blackhole_implementation::get_noc_params() const {
}

namespace blackhole {
std::vector<tt_xy_pair> get_pcie_cores(const BoardType board_type, const bool is_chip_remote) {
std::vector<tt_xy_pair> get_pcie_cores(const BoardType board_type, const uint8_t asic_location) {
// Default to type 1 chip.
if (board_type == BoardType::UNKNOWN) {
return PCIE_CORES_TYPE1;
}
auto chip_type = get_blackhole_chip_type(board_type, is_chip_remote);
auto chip_type = get_blackhole_chip_type(board_type, asic_location);
return chip_type == BlackholeChipType::Type1 ? PCIE_CORES_TYPE1 : PCIE_CORES_TYPE2;
}
} // namespace blackhole
Expand Down
6 changes: 3 additions & 3 deletions device/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,13 @@ std::unique_ptr<Chip> Cluster::construct_chip_from_cluster(
HarvestingMasks harvesting_masks =
get_harvesting_masks(chip_id, cluster_desc, perform_harvesting, simulated_harvesting_masks);
const BoardType chip_board_type = cluster_desc->get_board_type(chip_id);
bool is_chip_remote = cluster_desc->is_chip_remote(chip_id);
auto asic_location = cluster_desc->get_chip_uid(chip_id).asic_location;
tt_SocDescriptor soc_desc = tt_SocDescriptor(
soc_desc_path,
cluster_desc->get_noc_translation_table_en().at(chip_id),
harvesting_masks,
chip_board_type,
is_chip_remote);
asic_location);
return construct_chip_from_cluster(chip_id, cluster_desc, soc_desc, create_mock_chip);
}

Expand Down Expand Up @@ -3472,7 +3472,7 @@ std::unique_ptr<tt_ClusterDescriptor> Cluster::create_cluster_descriptor(
for (auto& it : chips) {
const chip_id_t chip_id = it.first;
const std::unique_ptr<Chip>& chip = it.second;
desc->chip_uid_to_chip_id.insert({chip->get_chip_info().chip_uid, it.first});
desc->add_chip_uid(chip_id, chip->get_chip_info().chip_uid);
}

for (auto& it : chips) {
Expand Down
4 changes: 2 additions & 2 deletions device/coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ std::shared_ptr<CoordinateManager> CoordinateManager::create_coordinate_manager(
const bool noc_translation_enabled,
const HarvestingMasks harvesting_masks,
const BoardType board_type,
bool is_chip_remote) {
uint8_t asic_location) {
switch (arch) {
case tt::ARCH::GRAYSKULL:
return create_coordinate_manager(
Expand Down Expand Up @@ -610,7 +610,7 @@ std::shared_ptr<CoordinateManager> CoordinateManager::create_coordinate_manager(
tt::umd::wormhole::ROUTER_CORES);
case tt::ARCH::QUASAR: // TODO (#450): Add Quasar configuration
case tt::ARCH::BLACKHOLE: {
const std::vector<tt_xy_pair> pcie_cores = tt::umd::blackhole::get_pcie_cores(board_type, is_chip_remote);
const std::vector<tt_xy_pair> pcie_cores = tt::umd::blackhole::get_pcie_cores(board_type, asic_location);
return create_coordinate_manager(
arch,
noc_translation_enabled,
Expand Down
7 changes: 7 additions & 0 deletions device/tt_cluster_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,15 @@ tt_ClusterDescriptor::get_chips_grouped_by_closest_mmio() const {
return chips_grouped_by_closest_mmio;
}

void tt_ClusterDescriptor::add_chip_uid(const chip_id_t chip_id, const ChipUID &chip_uid) {
chip_id_to_chip_uid[chip_id] = chip_uid;
chip_uid_to_chip_id[chip_uid] = chip_id;
}

chip_id_t tt_ClusterDescriptor::get_chip_id(const ChipUID &chip_uid) const { return chip_uid_to_chip_id.at(chip_uid); }

const ChipUID &tt_ClusterDescriptor::get_chip_uid(chip_id_t chip_id) const { return chip_id_to_chip_uid.at(chip_id); }

std::string tt_ClusterDescriptor::serialize() const {
YAML::Emitter out;

Expand Down
8 changes: 4 additions & 4 deletions device/tt_soc_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void tt_SocDescriptor::create_coordinate_manager(
const bool noc_translation_enabled,
const HarvestingMasks harvesting_masks,
const BoardType board_type,
const bool is_chip_remote) {
const uint8_t asic_location) {
const tt_xy_pair dram_grid_size = tt_xy_pair(dram_cores.size(), dram_cores.empty() ? 0 : dram_cores[0].size());
const tt_xy_pair arc_grid_size = tt_SocDescriptor::calculate_grid_size(arc_cores);
tt_xy_pair pcie_grid_size = tt_SocDescriptor::calculate_grid_size(pcie_cores);
Expand All @@ -206,7 +206,7 @@ void tt_SocDescriptor::create_coordinate_manager(
// enabling only one of the two pci cores. This is currently a unique case, and if another similar case shows up, we
// can figure out a better abstraction.
if (arch == tt::ARCH::BLACKHOLE && board_type != BoardType::UNKNOWN) {
auto pcie_cores_for_type = blackhole::get_pcie_cores(board_type, is_chip_remote);
auto pcie_cores_for_type = blackhole::get_pcie_cores(board_type, asic_location);
// Verify that the required pcie core was already mentioned in the device descriptor.
for (const auto &core : pcie_cores_for_type) {
if (std::find(pcie_cores.begin(), pcie_cores.end(), core) == pcie_cores.end()) {
Expand Down Expand Up @@ -261,7 +261,7 @@ tt_SocDescriptor::tt_SocDescriptor(
const bool noc_translation_enabled,
const HarvestingMasks harvesting_masks,
const BoardType board_type,
const bool is_chip_remote) :
const uint8_t asic_location) :
harvesting_masks(harvesting_masks) {
std::ifstream fdesc(device_descriptor_path);
if (fdesc.fail()) {
Expand All @@ -281,7 +281,7 @@ tt_SocDescriptor::tt_SocDescriptor(
arch_name_value = trim(arch_name_value);
arch = tt::arch_from_str(arch_name_value);
load_soc_features_from_device_descriptor(device_descriptor_yaml);
create_coordinate_manager(noc_translation_enabled, harvesting_masks, board_type, is_chip_remote);
create_coordinate_manager(noc_translation_enabled, harvesting_masks, board_type, asic_location);
}

int tt_SocDescriptor::get_num_dram_channels() const {
Expand Down

0 comments on commit a2c8cc0

Please sign in to comment.