From a632f28c36ec40c0d92318195dcb790845211588 Mon Sep 17 00:00:00 2001 From: juanmanuel Date: Wed, 13 Nov 2024 09:48:55 -0500 Subject: [PATCH 1/2] fix: logs added and bugs fixed --- CMakeLists.txt | 9 +- README.md | 5 +- config/ai_test/data.xml | 388 +++++++++---------- src/main.cpp | 4 + src/networkInterface/NetworkInterfaceTlm.cpp | 17 +- src/networkInterface/NetworkInterfaceTlm.h | 3 +- src/router/router.cpp | 6 +- src/router/router.h | 3 + src/router/router_cs.cpp | 1 + src/utils/report.cpp | 81 ++++ src/utils/report.h | 39 +- 11 files changed, 337 insertions(+), 219 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9924173..876fee7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ ADD_EXECUTABLE(${PROJECT_NAME} src/utils/memory_manager.cpp src/utils/utils.cpp src/utils/noc_logger.cpp + src/utils/report.cpp src/ratatoskrUtils/utils/Report.cpp src/ratatoskrUtils/utils/GlobalReport.cpp src/ratatoskrUtils/utils/Structures.cpp @@ -46,13 +47,7 @@ ADD_EXECUTABLE(${PROJECT_NAME} src/ratatoskrUtils/traffic/synthetic/SyntheticPool.cpp src/ratatoskrUtils/traffic/task/TaskPool.cpp src/ratatoskrUtils/traffic/TrafficPool.cpp - src/ratatoskrUtils/link/Link.cpp - src/ratatoskrUtils/traffic/netrace/NetracePool.cpp - src/ratatoskrUtils/traffic/netrace/NetracePool.h - src/ratatoskrUtils/traffic/netrace/ntNetrace.h - src/ratatoskrUtils/traffic/netrace/ntNetrace.cpp - src/ratatoskrUtils/traffic/netrace/ntQueue.h - src/ratatoskrUtils/traffic/netrace/ntQueue.cpp + src/ratatoskrUtils/link/Link.cpp src/ratatoskrUtils/utils/TrafficTracer.cpp ) diff --git a/README.md b/README.md index dbf0838..7b423ff 100755 --- a/README.md +++ b/README.md @@ -47,4 +47,7 @@ This project is licensed under the MIT License - see the LICENSE.md file for det ## Acknowledgments -* [Ratatoskr NoC simulator](https://github.com/jmjos/ratatoskr) \ No newline at end of file +* [Ratatoskr NoC simulator](https://github.com/jmjos/ratatoskr) + +### TODO +- Check why there is no throttled messages for router \ No newline at end of file diff --git a/config/ai_test/data.xml b/config/ai_test/data.xml index 49545fa..c9b79da 100755 --- a/config/ai_test/data.xml +++ b/config/ai_test/data.xml @@ -266,7 +266,7 @@ - + @@ -286,7 +286,7 @@ - + @@ -297,7 +297,7 @@ - + @@ -312,7 +312,7 @@ - + @@ -323,7 +323,7 @@ - + @@ -338,7 +338,7 @@ - + @@ -349,7 +349,7 @@ - + @@ -364,7 +364,7 @@ - + @@ -375,7 +375,7 @@ - + @@ -390,7 +390,7 @@ - + @@ -401,7 +401,7 @@ - + @@ -416,14 +416,14 @@ - + - + @@ -434,7 +434,7 @@ - + @@ -449,7 +449,7 @@ - + @@ -460,7 +460,7 @@ - + @@ -475,7 +475,7 @@ - + @@ -486,7 +486,7 @@ - + @@ -501,7 +501,7 @@ - + @@ -512,7 +512,7 @@ - + @@ -527,14 +527,14 @@ - + - + @@ -545,12 +545,12 @@ - + - + @@ -565,7 +565,7 @@ - + @@ -576,7 +576,7 @@ - + @@ -591,7 +591,7 @@ - + @@ -602,7 +602,7 @@ - + @@ -617,7 +617,7 @@ - + @@ -628,7 +628,7 @@ - + @@ -643,7 +643,7 @@ - + @@ -654,12 +654,12 @@ - + - + @@ -674,7 +674,7 @@ - + @@ -685,7 +685,7 @@ - + @@ -700,7 +700,7 @@ - + @@ -711,7 +711,7 @@ - + @@ -726,14 +726,14 @@ - + - + @@ -744,7 +744,7 @@ - + @@ -759,7 +759,7 @@ - + @@ -770,7 +770,7 @@ - + @@ -785,7 +785,7 @@ - + @@ -796,7 +796,7 @@ - + @@ -811,7 +811,7 @@ - + @@ -822,7 +822,7 @@ - + @@ -837,14 +837,14 @@ - + - + @@ -855,12 +855,12 @@ - + - + @@ -875,7 +875,7 @@ - + @@ -886,7 +886,7 @@ - + @@ -901,7 +901,7 @@ - + @@ -912,7 +912,7 @@ - + @@ -927,7 +927,7 @@ - + @@ -938,7 +938,7 @@ - + @@ -953,7 +953,7 @@ - + @@ -964,12 +964,12 @@ - + - + @@ -984,7 +984,7 @@ - + @@ -995,7 +995,7 @@ - + @@ -1010,7 +1010,7 @@ - + @@ -1021,7 +1021,7 @@ - + @@ -1036,14 +1036,14 @@ - + - + @@ -1054,7 +1054,7 @@ - + @@ -1069,7 +1069,7 @@ - + @@ -1080,7 +1080,7 @@ - + @@ -1095,7 +1095,7 @@ - + @@ -1106,7 +1106,7 @@ - + @@ -1121,7 +1121,7 @@ - + @@ -1132,7 +1132,7 @@ - + @@ -1147,14 +1147,14 @@ - + - + @@ -1165,12 +1165,12 @@ - + - + @@ -1185,7 +1185,7 @@ - + @@ -1196,7 +1196,7 @@ - + @@ -1211,7 +1211,7 @@ - + @@ -1222,7 +1222,7 @@ - + @@ -1237,7 +1237,7 @@ - + @@ -1248,7 +1248,7 @@ - + @@ -1263,14 +1263,14 @@ - + - + @@ -1281,12 +1281,12 @@ - + - + @@ -1301,7 +1301,7 @@ - + @@ -1312,7 +1312,7 @@ - + @@ -1327,7 +1327,7 @@ - + @@ -1338,7 +1338,7 @@ - + @@ -1353,7 +1353,7 @@ - + @@ -1364,7 +1364,7 @@ - + @@ -1379,7 +1379,7 @@ - + @@ -1390,12 +1390,12 @@ - + - + @@ -1410,7 +1410,7 @@ - + @@ -1421,7 +1421,7 @@ - + @@ -1436,7 +1436,7 @@ - + @@ -1447,7 +1447,7 @@ - + @@ -1462,14 +1462,14 @@ - + - + @@ -1480,7 +1480,7 @@ - + @@ -1495,7 +1495,7 @@ - + @@ -1506,7 +1506,7 @@ - + @@ -1521,7 +1521,7 @@ - + @@ -1532,7 +1532,7 @@ - + @@ -1547,7 +1547,7 @@ - + @@ -1558,7 +1558,7 @@ - + @@ -1573,14 +1573,14 @@ - + - + @@ -1591,12 +1591,12 @@ - + - + @@ -1611,7 +1611,7 @@ - + @@ -1622,7 +1622,7 @@ - + @@ -1637,7 +1637,7 @@ - + @@ -1648,7 +1648,7 @@ - + @@ -1663,7 +1663,7 @@ - + @@ -1674,7 +1674,7 @@ - + @@ -1689,14 +1689,14 @@ - + - + @@ -1707,12 +1707,12 @@ - + - + @@ -1727,7 +1727,7 @@ - + @@ -1738,7 +1738,7 @@ - + @@ -1753,7 +1753,7 @@ - + @@ -1764,7 +1764,7 @@ - + @@ -1779,7 +1779,7 @@ - + @@ -1790,7 +1790,7 @@ - + @@ -1805,7 +1805,7 @@ - + @@ -1816,12 +1816,12 @@ - + - + @@ -1836,7 +1836,7 @@ - + @@ -1847,7 +1847,7 @@ - + @@ -1862,7 +1862,7 @@ - + @@ -1873,7 +1873,7 @@ - + @@ -1888,14 +1888,14 @@ - + - + @@ -1906,7 +1906,7 @@ - + @@ -1921,7 +1921,7 @@ - + @@ -1932,7 +1932,7 @@ - + @@ -1947,7 +1947,7 @@ - + @@ -1958,7 +1958,7 @@ - + @@ -1973,7 +1973,7 @@ - + @@ -1984,7 +1984,7 @@ - + @@ -1999,14 +1999,14 @@ - + - + @@ -2017,12 +2017,12 @@ - + - + @@ -2037,7 +2037,7 @@ - + @@ -2048,7 +2048,7 @@ - + @@ -2063,7 +2063,7 @@ - + @@ -2074,7 +2074,7 @@ - + @@ -2089,7 +2089,7 @@ - + @@ -2100,7 +2100,7 @@ - + @@ -2115,14 +2115,14 @@ - + - + @@ -2133,12 +2133,12 @@ - + - + @@ -2153,7 +2153,7 @@ - + @@ -2164,7 +2164,7 @@ - + @@ -2179,7 +2179,7 @@ - + @@ -2190,7 +2190,7 @@ - + @@ -2205,7 +2205,7 @@ - + @@ -2216,7 +2216,7 @@ - + @@ -2231,14 +2231,14 @@ - + - + @@ -2249,12 +2249,12 @@ - + - + @@ -2269,7 +2269,7 @@ - + @@ -2280,7 +2280,7 @@ - + @@ -2295,7 +2295,7 @@ - + @@ -2306,7 +2306,7 @@ - + @@ -2321,7 +2321,7 @@ - + @@ -2332,7 +2332,7 @@ - + @@ -2347,7 +2347,7 @@ - + @@ -2358,12 +2358,12 @@ - + - + @@ -2378,7 +2378,7 @@ - + @@ -2389,7 +2389,7 @@ - + @@ -2404,7 +2404,7 @@ - + @@ -2415,7 +2415,7 @@ - + @@ -2430,7 +2430,7 @@ - + @@ -2441,7 +2441,7 @@ - + @@ -2456,7 +2456,7 @@ - + @@ -2467,7 +2467,7 @@ - + @@ -2482,7 +2482,7 @@ - + @@ -2493,7 +2493,7 @@ - + @@ -2508,7 +2508,7 @@ - + @@ -2519,7 +2519,7 @@ - + @@ -2534,7 +2534,7 @@ - + @@ -2545,7 +2545,7 @@ - + @@ -2560,7 +2560,7 @@ - + @@ -2571,7 +2571,7 @@ - + @@ -2589,7 +2589,7 @@ - + diff --git a/src/main.cpp b/src/main.cpp index 667cb93..18df502 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,6 +27,7 @@ #include "utils/GlobalResourcesCS.h" #include "networkManager/NetworkManager.h" +#include "utils/report.h" namespace po = boost::program_options; @@ -55,5 +56,8 @@ int sc_main(int arg_num, char *arg_vec[]) sc_start(globalResources.simulation_time, SC_NS); cout << endl << "Simulation completed! Time: "<< sc_time_stamp() << endl; + + TlmReport& report = TlmReport::getInstance(); + report.write_report(); return 0; } diff --git a/src/networkInterface/NetworkInterfaceTlm.cpp b/src/networkInterface/NetworkInterfaceTlm.cpp index 622e7a2..a71b41c 100755 --- a/src/networkInterface/NetworkInterfaceTlm.cpp +++ b/src/networkInterface/NetworkInterfaceTlm.cpp @@ -54,12 +54,12 @@ NetworkInterfaceTlm::NetworkInterfaceTlm(sc_module_name nm, Node& node, sensitive << packetPortContainer->portValidIn.pos(); for(uint8_t lay=0; layregister_nb_transport_bw(this, &NetworkInterfaceTlm::nb_transport_bw_cb, lay); - target[lay] = new ni_targ_socket((string(nm)+"_"+ + target[lay] = new ni_targ_socket((ni_name+"_"+ to_string(lay)+"targ").c_str()); target[lay]->register_nb_transport_fw(this, &NetworkInterfaceTlm::nb_transport_fw_cb, lay); @@ -263,6 +263,7 @@ void NetworkInterfaceTlm::thread() { } else { if(log_wait){ + report.update_throttled_count(ni_name); if(credit_counter == 0){ log_info("No more credits. Waiting for Router!"); } @@ -465,6 +466,7 @@ void NetworkInterfaceTlm::target_peq_cb(tlm_gp& trans, const tlm::tlm_phase& pha break; default: + report.update_packet_count(ni_name); if(phase == INTERNAL_PROC_PHASE){ receive_and_process_flit(trans); } @@ -522,27 +524,28 @@ void NetworkInterfaceTlm::send_response(tlm_gp& trans){ void NetworkInterfaceTlm::update_credits(tlm_gp&trans, int added_creds){ string type_name = get_type_name(get_type_from_extension(trans)); int p_id = get_packet_id_from_extension(trans); - - if(type_name == TYPE_PACKET || (type_name == TYPE_ROUT_CONFIG && p_id != -1)){ + //if(type_name == TYPE_PACKET || (type_name == TYPE_ROUT_CONFIG && p_id != -1)){ + if (!((type_name == TYPE_ROUT_CONFIG && p_id == -1) || + type_name == TYPE_STREAM)){ credit_counter += added_creds; log_info("Credit counter updated: "+to_string(credit_counter)); } } void NetworkInterfaceTlm::log_info(string msg){ - string log_msg = ni_name + ": (Node" + + string log_msg = string(name()) + ": (Node" + to_string(node.id)+"): "+msg; SC_REPORT_INFO(NI_LOG, (log_msg).c_str()); } void NetworkInterfaceTlm::log_error(string msg){ - string log_msg = ni_name + ": (Node" + + string log_msg = string(name()) + ": (Node" + to_string(node.id)+"): "+msg; SC_REPORT_ERROR(NI_LOG, (log_msg).c_str()); } void NetworkInterfaceTlm::log_fatal(string msg){ - string log_msg = ni_name + ": (Node" + + string log_msg = string(name()) + ": (Node" + to_string(node.id)+"): "+msg; SC_REPORT_FATAL(NI_LOG, (log_msg).c_str()); } diff --git a/src/networkInterface/NetworkInterfaceTlm.h b/src/networkInterface/NetworkInterfaceTlm.h index acd156b..d5f81b3 100755 --- a/src/networkInterface/NetworkInterfaceTlm.h +++ b/src/networkInterface/NetworkInterfaceTlm.h @@ -54,7 +54,6 @@ public: std::queue packet_send_queue; std::queue packet_recv_queue; - string ni_name; // To PE sc_in clk; PacketPortContainer* packetPortContainer; @@ -66,12 +65,14 @@ public: tlm_gp* curr_req; tlm_gp* nxt_resp_pend; + string ni_name; bool resp_in_progress; int credit_counter; MemoryManager m_mm; uint8_t max_pos[3]; bool valid_socket[NUM_ACC_LAYERS] = {false}; + TlmReport& report = TlmReport::getInstance(); sc_event_or_list ev_msg_arrv; diff --git a/src/router/router.cpp b/src/router/router.cpp index 0b57c79..7a554fa 100755 --- a/src/router/router.cpp +++ b/src/router/router.cpp @@ -46,12 +46,12 @@ void TlmRouter::initialize(){ to_string(link)+"_init").c_str()); (*init_socket[link]).register_nb_transport_bw(this, &TlmRouter::nb_transport_bw_cb, link); - + target_socket[link] = new rout_targ_socket((router_name+"_"+ to_string(link)+"_targ").c_str()); (*target_socket[link]).register_nb_transport_fw(this, &TlmRouter::nb_transport_fw_cb, link); - + valid_links[link] = false; resp_in_progress[link] = false; nxt_resp_pend[link] = 0; @@ -125,6 +125,7 @@ bool TlmRouter::send_data(int link, int dest_link, tlm_gp& trans){ } else { log_warn(link,trans, "Waiting for downstream Router!"); + report.update_throttled_count(router_name); return false; } } @@ -269,6 +270,7 @@ void TlmRouter::target_peq_cb(tlm_gp& trans, const tlm_phase& phase){ log_error(link,trans,"Illegal transaction phase received by target"); break; default: + report.update_packet_count(router_name); if(phase == INTERNAL_PROC_PHASE){ switching(link, trans); } diff --git a/src/router/router.h b/src/router/router.h index 7e73e2b..19b31d3 100755 --- a/src/router/router.h +++ b/src/router/router.h @@ -37,6 +37,7 @@ #include "utils/configuration.h" #include "utils/utils.h" #include "utils/noc_logger.h" +#include "utils/report.h" using namespace sc_core; using namespace sc_dt; @@ -72,6 +73,8 @@ class TlmRouter : public sc_module{ uint8_t max_pos[3]; bool valid_links[NUM_LINKS]; + TlmReport& report = TlmReport::getInstance(); + SC_HAS_PROCESS(TlmRouter); TlmRouter(sc_module_name name, uint8_t rout_pos[3], uint8_t max_pos[3]); diff --git a/src/router/router_cs.cpp b/src/router/router_cs.cpp index d63f360..b5a3f8e 100755 --- a/src/router/router_cs.cpp +++ b/src/router/router_cs.cpp @@ -122,6 +122,7 @@ void TlmRouterCS::target_peq_cb(tlm_gp& trans, const tlm_phase& phase){ send_end_req(link, trans); break; default: + report.update_packet_count(name()); if(phase == INTERNAL_PROC_PHASE){ switching(link, trans); } diff --git a/src/utils/report.cpp b/src/utils/report.cpp index e69de29..2719455 100644 --- a/src/utils/report.cpp +++ b/src/utils/report.cpp @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (C) 2024 Juan Neyra + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + ******************************************************************************/ +#include "report.h" +#include +#include +#include + +TlmReport::TlmReport(){ +} + +TlmReport &TlmReport::getInstance() +{ + static TlmReport instance; + return instance; +} + +void TlmReport::update_packet_count(string np_name){ + // check if np_name exists in packet_count + if(packet_count.count(np_name)){ + packet_count[np_name] += 1; + } + else{ + packet_count.insert(std::make_pair(np_name, 1)); + } +} + + +void TlmReport::update_throttled_count(string np_name){ + if(throttled_count.count(np_name)){ + throttled_count[np_name] += 1; + } + else{ + throttled_count.insert(std::make_pair(np_name, 1)); + } +} + + +void TlmReport::write_report(){ + cout << endl << "Write packet count csv file" << endl; + stringstream ss_msg_packet; + ss_msg_packet << "router,packet_count" << endl; + for(auto& pc_pair: packet_count){ + ss_msg_packet << string(pc_pair.first) << "," << to_string(pc_pair.second) << endl; + } + + ofstream log_file; + log_file.open(PACKET_COUNT_FILE); + log_file << ss_msg_packet.str(); + log_file.close(); + + + cout << "Write throttled count csv file" << endl << endl; + stringstream ss_msg_throttled; + ss_msg_throttled << "router,throttled_count" << endl; + for(auto& tc_pair: throttled_count){ + ss_msg_throttled << tc_pair.first << "," << tc_pair.second << endl; + } + + log_file.open(THROTTLED_COUNT_FILE); + log_file << ss_msg_throttled.str(); + log_file.close(); +} diff --git a/src/utils/report.h b/src/utils/report.h index 561c03b..8106de6 100644 --- a/src/utils/report.h +++ b/src/utils/report.h @@ -22,17 +22,42 @@ #pragma once #include -#include +//#include + +#define PACKET_COUNT_FILE "out/packet_count.csv" +#define THROTTLED_COUNT_FILE "out/throttled_count.csv" using namespace std; -using namespace sc_core; +//using namespace sc_core; -class Report { +class TlmReport { public: + + TlmReport(); + static TlmReport &getInstance(); + + /** + * Increases the packet count by one for the given router + * + * @param np_name network participant's name + */ + void update_packet_count(string np_name); + + /** + * Increases the throttled count by one for the given router + * + * @param np_name network participant's name + */ + void update_throttled_count(string np_name); + + /** + * Writes report as csv + */ + void write_report(); + + private: std::map packet_count; std::map throttled_count; - std::map task_start_time; - std::map task_completed_time; - - Report(); + //std::map task_start_time; + //std::map task_completed_time; }; \ No newline at end of file From 11666fb586513d3dbba6ab6b0d80fc1634a19d1e Mon Sep 17 00:00:00 2001 From: juanmanuel Date: Thu, 14 Nov 2024 03:18:30 -0500 Subject: [PATCH 2/2] 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){