Enable extended mode and add log parser

This commit is contained in:
Loic Guegan 2021-05-07 08:18:41 +02:00
parent 0ba773d913
commit 1c283a21a9
3 changed files with 98 additions and 9 deletions

View file

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