Skip to content

Commit

Permalink
Implement ETH channel id mapping (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanevskiTT authored Jan 22, 2025
1 parent 558328f commit 8ec6354
Show file tree
Hide file tree
Showing 19 changed files with 182 additions and 234 deletions.
3 changes: 0 additions & 3 deletions device/api/umd/device/blackhole_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class BlackholeCoordinateManager : public CoordinateManager {
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 size_t eth_harvesting_mask,
const tt_xy_pair& arc_grid_size,
Expand Down Expand Up @@ -49,10 +48,8 @@ class BlackholeCoordinateManager : public CoordinateManager {
std::vector<tt::umd::CoreCoord> get_harvested_eth_cores() const override;
tt_xy_pair get_tensix_grid_size() const override;
tt_xy_pair get_dram_grid_size() const override;
tt_xy_pair get_eth_grid_size() const override;
tt_xy_pair get_harvested_tensix_grid_size() const override;
tt_xy_pair get_harvested_dram_grid_size() const override;
tt_xy_pair get_harvested_eth_grid_size() const 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
35 changes: 17 additions & 18 deletions device/api/umd/device/blackhole_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,6 @@ static const std::vector<tt_xy_pair> DRAM_CORES = {
// the existing code in clients which rely on DRAM_LOCATIONS.
static const std::vector<tt_xy_pair> DRAM_LOCATIONS = DRAM_CORES;

static const tt_xy_pair ETH_GRID_SIZE = {14, 1};
static const std::vector<tt_xy_pair> ETH_CORES = {
{1, 1},
{2, 1},
{3, 1},
{4, 1},
{5, 1},
{6, 1},
{7, 1},
{10, 1},
{11, 1},
{12, 1},
{13, 1},
{14, 1},
{15, 1},
{16, 1}};
static const std::vector<tt_xy_pair> ETH_LOCATIONS = ETH_CORES;

static const tt_xy_pair ARC_GRID_SIZE = {1, 1};
static const std::vector<tt_xy_pair> ARC_CORES = {{8, 0}};
static const std::vector<tt_xy_pair> ARC_LOCATIONS = ARC_CORES;
Expand All @@ -124,6 +106,23 @@ static const std::vector<tt_xy_pair> ROUTER_CORES = {
{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {10, 0}, {12, 0}, {13, 0}, {14, 0}, {15, 0},
{16, 0}, {8, 1}, {8, 2}, {8, 3}, {8, 4}, {8, 5}, {8, 6}, {8, 7}, {8, 8}, {8, 9}, {8, 10}, {8, 11}};

static const size_t NUM_ETH_CHANNELS = 14;
static const std::vector<tt_xy_pair> ETH_CORES = {
{{1, 1},
{16, 1},
{2, 1},
{15, 1},
{3, 1},
{14, 1},
{4, 1},
{13, 1},
{5, 1},
{12, 1},
{6, 1},
{11, 1},
{7, 1},
{10, 1}}};
static const std::vector<tt_xy_pair> ETH_LOCATIONS = ETH_CORES;
// Return to std::array instead of std::vector once we get std::span support in C++20
static const std::vector<uint32_t> T6_X_LOCATIONS = {1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16};
static const std::vector<uint32_t> T6_Y_LOCATIONS = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
Expand Down
10 changes: 5 additions & 5 deletions device/api/umd/device/coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class CoordinateManager {
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 size_t eth_harvesting_mask,
const tt_xy_pair& arc_grid_size,
Expand Down Expand Up @@ -76,6 +75,10 @@ class CoordinateManager {
size_t get_dram_harvesting_mask() const;
size_t get_eth_harvesting_mask() const;

uint32_t get_num_eth_channels() const;

uint32_t get_num_harvested_eth_channels() const;

private:
const std::vector<tt_xy_pair>& get_physical_pairs(const CoreType core_type) const;
std::vector<tt::umd::CoreCoord> get_all_physical_cores(const CoreType core_type) const;
Expand All @@ -97,7 +100,6 @@ class CoordinateManager {
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 size_t eth_harvesting_mask,
const tt_xy_pair& arc_grid_size,
Expand Down Expand Up @@ -128,10 +130,8 @@ class CoordinateManager {
virtual std::vector<tt::umd::CoreCoord> get_harvested_eth_cores() const;
virtual tt_xy_pair get_tensix_grid_size() const;
virtual tt_xy_pair get_dram_grid_size() const;
virtual tt_xy_pair get_eth_grid_size() const;
virtual tt_xy_pair get_harvested_tensix_grid_size() const;
virtual tt_xy_pair get_harvested_dram_grid_size() const;
virtual tt_xy_pair get_harvested_eth_grid_size() const;

/*
* By default, translated coordinates are the same as physical coordinates.
Expand Down Expand Up @@ -210,7 +210,7 @@ class CoordinateManager {
const std::vector<tt_xy_pair> dram_cores;
size_t dram_harvesting_mask;

tt_xy_pair eth_grid_size;
const size_t num_eth_channels;
const std::vector<tt_xy_pair> eth_cores;
const size_t eth_harvesting_mask;

Expand Down
1 change: 0 additions & 1 deletion device/api/umd/device/grayskull_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class GrayskullCoordinateManager : public CoordinateManager {
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 size_t eth_harvesting_mask,
const tt_xy_pair& arc_grid_size,
Expand Down
3 changes: 3 additions & 0 deletions device/api/umd/device/tt_soc_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class tt_SocDescriptor {

int get_num_dram_channels() const;

uint32_t get_num_eth_channels() const;
uint32_t get_num_harvested_eth_channels() const;

bool is_worker_core(const tt_xy_pair &core) const;

tt_xy_pair get_core_for_dram_channel(int dram_chan, int subchannel) const;
Expand Down
1 change: 0 additions & 1 deletion device/api/umd/device/wormhole_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class WormholeCoordinateManager : public CoordinateManager {
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 size_t eth_harvesting_mask,
const tt_xy_pair& arc_grid_size,
Expand Down
20 changes: 10 additions & 10 deletions device/api/umd/device/wormhole_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,24 @@ static const std::vector<tt_xy_pair> DRAM_CORES = {
// the existing code in clients which rely on DRAM_LOCATIONS.
static const std::vector<tt_xy_pair> DRAM_LOCATIONS = DRAM_CORES;

static const tt_xy_pair ETH_GRID_SIZE = {8, 2};
static const size_t NUM_ETH_CHANNELS = 16;
static const std::vector<tt_xy_pair> ETH_CORES = {
{{1, 0},
{{9, 0},
{1, 0},
{8, 0},
{2, 0},
{7, 0},
{3, 0},
{4, 0},
{6, 0},
{7, 0},
{8, 0},
{9, 0},
{4, 0},
{9, 6},
{1, 6},
{8, 6},
{2, 6},
{7, 6},
{3, 6},
{4, 6},
{6, 6},
{7, 6},
{8, 6},
{9, 6}}};
{4, 6}}};
static const std::vector<tt_xy_pair> ETH_LOCATIONS = ETH_CORES;

static const tt_xy_pair ARC_GRID_SIZE = {1, 1};
Expand Down
115 changes: 45 additions & 70 deletions device/blackhole/blackhole_coordinate_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ BlackholeCoordinateManager::BlackholeCoordinateManager(
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 size_t eth_harvesting_mask,
const tt_xy_pair& arc_grid_size,
Expand All @@ -33,7 +32,6 @@ BlackholeCoordinateManager::BlackholeCoordinateManager(
dram_grid_size,
dram_cores,
dram_harvesting_mask,
eth_grid_size,
eth_cores,
eth_harvesting_mask,
arc_grid_size,
Expand Down Expand Up @@ -162,37 +160,29 @@ void BlackholeCoordinateManager::translate_dram_coords() {
}

void BlackholeCoordinateManager::translate_eth_coords() {
size_t num_harvested_x = CoordinateManager::get_num_harvested(eth_harvesting_mask);
size_t grid_size_x = eth_grid_size.x;
size_t grid_size_y = eth_grid_size.y;
size_t num_harvested_channels = CoordinateManager::get_num_harvested(eth_harvesting_mask);

size_t logical_x = 0;
size_t x_index = grid_size_x - num_harvested_x;
for (size_t x = 0; x < grid_size_x; x++) {
if (eth_harvesting_mask & (1 << x)) {
for (size_t y = 0; y < grid_size_y; y++) {
const tt_xy_pair& physical_core = eth_cores[x + y * grid_size_x];
const tt_xy_pair& virtual_core = eth_cores[x_index + y * grid_size_x];
size_t harvested_eth_channel_start = eth_cores.size() - num_harvested_channels;
size_t unharvested_logical_eth_channel = 0;
for (size_t eth_channel = 0; eth_channel < eth_cores.size(); eth_channel++) {
if (eth_harvesting_mask & (1 << eth_channel)) {
const tt_xy_pair& physical_core = eth_cores[eth_channel];
const tt_xy_pair& virtual_core = eth_cores[harvested_eth_channel_start++];

CoreCoord virtual_coord =
CoreCoord(virtual_core.x, virtual_core.y, CoreType::ETH, CoordSystem::VIRTUAL);
CoreCoord virtual_coord = CoreCoord(virtual_core.x, virtual_core.y, CoreType::ETH, CoordSystem::VIRTUAL);

add_core_translation(virtual_coord, physical_core);
}
x_index++;
add_core_translation(virtual_coord, physical_core);
} else {
for (size_t y = 0; y < grid_size_y; y++) {
const tt_xy_pair& tensix_core = eth_cores[x + y * grid_size_x];
const tt_xy_pair& virtual_core = eth_cores[logical_x + y * grid_size_x];
const tt_xy_pair& tensix_core = eth_cores[eth_channel];
const tt_xy_pair& virtual_core = eth_cores[unharvested_logical_eth_channel];

CoreCoord logical_coord = CoreCoord(logical_x, y, CoreType::ETH, CoordSystem::LOGICAL);
add_core_translation(logical_coord, tensix_core);
CoreCoord logical_coord =
CoreCoord(0, unharvested_logical_eth_channel, CoreType::ETH, CoordSystem::LOGICAL);
add_core_translation(logical_coord, tensix_core);

CoreCoord virtual_coord =
CoreCoord(virtual_core.x, virtual_core.y, CoreType::ETH, CoordSystem::VIRTUAL);
add_core_translation(virtual_coord, tensix_core);
}
logical_x++;
CoreCoord virtual_coord = CoreCoord(virtual_core.x, virtual_core.y, CoreType::ETH, CoordSystem::VIRTUAL);
add_core_translation(virtual_coord, tensix_core);
unharvested_logical_eth_channel++;
}
}

Expand All @@ -204,31 +194,27 @@ void BlackholeCoordinateManager::translate_eth_coords() {
}

void BlackholeCoordinateManager::fill_eth_physical_translated_mapping() {
const size_t num_harvested_x = CoordinateManager::get_num_harvested(eth_harvesting_mask);
for (size_t x = 0; x < eth_grid_size.x - num_harvested_x; x++) {
for (size_t y = 0; y < eth_grid_size.y; y++) {
const size_t translated_x = x + blackhole::eth_translated_coordinate_start_x;
const size_t translated_y = y + blackhole::eth_translated_coordinate_start_y;
const size_t num_harvested_channels = CoordinateManager::get_num_harvested(eth_harvesting_mask);
for (size_t eth_channel = 0; eth_channel < eth_cores.size() - num_harvested_channels; eth_channel++) {
const size_t translated_x = eth_channel + blackhole::eth_translated_coordinate_start_x;
const size_t translated_y = blackhole::eth_translated_coordinate_start_y;

CoreCoord logical_coord = CoreCoord(x, y, CoreType::ETH, CoordSystem::LOGICAL);
const tt_xy_pair physical_pair = to_physical_map[logical_coord];
CoreCoord logical_coord = CoreCoord(0, eth_channel, 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);
CoreCoord translated_coord = CoreCoord(translated_x, translated_y, CoreType::ETH, CoordSystem::TRANSLATED);

add_core_translation(translated_coord, physical_pair);
}
add_core_translation(translated_coord, physical_pair);
}

// Harvested ETH cores should be mapped to the same physical coordinates.
for (size_t y = 0; y < eth_grid_size.y; y++) {
for (size_t x = 0; x < eth_grid_size.x; x++) {
if (eth_harvesting_mask & (1 << x)) {
const tt_xy_pair& physical_pair = eth_cores[x + y * eth_grid_size.x];
const CoreCoord translated_coord =
CoreCoord(physical_pair.x, physical_pair.y, CoreType::ETH, CoordSystem::TRANSLATED);

add_core_translation(translated_coord, physical_pair);
}
for (size_t eth_channel = 0; eth_channel < eth_cores.size(); eth_channel++) {
if (eth_harvesting_mask & (1 << eth_channel)) {
const tt_xy_pair& physical_pair = eth_cores[eth_channel];
const CoreCoord translated_coord =
CoreCoord(physical_pair.x, physical_pair.y, CoreType::ETH, CoordSystem::TRANSLATED);

add_core_translation(translated_coord, physical_pair);
}
}
}
Expand Down Expand Up @@ -405,32 +391,29 @@ std::vector<CoreCoord> BlackholeCoordinateManager::get_harvested_dram_cores() co
}

std::vector<CoreCoord> BlackholeCoordinateManager::get_eth_cores() const {
std::vector<size_t> harvested_x_coords = get_harvested_indices(eth_harvesting_mask);
std::vector<size_t> harvested_channels = get_harvested_indices(eth_harvesting_mask);
std::vector<CoreCoord> unharvested_eth_cores;
for (size_t y = 0; y < eth_grid_size.y; y++) {
for (size_t x = 0; x < eth_grid_size.x; x++) {
const tt_xy_pair core = eth_cores[y * eth_grid_size.x + x];
CoreCoord core_coord(core.x, core.y, CoreType::ETH, CoordSystem::PHYSICAL);
if (std::find(harvested_x_coords.begin(), harvested_x_coords.end(), x) == harvested_x_coords.end()) {
unharvested_eth_cores.push_back(core_coord);
}
for (size_t eth_channel = 0; eth_channel < num_eth_channels; eth_channel++) {
const tt_xy_pair core = eth_cores[eth_channel];
CoreCoord core_coord(core.x, core.y, CoreType::ETH, CoordSystem::PHYSICAL);
if (std::find(harvested_channels.begin(), harvested_channels.end(), eth_channel) == harvested_channels.end()) {
unharvested_eth_cores.push_back(core_coord);
}
}
return unharvested_eth_cores;
}

std::vector<CoreCoord> BlackholeCoordinateManager::get_harvested_eth_cores() const {
std::vector<size_t> harvested_x_coords = get_harvested_indices(eth_harvesting_mask);
std::vector<size_t> harvested_channels = get_harvested_indices(eth_harvesting_mask);
std::vector<CoreCoord> harvested_eth_cores;
for (size_t y = 0; y < eth_grid_size.y; y++) {
for (size_t x = 0; x < eth_grid_size.x; x++) {
const tt_xy_pair core = eth_cores[y * eth_grid_size.x + x];
CoreCoord core_coord(core.x, core.y, CoreType::ETH, CoordSystem::PHYSICAL);
if (std::find(harvested_x_coords.begin(), harvested_x_coords.end(), x) != harvested_x_coords.end()) {
harvested_eth_cores.push_back(core_coord);
}
for (size_t eth_channel = 0; eth_channel < num_eth_channels; eth_channel++) {
const tt_xy_pair core = eth_cores[eth_channel];
CoreCoord core_coord(core.x, core.y, CoreType::ETH, CoordSystem::PHYSICAL);
if (std::find(harvested_channels.begin(), harvested_channels.end(), eth_channel) != harvested_channels.end()) {
harvested_eth_cores.push_back(core_coord);
}
}

return harvested_eth_cores;
}

Expand All @@ -442,18 +425,10 @@ tt_xy_pair BlackholeCoordinateManager::get_harvested_dram_grid_size() const {
return {CoordinateManager::get_num_harvested(dram_harvesting_mask), dram_grid_size.y};
}

tt_xy_pair BlackholeCoordinateManager::get_harvested_eth_grid_size() const {
return {CoordinateManager::get_num_harvested(eth_harvesting_mask), eth_grid_size.y};
}

tt_xy_pair BlackholeCoordinateManager::get_tensix_grid_size() const {
return {tensix_grid_size.x - CoordinateManager::get_num_harvested(tensix_harvesting_mask), tensix_grid_size.y};
}

tt_xy_pair BlackholeCoordinateManager::get_dram_grid_size() const {
return {dram_grid_size.x - CoordinateManager::get_num_harvested(dram_harvesting_mask), dram_grid_size.y};
}

tt_xy_pair BlackholeCoordinateManager::get_eth_grid_size() const {
return {eth_grid_size.x - CoordinateManager::get_num_harvested(eth_harvesting_mask), eth_grid_size.y};
}
Loading

0 comments on commit 8ec6354

Please sign in to comment.