Skip to content

Commit

Permalink
Fix wormhole ETH translation (#469)
Browse files Browse the repository at this point in the history
### Issue
While working on #439

### Description
Translation was being calculated by using logical coordinates. But we
want logical coordinates to be in the same order as defined in the input
yaml. Since these are not consecutive (meaning consecutive logical
coords are not consecutive any other coords), this breaks translation
logic.
BH to be fixed.

### List of the changes
- Fixed the wh eth translation test not to have any logic
- Fixed eth translation to match the earlier one from cluster

### Testing
Fixed the test to have hardcoded values.

### API Changes
There are no API changes in this PR.
  • Loading branch information
broskoTT authored Jan 23, 2025
1 parent 809311d commit a8e5223
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
26 changes: 16 additions & 10 deletions device/wormhole/wormhole_coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,24 @@ void WormholeCoordinateManager::fill_dram_physical_translated_mapping() {
}

void WormholeCoordinateManager::fill_eth_physical_translated_mapping() {
const size_t eth_grid_size_x = (num_eth_channels + 1) / 2;
const size_t eth_grid_size_y = num_eth_channels / eth_grid_size_x;
for (size_t x = 0; x < eth_grid_size_x; x++) {
for (size_t y = 0; y < eth_grid_size_y; y++) {
const size_t translated_x = x + wormhole::eth_translated_coordinate_start_x;
const size_t translated_y = y + wormhole::eth_translated_coordinate_start_y;
CoreCoord logical_coord = CoreCoord(0, y * eth_grid_size_x + x, CoreType::ETH, CoordSystem::LOGICAL);
const tt_xy_pair physical_pair = to_physical_map[logical_coord];
CoreCoord translated_coord = CoreCoord(translated_x, translated_y, CoreType::ETH, CoordSystem::TRANSLATED);
for (auto eth_core : eth_cores) {
CoreCoord translated_coord = CoreCoord(eth_core, CoreType::ETH, CoordSystem::TRANSLATED);

add_core_translation(translated_coord, physical_pair);
// X coordinate is in range [1-4], [6-9], but it should be consecutive in translated coordinates.
if (translated_coord.x > 5) {
translated_coord.x -= 1;
}
// Since the translated coordinates start from 1, we need to subtract 1 to the translated X coordinate.
translated_coord.x -= 1;
translated_coord.x += wormhole::eth_translated_coordinate_start_x;

// Y coordinate is either 0 or 6, but it should be consecutive in translated coordinates.
if (translated_coord.y == 6) {
translated_coord.y = 1;
}
translated_coord.y += wormhole::eth_translated_coordinate_start_y;

add_core_translation(translated_coord, eth_core);
}
}

Expand Down
19 changes: 8 additions & 11 deletions tests/api/test_core_coord_translation_wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,21 +292,18 @@ TEST(CoordinateManager, CoordinateManagerWormholeETHPhysicalEqualVirtual) {
}

// Test translation of logical to translated ethernet coordinates.
TEST(CoordinateManager, CoordinateManagerWormholeETHLogicalToTranslated) {
TEST(CoordinateManager, CoordinateManagerWormholeETHTranslated) {
std::shared_ptr<CoordinateManager> coordinate_manager =
CoordinateManager::create_coordinate_manager(tt::ARCH::WORMHOLE_B0, true);

const size_t num_eth_channels = tt::umd::wormhole::NUM_ETH_CHANNELS;
// Check translation for all corners of eth cores.
std::vector<std::pair<tt_xy_pair, tt_xy_pair>> input_output_eth_pairs = {
{{1, 0}, {18, 16}}, {{9, 0}, {25, 16}}, {{1, 6}, {18, 17}}, {{9, 6}, {25, 17}}};

for (size_t eth_channel = 0; eth_channel < num_eth_channels; eth_channel++) {
const CoreCoord eth_logical = CoreCoord(0, eth_channel, CoreType::ETH, CoordSystem::LOGICAL);
const CoreCoord eth_translated = coordinate_manager->translate_coord_to(eth_logical, CoordSystem::TRANSLATED);
EXPECT_EQ(
eth_translated.x,
tt::umd::wormhole::eth_translated_coordinate_start_x + eth_channel % (num_eth_channels / 2));
EXPECT_EQ(
eth_translated.y,
tt::umd::wormhole::eth_translated_coordinate_start_y + eth_channel / (num_eth_channels / 2));
for (auto& [input_pair, output_pair] : input_output_eth_pairs) {
const CoreCoord eth_physical = CoreCoord(input_pair, CoreType::ETH, CoordSystem::PHYSICAL);
const CoreCoord eth_translated = coordinate_manager->translate_coord_to(eth_physical, CoordSystem::TRANSLATED);
EXPECT_EQ((tt_xy_pair)eth_translated, output_pair);
}
}

Expand Down

0 comments on commit a8e5223

Please sign in to comment.