Skip to content

Commit

Permalink
Rename conversion functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanevskiTT committed Oct 25, 2024
1 parent c57ee0a commit 3e84f54
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 104 deletions.
40 changes: 20 additions & 20 deletions device/coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,56 @@
#include "coordinate_manager.h"
#include "grayskull/grayskull_coordinate_manager.h"

tt_physical_coords CoordinateManager::logical_to_physical_coords(tt_logical_coords logical_coords) {
tt_physical_coords CoordinateManager::to_physical_coords(tt_logical_coords logical_coords) {
return tt_physical_coords(logical_x_to_physical_x[logical_coords.x], logical_y_to_physical_y[logical_coords.y]);
}

// TODO(pjanevski): this is different for Wormhole and Blackhole.
// investigate and implement
tt_translated_coords CoordinateManager::logical_to_translated_coords(tt_logical_coords logical_coords) {
tt_physical_coords physical_coords = logical_to_physical_coords(logical_coords);
tt_translated_coords CoordinateManager::to_translated_coords(tt_logical_coords logical_coords) {
tt_physical_coords physical_coords = to_physical_coords(logical_coords);
return tt_translated_coords(physical_coords.x, physical_coords.y);
}

tt_virtual_coords CoordinateManager::logical_to_virtual_coords(tt_logical_coords logical_coords) {
tt_virtual_coords CoordinateManager::to_virtual_coords(tt_logical_coords logical_coords) {
return tt_virtual_coords(logical_x_to_virtual_x[logical_coords.x], logical_y_to_virtual_y[logical_coords.y]);
}

tt_logical_coords CoordinateManager::physical_to_logical_coords(tt_physical_coords physical_coords) {
tt_logical_coords CoordinateManager::to_logical_coords(tt_physical_coords physical_coords) {
return tt_logical_coords(physical_x_to_logical_x[physical_coords.x], physical_y_to_logical_y[physical_coords.y]);
}

tt_virtual_coords CoordinateManager::physical_to_virtual_coords(tt_physical_coords physical_coords) {
return logical_to_virtual_coords(physical_to_logical_coords(physical_coords));
tt_virtual_coords CoordinateManager::to_virtual_coords(tt_physical_coords physical_coords) {
return to_virtual_coords(to_logical_coords(physical_coords));
}

tt_translated_coords CoordinateManager::physical_to_translated_coords(tt_physical_coords physical_coords) {
return logical_to_translated_coords(physical_to_logical_coords(physical_coords));
tt_translated_coords CoordinateManager::to_translated_coords(tt_physical_coords physical_coords) {
return to_translated_coords(to_logical_coords(physical_coords));
}

tt_logical_coords CoordinateManager::virtual_to_logical_coords(tt_virtual_coords virtual_coords) {
tt_logical_coords CoordinateManager::to_logical_coords(tt_virtual_coords virtual_coords) {
return tt_logical_coords(virtual_x_to_logical_x[virtual_coords.x], virtual_y_to_logical_y[virtual_coords.y]);
}

tt_physical_coords CoordinateManager::virtual_to_physical_coords(tt_virtual_coords virtual_coords) {
return logical_to_physical_coords(virtual_to_logical_coords(virtual_coords));
tt_physical_coords CoordinateManager::to_physical_coords(tt_virtual_coords virtual_coords) {
return to_physical_coords(to_logical_coords(virtual_coords));
}

tt_translated_coords CoordinateManager::virtual_to_translated_coords(tt_virtual_coords virtual_coords) {
return logical_to_translated_coords(virtual_to_logical_coords(virtual_coords));
tt_translated_coords CoordinateManager::to_translated_coords(tt_virtual_coords virtual_coords) {
return to_translated_coords(to_logical_coords(virtual_coords));
}

tt_logical_coords CoordinateManager::translated_to_logical_coords(tt_translated_coords translated_coords) {
tt_logical_coords CoordinateManager::to_logical_coords(tt_translated_coords translated_coords) {
tt_physical_coords physical_coords = tt_physical_coords(translated_coords.x, translated_coords.y);
return physical_to_logical_coords(physical_coords);
return to_logical_coords(physical_coords);
}

tt_physical_coords CoordinateManager::translated_to_physical_coords(tt_translated_coords translated_coords) {
return logical_to_physical_coords(translated_to_logical_coords(translated_coords));
tt_physical_coords CoordinateManager::to_physical_coords(tt_translated_coords translated_coords) {
return to_physical_coords(to_logical_coords(translated_coords));
}

tt_virtual_coords CoordinateManager::translated_to_virtual_coords(tt_translated_coords translated_coords) {
return logical_to_virtual_coords(translated_to_logical_coords(translated_coords));
tt_virtual_coords CoordinateManager::to_virtual_coords(tt_translated_coords translated_coords) {
return to_virtual_coords(to_logical_coords(translated_coords));
}

void CoordinateManager::clear_harvesting_structures() {
Expand Down
24 changes: 12 additions & 12 deletions device/coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ class CoordinateManager {

virtual void perform_harvesting(std::size_t harvesting_mask);

virtual tt_physical_coords logical_to_physical_coords(tt_logical_coords logical_coords);
virtual tt_translated_coords logical_to_translated_coords(tt_logical_coords logical_coords);
virtual tt_virtual_coords logical_to_virtual_coords(tt_logical_coords logical_coords);
virtual tt_physical_coords to_physical_coords(tt_logical_coords logical_coords);
virtual tt_translated_coords to_translated_coords(tt_logical_coords logical_coords);
virtual tt_virtual_coords to_virtual_coords(tt_logical_coords logical_coords);

virtual tt_logical_coords physical_to_logical_coords(tt_physical_coords physical_coords);
virtual tt_virtual_coords physical_to_virtual_coords(tt_physical_coords physical_coords);
virtual tt_translated_coords physical_to_translated_coords(tt_physical_coords physical_coords);
virtual tt_logical_coords to_logical_coords(tt_physical_coords physical_coords);
virtual tt_virtual_coords to_virtual_coords(tt_physical_coords physical_coords);
virtual tt_translated_coords to_translated_coords(tt_physical_coords physical_coords);

virtual tt_logical_coords virtual_to_logical_coords(tt_virtual_coords virtual_coords);
virtual tt_physical_coords virtual_to_physical_coords(tt_virtual_coords virtual_coords);
virtual tt_translated_coords virtual_to_translated_coords(tt_virtual_coords virtual_coords);
virtual tt_logical_coords to_logical_coords(tt_virtual_coords virtual_coords);
virtual tt_physical_coords to_physical_coords(tt_virtual_coords virtual_coords);
virtual tt_translated_coords to_translated_coords(tt_virtual_coords virtual_coords);

virtual tt_logical_coords translated_to_logical_coords(tt_translated_coords translated_coords);
virtual tt_physical_coords translated_to_physical_coords(tt_translated_coords translated_coords);
virtual tt_virtual_coords translated_to_virtual_coords(tt_translated_coords translated_coords);
virtual tt_logical_coords to_logical_coords(tt_translated_coords translated_coords);
virtual tt_physical_coords to_physical_coords(tt_translated_coords translated_coords);
virtual tt_virtual_coords to_virtual_coords(tt_translated_coords translated_coords);

static std::unique_ptr<CoordinateManager> get_coordinate_manager(
tt::ARCH arch,
Expand Down
48 changes: 24 additions & 24 deletions device/tt_soc_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,52 +174,52 @@ void tt_SocDescriptor::perform_harvesting(std::size_t harvesting_mask) {
coordinate_manager->perform_harvesting(harvesting_mask);
}

tt_physical_coords tt_SocDescriptor::logical_to_physical_coords(tt_logical_coords logical_coords) {
return coordinate_manager->logical_to_physical_coords(logical_coords);
tt_physical_coords tt_SocDescriptor::to_physical_coords(tt_logical_coords logical_coords) {
return coordinate_manager->to_physical_coords(logical_coords);
}

tt_virtual_coords tt_SocDescriptor::logical_to_virtual_coords(tt_logical_coords logical_coords) {
return coordinate_manager->logical_to_virtual_coords(logical_coords);
tt_virtual_coords tt_SocDescriptor::to_virtual_coords(tt_logical_coords logical_coords) {
return coordinate_manager->to_virtual_coords(logical_coords);
}

tt_translated_coords tt_SocDescriptor::logical_to_translated_coords(tt_logical_coords logical_coords) {
return coordinate_manager->logical_to_translated_coords(logical_coords);
tt_translated_coords tt_SocDescriptor::to_translated_coords(tt_logical_coords logical_coords) {
return coordinate_manager->to_translated_coords(logical_coords);
}

tt_logical_coords tt_SocDescriptor::physical_to_logical_coords(tt_physical_coords physical_coords) {
return coordinate_manager->physical_to_logical_coords(physical_coords);
tt_logical_coords tt_SocDescriptor::to_logical_coords(tt_physical_coords physical_coords) {
return coordinate_manager->to_logical_coords(physical_coords);
}

tt_virtual_coords tt_SocDescriptor::physical_to_virtual_coords(tt_physical_coords physical_coords) {
return coordinate_manager->physical_to_virtual_coords(physical_coords);
tt_virtual_coords tt_SocDescriptor::to_virtual_coords(tt_physical_coords physical_coords) {
return coordinate_manager->to_virtual_coords(physical_coords);
}

tt_translated_coords tt_SocDescriptor::physical_to_translated_coords(tt_physical_coords physical_coords) {
return coordinate_manager->physical_to_translated_coords(physical_coords);
tt_translated_coords tt_SocDescriptor::to_translated_coords(tt_physical_coords physical_coords) {
return coordinate_manager->to_translated_coords(physical_coords);
}

tt_logical_coords tt_SocDescriptor::virtual_to_logical_coords(tt_virtual_coords virtual_coords) {
return coordinate_manager->virtual_to_logical_coords(virtual_coords);
tt_logical_coords tt_SocDescriptor::to_logical_coords(tt_virtual_coords virtual_coords) {
return coordinate_manager->to_logical_coords(virtual_coords);
}

tt_physical_coords tt_SocDescriptor::virtual_to_physical_coords(tt_virtual_coords virtual_coords) {
return coordinate_manager->virtual_to_physical_coords(virtual_coords);
tt_physical_coords tt_SocDescriptor::to_physical_coords(tt_virtual_coords virtual_coords) {
return coordinate_manager->to_physical_coords(virtual_coords);
}

tt_translated_coords tt_SocDescriptor::virtual_to_translated_coords(tt_virtual_coords virtual_coords) {
return coordinate_manager->virtual_to_translated_coords(virtual_coords);
tt_translated_coords tt_SocDescriptor::to_translated_coords(tt_virtual_coords virtual_coords) {
return coordinate_manager->to_translated_coords(virtual_coords);
}

tt_logical_coords tt_SocDescriptor::translated_to_logical_coords(tt_translated_coords translated_coords) {
return coordinate_manager->translated_to_logical_coords(translated_coords);
tt_logical_coords tt_SocDescriptor::to_logical_coords(tt_translated_coords translated_coords) {
return coordinate_manager->to_logical_coords(translated_coords);
}

tt_physical_coords tt_SocDescriptor::translated_to_physical_coords(tt_translated_coords translated_coords) {
return coordinate_manager->translated_to_physical_coords(translated_coords);
tt_physical_coords tt_SocDescriptor::to_physical_coords(tt_translated_coords translated_coords) {
return coordinate_manager->to_physical_coords(translated_coords);
}

tt_virtual_coords tt_SocDescriptor::translated_to_virtual_coords(tt_translated_coords translated_coords) {
return coordinate_manager->translated_to_virtual_coords(translated_coords);
tt_virtual_coords tt_SocDescriptor::to_virtual_coords(tt_translated_coords translated_coords) {
return coordinate_manager->to_virtual_coords(translated_coords);
}

tt_SocDescriptor::tt_SocDescriptor(std::string device_descriptor_path, std::size_t harvesting_mask) {
Expand Down
24 changes: 12 additions & 12 deletions device/tt_soc_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,21 @@ class tt_SocDescriptor {
// Coordinate conversions.

// Conversions from logical coordinates should be used just for worker cores.
tt_physical_coords logical_to_physical_coords(tt_logical_coords logical_coords);
tt_virtual_coords logical_to_virtual_coords(tt_logical_coords logical_coords);
tt_translated_coords logical_to_translated_coords(tt_logical_coords logical_coords);
tt_physical_coords to_physical_coords(tt_logical_coords logical_coords);
tt_virtual_coords to_virtual_coords(tt_logical_coords logical_coords);
tt_translated_coords to_translated_coords(tt_logical_coords logical_coords);

tt_logical_coords physical_to_logical_coords(tt_physical_coords physical_coords);
tt_virtual_coords physical_to_virtual_coords(tt_physical_coords physical_coords);
tt_translated_coords physical_to_translated_coords(tt_physical_coords physical_coords);
tt_logical_coords to_logical_coords(tt_physical_coords physical_coords);
tt_virtual_coords to_virtual_coords(tt_physical_coords physical_coords);
tt_translated_coords to_translated_coords(tt_physical_coords physical_coords);

tt_logical_coords virtual_to_logical_coords(tt_virtual_coords virtual_coords);
tt_physical_coords virtual_to_physical_coords(tt_virtual_coords virtual_coords);
tt_translated_coords virtual_to_translated_coords(tt_virtual_coords virtual_coords);
tt_logical_coords to_logical_coords(tt_virtual_coords virtual_coords);
tt_physical_coords to_physical_coords(tt_virtual_coords virtual_coords);
tt_translated_coords to_translated_coords(tt_virtual_coords virtual_coords);

tt_logical_coords translated_to_logical_coords(tt_translated_coords translated_coords);
tt_physical_coords translated_to_physical_coords(tt_translated_coords translated_coords);
tt_virtual_coords translated_to_virtual_coords(tt_translated_coords translated_coords);
tt_logical_coords to_logical_coords(tt_translated_coords translated_coords);
tt_physical_coords to_physical_coords(tt_translated_coords translated_coords);
tt_virtual_coords to_virtual_coords(tt_translated_coords translated_coords);

void perform_harvesting(std::size_t harvesting_mask);

Expand Down
4 changes: 2 additions & 2 deletions device/wormhole/wormhole_coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ std::set<std::size_t> WormholeCoordinateManager::get_y_coordinates_to_harvest(st
return y_to_harvest;
}

tt_translated_coords WormholeCoordinateManager::logical_to_translated_coords(tt_logical_coords logical_coords) {
tt_translated_coords WormholeCoordinateManager::to_translated_coords(tt_logical_coords logical_coords) {
return tt_translated_coords(logical_coords.x + translated_coordinate_start_x, logical_coords.y + translated_coordinate_start_y);
}

tt_logical_coords WormholeCoordinateManager::translated_to_logical_coords(tt_translated_coords translated_coords) {
tt_logical_coords WormholeCoordinateManager::to_logical_coords(tt_translated_coords translated_coords) {
return tt_logical_coords(translated_coords.x - translated_coordinate_start_x, translated_coords.y - translated_coordinate_start_y);
}
4 changes: 2 additions & 2 deletions device/wormhole/wormhole_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class WormholeCoordinateManager : public CoordinateManager {
WormholeCoordinateManager(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) {}

tt_translated_coords logical_to_translated_coords(tt_logical_coords logical_coords) override;
tt_translated_coords to_translated_coords(tt_logical_coords logical_coords) override;

tt_logical_coords translated_to_logical_coords(tt_translated_coords translated_coords) override;
tt_logical_coords to_logical_coords(tt_translated_coords translated_coords) override;

protected:
std::set<std::size_t> get_y_coordinates_to_harvest(std::size_t harvesting_mask) override;
Expand Down
16 changes: 8 additions & 8 deletions tests/api/test_soc_descriptor_bh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ TEST(SocDescriptor, SocDescriptorBHNoHarvesting) {
for (size_t x = 0; x < worker_grid_size.x; x++) {
for (size_t y = 0; y < worker_grid_size.y; y++) {
tt_logical_coords logical_coords = tt_logical_coords(x, y);
tt_virtual_coords virtual_coords = soc_desc.logical_to_virtual_coords(logical_coords);
tt_physical_coords physical_coords = soc_desc.logical_to_physical_coords(logical_coords);
tt_virtual_coords virtual_coords = soc_desc.to_virtual_coords(logical_coords);
tt_physical_coords physical_coords = soc_desc.to_physical_coords(logical_coords);

// Virtual and physical coordinates should be the same.
EXPECT_EQ(physical_coords, virtual_coords);
Expand All @@ -50,11 +50,11 @@ TEST(SocDescriptor, SocDescriptorBHTopLeftCore) {
tt_logical_coords logical_coords = tt_logical_coords(0, 0);

// Always expect same virtual coordinate for (0, 0) logical coordinate.
tt_virtual_coords virtual_cords = soc_desc.logical_to_virtual_coords(logical_coords);
tt_virtual_coords virtual_cords = soc_desc.to_virtual_coords(logical_coords);
EXPECT_EQ(virtual_cords, tt_virtual_coords(1, 2));

// This depends on harvesting mask. So expected physical coord is specific to this test and Blackhole arch.
tt_physical_coords physical_cords = soc_desc.logical_to_physical_coords(logical_coords);
tt_physical_coords physical_cords = soc_desc.to_physical_coords(logical_coords);
EXPECT_EQ(physical_cords, tt_physical_coords(2, 2));
}

Expand All @@ -78,7 +78,7 @@ TEST(SocDescriptor, SocDescriptorBHLogicalPhysicalMapping) {
for (size_t x = 0; x < worker_grid_size.x - num_harvested_x; x++) {
for (size_t y = 0; y < worker_grid_size.y; y++) {
tt_logical_coords logical_coords = tt_logical_coords(x, y);
tt_physical_coords physical_coords = soc_desc.logical_to_physical_coords(logical_coords);
tt_physical_coords physical_coords = soc_desc.to_physical_coords(logical_coords);
logical_to_physical[logical_coords] = physical_coords;

// Expect that logical to physical translation is 1-1 mapping. No duplicates for physical coordinates.
Expand All @@ -91,7 +91,7 @@ TEST(SocDescriptor, SocDescriptorBHLogicalPhysicalMapping) {

for (auto it : logical_to_physical) {
tt_physical_coords physical_coords = it.second;
tt_logical_coords logical_coords = soc_desc.physical_to_logical_coords(physical_coords);
tt_logical_coords logical_coords = soc_desc.to_logical_coords(physical_coords);

// Expect that reverse mapping of physical coordinates gives the same logical coordinates
// using which we got the physical coordinates.
Expand Down Expand Up @@ -120,7 +120,7 @@ TEST(SocDescriptor, SocDescriptorBHLogicalVirtualMapping) {
for (size_t x = 0; x < worker_grid_size.x - num_harvested_x; x++) {
for (size_t y = 0; y < worker_grid_size.y; y++) {
tt_logical_coords logical_coords = tt_logical_coords(x, y);
tt_virtual_coords virtual_coords = soc_desc.logical_to_virtual_coords(logical_coords);
tt_virtual_coords virtual_coords = soc_desc.to_virtual_coords(logical_coords);
logical_to_virtual[logical_coords] = virtual_coords;

// Expect that logical to virtual translation is 1-1 mapping. No duplicates for virtual coordinates.
Expand All @@ -133,7 +133,7 @@ TEST(SocDescriptor, SocDescriptorBHLogicalVirtualMapping) {

for (auto it : logical_to_virtual) {
tt_virtual_coords virtual_coords = it.second;
tt_logical_coords logical_coords = soc_desc.virtual_to_logical_coords(virtual_coords);
tt_logical_coords logical_coords = soc_desc.to_logical_coords(virtual_coords);

// Expect that reverse mapping of virtual coordinates gives the same logical coordinates
// using which we got the virtual coordinates.
Expand Down
Loading

0 comments on commit 3e84f54

Please sign in to comment.