Skip to content

Commit

Permalink
#14427: use dispatch buffer base
Browse files Browse the repository at this point in the history
dispatch buffer base is the correct addr to
use for the queue start addr. hal does not
account for dispatch dev addr and can easily
result in overlapping memory regions
  • Loading branch information
nhuang-tt committed Jan 16, 2025
1 parent c21e4bd commit ef631eb
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
5 changes: 3 additions & 2 deletions tt_metal/impl/dispatch/kernel_config/demux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//
// SPDX-License-Identifier: Apache-2.0
#include "demux.hpp"
#include "common/logger.hpp"
#include "dispatch.hpp"
#include "eth_tunneler.hpp"

Expand All @@ -11,12 +12,12 @@
using namespace tt::tt_metal;

void DemuxKernel::GenerateStaticConfigs() {
auto& my_dispatch_constants = dispatch_constants::get(GetCoreType());
uint16_t channel =
tt::Cluster::instance().get_assigned_channel_for_device(servicing_device_id_); // TODO: this can be mmio
logical_core_ = dispatch_core_manager::instance().demux_core(servicing_device_id_, channel, placement_cq_id_);
static_config_.endpoint_id_start_index = 0xD1;
static_config_.rx_queue_start_addr_words =
hal.get_dev_addr(HalProgrammableCoreType::TENSIX, HalL1MemAddrType::UNRESERVED) >> 4;
static_config_.rx_queue_start_addr_words = my_dispatch_constants.dispatch_buffer_base() >> 4;
static_config_.rx_queue_size_words = 0x10000 >> 4;
static_config_.demux_fan_out = downstream_kernels_.size();

Expand Down
3 changes: 1 addition & 2 deletions tt_metal/impl/dispatch/kernel_config/eth_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ void EthRouterKernel::GenerateStaticConfigs() {
} else {
uint16_t channel = tt::Cluster::instance().get_assigned_channel_for_device(device_->id());
logical_core_ = dispatch_core_manager::instance().demux_d_core(device_->id(), channel, placement_cq_id_);
static_config_.rx_queue_start_addr_words =
hal.get_dev_addr(HalProgrammableCoreType::TENSIX, HalL1MemAddrType::UNRESERVED) >> 4;
static_config_.rx_queue_start_addr_words = my_dispatch_constants.dispatch_buffer_base() >> 4;
static_config_.rx_queue_size_words = 0x8000 >> 4;

static_config_.kernel_status_buf_addr_arg = 0;
Expand Down
2 changes: 1 addition & 1 deletion tt_metal/impl/dispatch/kernel_config/eth_tunneler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void EthTunnelerKernel::GenerateStaticConfigs() {
logical_core_ = dispatch_core_manager::instance().us_tunneler_core_local(device_->id(), channel, cq_id_);
}
static_config_.endpoint_id_start_index = 0xDACADACA;
static_config_.in_queue_start_addr_words = 0x19000 >> 4;
static_config_.in_queue_start_addr_words = 0x19A00 >> 4;
static_config_.in_queue_size_words = 0x4000 >> 4;
static_config_.kernel_status_buf_addr_arg = 0x39000;
static_config_.kernel_status_buf_size_bytes = 0x7000;
Expand Down
6 changes: 3 additions & 3 deletions tt_metal/impl/dispatch/kernel_config/fd_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ void FDKernel::configure_kernel_variant(
if (tt::llrt::RunTimeOptions::get_instance().watcher_dispatch_disabled()) {
defines["FORCE_WATCHER_OFF"] = "1";
}
// if (!tt::DPrintServerReadsDispatchCores(device_)) {
// defines["FORCE_DPRINT_OFF"] = "1";
// }
if (!tt::DPrintServerReadsDispatchCores(device_)) {
defines["FORCE_DPRINT_OFF"] = "1";
}
defines.insert(defines_in.begin(), defines_in.end());

if (GetCoreType() == CoreType::WORKER) {
Expand Down
2 changes: 1 addition & 1 deletion tt_metal/impl/dispatch/kernels/vc_eth_tunneler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ using output_queue_cb_mode_sequence = CBModeTypeSequence<false,
false,
false>;

#define SWITCH_THRESHOLD 32
#define SWITCH_THRESHOLD 16
void kernel_main() {
rtos_context_switch_ptr = (void (*)())RtosTable[0];

Expand Down
6 changes: 4 additions & 2 deletions tt_metal/impl/dispatch/kernels/vc_packet_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,10 @@ void kernel_main() {
bool full_packet_sent;
const auto words_sent = output_queues[sequence_i].template forward_data_from_input<remote_tx_network_type[sequence_i], output_depacketize[sequence_i], remote_rx_network_type[sequence_i], input_packetize[sequence_i]>(0, 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();
}
}
}

Expand Down

0 comments on commit ef631eb

Please sign in to comment.