Skip to content

Commit

Permalink
#12844: Combine NOC XY arrays to transfer one big array in device.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
spoojaryTT committed Nov 14, 2024
1 parent ed0095f commit 6fb325a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
26 changes: 7 additions & 19 deletions tt_metal/impl/device/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,21 +408,11 @@ void Device::build_firmware() {

void Device::initialize_global_array(const HalProgrammableCoreType &core_type, CoreCoord phys_core)
{
tt::Cluster::instance().write_core(&dram_bank_to_noc_xy_[0][0], dram_bank_to_noc_xy_[0].size() * sizeof(uint16_t), tt_cxy_pair(this->id(), phys_core), MEM_BANK_TO_NOC_XY_SCRATCH);


uint64_t addr = MEM_BANK_TO_NOC_XY_SCRATCH + (dram_bank_to_noc_xy_[0].size() * sizeof(uint16_t));
//tt::log_info(tt::LogTest, "initialize_global_array dram array 1 addr = {}", addr);
tt::Cluster::instance().write_core(&dram_bank_to_noc_xy_[1][0], dram_bank_to_noc_xy_[1].size() * sizeof(uint16_t), tt_cxy_pair(this->id(), phys_core), addr);

addr = MEM_BANK_TO_NOC_XY_SCRATCH + (sizeof(uint16_t) * (dram_bank_to_noc_xy_[0].size() + dram_bank_to_noc_xy_[1].size()));
tt::Cluster::instance().write_core(&l1_bank_to_noc_xy_[0][0], l1_bank_to_noc_xy_[0].size() * sizeof(uint16_t), tt_cxy_pair(this->id(), phys_core), addr);

addr = MEM_BANK_TO_NOC_XY_SCRATCH + (sizeof(uint16_t) * (dram_bank_to_noc_xy_[0].size() + dram_bank_to_noc_xy_[1].size() + l1_bank_to_noc_xy_[0].size()));
tt::Cluster::instance().write_core(&l1_bank_to_noc_xy_[1][0], l1_bank_to_noc_xy_[1].size() * sizeof(uint16_t), tt_cxy_pair(this->id(), phys_core), addr);
tt::Cluster::instance().write_core(&dram_bank_to_noc_xy_[0], dram_bank_to_noc_xy_.size() * sizeof(uint16_t), tt_cxy_pair(this->id(), phys_core), MEM_BANK_TO_NOC_XY_SCRATCH);
uint64_t addr = MEM_BANK_TO_NOC_XY_SCRATCH + (dram_bank_to_noc_xy_.size() * sizeof(uint16_t));
tt::Cluster::instance().write_core(&l1_bank_to_noc_xy_[0], l1_bank_to_noc_xy_.size() * sizeof(uint16_t), tt_cxy_pair(this->id(), phys_core), addr);

tt::Cluster::instance().write_core(&dram_bank_offset_map_[0], dram_bank_offset_map_.size() * sizeof(int32_t), tt_cxy_pair(this->id(), phys_core), MEM_BANK_OFFSET_SCRATCH);

addr = MEM_BANK_OFFSET_SCRATCH + (dram_bank_offset_map_.size() * sizeof(int32_t));
tt::Cluster::instance().write_core(&l1_bank_offset_map_[0], l1_bank_offset_map_.size() * sizeof(int32_t), tt_cxy_pair(this->id(), phys_core), addr);
}
Expand Down Expand Up @@ -3615,26 +3605,24 @@ void Device::generate_mem_bank_info(
{
tt::log_info(tt::LogTest, "generate_mem_bank_info called for device {}\n", this->id_);
dram_bank_to_noc_xy_.clear();
dram_bank_to_noc_xy_.resize(2);
dram_bank_to_noc_xy_.reserve(2 * dram_bank_map.size());
for (unsigned int noc = 0; noc < 2; noc++) {
dram_bank_to_noc_xy_[noc].reserve(dram_bank_map.size());
for (unsigned int bank_id = 0; bank_id < dram_bank_map.size(); bank_id++) {
uint16_t noc_x = NOC_0_X(noc, grid_size.x, dram_bank_map[bank_id].x);
uint16_t noc_y = NOC_0_Y(noc, grid_size.y, dram_bank_map[bank_id].y);
uint16_t xy = ((noc_y << NOC_ADDR_NODE_ID_BITS) | noc_x) << NOC_COORD_REG_OFFSET;
dram_bank_to_noc_xy_[noc].push_back(xy);
dram_bank_to_noc_xy_.push_back(xy);
}
}

l1_bank_to_noc_xy_.clear();
l1_bank_to_noc_xy_.resize(2);
l1_bank_to_noc_xy_.reserve(2 * l1_bank_map.size());
for (unsigned int noc = 0; noc < 2; noc++) {
l1_bank_to_noc_xy_[noc].reserve(l1_bank_map.size());
for (unsigned int bank_id = 0; bank_id < l1_bank_map.size(); bank_id++) {
uint16_t noc_x = NOC_0_X(noc, grid_size.x, l1_bank_map[bank_id].x);
uint16_t noc_y = NOC_0_Y(noc, grid_size.y, l1_bank_map[bank_id].y);
uint16_t xy = ((noc_y << NOC_ADDR_NODE_ID_BITS) | noc_x) << NOC_COORD_REG_OFFSET;
l1_bank_to_noc_xy_[noc].push_back(xy);
l1_bank_to_noc_xy_.push_back(xy);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tt_metal/impl/device/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ class Device {

std::vector<int32_t> dram_bank_offset_map_;
std::vector<int32_t> l1_bank_offset_map_;
std::vector<std::vector<uint16_t>> dram_bank_to_noc_xy_;
std::vector<std::vector<uint16_t>> l1_bank_to_noc_xy_;
std::vector<uint16_t> dram_bank_to_noc_xy_;
std::vector<uint16_t> l1_bank_to_noc_xy_;
};

} // namespace v0
Expand Down

0 comments on commit 6fb325a

Please sign in to comment.