diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2021-06-10 17:31:41 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2021-06-10 17:31:41 +0200 |
| commit | 82b5b6a0768755b6da24f8daad794f0c4bb43108 (patch) | |
| tree | 3f12f1c03025cc3d8b15b07c307dbfe623299f1e /src | |
| parent | dbdcb144491641624eb0c99e4ffa2b68401e5145 (diff) | |
Debug
Diffstat (limited to 'src')
| -rw-r--r-- | src/scenarios.cc | 4 | ||||
| -rw-r--r-- | src/simulator.cc | 16 |
2 files changed, 11 insertions, 9 deletions
diff --git a/src/scenarios.cc b/src/scenarios.cc index 140696c..90a7849 100644 --- a/src/scenarios.cc +++ b/src/scenarios.cc @@ -29,7 +29,7 @@ int main(int argc, char **argv){ int seed=atoi(argv[1]); double simtime=stod(argv[2]); unsigned int wakeupevery=atoi(argv[3]); - double wakeupfor=stod(argv[4]); + unsigned int wakeupfor=stoi(argv[4]); unsigned int n_nodes=atoi(argv[5]); bool extended=!strcmp("true",argv[6]); bool hint=!strcmp("true",argv[7]); @@ -74,7 +74,7 @@ int main(int argc, char **argv){ Value ts(kArrayType); Value duration(kArrayType); for(unsigned int i=0;i<simtime;i+=wakeupevery){ - ts.PushBack(Value().SetDouble(RAND(i,i+wakeupevery)),d.GetAllocator()); + ts.PushBack(Value().SetDouble(RAND(i,i+wakeupevery-wakeupfor)),d.GetAllocator()); duration.PushBack(Value().SetDouble(wakeupfor),d.GetAllocator()); } node.AddMember("wake_ts",ts,d.GetAllocator()); diff --git a/src/simulator.cc b/src/simulator.cc index d6c8882..aedf810 100644 --- a/src/simulator.cc +++ b/src/simulator.cc @@ -8,6 +8,7 @@ #include <sstream> #include "Inputs.hpp" +#include "simgrid/s4u/Actor.hpp" #define PLATFORM_FILE "platform.xml" @@ -25,10 +26,8 @@ } #define TRACK_UPTIME(instruction) \ { \ - double uptimeTrack=CLOCK; \ instruction; \ - uptimeTrack=CLOCK-uptimeTrack; \ - uptime-=uptimeTrack; \ + uptime=upuntil-CLOCK; \ uptime=uptime > 0 ? uptime : 0; \ } /// @brief Note that we need to simulate latency our self since we need to send instantaneous messages @@ -54,6 +53,7 @@ catch(...){ \ XBT_INFO("%s fail to forward a hint",CNAME); \ MODE_ON(); \ + uptime=upuntil-CLOCK; \ TRACK_UPTIME(simgrid::s4u::this_actor::sleep_for(FOR(TRY_FORWARD_DURING))); \ } \ } \ @@ -156,7 +156,7 @@ static void obs_node(std::vector<std::string> args) { bool forward_mode=false; // Turned on and off every x seconds by the receiver (to switch between forward hint mode and receiving data mode) bool forward_only=false; // When observer receive a hint it switch to forward only up to the next wake up time bool sendhint_mode=false; // Turned on and off every x seconds by the sender (to switch between send hint and send data) - while(uptime>0) + while(CLOCK < upuntil) { // ---------- SENDER ---------- if(is_sender){ @@ -273,8 +273,9 @@ static void obs_node(std::vector<std::string> args) { if(i.extended){ p=m_ded->get<Payload>(); // Fetch data until sended } - else - p=m_ded->get<Payload>(uptime); // Fetch data until sended or uptime expire + else{ + TRACK_UPTIME(p=m_ded->get<Payload>(uptime)); // Fetch data until sended or uptime expire + } // If we reach here, data has been received successfully XBT_INFO("%s received data successfully",CNAME); timeDataRcv=CLOCK; @@ -335,10 +336,11 @@ static void obs_node(std::vector<std::string> args) { forward_mode=!forward_mode; } else { - simgrid::s4u::this_actor::sleep_for(uptime); + simgrid::s4u::this_actor::sleep_until(upuntil); } } uptime=upuntil-CLOCK; // Note that uptime can be < 0 in extended mode + uptime=uptime > 0 ? uptime : 0; // Just in case } // Load next event i.GotoNextEvent(); |
