Skip to content

Commit

Permalink
CoreCoord to namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanevskiTT committed Nov 27, 2024
1 parent 96c6ecc commit 8ff716a
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 55 deletions.
2 changes: 1 addition & 1 deletion device/blackhole/blackhole_coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
#include "blackhole_coordinate_manager.h"

#include <iostream>
using namespace tt::umd;

void BlackholeCoordinateManager::tensix_harvesting(const size_t tensix_harvesting_mask) {
CoordinateManager::tensix_harvesting_mask = tensix_harvesting_mask;
Expand Down
2 changes: 2 additions & 0 deletions device/coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "grayskull/grayskull_implementation.h"
#include "tt_core_coordinates.h"

using namespace tt::umd;

std::map<tt_xy_pair, CoreCoord>& CoordinateManager::get_logical_to_translated(CoreType core_type) {
switch (core_type) {
case CoreType::TENSIX:
Expand Down
82 changes: 41 additions & 41 deletions device/coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ class CoordinateManager {

CoordinateManager(CoordinateManager& other) = default;

CoreCoord to(const CoreCoord core_coord, const CoordSystem coord_system);
tt::umd::CoreCoord to(const tt::umd::CoreCoord core_coord, const CoordSystem coord_system);

virtual ~CoordinateManager() = default;

private:
CoreCoord to_physical(const CoreCoord core_coord);
CoreCoord to_logical(const CoreCoord core_coord);
CoreCoord to_virtual(const CoreCoord core_coord);
CoreCoord to_translated(const CoreCoord core_coord);
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);

protected:
virtual void tensix_harvesting(const size_t harvesting_mask);
Expand All @@ -86,53 +86,53 @@ class CoordinateManager {
virtual void fill_eth_logical_to_translated();
virtual void fill_pcie_logical_to_translated();

std::map<tt_xy_pair, CoreCoord> tensix_logical_to_translated;
std::map<tt_xy_pair, CoreCoord> tensix_logical_to_virtual;
std::map<tt_xy_pair, CoreCoord> tensix_logical_to_physical;
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, CoreCoord> tensix_physical_to_logical;
std::map<tt_xy_pair, CoreCoord> tensix_virtual_to_logical;
std::map<tt_xy_pair, CoreCoord> tensix_translated_to_logical;
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, CoreCoord> dram_logical_to_translated;
std::map<tt_xy_pair, CoreCoord> dram_logical_to_virtual;
std::map<tt_xy_pair, CoreCoord> dram_logical_to_physical;
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, CoreCoord> dram_physical_to_logical;
std::map<tt_xy_pair, CoreCoord> dram_virtual_to_logical;
std::map<tt_xy_pair, CoreCoord> dram_translated_to_logical;
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, CoreCoord> eth_logical_to_translated;
std::map<tt_xy_pair, CoreCoord> eth_logical_to_virtual;
std::map<tt_xy_pair, CoreCoord> eth_logical_to_physical;
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, CoreCoord> eth_physical_to_logical;
std::map<tt_xy_pair, CoreCoord> eth_virtual_to_logical;
std::map<tt_xy_pair, CoreCoord> eth_translated_to_logical;
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, CoreCoord> arc_logical_to_translated;
std::map<tt_xy_pair, CoreCoord> arc_logical_to_virtual;
std::map<tt_xy_pair, CoreCoord> arc_logical_to_physical;
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, CoreCoord> arc_physical_to_logical;
std::map<tt_xy_pair, CoreCoord> arc_virtual_to_logical;
std::map<tt_xy_pair, CoreCoord> arc_translated_to_logical;
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, CoreCoord> pcie_logical_to_translated;
std::map<tt_xy_pair, CoreCoord> pcie_logical_to_virtual;
std::map<tt_xy_pair, CoreCoord> pcie_logical_to_physical;
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, CoreCoord> pcie_physical_to_logical;
std::map<tt_xy_pair, CoreCoord> pcie_virtual_to_logical;
std::map<tt_xy_pair, CoreCoord> pcie_translated_to_logical;
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, CoreCoord>& get_logical_to_translated(CoreType core_type);
std::map<tt_xy_pair, CoreCoord>& get_logical_to_virtual(CoreType core_type);
std::map<tt_xy_pair, CoreCoord>& get_logical_to_physical(CoreType core_type);
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);

std::map<tt_xy_pair, CoreCoord>& get_physical_to_logical(CoreType core_type);
std::map<tt_xy_pair, CoreCoord>& get_virtual_to_logical(CoreType core_type);
std::map<tt_xy_pair, CoreCoord>& get_translated_to_logical(CoreType core_type);
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);

const tt_xy_pair tensix_grid_size;
const std::vector<tt_xy_pair>& tensix_cores;
Expand Down
2 changes: 2 additions & 0 deletions device/grayskull/grayskull_coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
#include "grayskull_coordinate_manager.h"

using namespace tt::umd;

void GrayskullCoordinateManager::fill_tensix_logical_to_translated() {
size_t num_harvested_y = __builtin_popcount(CoordinateManager::tensix_harvesting_mask);

Expand Down
26 changes: 15 additions & 11 deletions device/tt_core_coordinates.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@

// For documentation on Coordinate systems, lookup docs/coordinate_systems.md

/*
* CoordSystem is an enum class that represents all types of coordinate
* systems that can be used to represent a core's location.
*/
enum class CoordSystem : std::uint8_t {
LOGICAL,
PHYSICAL,
VIRTUAL,
TRANSLATED,
};

/*
* CoreType is an enum class that represents all types of cores
* present on the Tenstorrent chip.
Expand All @@ -39,6 +28,19 @@ enum class CoreType : std::uint8_t {
ETH,
};

/*
* CoordSystem is an enum class that represents all types of coordinate
* systems that can be used to represent a core's location.
*/
enum class CoordSystem : std::uint8_t {
LOGICAL,
PHYSICAL,
VIRTUAL,
TRANSLATED,
};

namespace tt::umd {

struct CoreCoord : public tt_xy_pair {
CoreCoord() {}

Expand All @@ -53,3 +55,5 @@ struct CoreCoord : public tt_xy_pair {
this->coord_system == other.coord_system;
}
};

} // namespace tt::umd
2 changes: 1 addition & 1 deletion device/tt_soc_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void tt_SocDescriptor::create_coordinate_manager(
coordinate_manager = CoordinateManager::get_coordinate_manager(arch, tensix_harvesting_mask, dram_harvesting_mask);
}

CoreCoord tt_SocDescriptor::to(const CoreCoord core_coord, const CoordSystem coord_system) {
tt::umd::CoreCoord tt_SocDescriptor::to(const tt::umd::CoreCoord core_coord, const CoordSystem coord_system) {
return coordinate_manager->to(core_coord, coord_system);
}

Expand Down
2 changes: 1 addition & 1 deletion device/tt_soc_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class tt_SocDescriptor {
coordinate_manager(other.coordinate_manager) {}

// CoreCoord conversions.
CoreCoord to(const CoreCoord core_coord, const CoordSystem coord_system);
tt::umd::CoreCoord to(const tt::umd::CoreCoord core_coord, const CoordSystem coord_system);

static std::string get_soc_descriptor_path(tt::ARCH arch);

Expand Down
2 changes: 2 additions & 0 deletions device/wormhole/wormhole_coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
#include "wormhole_coordinate_manager.h"

using namespace tt::umd;

void WormholeCoordinateManager::fill_tensix_logical_to_translated() {
size_t num_harvested_y = __builtin_popcount(CoordinateManager::tensix_harvesting_mask);

Expand Down
2 changes: 2 additions & 0 deletions tests/api/test_core_coord_translation_bh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "tests/test_utils/generate_cluster_desc.hpp"
#include "tests/test_utils/soc_desc_test_utils.hpp"

using namespace tt::umd;

// Tests that all physical coordinates are same as all virtual coordinates
// when there is no harvesting.
TEST(CoordinateManager, CoordinateManagerBlackholeNoHarvesting) {
Expand Down
2 changes: 2 additions & 0 deletions tests/api/test_core_coord_translation_gs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "tests/test_utils/generate_cluster_desc.hpp"
#include "tests/test_utils/soc_desc_test_utils.hpp"

using namespace tt::umd;

// Tests that all physical coordinates are same as all virtual coordinates
// when there is no harvesting.
TEST(CoordinateManager, CoordinateManagerGrayskullNoHarvesting) {
Expand Down
2 changes: 2 additions & 0 deletions tests/api/test_core_coord_translation_wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "tests/test_utils/generate_cluster_desc.hpp"
#include "tests/test_utils/soc_desc_test_utils.hpp"

using namespace tt::umd;

// Tests that all physical coordinates are same as all virtual coordinates
// when there is no harvesting.
TEST(CoordinateManager, CoordinateManagerWormholeNoHarvesting) {
Expand Down

0 comments on commit 8ff716a

Please sign in to comment.