Skip to content

Commit

Permalink
Coordinate manager maps redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanevskiTT committed Dec 10, 2024
1 parent c6b1ada commit 8e69799
Show file tree
Hide file tree
Showing 12 changed files with 559 additions and 437 deletions.
8 changes: 4 additions & 4 deletions device/api/umd/device/blackhole_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class BlackholeCoordinateManager : public CoordinateManager {
void translate_dram_coords() override;
void translate_tensix_coords() override;

void fill_tensix_logical_to_translated() override;
void fill_eth_logical_to_translated() override;
void fill_pcie_logical_to_translated() override;
void fill_dram_logical_to_translated() override;
void fill_tensix_physical_translated_mapping() override;
void fill_eth_physical_translated_mapping() override;
void fill_pcie_physical_translated_mapping() override;
void fill_dram_physical_translated_mapping() override;

private:
void map_column_of_dram_banks(const size_t start_bank, const size_t end_bank, const size_t x_coord);
Expand Down
103 changes: 28 additions & 75 deletions device/api/umd/device/coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@

class CoordinateManager {
public:
CoordinateManager(
const tt_xy_pair& tensix_grid_size,
const std::vector<tt_xy_pair>& tensix_cores,
const size_t tensix_harvesting_mask,
const tt_xy_pair& dram_grid_size,
const std::vector<tt_xy_pair>& dram_cores,
const 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);

static std::shared_ptr<CoordinateManager> create_coordinate_manager(
tt::ARCH arch,
const tt_xy_pair& tensix_grid_size,
Expand Down Expand Up @@ -59,112 +45,79 @@ class CoordinateManager {
virtual ~CoordinateManager() = default;

private:
tt::umd::CoreCoord to_physical(const tt::umd::CoreCoord core_coord);
tt::umd::CoreCoord to_logical(const tt::umd::CoreCoord core_coord);
tt::umd::CoreCoord to_virtual(const tt::umd::CoreCoord core_coord);
tt::umd::CoreCoord to_translated(const tt::umd::CoreCoord core_coord);

static void assert_create_coordinate_manager(
const tt::ARCH arch, const size_t tensix_harvesting_mask, const size_t dram_harvesting_mask);

protected:
CoordinateManager(
const tt_xy_pair& tensix_grid_size,
const std::vector<tt_xy_pair>& tensix_cores,
const size_t tensix_harvesting_mask,
const tt_xy_pair& dram_grid_size,
const std::vector<tt_xy_pair>& dram_cores,
const 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);

virtual void translate_tensix_coords();
virtual void translate_dram_coords();
virtual void translate_eth_coords();
virtual void translate_arc_coords();
virtual void translate_pcie_coords();

void identity_map_physical_cores();
void add_core_translation(const tt::umd::CoreCoord& core_coord, const tt_xy_pair& physical_pair);

/*
* Fills the logical to translated mapping for the tensix cores.
* By default, translated coordinates are the same as physical coordinates.
* Derived coordinate managers that need to implement different mapping
* should override this method. Wormhole and Blackhole coordinate managers
* override this method to implement different mapping.
*/
virtual void fill_tensix_logical_to_translated();
virtual void fill_tensix_physical_translated_mapping();

/*
* Fills the logical to translated mapping for the ethernet cores.
* Fills the physical to translated mapping for the ethernet cores.
* By default, translated coordinates are the same as physical coordinates.
* Derived coordinate managers that need to implement different mapping
* should override this method. Wormhole and Blackhole coordinate managers
* override this method to implement different mapping.
*/
virtual void fill_eth_logical_to_translated();
virtual void fill_eth_physical_translated_mapping();

/*
* Fills the logical to translated mapping for the DRAM cores.
* Fills the physical to translated mapping for the DRAM cores.
* By default, translated coordinates are the same as physical coordinates.
* Derived coordinate managers that need to implement different mapping
* should override this method. Blackhole coordinate manager overrides
* this method to implement different mapping.
*/
virtual void fill_dram_logical_to_translated();
virtual void fill_dram_physical_translated_mapping();

/*
* Fills the logical to translated mapping for the PCIE cores.
* Fills the physical to translated mapping for the PCIE cores.
* By default, translated coordinates are the same as physical coordinates.
* Derived coordinate managers that need to implement different mapping
* should override this method. Blackhole coordinate manager overrides
* this method to implement different mapping.
*/
virtual void fill_pcie_logical_to_translated();
virtual void fill_pcie_physical_translated_mapping();

/*
* Fills the logical to translated mapping for the ARC cores.
* Fills the physical to translated mapping for the ARC cores.
* By default, translated coordinates are the same as physical coordinates.
* Derived coordinate managers that need to implement different mapping
* should override this method.
*/
virtual void fill_arc_logical_to_translated();

std::map<tt_xy_pair, tt::umd::CoreCoord> tensix_logical_to_translated;
std::map<tt_xy_pair, tt::umd::CoreCoord> tensix_logical_to_virtual;
std::map<tt_xy_pair, tt::umd::CoreCoord> tensix_logical_to_physical;

std::map<tt_xy_pair, tt::umd::CoreCoord> tensix_physical_to_logical;
std::map<tt_xy_pair, tt::umd::CoreCoord> tensix_virtual_to_logical;
std::map<tt_xy_pair, tt::umd::CoreCoord> tensix_translated_to_logical;

std::map<tt_xy_pair, tt::umd::CoreCoord> dram_logical_to_translated;
std::map<tt_xy_pair, tt::umd::CoreCoord> dram_logical_to_virtual;
std::map<tt_xy_pair, tt::umd::CoreCoord> dram_logical_to_physical;

std::map<tt_xy_pair, tt::umd::CoreCoord> dram_physical_to_logical;
std::map<tt_xy_pair, tt::umd::CoreCoord> dram_virtual_to_logical;
std::map<tt_xy_pair, tt::umd::CoreCoord> dram_translated_to_logical;

std::map<tt_xy_pair, tt::umd::CoreCoord> eth_logical_to_translated;
std::map<tt_xy_pair, tt::umd::CoreCoord> eth_logical_to_virtual;
std::map<tt_xy_pair, tt::umd::CoreCoord> eth_logical_to_physical;

std::map<tt_xy_pair, tt::umd::CoreCoord> eth_physical_to_logical;
std::map<tt_xy_pair, tt::umd::CoreCoord> eth_virtual_to_logical;
std::map<tt_xy_pair, tt::umd::CoreCoord> eth_translated_to_logical;

std::map<tt_xy_pair, tt::umd::CoreCoord> arc_logical_to_translated;
std::map<tt_xy_pair, tt::umd::CoreCoord> arc_logical_to_virtual;
std::map<tt_xy_pair, tt::umd::CoreCoord> arc_logical_to_physical;

std::map<tt_xy_pair, tt::umd::CoreCoord> arc_physical_to_logical;
std::map<tt_xy_pair, tt::umd::CoreCoord> arc_virtual_to_logical;
std::map<tt_xy_pair, tt::umd::CoreCoord> arc_translated_to_logical;

std::map<tt_xy_pair, tt::umd::CoreCoord> pcie_logical_to_translated;
std::map<tt_xy_pair, tt::umd::CoreCoord> pcie_logical_to_virtual;
std::map<tt_xy_pair, tt::umd::CoreCoord> pcie_logical_to_physical;

std::map<tt_xy_pair, tt::umd::CoreCoord> pcie_physical_to_logical;
std::map<tt_xy_pair, tt::umd::CoreCoord> pcie_virtual_to_logical;
std::map<tt_xy_pair, tt::umd::CoreCoord> pcie_translated_to_logical;

std::map<tt_xy_pair, tt::umd::CoreCoord>& get_logical_to_translated(CoreType core_type);
std::map<tt_xy_pair, tt::umd::CoreCoord>& get_logical_to_virtual(CoreType core_type);
std::map<tt_xy_pair, tt::umd::CoreCoord>& get_logical_to_physical(CoreType core_type);
virtual void fill_arc_physical_translated_mapping();

std::map<tt_xy_pair, tt::umd::CoreCoord>& get_physical_to_logical(CoreType core_type);
std::map<tt_xy_pair, tt::umd::CoreCoord>& get_virtual_to_logical(CoreType core_type);
std::map<tt_xy_pair, tt::umd::CoreCoord>& get_translated_to_logical(CoreType core_type);
std::map<tt::umd::CoreCoord, tt_xy_pair> to_physical_map;
std::map<std::pair<tt_xy_pair, CoordSystem>, tt::umd::CoreCoord> from_physical_map;

const tt_xy_pair tensix_grid_size;
const std::vector<tt_xy_pair>& tensix_cores;
Expand Down
2 changes: 1 addition & 1 deletion device/api/umd/device/grayskull_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ class GrayskullCoordinateManager : public CoordinateManager {
const std::vector<tt_xy_pair>& pcie_cores);

protected:
void fill_eth_logical_to_translated() override;
void fill_eth_physical_translated_mapping() override;
};
22 changes: 22 additions & 0 deletions device/api/umd/device/tt_core_coordinates.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ struct CoreCoord : public tt_xy_pair {
return this->x == other.x && this->y == other.y && this->core_type == other.core_type &&
this->coord_system == other.coord_system;
}

bool operator<(const CoreCoord& o) const {
if (x < o.x) {
return true;
}
if (x > o.x) {
return false;
}
if (y < o.y) {
return true;
}
if (y > o.y) {
return false;
}
if (core_type < o.core_type) {
return true;
}
if (core_type > o.core_type) {
return false;
}
return coord_system < o.coord_system;
}
};

} // namespace tt::umd
4 changes: 2 additions & 2 deletions device/api/umd/device/wormhole_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ class WormholeCoordinateManager : public CoordinateManager {
const std::vector<tt_xy_pair>& pcie_cores);

protected:
void fill_tensix_logical_to_translated() override;
void fill_eth_logical_to_translated() override;
void fill_tensix_physical_translated_mapping() override;
void fill_eth_physical_translated_mapping() override;
};
Loading

0 comments on commit 8e69799

Please sign in to comment.