aboutsummaryrefslogtreecommitdiff
path: root/src/simulator.cc
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 /src/simulator.cc
parent0ba773d913450f88ff7bcf54a39e0c8a8c4d7d64 (diff)
Enable extended mode and add log parser
Diffstat (limited to 'src/simulator.cc')
-rw-r--r--src/simulator.cc44
1 files changed, 38 insertions, 6 deletions
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