aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2021-05-07 08:18:41 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2021-05-07 08:18:41 +0200
commit1c283a21a955e8ccb4ac98118bfa5f50535e6765 (patch)
tree6958befc34dc35f0da022bb8c87bad2e176ea8dc
parent0ba773d913450f88ff7bcf54a39e0c8a8c4d7d64 (diff)
Enable extended mode and add log parser
-rw-r--r--inputs.json15
-rwxr-xr-xparser.awk48
-rw-r--r--src/simulator.cc44
3 files changed, 98 insertions, 9 deletions
diff --git a/inputs.json b/inputs.json
index 82ad885..2cf87a6 100644
--- a/inputs.json
+++ b/inputs.json
@@ -1,5 +1,5 @@
{
- "extended":false,
+ "extended":true,
"nodes":{
"on0":{
"is_sender": true,
@@ -15,8 +15,17 @@
"power_off": 0,
"power_on":10,
"use_hint": false,
- "wake_ts": [ 1, 7 ],
- "wake_duration": [ 5, 1],
+ "wake_ts": [ 1, 7, 8 ],
+ "wake_duration": [ 5, 5, 1],
+ "data_size": 50
+ },
+ "on2":{
+ "is_sender": false,
+ "power_off": 0,
+ "power_on":10,
+ "use_hint": false,
+ "wake_ts": [ 1, 7 , 8 ],
+ "wake_duration": [ 5, 5, 1],
"data_size": 50
}
}
diff --git a/parser.awk b/parser.awk
new file mode 100755
index 0000000..d1e4289
--- /dev/null
+++ b/parser.awk
@@ -0,0 +1,48 @@
+#!/usr/bin/awk -f
+
+BEGIN {
+ RS=" "
+ CSV_HEADER=""
+ CSV_DATA=""
+}
+
+/LOG2PARSE/{
+ # First extract what we need
+ to_parse=$1
+ gsub(/\[LOG2PARSE\]\(/,"",to_parse)
+ gsub(/\)/,"",to_parse)
+ split(to_parse,tokens,"|")
+
+ # Check if we have to build the csv header
+ if(CSV_HEADER==""){
+ for(i = 1; i<length(tokens);i++){
+ split(tokens[i],h,":")
+ if(CSV_HEADER=="")
+ CSV_HEADER=h[1]
+ else
+ CSV_HEADER=CSV_HEADER","h[1]
+ }
+ }
+
+ # Build a row
+ row=""
+ for(i = 1; i<length(tokens);i++){
+ split(tokens[i],h,":")
+ if(row=="")
+ row=h[2]
+ else
+ row=row","h[2]
+ }
+
+ # Add the row to the csv data
+ if(CSV_DATA=="")
+ CSV_DATA=row
+ else
+ CSV_DATA=CSV_DATA"\n"row
+}
+
+
+END {
+ print(CSV_HEADER);
+ print(CSV_DATA)
+} \ No newline at end of file
diff --git a/src/simulator.cc b/src/simulator.cc
index 15d7f0d..167810f 100644
--- a/src/simulator.cc
+++ b/src/simulator.cc
@@ -29,6 +29,7 @@ public:
double hint;
double duration;
bool containsHint;
+ std::string node;
};
/// @brief Observation node code
@@ -87,6 +88,8 @@ static void obs_node(std::vector<std::string> args) {
// Starting node
u32 nWakeUp=0;
u32 nDataRcv=0;
+ u32 nSendFail=0;
+ u32 nRcvFail=0;
while(i.ShouldContinue()){
XBT_INFO("%s is spleeping",selfName.c_str());
TURN_OFF();
@@ -98,18 +101,43 @@ static void obs_node(std::vector<std::string> args) {
try {
if(isSender){ // If I am a sender
Payload *p=new Payload();
+ p->node=selfName;
if(useHint&&i.HasNext()){
p->containsHint=true;
p->hint=i.GetNextTS();
p->duration=i.GetNextDuration();
}
- m->put(p,data_size,i.GetDuration());
+ if(i.extended){
+ // We use a trick here
+ // First we send an instantanous message (size=0) with a timeout
+ // to check whether there is a receiver!
+ // If there is one, we are sure that a put in the "medium"+selfName
+ // will not lead to a deadlock (cf anchor:5623) and we are using a exclusive
+ // channel (to avoid another receiver to get the message)
+ m->put(p,0,i.GetDuration());
+ simgrid::s4u::Mailbox *m_ext= simgrid::s4u::Mailbox::by_name("medium"+selfName);
+ m_ext->put(p,data_size);
+ }
+ else{
+ m->put(p,data_size,i.GetDuration());
+ }
XBT_INFO("%s send data successfully",selfName.c_str());
isObserver=true; // Do one send for now...
isSender=false;
}
else if (!isObserver){
- Payload* p=m->get<Payload>(i.GetDuration());
+ Payload* p;
+ if(i.extended){
+ // anchor:5623 We can see here that
+ // we first receive the instantaneous message
+ // and then use the mailbox specific to the sender (to have an exclusive channel)
+ p=m->get<Payload>(i.GetDuration());
+ simgrid::s4u::Mailbox *m_ext_sender = simgrid::s4u::Mailbox::by_name("medium"+p->node);
+ p=m_ext_sender->get<Payload>();
+ }
+ else{
+ p=m->get<Payload>(i.GetDuration());
+ }
nDataRcv++; // New data received
if(p->containsHint){
XBT_INFO("%s received and hint of %f",selfName.c_str(),p->hint);
@@ -117,7 +145,7 @@ static void obs_node(std::vector<std::string> args) {
}
else{
XBT_INFO("%s received data successfully and switch to forwarding mode",selfName.c_str());
- isSender=!isSender; // Toggle isSender to start sending
+ isSender=!isSender; // Toggle isSender to start sending
}
}
else {
@@ -127,10 +155,14 @@ static void obs_node(std::vector<std::string> args) {
}
catch (...)
{
- if(isSender)
+ if(isSender){
XBT_INFO("%s failed to send data",selfName.c_str());
- else
+ nSendFail++;
+ }
+ else{
XBT_INFO("%s failed to receive data",selfName.c_str());
+ nRcvFail++;
+ }
}
// Load next event
i.GotoNextEvent();
@@ -138,5 +170,5 @@ static void obs_node(std::vector<std::string> args) {
}
// Done
TURN_OFF()
- XBT_INFO("Observation node %s finished (nWakeUp:%d|nDataRcv:%d)",selfName.c_str(),nWakeUp,nDataRcv);
+ XBT_INFO("Observation node %s finished [LOG2PARSE](node:%s|nWakeUp:%d|nDataRcv:%d|nSendFail:%d|nRcvFail:%d)",selfName.c_str(),selfName.c_str(),nWakeUp,nDataRcv,nSendFail,nRcvFail);
} \ No newline at end of file