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 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 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(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(i.GetDuration()); + simgrid::s4u::Mailbox *m_ext_sender = simgrid::s4u::Mailbox::by_name("medium"+p->node); + p=m_ext_sender->get(); + } + else{ + p=m->get(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 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 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 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