From 11666fb586513d3dbba6ab6b0d80fc1634a19d1e Mon Sep 17 00:00:00 2001 From: juanmanuel Date: Thu, 14 Nov 2024 03:18:30 -0500 Subject: [PATCH] fix: lack of throttle count in routers fixed --- config/ai_test/data.xml | 386 ++++---- config/simple_2_point_test/2pt_data.xml | 17 +- config/simple_2_point_test/config.xml | 2 +- config/throttle_test/config.xml | 55 ++ config/throttle_test/data.xml | 245 ++++++ config/throttle_test/map.xml | 51 ++ config/throttle_test/net.xml | 879 +++++++++++++++++++ src/networkInterface/NetworkInterfaceTlm.cpp | 4 +- src/networkManager/NetworkManager.cpp | 2 - src/router/router.cpp | 88 +- src/router/router.h | 9 +- src/router/router_cs.cpp | 14 +- src/utils/configuration.h | 8 +- src/utils/utils.cpp | 15 +- 14 files changed, 1498 insertions(+), 277 deletions(-) create mode 100755 config/throttle_test/config.xml create mode 100755 config/throttle_test/data.xml create mode 100755 config/throttle_test/map.xml create mode 100755 config/throttle_test/net.xml diff --git a/config/ai_test/data.xml b/config/ai_test/data.xml index c9b79da..e373369 100755 --- a/config/ai_test/data.xml +++ b/config/ai_test/data.xml @@ -264,8 +264,8 @@ - - + + @@ -284,8 +284,8 @@ - - + + @@ -310,8 +310,8 @@ - - + + @@ -336,8 +336,8 @@ - - + + @@ -362,8 +362,8 @@ - - + + @@ -388,8 +388,8 @@ - - + + @@ -414,15 +414,15 @@ - - + + - - + + @@ -447,8 +447,8 @@ - - + + @@ -473,8 +473,8 @@ - - + + @@ -499,8 +499,8 @@ - - + + @@ -525,15 +525,15 @@ - - + + - - + + @@ -563,8 +563,8 @@ - - + + @@ -589,8 +589,8 @@ - - + + @@ -615,8 +615,8 @@ - - + + @@ -641,8 +641,8 @@ - - + + @@ -672,8 +672,8 @@ - - + + @@ -698,8 +698,8 @@ - - + + @@ -724,15 +724,15 @@ - - + + - - + + @@ -757,8 +757,8 @@ - - + + @@ -783,8 +783,8 @@ - - + + @@ -809,8 +809,8 @@ - - + + @@ -835,15 +835,15 @@ - - + + - - + + @@ -873,8 +873,8 @@ - - + + @@ -899,8 +899,8 @@ - - + + @@ -925,8 +925,8 @@ - - + + @@ -951,8 +951,8 @@ - - + + @@ -982,8 +982,8 @@ - - + + @@ -1008,8 +1008,8 @@ - - + + @@ -1034,15 +1034,15 @@ - - + + - - + + @@ -1067,8 +1067,8 @@ - - + + @@ -1093,8 +1093,8 @@ - - + + @@ -1119,8 +1119,8 @@ - - + + @@ -1145,15 +1145,15 @@ - - + + - - + + @@ -1183,8 +1183,8 @@ - - + + @@ -1209,8 +1209,8 @@ - - + + @@ -1235,8 +1235,8 @@ - - + + @@ -1261,15 +1261,15 @@ - - + + - - + + @@ -1299,8 +1299,8 @@ - - + + @@ -1325,8 +1325,8 @@ - - + + @@ -1351,8 +1351,8 @@ - - + + @@ -1377,8 +1377,8 @@ - - + + @@ -1408,8 +1408,8 @@ - - + + @@ -1434,8 +1434,8 @@ - - + + @@ -1460,15 +1460,15 @@ - - + + - - + + @@ -1493,8 +1493,8 @@ - - + + @@ -1519,8 +1519,8 @@ - - + + @@ -1545,8 +1545,8 @@ - - + + @@ -1571,15 +1571,15 @@ - - + + - - + + @@ -1609,8 +1609,8 @@ - - + + @@ -1635,8 +1635,8 @@ - - + + @@ -1661,8 +1661,8 @@ - - + + @@ -1687,15 +1687,15 @@ - - + + - - + + @@ -1725,8 +1725,8 @@ - - + + @@ -1751,8 +1751,8 @@ - - + + @@ -1777,8 +1777,8 @@ - - + + @@ -1803,8 +1803,8 @@ - - + + @@ -1834,8 +1834,8 @@ - - + + @@ -1860,8 +1860,8 @@ - - + + @@ -1886,15 +1886,15 @@ - - + + - - + + @@ -1919,8 +1919,8 @@ - - + + @@ -1945,8 +1945,8 @@ - - + + @@ -1971,8 +1971,8 @@ - - + + @@ -1997,15 +1997,15 @@ - - + + - - + + @@ -2035,8 +2035,8 @@ - - + + @@ -2061,8 +2061,8 @@ - - + + @@ -2087,8 +2087,8 @@ - - + + @@ -2113,15 +2113,15 @@ - - + + - - + + @@ -2151,8 +2151,8 @@ - - + + @@ -2177,8 +2177,8 @@ - - + + @@ -2203,8 +2203,8 @@ - - + + @@ -2229,15 +2229,15 @@ - - + + - - + + @@ -2267,8 +2267,8 @@ - - + + @@ -2293,8 +2293,8 @@ - - + + @@ -2319,8 +2319,8 @@ - - + + @@ -2345,8 +2345,8 @@ - - + + @@ -2376,8 +2376,8 @@ - - + + @@ -2402,8 +2402,8 @@ - - + + @@ -2428,8 +2428,8 @@ - - + + @@ -2454,8 +2454,8 @@ - - + + @@ -2480,8 +2480,8 @@ - - + + @@ -2507,7 +2507,7 @@ - + @@ -2532,8 +2532,8 @@ - - + + @@ -2558,8 +2558,8 @@ - - + + diff --git a/config/simple_2_point_test/2pt_data.xml b/config/simple_2_point_test/2pt_data.xml index c91fdb8..42b28e9 100755 --- a/config/simple_2_point_test/2pt_data.xml +++ b/config/simple_2_point_test/2pt_data.xml @@ -5,7 +5,7 @@ - + @@ -18,8 +18,8 @@ - - + + @@ -38,8 +38,8 @@ - - + + @@ -57,12 +57,7 @@ - - - - - - + diff --git a/config/simple_2_point_test/config.xml b/config/simple_2_point_test/config.xml index 4de57e7..bc0faa5 100755 --- a/config/simple_2_point_test/config.xml +++ b/config/simple_2_point_test/config.xml @@ -5,7 +5,7 @@ report - config/simple_test/net.xml + config/simple_2_point_test/net.xml diff --git a/config/throttle_test/config.xml b/config/throttle_test/config.xml new file mode 100755 index 0000000..8f5501d --- /dev/null +++ b/config/throttle_test/config.xml @@ -0,0 +1,55 @@ + + + + + report + + + config/throttle_test/net.xml + + + + + + task + config/throttle_test/data.xml + config/throttle_test/map.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 6 9 10 + + diff --git a/config/throttle_test/data.xml b/config/throttle_test/data.xml new file mode 100755 index 0000000..b79db77 --- /dev/null +++ b/config/throttle_test/data.xml @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/throttle_test/map.xml b/config/throttle_test/map.xml new file mode 100755 index 0000000..f165073 --- /dev/null +++ b/config/throttle_test/map.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/throttle_test/net.xml b/config/throttle_test/net.xml new file mode 100755 index 0000000..7407f52 --- /dev/null +++ b/config/throttle_test/net.xml @@ -0,0 +1,879 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/networkInterface/NetworkInterfaceTlm.cpp b/src/networkInterface/NetworkInterfaceTlm.cpp index a71b41c..ec57717 100755 --- a/src/networkInterface/NetworkInterfaceTlm.cpp +++ b/src/networkInterface/NetworkInterfaceTlm.cpp @@ -313,7 +313,7 @@ void NetworkInterfaceTlm::init_peq_cb(tlm_gp& trans, const tlm::tlm_phase& phase log_info("Init PEQ callback start for packet "+to_string(p_id)); log_info("Phase "+string(phase.get_name())+" received"); if (phase == tlm::END_REQ) { - update_credits(trans, 1); + //update_credits(trans, 1); curr_req = 0; if(p_id == -1){ // Config msg transaction ended, so packet can be scheduled for deletion @@ -507,7 +507,7 @@ void NetworkInterfaceTlm::send_response(tlm_gp& trans){ tlm::tlm_sync_enum status = (*target[0])->nb_transport_bw( trans, bw_phase, delay); - update_credits(trans, -1); + //update_credits(trans, -1); if (status == tlm::TLM_UPDATED){ target_peq.notify(trans, bw_phase, delay); diff --git a/src/networkManager/NetworkManager.cpp b/src/networkManager/NetworkManager.cpp index c1fa379..727fb3f 100755 --- a/src/networkManager/NetworkManager.cpp +++ b/src/networkManager/NetworkManager.cpp @@ -55,7 +55,6 @@ void NetworkManager::createTrafficPool() { get_max_pos(max_pos); // divided by num of layers (assuming equal number of nodes in each layer) unsigned long numOfPEs = globalResources.nodes.size() / (max_pos[2]+1); -#ifndef ENABLE_NETRACE if (globalResources.benchmark == "task") { tp = std::make_unique(); } else if (globalResources.benchmark == "synthetic") { @@ -63,7 +62,6 @@ void NetworkManager::createTrafficPool() { } else { FATAL("Please specify correct benchmark type"); } -#endif tp->processingElements.resize(numOfPEs); } diff --git a/src/router/router.cpp b/src/router/router.cpp index 7a554fa..73b31e9 100755 --- a/src/router/router.cpp +++ b/src/router/router.cpp @@ -54,10 +54,10 @@ void TlmRouter::initialize(){ valid_links[link] = false; resp_in_progress[link] = false; - nxt_resp_pend[link] = 0; - nxt_send_data_pend[link] = 0; + //nxt_resp_pend[link] = 0; + //nxt_send_data_pend[link] = 0; curr_req[link] = 0; - send_data_in_prog_dest[link] = Direction::invalid; + //send_data_in_prog_dest[link] = Direction::invalid; credit_counter[link] = NUM_CREDITS; } } @@ -98,8 +98,8 @@ void TlmRouter::send_begin_req(int link, tlm_gp& trans, int dest_link){ *new_trans, phase, delay); curr_req[dest_link] = new_trans; credit_counter[dest_link]--; - log_info(link, trans, - "credits value updated: " + to_string(credit_counter[dest_link])); + log_info(link, trans, "credits value updated on link " + DIR::toString(dest_link) + + ": " + to_string(credit_counter[dest_link])); // react to result if(status == TLM_UPDATED) { init_peq.notify(*new_trans, phase, delay); @@ -109,8 +109,8 @@ void TlmRouter::send_begin_req(int link, tlm_gp& trans, int dest_link){ curr_req[dest_link] = 0; check_transaction(link, *new_trans); credit_counter[dest_link]++; - log_info(link, trans, - "credits value updated: " + to_string(credit_counter[dest_link])); + log_info(link, trans, "credits value updated on link " + DIR::toString(dest_link) + + ": " + to_string(credit_counter[dest_link])); new_trans->release(); } } @@ -121,6 +121,12 @@ bool TlmRouter::send_data(int link, int dest_link, tlm_gp& trans){ // check credits or that previous message is complete if (credit_counter[dest_link] > 0){ send_begin_req(link, trans, dest_link); + // send response or add it to queue + if(resp_in_progress[link]) { + nxt_resp_pend[link].push(&trans); + } + else{ send_begin_response(link, trans); } + return true; } else { @@ -146,7 +152,6 @@ void TlmRouter::check_transaction(int link, tlm_gp& trans) { stream << hex << adr << " check, cmd=" << (cmd ? 'W' : 'R') << ", data=" << hex << *ptr; log_info(link,trans, stream.str()); - // Allow the memory manager to free the transaction object trans.release(); } @@ -177,12 +182,12 @@ void TlmRouter::init_peq_cb(tlm_gp& trans, const tlm_phase& phase){ int link = get_link_from_extension(trans); log_info(link,trans, "Initiator PEQ callback start"); log_info(link,trans, "Phase "+string(phase.get_name())+" received"); - if (phase == END_REQ || (&trans == curr_req[link] && - phase == BEGIN_RESP)){ + if (phase == END_REQ || (&trans == curr_req[link] && phase == BEGIN_RESP)){ curr_req[link] = 0; - credit_counter[link]++; - log_info(link, trans, - "credits value updated: " + to_string(credit_counter[link])); + /*credit_counter[link]++; + log_info(link, trans, "credits value updated on link " + DIR::toString(link) + + ": " + to_string(credit_counter[link]));*/ + log_info(link, trans, "Issuing next request"); start_pend_req(link, trans); } else if (phase == BEGIN_REQ || phase == END_RESP){ @@ -190,7 +195,9 @@ void TlmRouter::init_peq_cb(tlm_gp& trans, const tlm_phase& phase){ } if (phase == BEGIN_RESP) { - check_transaction(link, trans); + credit_counter[link]++; + log_info(link, trans, "credits value updated on link " + DIR::toString(link) + + ": " + to_string(credit_counter[link])); send_end_response(link, trans); } } @@ -198,20 +205,20 @@ void TlmRouter::init_peq_cb(tlm_gp& trans, const tlm_phase& phase){ void TlmRouter::start_pend_req(int rel_link, tlm_gp& trans){ // find pending link - Direction pending_link = Direction::invalid; for(uint8_t dir=0; dir #include +#include #include "tlm.h" #include "tlm_utils/simple_initiator_socket.h" @@ -60,12 +61,12 @@ class TlmRouter : public sc_module{ peq_with_cb_and_phase init_peq; peq_with_cb_and_phase target_peq; tlm_gp* curr_req[NUM_LINKS]; - tlm_gp* nxt_resp_pend[NUM_LINKS]; - tlm_gp* nxt_send_data_pend[NUM_LINKS]; MemoryManager m_mm; - bool resp_in_progress[NUM_LINKS]; int credit_counter[NUM_LINKS]; - Dir send_data_in_prog_dest[NUM_LINKS]; + bool resp_in_progress[NUM_LINKS]; + queue nxt_resp_pend[NUM_LINKS]; + queue nxt_send_data_pend[NUM_LINKS]; + queue send_data_in_prog_dest[NUM_LINKS]; // attributes string router_name; diff --git a/src/router/router_cs.cpp b/src/router/router_cs.cpp index b5a3f8e..d310bfe 100755 --- a/src/router/router_cs.cpp +++ b/src/router/router_cs.cpp @@ -35,7 +35,7 @@ void TlmRouterCS::initialize(){ TlmRouter::initialize(); cout<<"Inherited function called"; for(int link=0; linknb_transport_fw( *new_trans, phase, delay); curr_req[dest_link] = new_trans; - credit_counter[dest_link]--; - log_info(link, trans, - "credits value updated: " + to_string(credit_counter[link])); + //credit_counter[dest_link]--; + /*log_info(link, trans, + "credits value updated: " + to_string(credit_counter[link]));*/ // react to result if(status == TLM_COMPLETED) { log_error(link, trans, "Request completed prematurely"); curr_req[dest_link] = 0; check_transaction(link, *new_trans); - credit_counter[dest_link]++; - log_info(link, trans, - "credits value updated: " + to_string(credit_counter[dest_link])); + //credit_counter[dest_link]++; + /*log_info(link, trans, + "credits value updated: " + to_string(credit_counter[dest_link]));*/ new_trans->release(); } } diff --git a/src/utils/configuration.h b/src/utils/configuration.h index 5172a1a..064c9a7 100755 --- a/src/utils/configuration.h +++ b/src/utils/configuration.h @@ -34,10 +34,10 @@ using namespace sc_dt; // router paremters #define NUM_CREDITS 7 // router delays -#define REQ_INIT_DELAY 20 -#define REQ_END_DELAY 20 -#define INTERN_PROC_DELAY 20 -#define RESP_END_DELAY 20 +#define REQ_INIT_DELAY 10 +#define REQ_END_DELAY 10 +#define INTERN_PROC_DELAY 100 +#define RESP_END_DELAY 10 #define UNITS_DELAY SC_NS // types diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index 50d0f3d..b7f5a30 100755 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -51,12 +51,15 @@ void get_max_pos(uint8_t max_pos[3]){ vector gr_pos[3]; get_pos_distances(dists, gr_pos); - max_pos[0] = 1+round(max_element(gr_pos[0].begin(), - gr_pos[0].end())[0]/dists[0]); - max_pos[1] = 1+round(max_element(gr_pos[1].begin(), - gr_pos[1].end())[0]/dists[1]); - max_pos[2] = 1+round(max_element(gr_pos[2].begin(), - gr_pos[2].end())[0]/dists[2]); + max_pos[0] = dists[0] != 0 ? + 1+round(max_element(gr_pos[0].begin(), gr_pos[0].end())[0]/dists[0]) + : 1; + max_pos[1] = dists[1] != 0 ? + 1+round(max_element(gr_pos[1].begin(),gr_pos[1].end())[0]/dists[1]) + : 1; + max_pos[2] = dists[2] != 0 ? + 1+round(max_element(gr_pos[2].begin(), gr_pos[2].end())[0]/dists[2]) + : 1; } string get_type_name(dataTypeID_t id){