Skip to content

Commit

Permalink
Refactoring same definitions (#17747)
Browse files Browse the repository at this point in the history
### Ticket
N/A

### Problem description
There are same definitions spreading to multiple files.
The name is overwrapping with other file's one, so refactoring to make
it really unique

### What's changed
Fix name
- PACKET_QUEUE_TEST to TT_FABRIC_STATUS
- PQ_TEST to TT_FABRIC
- move common test utilities to test_common.hpp

### Checklist
- [ ] [All post
commit](https://github.com/tenstorrent/tt-metal/actions/workflows/all-post-commit-workflows.yaml)
CI passes
- [ ] [Blackhole Post
commit](https://github.com/tenstorrent/tt-metal/actions/workflows/blackhole-post-commit.yaml)
CI passes (if applicable)
- [ ] [Model
regression](https://github.com/tenstorrent/tt-metal/actions/workflows/perf-models.yaml)
CI passes (if applicable)
- [ ] [Device performance
regression](https://github.com/tenstorrent/tt-metal/actions/workflows/perf-device-models.yaml)
CI passes (if applicable)
- [ ] **(For models and ops writers)** Full [new models
tests](https://github.com/tenstorrent/tt-metal/actions/workflows/full-new-models-suite.yaml)
CI passes (if applicable)
- [ ] New/Existing tests provide coverage for changes
  • Loading branch information
daminakaTT authored Feb 11, 2025
1 parent 88bd402 commit 02fb212
Show file tree
Hide file tree
Showing 24 changed files with 162 additions and 255 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "common.h"
#include "tt_cluster.hpp"
#include "tt_metal/impl/dispatch/kernels/packet_queue_ctrl.hpp"
#include "tests/tt_metal/tt_metal/perf_microbenchmark/routing/kernels/traffic_gen_test.hpp"

#include <tt-metalium/hal.hpp>
#include "llrt.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include "debug/dprint.h"
#include "tests/tt_metal/tt_metal/perf_microbenchmark/routing/kernels/traffic_gen_test.hpp"
#include "tt_fabric/hw/inc/tt_fabric_status.h"

inline uint32_t prng_next(uint32_t n) {
uint32_t x = n;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "dataflow_api.h"
#include "debug/dprint.h"
#include "tt_metal/impl/dispatch/kernels/packet_queue.hpp"
#include "tt_fabric/hw/inc/tt_fabric_status.h"
#include "tests/tt_metal/tt_metal/perf_microbenchmark/routing/kernels/traffic_gen.hpp"

constexpr uint32_t src_endpoint_id = get_compile_time_arg_val(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include "debug/dprint.h"
#include "tests/tt_metal/tt_metal/perf_microbenchmark/routing/kernels/tt_fabric_traffic_gen_test.hpp"
#include "tt_fabric/hw/inc/tt_fabric_status.h"

#define is_power_of_2(x) (((x) > 0) && (((x) & ((x) - 1)) == 0))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "dataflow_api.h"
#include "tt_fabric/hw/inc/tt_fabric.h"
#include "tests/tt_metal/tt_metal/perf_microbenchmark/routing/kernels/tt_fabric_traffic_gen.hpp"
#include "tests/tt_metal/tt_metal/perf_microbenchmark/routing/kernels/tt_fabric_traffic_gen_test.hpp"
#include "tt_fabric/hw/inc/tt_fabric_status.h"
#include "tt_fabric/hw/inc/tt_fabric_interface.h"
#include "tests/tt_metal/tt_metal/perf_microbenchmark/common/kernel_utils.hpp"
// clang-format on
Expand Down Expand Up @@ -61,8 +61,8 @@ void kernel_main() {
rx_buf_size = get_arg_val<uint32_t>(increment_arg_idx(rt_args_idx));

zero_l1_buf(test_results, test_results_size_bytes);
test_results[PQ_TEST_STATUS_INDEX] = PACKET_QUEUE_TEST_STARTED;
test_results[PQ_TEST_MISC_INDEX] = 0xff000000;
test_results[TT_FABRIC_STATUS_INDEX] = TT_FABRIC_STATUS_STARTED;
test_results[TT_FABRIC_MISC_INDEX] = 0xff000000;

if constexpr (ASYNC_WR & test_command) {
uint32_t packet_rnd_seed;
Expand Down Expand Up @@ -174,9 +174,9 @@ void kernel_main() {
read_addr, curr_payload_words, start_val, mismatch_addr, mismatch_val, expected_val);
if (!match) {
async_wr_check_failed = true;
test_results[PQ_TEST_MISC_INDEX + 12] = mismatch_addr;
test_results[PQ_TEST_MISC_INDEX + 13] = mismatch_val;
test_results[PQ_TEST_MISC_INDEX + 14] = expected_val;
test_results[TT_FABRIC_MISC_INDEX + 12] = mismatch_addr;
test_results[TT_FABRIC_MISC_INDEX + 13] = mismatch_val;
test_results[TT_FABRIC_MISC_INDEX + 14] = expected_val;
break;
}
}
Expand All @@ -200,13 +200,13 @@ void kernel_main() {
}

// write out results
set_64b_result(test_results, processed_packet_words, PQ_TEST_WORD_CNT_INDEX);
set_64b_result(test_results, processed_packet_words, TT_FABRIC_WORD_CNT_INDEX);
set_64b_result(test_results, num_packets, TX_TEST_IDX_NPKT);

if (async_wr_check_failed) {
test_results[PQ_TEST_STATUS_INDEX] = PACKET_QUEUE_TEST_DATA_MISMATCH;
test_results[TT_FABRIC_STATUS_INDEX] = TT_FABRIC_STATUS_DATA_MISMATCH;
} else {
test_results[PQ_TEST_STATUS_INDEX] = PACKET_QUEUE_TEST_PASS;
test_results[PQ_TEST_MISC_INDEX] = 0xff000005;
test_results[TT_FABRIC_STATUS_INDEX] = TT_FABRIC_STATUS_PASS;
test_results[TT_FABRIC_MISC_INDEX] = 0xff000005;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ void kernel_main() {
target_address = base_target_address;

zero_l1_buf(test_results, test_results_size_bytes);
test_results[PQ_TEST_STATUS_INDEX] = PACKET_QUEUE_TEST_STARTED;
test_results[PQ_TEST_MISC_INDEX] = 0xff000000;
test_results[PQ_TEST_MISC_INDEX + 1] = 0xcc000000 | src_endpoint_id;
test_results[TT_FABRIC_STATUS_INDEX] = TT_FABRIC_STATUS_STARTED;
test_results[TT_FABRIC_MISC_INDEX] = 0xff000000;
test_results[TT_FABRIC_MISC_INDEX + 1] = 0xcc000000 | src_endpoint_id;

zero_l1_buf(
reinterpret_cast<tt_l1_ptr uint32_t*>(data_buffer_start_addr), data_buffer_size_words * PACKET_WORD_SIZE_BYTES);
Expand Down Expand Up @@ -199,11 +199,11 @@ void kernel_main() {
uint64_t cycles_elapsed = get_timestamp() - start_timestamp;

uint64_t num_packets = packet_count;
set_64b_result(test_results, data_words_sent, PQ_TEST_WORD_CNT_INDEX);
set_64b_result(test_results, cycles_elapsed, PQ_TEST_CYCLES_INDEX);
set_64b_result(test_results, data_words_sent, TT_FABRIC_WORD_CNT_INDEX);
set_64b_result(test_results, cycles_elapsed, TT_FABRIC_CYCLES_INDEX);
set_64b_result(test_results, total_data_words, TX_TEST_IDX_TOT_DATA_WORDS);
set_64b_result(test_results, num_packets, TX_TEST_IDX_NPKT);

test_results[PQ_TEST_STATUS_INDEX] = PACKET_QUEUE_TEST_PASS;
test_results[PQ_TEST_MISC_INDEX] = packet_count;
test_results[TT_FABRIC_STATUS_INDEX] = TT_FABRIC_STATUS_PASS;
test_results[TT_FABRIC_MISC_INDEX] = packet_count;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <nlohmann/json.hpp>
#include <tt-metalium/core_coord.hpp>
#include "hw/inc/tt_fabric_status.h"
#include "llrt.hpp"

static inline std::string to_string(pkt_dest_size_choices_t choice) {
Expand All @@ -25,3 +26,11 @@ static inline void log_phys_coord_to_json(nlohmann::json& config, const std::vec
static inline void log_phys_coord_to_json(nlohmann::json& config, const CoreCoord& phys_core, const std::string& name) {
config[name] = fmt::format("({}, {})", phys_core.x, phys_core.y);
}

inline uint64_t get_64b_result(uint32_t* buf, uint32_t index) {
return (((uint64_t)buf[index]) << 32) | buf[index+1];
}

inline uint64_t get_64b_result(const std::vector<uint32_t>& vec, uint32_t index) {
return (((uint64_t)vec[index]) << 32) | vec[index+1];
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#include <tt-metalium/cq_commands.hpp>
#include <tt-metalium/device.hpp>
#include "tt_metal/impl/dispatch/kernels/packet_queue_ctrl.hpp"
#include "kernels/traffic_gen_test.hpp"
#include "tests/tt_metal/tt_metal/perf_microbenchmark/routing/test_common.hpp"
#include "test_common.hpp"
#include "llrt.hpp"

using std::vector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <tt-metalium/tt_metal.hpp>
#include <tt-metalium/rtoptions.hpp>
#include "tt_metal/impl/dispatch/kernels/packet_queue_ctrl.hpp"
#include "kernels/traffic_gen_test.hpp"
#include "test_common.hpp"
#include "llrt.hpp"

using std::vector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "tt_fabric/control_plane.hpp"
// #include <tt-metalium/cq_commands.hpp>
// #include "tt_metal/impl/dispatch/kernels/packet_queue_ctrl.hpp"
#include "kernels/tt_fabric_traffic_gen_test.hpp"
#include "tests/tt_metal/tt_metal/perf_microbenchmark/routing/test_common.hpp"
#include "tt_fabric/hw/inc/tt_fabric_status.h"
#include "test_common.hpp"
#include "eth_l1_address_map.h"
#include "tt_fabric/hw/inc/tt_fabric_interface.h"

Expand Down Expand Up @@ -542,12 +542,8 @@ int main(int argc, char** argv) {
for (uint32_t i = 0; i < num_src_endpoints; i++) {
tx_results.push_back(tt::llrt::read_hex_vec_from_core(
device_map[test_device_id_l]->id(), tx_phys_core[i], test_results_addr, 128));
log_info(
LogTest,
"TX{} status = {}",
i,
packet_queue_test_status_to_string(tx_results[i][PQ_TEST_STATUS_INDEX]));
pass &= (tx_results[i][PQ_TEST_STATUS_INDEX] == PACKET_QUEUE_TEST_PASS);
log_info(LogTest, "TX{} status = {}", i, tt_fabric_status_to_string(tx_results[i][TT_FABRIC_STATUS_INDEX]));
pass &= (tx_results[i][TT_FABRIC_STATUS_INDEX] == TT_FABRIC_STATUS_PASS);
}
/*
TODO: Need to add these once control plane api is available to
Expand All @@ -556,15 +552,15 @@ int main(int argc, char** argv) {
tt::llrt::read_hex_vec_from_core(
device_map[test_device_id_l]->id(), tunneler_phys_core, tunneler_test_results_addr, 128);
log_info(LogTest, "L Router status = {}",
packet_queue_test_status_to_string(router_results[PQ_TEST_STATUS_INDEX])); pass &=
(router_results[PQ_TEST_STATUS_INDEX] == PACKET_QUEUE_TEST_PASS);
tt_fabric_status_to_string(router_results[TT_FABRIC_STATUS_INDEX])); pass &=
(router_results[TT_FABRIC_STATUS_INDEX] == TT_FABRIC_STATUS_PASS);
vector<uint32_t> r_router_results =
tt::llrt::read_hex_vec_from_core(
device_map[test_device_id_r]->id(), r_tunneler_phys_core, tunneler_test_results_addr, 128);
log_info(LogTest, "R Router status = {}",
packet_queue_test_status_to_string(r_router_results[PQ_TEST_STATUS_INDEX])); pass &=
(r_router_results[PQ_TEST_STATUS_INDEX] == PACKET_QUEUE_TEST_PASS);
tt_fabric_status_to_string(r_router_results[TT_FABRIC_STATUS_INDEX])); pass &=
(r_router_results[TT_FABRIC_STATUS_INDEX] == TT_FABRIC_STATUS_PASS);
*/
for (auto active_device : device_map) {
pass &= tt_metal::CloseDevice(active_device.second);
Expand All @@ -575,12 +571,12 @@ int main(int argc, char** argv) {
uint64_t total_tx_words_sent = 0;
uint64_t total_rx_words_checked = 0;
for (uint32_t i = 0; i < num_src_endpoints; i++) {
uint64_t tx_words_sent = get_64b_result(tx_results[i], PQ_TEST_WORD_CNT_INDEX);
uint64_t tx_words_sent = get_64b_result(tx_results[i], TT_FABRIC_WORD_CNT_INDEX);
total_tx_words_sent += tx_words_sent;
uint64_t tx_elapsed_cycles = get_64b_result(tx_results[i], PQ_TEST_CYCLES_INDEX);
uint64_t tx_elapsed_cycles = get_64b_result(tx_results[i], TT_FABRIC_CYCLES_INDEX);
double tx_bw = ((double)tx_words_sent) * PACKET_WORD_SIZE_BYTES / tx_elapsed_cycles;
total_tx_bw += tx_bw;
uint64_t iter = get_64b_result(tx_results[i], PQ_TEST_ITER_INDEX);
uint64_t iter = get_64b_result(tx_results[i], TT_FABRIC_ITER_INDEX);
// uint64_t zero_data_sent_iter = get_64b_result(tx_results[i], TX_TEST_IDX_ZERO_DATA_WORDS_SENT_ITER);
// uint64_t few_data_sent_iter = get_64b_result(tx_results[i], TX_TEST_IDX_FEW_DATA_WORDS_SENT_ITER);
// uint64_t many_data_sent_iter = get_64b_result(tx_results[i], TX_TEST_IDX_MANY_DATA_WORDS_SENT_ITER);
Expand Down
Loading

0 comments on commit 02fb212

Please sign in to comment.