Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Add missing barrier types for Dynamic NoC #18486

wants to merge 7 commits into from

Conversation

yugaoTT
Copy link
Contributor

@yugaoTT yugaoTT commented Feb 28, 2025

@yugaoTT yugaoTT self-assigned this Feb 28, 2025
Comment on lines 45 to 56
} 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");
Copy link
Contributor

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?

Comment on lines 45 to 56
} 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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above

Copy link
Contributor Author

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

Comment on lines +477 to +510
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));
Copy link
Contributor

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.

Copy link
Contributor Author

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

Comment on lines 601 to 610
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);
}
Copy link
Contributor

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?

Copy link
Contributor Author

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

Comment on lines 34 to 43
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);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants