Skip to content

Commit

Permalink
#6748: Clean up function footprints
Browse files Browse the repository at this point in the history
  • Loading branch information
mo-tenstorrent committed Oct 3, 2024
1 parent 03e6cff commit f52272a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 36 deletions.
1 change: 1 addition & 0 deletions tt_metal/hostdevcommon/profiler_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ namespace kernel_profiler{
NOC_X,
NOC_Y,
FLAT_ID,
CORE_COUNT_PER_DRAM,
DROPPED_ZONES,
PROFILER_DONE,
};
Expand Down
4 changes: 1 addition & 3 deletions tt_metal/impl/device/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2911,9 +2911,7 @@ void Device::generate_device_headers(const std::string &path) const
dram_noc_coord_per_bank,
dram_offsets_per_bank,
l1_noc_coord_per_bank,
l1_offset_per_bank,
soc_d.profiler_ceiled_core_count_perf_dram_bank,
soc_d.physical_routing_to_profiler_flat_id
l1_offset_per_bank
);
}

Expand Down
30 changes: 3 additions & 27 deletions tt_metal/jit_build/genfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,7 @@ std::string generate_bank_to_noc_coord_descriptor_string(
std::vector<CoreCoord>& dram_bank_map,
std::vector<int32_t>& dram_bank_offset_map,
std::vector<CoreCoord>& l1_bank_map,
std::vector<int32_t>& l1_bank_offset_map,
int core_count_per_dram,
const std::map<CoreCoord, int32_t>& profiler_flat_id_map) {
std::vector<int32_t>& l1_bank_offset_map) {
stringstream ss;
bool is_dram_pow2 = ceil(log2(dram_bank_map.size())) == log2(dram_bank_map.size());
bool is_l1_pow2 = ceil(log2(l1_bank_map.size())) == log2(l1_bank_map.size());
Expand Down Expand Up @@ -577,13 +575,6 @@ std::string generate_bank_to_noc_coord_descriptor_string(
ss << "extern int32_t bank_to_dram_offset[NUM_DRAM_BANKS];" << endl;
ss << "extern uint16_t l1_bank_to_noc_xy[NUM_NOCS][NUM_L1_BANKS];" << endl;
ss << "extern int32_t bank_to_l1_offset[NUM_L1_BANKS];" << endl;
#if defined(TRACY_ENABLE)
ss << "#if defined(PROFILE_KERNEL) && (defined(COMPILE_FOR_BRISC) || defined(COMPILE_FOR_NCRISC) || "
"defined(COMPILE_FOR_ERISC))"
<< endl;
ss << "extern uint16_t profiler_core_count_per_dram;" << endl;
ss << "#endif" << endl;
#endif

ss << endl;
ss << "#else // !KERNEL_BUILD (FW_BUILD)" << endl;
Expand Down Expand Up @@ -611,17 +602,6 @@ std::string generate_bank_to_noc_coord_descriptor_string(
ss << "};" << endl;
ss << endl;

#if defined(TRACY_ENABLE)
ss << "#if defined(PROFILE_KERNEL) && (defined(COMPILE_FOR_BRISC) || defined(COMPILE_FOR_NCRISC) || "
"defined(COMPILE_FOR_ERISC))"
<< endl;
ss << "uint16_t profiler_core_count_per_dram __attribute__((used)) = ";
ss << core_count_per_dram << ";" << endl;
ss << endl;
ss << "#endif" << endl;

#endif

ss << "uint16_t l1_bank_to_noc_xy[NUM_NOCS][NUM_L1_BANKS] __attribute__((used)) = {" << endl;
for (unsigned int noc = 0; noc < 2; noc++) {
ss << " {"
Expand Down Expand Up @@ -654,17 +634,13 @@ void jit_build_genfiles_bank_to_noc_coord_descriptor(
std::vector<CoreCoord>& dram_bank_map,
std::vector<int32_t>& dram_bank_offset_map,
std::vector<CoreCoord>& l1_bank_map,
std::vector<int32_t>& l1_bank_offset_map,
int core_count_per_dram,
const std::map<CoreCoord, int32_t>& profiler_flat_id_map) {
std::vector<int32_t>& l1_bank_offset_map) {
string output_string = generate_bank_to_noc_coord_descriptor_string(
grid_size,
dram_bank_map,
dram_bank_offset_map,
l1_bank_map,
l1_bank_offset_map,
core_count_per_dram,
profiler_flat_id_map);
l1_bank_offset_map);

fs::create_directories(path + "/brisc");
ofstream file_stream_br(path + "/brisc/generated_bank_to_noc_coord_mapping.h");
Expand Down
4 changes: 1 addition & 3 deletions tt_metal/jit_build/genfiles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ void jit_build_genfiles_bank_to_noc_coord_descriptor(
std::vector<CoreCoord>& dram_bank_map,
std::vector<int32_t>& dram_bank_offset_map,
std::vector<CoreCoord>& l1_bank_map,
std::vector<int32_t>& l1_bank_offset_map,
int core_count_per_dram,
const std::map<CoreCoord, int32_t>& profiler_flat_id_map);
std::vector<int32_t>& l1_bank_offset_map);

void jit_build_genfiles_descriptors(const JitBuildEnv& env, JitBuildOptions& options);

Expand Down
8 changes: 5 additions & 3 deletions tt_metal/tools/profiler/kernel_profiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,12 @@ namespace kernel_profiler{
if (profiler_control_buffer[PROFILER_DONE] == 1){
return;
}
uint32_t pageSize =
PROFILER_FULL_HOST_BUFFER_SIZE_PER_RISC * MAX_RISCV_PER_CORE * profiler_core_count_per_dram;

while (!profiler_control_buffer[DRAM_PROFILER_ADDRESS]);
uint32_t core_flat_id = profiler_control_buffer[FLAT_ID];
uint32_t profiler_core_count_per_dram = profiler_control_buffer[CORE_COUNT_PER_DRAM];

uint32_t pageSize =
PROFILER_FULL_HOST_BUFFER_SIZE_PER_RISC * MAX_RISCV_PER_CORE * profiler_core_count_per_dram;

for (uint32_t riscID = 0; riscID < PROFILER_RISC_COUNT; riscID ++)
{
Expand Down Expand Up @@ -267,6 +268,7 @@ namespace kernel_profiler{

while (!profiler_control_buffer[DRAM_PROFILER_ADDRESS]);
uint32_t core_flat_id = profiler_control_buffer[FLAT_ID];
uint32_t profiler_core_count_per_dram = profiler_control_buffer[CORE_COUNT_PER_DRAM];

profiler_data_buffer[myRiscID][ID_LH] = ((core_flat_id & 0xFF) << 3) | myRiscID;

Expand Down
2 changes: 2 additions & 0 deletions tt_metal/tools/profiler/tt_metal_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ void setControlBuffer(uint32_t device_id, std::vector<uint32_t>& control_buffer)
#if defined(TRACY_ENABLE)
const metal_SocDescriptor& soc_d = tt::Cluster::instance().get_soc_desc(device_id);

control_buffer[kernel_profiler::CORE_COUNT_PER_DRAM] = soc_d.profiler_ceiled_core_count_perf_dram_bank;

auto ethCores = soc_d.get_physical_ethernet_cores() ;
for (auto &core : soc_d.physical_routing_to_profiler_flat_id)
{
Expand Down

0 comments on commit f52272a

Please sign in to comment.