Skip to content

Commit

Permalink
Grayskull tests and full API
Browse files Browse the repository at this point in the history
- Add grayskull tests for harvesting

- Implement API for full coordinate translation to any system

- Separate soc desc tests per arch
  • Loading branch information
pjanevskiTT committed Oct 24, 2024
1 parent 36c3600 commit 950feee
Show file tree
Hide file tree
Showing 13 changed files with 613 additions and 340 deletions.
43 changes: 33 additions & 10 deletions device/coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,57 @@
#include "grayskull/grayskull_coordinate_manager.h"

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

// TODO(pjanevski): is it enough just to add 18 to the logical coordinates
// in order to get the translated coordinates?
// 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) {
static const std::size_t translated_offset = 18;
return tt_translated_coords(logical_coords.x + translated_offset, logical_coords.y + translated_offset);
tt_physical_coords physical_coords = logical_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) {
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) {
return tt_logical_coords(physical_x_to_logical_x[physical_coords.x], physical_y_to_logical_y[physical_coords.y]);
}

tt_translated_coords CoordinateManager::physical_to_translated_coords(tt_physical_coords physical_coords) {
return tt_translated_coords(0, 0);
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::logical_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_translated_coords CoordinateManager::physical_to_translated_coords(tt_physical_coords physical_coords) {
return logical_to_translated_coords(physical_to_logical_coords(physical_coords));
}

tt_logical_coords CoordinateManager::virtual_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_translated_coords CoordinateManager::virtual_to_translated_coords(tt_virtual_coords virtual_coords) {
return logical_to_translated_coords(virtual_to_logical_coords(virtual_coords));
}

tt_logical_coords CoordinateManager::translated_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);
}

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_virtual_coords CoordinateManager::translated_to_virtual_coords(tt_translated_coords translated_coords) {
return logical_to_virtual_coords(translated_to_logical_coords(translated_coords));
}

void CoordinateManager::clear_harvesting_structures() {
logical_x_to_physical_x.clear();
logical_y_to_physical_y.clear();
Expand Down
11 changes: 10 additions & 1 deletion device/coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,19 @@ class CoordinateManager {

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_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_virtual_coords logical_to_virtual_coords(tt_logical_coords logical_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 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);

static CoordinateManager* get_coordinate_manager(
tt::ARCH arch,
Expand Down
32 changes: 28 additions & 4 deletions device/tt_soc_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ tt_physical_coords tt_SocDescriptor::logical_to_physical_coords(tt_logical_coord
return coordinate_manager->logical_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_translated_coords tt_SocDescriptor::logical_to_translated_coords(tt_logical_coords logical_coords) {
return coordinate_manager->logical_to_translated_coords(logical_coords);
}
Expand All @@ -186,18 +190,38 @@ tt_logical_coords tt_SocDescriptor::physical_to_logical_coords(tt_physical_coord
return coordinate_manager->physical_to_logical_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_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::logical_to_virtual_coords(tt_logical_coords logical_coords) {
return coordinate_manager->logical_to_virtual_coords(logical_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_logical_coords tt_SocDescriptor::virtual_to_logical_coords(tt_virtual_coords virtual_coords) {
return coordinate_manager->virtual_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_translated_coords tt_SocDescriptor::virtual_to_translated_coords(tt_virtual_coords virtual_coords) {
return coordinate_manager->virtual_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_physical_coords tt_SocDescriptor::translated_to_physical_coords(tt_translated_coords translated_coords) {
return coordinate_manager->translated_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_SocDescriptor::tt_SocDescriptor(std::string device_descriptor_path, std::size_t harvesting_mask) {
std::ifstream fdesc(device_descriptor_path);
if (fdesc.fail()) {
Expand Down
15 changes: 13 additions & 2 deletions device/tt_soc_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,24 @@ class tt_SocDescriptor {
coordinate_manager(other.coordinate_manager) {
}

// Coordinate converters.
// 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_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_virtual_coords logical_to_virtual_coords(tt_logical_coords logical_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 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);

void perform_harvesting(std::size_t harvesting_mask);

Expand Down
8 changes: 8 additions & 0 deletions device/wormhole/wormhole_coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ 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) {
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) {
return tt_logical_coords(translated_coords.x - translated_coordinate_start_x, translated_coords.y - translated_coordinate_start_y);
}
10 changes: 9 additions & 1 deletion device/wormhole/wormhole_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ 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_logical_coords translated_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;
};

private:
static const std::size_t translated_coordinate_start_x = 18;
static const std::size_t translated_coordinate_start_y = 18;
};
14 changes: 10 additions & 4 deletions tests/api/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
set(API_TESTS_SRCS
test_cluster.cpp
test_cluster_descriptor.cpp
test_soc_descriptor.cpp
test_soc_descriptor_gs.cpp
test_soc_descriptor_wh.cpp
test_soc_descriptor_bh.cpp
)

add_executable(api_tests ${API_TESTS_SRCS})
target_link_libraries(api_tests PRIVATE test_common)
set_target_properties(api_tests PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test/umd/api
OUTPUT_NAME api_tests
set_target_properties(
api_tests
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/test/umd/api
OUTPUT_NAME
api_tests
)
Loading

0 comments on commit 950feee

Please sign in to comment.