feat: logs added to pe for tasks

This commit is contained in:
juanmanuel 2024-11-10 08:44:04 -05:00
parent 4d63576d44
commit 51773f89ac
8 changed files with 364 additions and 288 deletions

File diff suppressed because it is too large Load diff

View file

@ -254,14 +254,7 @@
<destination id="4">
<delay min="0" max="100"/>
<interval min="100" max="100"/>
<count min="1" max="1"/>
<type value="1"/>
<task value="7"/>
</destination>
<destination id="5">
<delay min="0" max="100"/>
<interval min="100" max="100"/>
<count min="1" max="1"/>
<count min="2" max="2"/>
<type value="1"/>
<task value="7"/>
</destination>

View file

@ -21,6 +21,7 @@
******************************************************************************/
#include "ProcessingElementCS.h"
#include "traffic/PacketCS.h"
#include "utils/noc_logger.h"
void ProcessingElementCS::thread(){
while(true) {
@ -52,6 +53,7 @@ void ProcessingElementCS::thread(){
DataDestinationCS dest = pair.first;
// EXPLAIN: check if the current time is smaller or equal to the time of the destination if yes generate packet
if (pair.second<=timeStamp) {
std::string curr_task_id = std::to_string(destToTask.at(dest).id);
TaskCS task = globalResources.tasks.at(dest.destinationTask);
Node dstNode = globalResources.nodes.at(task.nodeID);
PacketCS* p = packetFactoryCS.createPacket(this->node,
@ -68,11 +70,15 @@ void ProcessingElementCS::thread(){
// EXPLAIN: decrement number of packets left to be sent
countLeft.at(dest)--;
log_info("Task "+curr_task_id+" sent a packet");
// EXPLAIN: if there are no more packet to this destination remove destination from list of destinations
if (!countLeft.at(dest)) {
countLeft.erase(dest);
destWait.erase(dest);
log_info("Task " + curr_task_id +
" has sent all packets to destination " +
std::to_string(task.id));
TaskCS task = destToTask.at(dest);
destToTask.erase(dest);
@ -88,7 +94,7 @@ void ProcessingElementCS::thread(){
else {
destWait.at(dest) =
globalResources.getRandomIntBetween(dest.minInterval, dest.maxInterval)+timeStamp;
}
}
break;
}
}
@ -272,6 +278,7 @@ void ProcessingElementCS::checkNeed()
// EXPLAIN: check if the needed amount (datatype for specific task) is reached. If yes remove the pair
if (neededAmount.at(pair)<=0) {
removeList.push_back(pair);
log_info("Task "+std::to_string(t.id)+" has requirements fullfilled");
// This line is also commented out for the same reason mentioned above.
// receivedData.at(type) = -neededAmount.at(pair);
}
@ -289,4 +296,18 @@ void ProcessingElementCS::checkNeed()
}
}
}
}
}
/******************* LOG FUNCTIONS ********************/
void ProcessingElementCS::log_info(std::string msg){
SC_REPORT_INFO(PE_LOG, (msg).c_str());
}
void ProcessingElementCS::log_warn(std::string msg){
SC_REPORT_WARNING(PE_LOG, (msg).c_str());
}
void ProcessingElementCS::log_error(std::string msg){
SC_REPORT_ERROR(PE_LOG, (msg).c_str());
}

View file

@ -21,6 +21,7 @@
******************************************************************************/
#pragma once
#include "systemc.h"
#include "ratatoskrUtils/processingElement/ProcessingElementVC.h"
#include "utils/PacketFactoryCS.h"
#include "utils/GlobalResourcesCS.h"
@ -75,4 +76,19 @@ public:
* Checks if requirements are fullfilled
*/
void checkNeed();
/** Log info
* @param msg log message
*/
void log_info(std::string msg);
/** Log warning
* @param msg log message
*/
void log_warn(std::string msg);
/** Log error
* @param msg log message
*/
void log_error(std::string msg);
};

View file

@ -78,6 +78,9 @@ void report_handler(const sc_report& report, const sc_actions& actions){
else if(string(report.get_msg_type()) == NM_LOG){
log_filename = NM_LOGFILENAME;
}
else if(string(report.get_msg_type()) == PE_LOG){
log_filename = PE_LOGFILENAME;
}
ofstream log_file;
log_file.open(log_filename, std::ios_base::app);
@ -98,6 +101,8 @@ void setup_logger(){
log_file.close();
log_file.open(NM_LOGFILENAME);
log_file.close();
log_file.open(PE_LOGFILENAME);
log_file.close();
log_file.open(DEF_LOGFILENAME);
log_file.close();

View file

@ -39,6 +39,9 @@
#define NM_LOGFILENAME "./out/nm_conn.log"
#define NM_LOG "NetworkManager"
#define PE_LOGFILENAME "./out/pe_tasks.log"
#define PE_LOG "ProcessingElement"
#define ASCII_RED "31"
#define ASCII_GREEN "32"
#define ASCII_YELLOW "33"

0
src/utils/report.cpp Normal file
View file

38
src/utils/report.h Normal file
View file

@ -0,0 +1,38 @@
/*******************************************************************************
* 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.
******************************************************************************/
#pragma once
#include <map>
#include <systemc>
using namespace std;
using namespace sc_core;
class Report {
public:
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();
};