-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#7844: Re-implement NOC xfer size recording to be more efficient
Now keeps histograms in L1, overloading dprint buffers, and is read out using watcher dump tool. This way neither dprint nor watcher needs to be active to measure noc transfers.
- Loading branch information
Showing
16 changed files
with
273 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-FileCopyrightText: © 2024 Tenstorrent Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
#include "dprint_buffer.h" | ||
|
||
// Add option to skip noc logging for certain cores via a define. | ||
#if defined(NOC_LOGGING_ENABLED) && !defined(SKIP_NOC_LOGGING) | ||
void log_noc_xfer(uint32_t len) { | ||
// Hijack print buffer for noc logging data. | ||
volatile tt_l1_ptr uint32_t *buf_ptr = | ||
(volatile tt_l1_ptr uint32_t *)(reinterpret_cast<DebugPrintMemLayout *>(get_debug_print_buffer())->data); | ||
|
||
int highest_bit_position = 0; | ||
while (len >>= 1) highest_bit_position++; | ||
|
||
buf_ptr[highest_bit_position]++; | ||
} | ||
|
||
#define LOG_LEN(l) log_noc_xfer(l); | ||
#define LOG_READ_LEN_FROM_STATE(noc_id) LOG_LEN(NOC_CMD_BUF_READ_REG(noc_id, NCRISC_RD_CMD_BUF, NOC_AT_LEN_BE)); | ||
#define LOG_WRITE_LEN_FROM_STATE(noc_id) LOG_LEN(NOC_CMD_BUF_READ_REG(noc_id, NCRISC_WR_CMD_BUF, NOC_AT_LEN_BE)); | ||
|
||
#else | ||
|
||
#define LOG_LEN(l) | ||
#define LOG_READ_LEN_FROM_STATE(noc_id) | ||
#define LOG_WRITE_LEN_FROM_STATE(noc_id) | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// SPDX-FileCopyrightText: © 2024 Tenstorrent Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include <set> | ||
|
||
#include "hostdevcommon/dprint_common.h" | ||
#include "tt_metal/impl/device/device.hpp" | ||
|
||
// Helper function for comparing CoreDescriptors for using in sets. | ||
struct CoreDescriptorComparator { | ||
bool operator()(const CoreDescriptor &x, const CoreDescriptor &y) const { | ||
if (x.coord == y.coord) { | ||
return x.type < y.type; | ||
} else { | ||
return x.coord < y.coord; | ||
} | ||
} | ||
}; | ||
#define CoreDescriptorSet std::set<CoreDescriptor, CoreDescriptorComparator> | ||
|
||
// Helper function to get CoreDescriptors for all debug-relevant cores on device. | ||
static CoreDescriptorSet GetAllCores(Device *device) { | ||
CoreDescriptorSet all_cores; | ||
// The set of all printable cores is Tensix + Eth cores | ||
CoreCoord logical_grid_size = device->logical_grid_size(); | ||
for (uint32_t x = 0; x < logical_grid_size.x; x++) { | ||
for (uint32_t y = 0; y < logical_grid_size.y; y++) { | ||
all_cores.insert({{x, y}, CoreType::WORKER}); | ||
} | ||
} | ||
for (const auto& logical_core : device->get_active_ethernet_cores()) { | ||
all_cores.insert({logical_core, CoreType::ETH}); | ||
} | ||
for (const auto& logical_core : device->get_inactive_ethernet_cores()) { | ||
all_cores.insert({logical_core, CoreType::ETH}); | ||
} | ||
|
||
return all_cores; | ||
} | ||
|
||
// Helper function to get CoreDescriptors for all cores that are used for dispatch. Should be a subset of | ||
// GetAllCores(). | ||
static CoreDescriptorSet GetDispatchCores(Device* device) { | ||
CoreDescriptorSet dispatch_cores; | ||
unsigned num_cqs = device->num_hw_cqs(); | ||
CoreType dispatch_core_type = dispatch_core_manager::instance().get_dispatch_core_type(device->id()); | ||
tt::log_warning("Dispatch Core Type = {}", dispatch_core_type); | ||
for (auto logical_core : tt::get_logical_dispatch_cores(device->id(), num_cqs, dispatch_core_type)) { | ||
dispatch_cores.insert({logical_core, dispatch_core_type}); | ||
} | ||
return dispatch_cores; | ||
} | ||
|
||
inline uint64_t GetDprintBufAddr(Device *device, const CoreCoord &phys_core, int risc_id) { | ||
|
||
dprint_buf_msg_t *buf = device->get_dev_addr<dprint_buf_msg_t *>(phys_core, HalMemAddrType::DPRINT); | ||
return reinterpret_cast<uint64_t>(buf->data[risc_id]); | ||
} | ||
|
||
inline int GetNumRiscs(const CoreDescriptor &core) { | ||
return (core.type == CoreType::ETH)? DPRINT_NRISCVS_ETH : DPRINT_NRISCVS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.