fix: logs added and bugs fixed

This commit is contained in:
juanmanuel 2024-11-13 09:48:55 -05:00
parent 51773f89ac
commit a632f28c36
11 changed files with 337 additions and 219 deletions

View file

@ -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
)

View file

@ -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)
* [Ratatoskr NoC simulator](https://github.com/jmjos/ratatoskr)
### TODO
- Check why there is no throttled messages for router

File diff suppressed because it is too large Load diff

View file

@ -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;
}

View file

@ -54,12 +54,12 @@ NetworkInterfaceTlm::NetworkInterfaceTlm(sc_module_name nm, Node& node,
sensitive << packetPortContainer->portValidIn.pos();
for(uint8_t lay=0; lay<NUM_ACC_LAYERS; lay++){
initiator[lay] = new ni_init_socket((string(nm)+"_"+
initiator[lay] = new ni_init_socket((ni_name+"_"+
to_string(lay)+"_init").c_str());
initiator[lay]->register_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());
}

View file

@ -54,7 +54,6 @@ public:
std::queue<PacketCS*> packet_send_queue;
std::queue<PacketCS*> packet_recv_queue;
string ni_name;
// To PE
sc_in<bool> 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;

View file

@ -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);
}

View file

@ -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]);

View file

@ -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);
}

View file

@ -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 <iostream>
#include <fstream>
#include <sstream>
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();
}

View file

@ -22,17 +22,42 @@
#pragma once
#include <map>
#include <systemc>
//#include <systemc>
#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<string, int> packet_count;
std::map<string, int> throttled_count;
std::map<int, sc_time> task_start_time;
std::map<int, sc_time> task_completed_time;
Report();
//std::map<int, sc_time> task_start_time;
//std::map<int, sc_time> task_completed_time;
};