Skip to content

Commit

Permalink
#14427: constexpr timeout cycles
Browse files Browse the repository at this point in the history
timeout cycles can be made constexpr
  • Loading branch information
nhuang-tt committed Jan 16, 2025
1 parent ef631eb commit 4fc8193
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion tt_metal/impl/dispatch/kernel_config/demux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: Apache-2.0
#include "demux.hpp"
#include "common/logger.hpp"
#include "dispatch.hpp"
#include "eth_tunneler.hpp"

Expand Down
8 changes: 5 additions & 3 deletions tt_metal/impl/dispatch/kernels/packet_demux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void kernel_main() {
DeviceZoneScopedN("PACKET-DEMUX");
IDLE_ERISC_HEARTBEAT_AND_RETURN(heartbeat);
iter++;
if (timeout_cycles > 0) {
if constexpr (timeout_cycles > 0) {
uint32_t cycles_since_progress = get_timestamp_32b() - progress_timestamp;
if (cycles_since_progress > timeout_cycles) {
timeout = true;
Expand Down Expand Up @@ -261,8 +261,10 @@ void kernel_main() {
break;
}
data_words_sent += words_sent;
if ((words_sent > 0) && (timeout_cycles > 0)) {
progress_timestamp = get_timestamp_32b();
if constexpr (timeout_cycles > 0) {
if (words_sent > 0) {
progress_timestamp = get_timestamp_32b();
}
}
}
all_outputs_finished = true;
Expand Down
8 changes: 5 additions & 3 deletions tt_metal/impl/dispatch/kernels/packet_mux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void kernel_main() {
DeviceZoneScopedN("PACKET-MUX");
IDLE_ERISC_HEARTBEAT_AND_RETURN(heartbeat);
iter++;
if (timeout_cycles > 0) {
if constexpr (timeout_cycles > 0) {
uint32_t cycles_since_progress = get_timestamp_32b() - progress_timestamp;
if (cycles_since_progress > timeout_cycles) {
timeout = true;
Expand All @@ -202,8 +202,10 @@ void kernel_main() {
bool full_packet_sent;
uint32_t words_sent = output_queue.template forward_data_from_input<tx_network_type, output_depacketize, input_network_type, input_cb_mode>(sequence_i, full_packet_sent, input_queues[sequence_i].get_end_of_cmd());
data_words_sent += words_sent;
if ((words_sent > 0) && (timeout_cycles > 0)) {
progress_timestamp = get_timestamp_32b();
if constexpr (timeout_cycles > 0) {
if (words_sent > 0) {
progress_timestamp = get_timestamp_32b();
}
}
curr_input_partial_packet_sent = !full_packet_sent;
}
Expand Down

0 comments on commit 4fc8193

Please sign in to comment.