-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing barrier types for Dynamic NoC #18486
base: main
Are you sure you want to change the base?
Conversation
e6e65eb
to
016f839
Compare
} else { | ||
WAYPOINT("NKFW"); | ||
// Assert that no noc transactions are outstanding, to ensure that all reads and writes have landed and the | ||
// NOC interface is in a known idle state for the next kernel. | ||
for (int noc = 0; noc < NUM_NOCS; noc++) { | ||
ASSERT(ncrisc_dynamic_noc_reads_flushed(noc)); | ||
ASSERT(ncrisc_dynamic_noc_nonposted_writes_sent(noc)); | ||
ASSERT(ncrisc_dynamic_noc_nonposted_writes_flushed(noc)); | ||
ASSERT(ncrisc_dynamic_noc_nonposted_atomics_flushed(noc)); | ||
ASSERT(ncrisc_dynamic_noc_posted_writes_sent(noc)); | ||
} | ||
WAYPOINT("NKFD"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we didn't support dynamic noc on ethernet?
} else { | ||
WAYPOINT("NKFW"); | ||
// Assert that no noc transactions are outstanding, to ensure that all reads and writes have landed and the | ||
// NOC interface is in a known idle state for the next kernel. | ||
for (int noc = 0; noc < NUM_NOCS; noc++) { | ||
ASSERT(ncrisc_dynamic_noc_reads_flushed(noc)); | ||
ASSERT(ncrisc_dynamic_noc_nonposted_writes_sent(noc)); | ||
ASSERT(ncrisc_dynamic_noc_nonposted_writes_flushed(noc)); | ||
ASSERT(ncrisc_dynamic_noc_nonposted_atomics_flushed(noc)); | ||
ASSERT(ncrisc_dynamic_noc_posted_writes_sent(noc)); | ||
} | ||
WAYPOINT("NKFD"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like debug code, will remove
set_noc_counter_val<dm0, NocBarrierType::READS_NUM_ISSUED>( | ||
NOC_0, NOC_STATUS_READ_REG(NOC_0, NIU_MST_RD_RESP_RECEIVED)); | ||
set_noc_counter_val<dm0, NocBarrierType::READS_NUM_ISSUED>(NOC_1, 0); | ||
set_noc_counter_val<dm1, NocBarrierType::READS_NUM_ISSUED>(NOC_0, 0); | ||
set_noc_counter_val<dm1, NocBarrierType::READS_NUM_ISSUED>( | ||
NOC_1, NOC_STATUS_READ_REG(NOC_1, NIU_MST_RD_RESP_RECEIVED)); | ||
|
||
set_noc_counter_val<dm0, NocBarrierType::NONPOSTED_WRITES_NUM_ISSUED>( | ||
NOC_0, NOC_STATUS_READ_REG(NOC_0, NIU_MST_NONPOSTED_WR_REQ_SENT)); | ||
set_noc_counter_val<dm0, NocBarrierType::NONPOSTED_WRITES_NUM_ISSUED>(NOC_1, 0); | ||
set_noc_counter_val<dm1, NocBarrierType::NONPOSTED_WRITES_NUM_ISSUED>(NOC_0, 0); | ||
set_noc_counter_val<dm1, NocBarrierType::NONPOSTED_WRITES_NUM_ISSUED>( | ||
NOC_1, NOC_STATUS_READ_REG(NOC_1, NIU_MST_NONPOSTED_WR_REQ_SENT)); | ||
|
||
set_noc_counter_val<dm0, NocBarrierType::NONPOSTED_WRITES_ACKED>( | ||
NOC_0, NOC_STATUS_READ_REG(NOC_0, NIU_MST_WR_ACK_RECEIVED)); | ||
set_noc_counter_val<dm0, NocBarrierType::NONPOSTED_WRITES_ACKED>(NOC_1, 0); | ||
set_noc_counter_val<dm1, NocBarrierType::NONPOSTED_WRITES_ACKED>(NOC_0, 0); | ||
set_noc_counter_val<dm1, NocBarrierType::NONPOSTED_WRITES_ACKED>( | ||
NOC_1, NOC_STATUS_READ_REG(NOC_1, NIU_MST_WR_ACK_RECEIVED)); | ||
|
||
set_noc_counter_val<dm0, NocBarrierType::NONPOSTED_ATOMICS_ACKED>( | ||
NOC_0, NOC_STATUS_READ_REG(NOC_0, NIU_MST_ATOMIC_RESP_RECEIVED)); | ||
set_noc_counter_val<dm0, NocBarrierType::NONPOSTED_ATOMICS_ACKED>(NOC_1, 0); | ||
set_noc_counter_val<dm1, NocBarrierType::NONPOSTED_ATOMICS_ACKED>(NOC_0, 0); | ||
set_noc_counter_val<dm1, NocBarrierType::NONPOSTED_ATOMICS_ACKED>( | ||
NOC_1, NOC_STATUS_READ_REG(NOC_1, NIU_MST_ATOMIC_RESP_RECEIVED)); | ||
|
||
set_noc_counter_val<dm0, NocBarrierType::POSTED_WRITES_NUM_ISSUED>( | ||
NOC_0, NOC_STATUS_READ_REG(NOC_0, NIU_MST_POSTED_WR_REQ_SENT)); | ||
set_noc_counter_val<dm0, NocBarrierType::POSTED_WRITES_NUM_ISSUED>(NOC_1, 0); | ||
set_noc_counter_val<dm1, NocBarrierType::POSTED_WRITES_NUM_ISSUED>(NOC_0, 0); | ||
set_noc_counter_val<dm1, NocBarrierType::POSTED_WRITES_NUM_ISSUED>( | ||
NOC_1, NOC_STATUS_READ_REG(NOC_1, NIU_MST_POSTED_WR_REQ_SENT)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if we can clean this up in a nice way since it's basically doing the same thing for each barrier type, register pair.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm not sure how to make the code shorter
tt_metal/hw/firmware/src/brisc.cc
Outdated
if (noc_mode == DM_DYNAMIC_NOC) { | ||
// inc dm noc counter for BH as this is non-posted | ||
inc_noc_counter_val< | ||
static_cast<std::underlying_type_t<TensixProcessorTypes>>(TensixProcessorTypes::DM0), | ||
NocBarrierType::NONPOSTED_ATOMICS_ACKED>(noc_index, 1); | ||
// barrier till the atomic response is back | ||
while (!ncrisc_dynamic_noc_nonposted_atomics_flushed(noc_index)); | ||
// reset local counters | ||
noc_local_state_init(noc_index); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have to do this increment manually, and then reset the dedicated noc counters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was some patches that I made to stop BH hang, I did the inc to make the barrier work in dynamic mode.
But it seems we aren't doing any barrier in dedicated mode, this can be removed
noc_fast_atomic_increment( | ||
noc, | ||
write_at_cmd_buf, | ||
remote_ack_ptr_addr, | ||
NOC_UNICAST_WRITE_VC, | ||
aligned_page_adjustment, | ||
31 /*wrap*/, | ||
false /*linked*/, | ||
true /*posted*/, | ||
MEM_NOC_ATOMIC_RET_VAL_ADDR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is doing a posted atomic. Wasn't this unsafe for BH?
Also, doesn't this assume dedicated noc mode since you aren't setting the noc mode? How does this work for FW?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah good point, previously the remote cb setup is before run ncrisc, so it works fine since there's no other txns and we can use dedicated mode.
Now that we moved the ncrisc start before remote cb setup, I think we need to use the proper mode now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea for BH we need to do non posted
Llama model hang when in Dynamic noc mode, the bug was found to be the interaction with remote cb and dm noc mode.
Bug fixed in this PR also added missing barriers for dm noc
Checklist