aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2021-05-06 17:46:34 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2021-05-06 17:46:34 +0200
commit0ba773d913450f88ff7bcf54a39e0c8a8c4d7d64 (patch)
tree4a4e034d38620bd0161388e5f1739918c631dc56 /src
parent87dd4219138ec98999b50d08c7190a942072b33f (diff)
Refactoring and start extended version
Diffstat (limited to 'src')
-rw-r--r--src/Inputs.cc (renamed from src/inputs.cc)32
-rw-r--r--src/Inputs.hpp (renamed from src/inputs.hpp)9
-rw-r--r--src/simulator.cc15
3 files changed, 31 insertions, 25 deletions
diff --git a/src/inputs.cc b/src/Inputs.cc
index 84acdb7..de81aec 100644
--- a/src/inputs.cc
+++ b/src/Inputs.cc
@@ -1,10 +1,9 @@
-#include "inputs.hpp"
-#include "xbt/log.h"
+#include "Inputs.hpp"
+
#include <algorithm>
#include <iostream>
#include <fstream>
-
Inputs::Inputs(std::string node_name){
// Here we doing all the boring stuff
FILE* input_file = fopen(INPUTS_FILE, "rb");
@@ -14,13 +13,18 @@ Inputs::Inputs(std::string node_name){
fclose(input_file);
// Init all variables
- is_sender=d[node_name.c_str()]["is_sender"].GetBool();
- use_hint=d[node_name.c_str()]["use_hint"].GetBool();
- data_size=d[node_name.c_str()]["data_size"].GetInt();
- for(auto& v:d[node_name.c_str()]["wake_ts"].GetArray()){
+ is_sender=d["nodes"][node_name.c_str()]["is_sender"].GetBool();
+ use_hint=d["nodes"][node_name.c_str()]["use_hint"].GetBool();
+ data_size=d["nodes"][node_name.c_str()]["data_size"].GetInt();
+ extended=d["extended"].GetBool();
+
+ // Instantiate wake_ts
+ for(auto& v:d["nodes"][node_name.c_str()]["wake_ts"].GetArray()){
wake_ts.push_back(v.GetDouble());
}
- for(auto& v:d[node_name.c_str()]["wake_duration"].GetArray()){
+
+ // Instantiate wake_duration
+ for(auto& v:d["nodes"][node_name.c_str()]["wake_duration"].GetArray()){
wake_duration.push_back(v.GetDouble());
}
@@ -130,6 +134,7 @@ void Inputs::AddEvent(double ts, double duration){
}
void Inputs::GeneratePlatform(std::string p){
+
// The boring stuff
FILE* input_file = fopen(INPUTS_FILE, "rb");
char input_file_buffer[JSON_BUFFER_SIZE];
@@ -137,7 +142,7 @@ void Inputs::GeneratePlatform(std::string p){
rapidjson::Document d;
d.ParseStream(is);
fclose(input_file);
-
+
// Write platform file
std::ofstream pf;
pf.open (p);
@@ -145,13 +150,12 @@ void Inputs::GeneratePlatform(std::string p){
pf << "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n";
pf << "<platform version=\"4.1\">\n <AS id=\"AS0\" routing=\"Cluster\">\n";
pf << " <link id=\"link\" bandwidth=\"1Mbps\" latency=\"0ms\" sharing_policy=\"SHARED\"></link>\n";
- for (Value::ConstMemberIterator itr = d.MemberBegin(); itr != d.MemberEnd(); ++itr)
+ for (Value::ConstMemberIterator itr = d["nodes"].MemberBegin(); itr != d["nodes"].MemberEnd(); ++itr)
{
std::string name=itr->name.GetString();
- double power_on=d[itr->name.GetString()]["power_on"].GetDouble();
- double power_off=d[itr->name.GetString()]["power_off"].GetDouble();
-
- //db=d[itr->name.GetString()]["wake_interval"].GetDouble();
+ double power_on=d["nodes"][itr->name.GetString()]["power_on"].GetDouble();
+ double power_off=d["nodes"][itr->name.GetString()]["power_off"].GetDouble();
+ // Create node
pf << " <host id=\""<<name<<"\" speed=\"100.0f,100.0f\" pstate=\"0\">\n";
pf << " <prop id=\"wattage_per_state\" value=\""<< power_off<<":"<<power_off<<", "<< power_on<<":"<<power_on<<"\" />\n";
pf << " <prop id=\"wattage_off\" value=\"0\" />\n </host>\n";
diff --git a/src/inputs.hpp b/src/Inputs.hpp
index 23ced49..e709d89 100644
--- a/src/inputs.hpp
+++ b/src/Inputs.hpp
@@ -1,11 +1,9 @@
-#include "rapidjson/document.h"
-#include "rapidjson/filereadstream.h"
+#include <rapidjson/document.h>
+#include <rapidjson/filereadstream.h>
+
#include <cstdio>
#include <string>
#include <vector>
-#include <iostream>
-#include <algorithm>
-#include "xbt/log.h"
#include <iomanip>
#define INPUTS_FILE "inputs.json"
@@ -77,6 +75,7 @@ public:
/// @brief These are public attributes, please take care they are fragile
bool is_sender;
bool use_hint;
+ bool extended;
int data_size;
}; \ No newline at end of file
diff --git a/src/simulator.cc b/src/simulator.cc
index 0bf2d2f..15d7f0d 100644
--- a/src/simulator.cc
+++ b/src/simulator.cc
@@ -1,11 +1,14 @@
-#include "simgrid/s4u.hpp"
+#include <simgrid/s4u.hpp>
#include <simgrid/s4u/Mailbox.hpp>
+#include <simgrid/s4u/Host.hpp>
+#include <simgrid/plugins/energy.h>
+#include <xbt/log.h>
+
#include <string>
#include <sstream>
-#include "inputs.hpp"
-#include "simgrid/s4u/Host.hpp"
-#include "simgrid/plugins/energy.h"
-#include "xbt/log.h"
+
+#include "Inputs.hpp"
+
#define PLATFORM_FILE "platform.xml"
#define TURN_OFF() simgrid::s4u::this_actor::get_host()->set_pstate(0);
@@ -74,7 +77,7 @@ static void obs_node(std::vector<std::string> args) {
Inputs i(selfName);
simgrid::s4u::Mailbox *m = simgrid::s4u::Mailbox::by_name("medium");
XBT_INFO("Deploying observation node %s",selfName.c_str());
-
+
// Init convenient variables
bool isSender=i.is_sender;
bool useHint=i.use_hint;