Skip to content

Commit

Permalink
#12844: Add global arrays to erisc.cc and idle_erisc.cc.
Browse files Browse the repository at this point in the history
  • Loading branch information
spoojaryTT committed Nov 14, 2024
1 parent 5611f40 commit ac2686a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
15 changes: 15 additions & 0 deletions tt_metal/hw/firmware/src/erisc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ uint32_t tt_l1_ptr *rta_l1_base __attribute__((used));
uint32_t tt_l1_ptr *crta_l1_base __attribute__((used));
uint32_t tt_l1_ptr *sem_l1_base[ProgrammableCoreType::COUNT] __attribute__((used));

uint16_t dram_bank_to_noc_xy[NUM_NOCS][NUM_DRAM_BANKS] __attribute__((used));
uint16_t l1_bank_to_noc_xy[NUM_NOCS][NUM_L1_BANKS] __attribute__((used));
int32_t bank_to_dram_offset[NUM_DRAM_BANKS] __attribute__((used));
int32_t bank_to_l1_offset[NUM_L1_BANKS] __attribute__((used));

void __attribute__((noinline)) Application(void) {
WAYPOINT("I");
rtos_context_switch_ptr = (void (*)())RtosTable[0];
Expand All @@ -41,6 +46,16 @@ void __attribute__((noinline)) Application(void) {
// TODO: need to find free space that routing FW is not using
wzerorange(__ldm_bss_start, __ldm_bss_end);

int32_t num_dram_to_noc_words = (NUM_NOCS * NUM_DRAM_BANKS) << 1;
l1_to_local_mem_copy((uint*)dram_bank_to_noc_xy, (uint tt_l1_ptr*)MEM_BANK_TO_NOC_XY_SCRATCH, num_dram_to_noc_words);
int32_t num_l1_to_noc_words = (NUM_NOCS * NUM_L1_BANKS) << 1;
l1_to_local_mem_copy((uint*)l1_bank_to_noc_xy, (uint tt_l1_ptr*)(MEM_BANK_TO_NOC_XY_SCRATCH + num_dram_to_noc_words), num_l1_to_noc_words);

int32_t num_dram_offset_words = NUM_DRAM_BANKS << 2;
l1_to_local_mem_copy((uint*)bank_to_dram_offset, (uint tt_l1_ptr*)(MEM_BANK_OFFSET_SCRATCH), num_dram_offset_words);
int32_t num_l1_offset_words = NUM_L1_BANKS << 2;
l1_to_local_mem_copy((uint*)bank_to_l1_offset, (uint tt_l1_ptr*)(MEM_BANK_OFFSET_SCRATCH + num_dram_offset_words), num_l1_offset_words);

risc_init();
noc_init(MEM_NOC_ATOMIC_RET_VAL_ADDR);
wzerorange(__ldm_bss_start, __ldm_bss_end);
Expand Down
15 changes: 15 additions & 0 deletions tt_metal/hw/firmware/src/idle_erisc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ uint32_t tt_l1_ptr *sem_l1_base[ProgrammableCoreType::COUNT] __attribute__((used
uint8_t my_x[NUM_NOCS] __attribute__((used));
uint8_t my_y[NUM_NOCS] __attribute__((used));

uint16_t dram_bank_to_noc_xy[NUM_NOCS][NUM_DRAM_BANKS] __attribute__((used));
uint16_t l1_bank_to_noc_xy[NUM_NOCS][NUM_L1_BANKS] __attribute__((used));
int32_t bank_to_dram_offset[NUM_DRAM_BANKS] __attribute__((used));
int32_t bank_to_l1_offset[NUM_L1_BANKS] __attribute__((used));

//c_tensix_core core;

tt_l1_ptr mailboxes_t * const mailboxes = (tt_l1_ptr mailboxes_t *)(MEM_IERISC_MAILBOX_BASE);
Expand Down Expand Up @@ -105,6 +110,16 @@ int main() {
local_mem_ptr[i] = l1_data_ptr[i];
}

int32_t num_dram_to_noc_words = (NUM_NOCS * NUM_DRAM_BANKS) << 1;
l1_to_local_mem_copy((uint*)dram_bank_to_noc_xy, (uint tt_l1_ptr*)MEM_BANK_TO_NOC_XY_SCRATCH, num_dram_to_noc_words);
int32_t num_l1_to_noc_words = (NUM_NOCS * NUM_L1_BANKS) << 1;
l1_to_local_mem_copy((uint*)l1_bank_to_noc_xy, (uint tt_l1_ptr*)(MEM_BANK_TO_NOC_XY_SCRATCH + num_dram_to_noc_words), num_l1_to_noc_words);

int32_t num_dram_offset_words = NUM_DRAM_BANKS << 2;
l1_to_local_mem_copy((uint*)bank_to_dram_offset, (uint tt_l1_ptr*)(MEM_BANK_OFFSET_SCRATCH), num_dram_offset_words);
int32_t num_l1_offset_words = NUM_L1_BANKS << 2;
l1_to_local_mem_copy((uint*)bank_to_l1_offset, (uint tt_l1_ptr*)(MEM_BANK_OFFSET_SCRATCH + num_dram_offset_words), num_l1_offset_words);

risc_init();

mailboxes->slave_sync.all = RUN_SYNC_MSG_ALL_SLAVES_DONE;
Expand Down
2 changes: 1 addition & 1 deletion tt_metal/impl/device/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,12 @@ void Device::initialize_global_array(const HalProgrammableCoreType &core_type, C
void Device::initialize_firmware(const HalProgrammableCoreType &core_type, CoreCoord phys_core, launch_msg_t *launch_msg, go_msg_t* go_msg) {
ZoneScoped;

this->initialize_global_array(core_type, phys_core);
uint32_t core_type_idx = hal.get_programmable_core_type_index(core_type);
uint32_t processor_class_count = hal.get_processor_classes_count(core_type);

switch (core_type) {
case HalProgrammableCoreType::TENSIX: {
this->initialize_global_array(core_type, phys_core);
llrt::program_risc_startup_addr(this->id(), phys_core);
for (uint32_t processor_class = 0; processor_class < processor_class_count; processor_class++) {
auto [build_idx, num_build_states] = this->build_processor_type_to_index(core_type_idx, processor_class);
Expand Down

0 comments on commit ac2686a

Please sign in to comment.