Debug and add scenarios in paper

This commit is contained in:
Loic Guegan 2021-05-09 11:07:16 +02:00
parent 69e8818642
commit 51d0c256a3
6 changed files with 492 additions and 121 deletions

View file

@ -19,6 +19,7 @@ Inputs::Inputs(std::string node_name){
extended=d["extended"].GetBool();
simkey=d["simkey"].GetString();
seed=d["seed"].GetInt();
n_nodes=d["nodes"].MemberCount();
// Instantiate wake_ts
for(auto& v:d["nodes"][node_name.c_str()]["wake_ts"].GetArray()){

View file

@ -41,7 +41,7 @@ public:
/**
* Is there another event to process ?
*/
bool HasNext(){return(wake_ts.size()>1);}
bool HasNext(){return wake_ts.size()>1 ;}
/**
* Get current event timestamp
*/
@ -78,6 +78,7 @@ public:
bool extended;
int data_size;
int seed;
int n_nodes;
std::string simkey;
};

View file

@ -10,7 +10,7 @@
#include <sstream>
#define RAND(min,max) (rand()%(max-min+1)+min)
#define RAND(min,max) (rand()%((max)-(min)+1)+(min))
using namespace std;
using namespace rapidjson;
@ -19,7 +19,7 @@ int main(int argc, char **argv){
// Setup seed
if(argc!=15){
cerr << "Usage: " << argv[0] <<
" <seed> <simtime> <maxstartupdelay> <wakeupevery> <wakeupfor> <n_nodes>" <<
" <seed> <simtime> <wakeupsd> <wakeupevery> <wakeupfor> <n_nodes>" <<
" <extended> <hint> <poff> <pon> <prx> <ptx> <datasize> <simkey>" <<
endl;
exit(1);
@ -28,8 +28,8 @@ int main(int argc, char **argv){
// Init parameters
int seed=atoi(argv[1]);
double simtime=stod(argv[2]);
unsigned int maxstartupdelay=atoi(argv[3]);
double wakeupevery=stod(argv[4]);
unsigned int wakeupsd=atoi(argv[3]);
unsigned int wakeupevery=atoi(argv[4]);
double wakeupfor=stod(argv[5]);
unsigned int n_nodes=atoi(argv[6]);
bool extended=!strcmp("true",argv[7]);
@ -69,7 +69,7 @@ int main(int argc, char **argv){
// Setup ts and durations
Value ts(kArrayType);
Value duration(kArrayType);
for(unsigned int i=maxstartupdelay;(i+wakeupfor)<simtime;i+=wakeupevery){
for(unsigned int i=0;(i+wakeupfor)<simtime;i+=RAND(wakeupevery-wakeupsd,wakeupevery+wakeupsd)){
ts.PushBack(Value().SetDouble(i),d.GetAllocator());
duration.PushBack(Value().SetDouble(wakeupfor),d.GetAllocator());
}

View file

@ -92,6 +92,7 @@ static void obs_node(std::vector<std::string> args) {
u32 nDataRcv=0;
u32 nSendFail=0;
u32 nRcvFail=0;
u32 nSend=0;
while(i.ShouldContinue()){
XBT_INFO("%s is spleeping",selfName.c_str());
MODE_OFF();
@ -100,73 +101,81 @@ static void obs_node(std::vector<std::string> args) {
XBT_INFO("%s wakes up",selfName.c_str());
// Doing wake up stuff
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();
double uptime=i.GetDuration();
while(uptime>0.00001){ // Ensure not infinite loop even if it should not happend (we loose accuracy here but just in case)
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();
}
if(i.extended){
// We use a trick here
// First we send an instantaneous message (size=0) with the usual 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 other receivers to get the message)
m->put(p,0,uptime);
simgrid::s4u::Mailbox *m_ext= simgrid::s4u::Mailbox::by_name("medium"+selfName);
MODE_TX();
m_ext->put(p,data_size);
}
else{
MODE_TX();
m->put(p,data_size,uptime);
}
nSend++;
isSender=(nSend<(i.n_nodes-1));
isObserver=!isSender;
XBT_INFO("%s sent data successfully",selfName.c_str());
}
if(i.extended){
// We use a trick here
// First we send an instantaneous message (size=0) with the usual 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 other receivers to get the message)
m->put(p,0,i.GetDuration());
simgrid::s4u::Mailbox *m_ext= simgrid::s4u::Mailbox::by_name("medium"+selfName);
MODE_TX();
m_ext->put(p,data_size);
else if (!isObserver){
Payload* p;
if(i.extended){
// anchor:5623 We can see here that
// we first receive the instantaneous message
// and then we use a mailbox specific to the sender (to have an exclusive channel)
p=m->get<Payload>(uptime);
simgrid::s4u::Mailbox *m_ext_sender = simgrid::s4u::Mailbox::by_name("medium"+p->node);
MODE_RX();
p=m_ext_sender->get<Payload>();
}
else{
MODE_RX();
p=m->get<Payload>(uptime);
}
nDataRcv++; // New data received
if(p->containsHint){
XBT_INFO("%s received and hint of %f",selfName.c_str(),p->hint);
i.AddEvent(p->hint, p->duration); // Schedule a new wake up time
}
else{
XBT_INFO("%s received data successfully",selfName.c_str());
}
isObserver=true; // Now we received the data we switch to observer
}
else{
MODE_TX();
m->put(p,data_size,i.GetDuration());
else {
XBT_INFO("%s is observing his environment...",selfName.c_str());
MODE_ON();
simgrid::s4u::this_actor::sleep_for(uptime);
}
XBT_INFO("%s sent data successfully",selfName.c_str());
}
else if (!isObserver){
Payload* p;
if(i.extended){
// anchor:5623 We can see here that
// we first receive the instantaneous message
// and then we use a 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);
MODE_RX();
p=m_ext_sender->get<Payload>();
}
else{
MODE_RX();
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);
i.AddEvent(p->hint, p->duration); // Schedule a new wake up time
}
else{
XBT_INFO("%s received data successfully and switch to forwarding mode",selfName.c_str());
}
isObserver=true; // Now we received the data we switch to observer
catch (...)
{
if(isSender){
XBT_INFO("%s could not send any data",selfName.c_str());
nSendFail++;
}
else{
XBT_INFO("%s could not receive any data",selfName.c_str());
nRcvFail++;
}
}
else {
XBT_INFO("%s is observing his environment...",selfName.c_str());
simgrid::s4u::this_actor::sleep_until(i.GetDuration());
}
}
catch (...)
{
if(isSender){
XBT_INFO("%s could not send any data",selfName.c_str());
nSendFail++;
}
else{
XBT_INFO("%s could not receive any data",selfName.c_str());
nRcvFail++;
}
uptime=(i.GetTS()+i.GetDuration())-simgrid::s4u::Engine::get_clock();
}
// Load next event
i.GotoNextEvent();
@ -174,5 +183,5 @@ static void obs_node(std::vector<std::string> args) {
}
// Done
MODE_OFF()
XBT_INFO("Observation node %s finished [LOG2PARSE](node:%s|nWakeUp:%d|nDataRcv:%d|nSendFail:%d|nRcvFail:%d|simkey:%s|seed:%d)",selfName.c_str(),selfName.c_str(),nWakeUp,nDataRcv,nSendFail,nRcvFail,i.simkey.c_str(),i.seed);
XBT_INFO("Observation node %s finished [LOG2PARSE](node:%s|nSend:%d|nWakeUp:%d|nDataRcv:%d|nSendFail:%d|nRcvFail:%d|simkey:%s|seed:%d)",selfName.c_str(),selfName.c_str(),nSend,nWakeUp,nDataRcv,nSendFail,nRcvFail,i.simkey.c_str(),i.seed);
}