2021-05-06 17:46:34 +02:00
|
|
|
#include <rapidjson/document.h>
|
|
|
|
#include <rapidjson/filereadstream.h>
|
|
|
|
|
2021-05-05 16:42:11 +02:00
|
|
|
#include <cstdio>
|
|
|
|
#include <string>
|
2021-05-06 16:14:57 +02:00
|
|
|
#include <vector>
|
|
|
|
#include <iomanip>
|
2021-05-05 16:42:11 +02:00
|
|
|
|
|
|
|
#define INPUTS_FILE "inputs.json"
|
2021-05-06 16:14:57 +02:00
|
|
|
/// @brief Pay attention to this strange number, you could tear your hairs out
|
|
|
|
#define JSON_BUFFER_SIZE 65536
|
2021-05-05 16:42:11 +02:00
|
|
|
|
|
|
|
using namespace rapidjson;
|
|
|
|
|
|
|
|
class Inputs {
|
2021-05-06 16:14:57 +02:00
|
|
|
/// @brief RapidJSON
|
2021-05-05 16:42:11 +02:00
|
|
|
Document d;
|
2021-05-06 16:14:57 +02:00
|
|
|
/// @brief Current node associated with the Inputs
|
2021-05-05 16:42:11 +02:00
|
|
|
std::string node_name;
|
2021-05-06 16:14:57 +02:00
|
|
|
/// @brief Timestamps (at which time the nodes should wake up)
|
|
|
|
std::vector<double> wake_ts;
|
|
|
|
/// @brief Wake up time durations
|
|
|
|
std::vector<double> wake_duration;
|
|
|
|
/**
|
|
|
|
* Recursively merge overlapping events
|
|
|
|
*/
|
|
|
|
void MergeEvents();
|
2021-05-05 16:42:11 +02:00
|
|
|
public:
|
2021-05-06 16:14:57 +02:00
|
|
|
/**
|
|
|
|
* Load node_name configuration
|
|
|
|
*/
|
2021-05-05 16:42:11 +02:00
|
|
|
Inputs(std::string node_name);
|
2021-05-06 16:14:57 +02:00
|
|
|
/**
|
|
|
|
* Generate a SimGrid platform file from the json configuration
|
|
|
|
*/
|
2021-05-06 09:04:35 +02:00
|
|
|
static void GeneratePlatform(std::string p);
|
2021-05-06 16:14:57 +02:00
|
|
|
/**
|
|
|
|
* Is there any event that remains in the queue ?
|
|
|
|
*/
|
|
|
|
bool ShouldContinue(){return wake_ts.size()!=0;}
|
|
|
|
/**
|
|
|
|
* Is there another event to process ?
|
|
|
|
*/
|
2021-05-09 11:07:16 +02:00
|
|
|
bool HasNext(){return wake_ts.size()>1 ;}
|
2021-05-06 16:14:57 +02:00
|
|
|
/**
|
|
|
|
* Get current event timestamp
|
|
|
|
*/
|
|
|
|
double GetTS(){return wake_ts.front();}
|
|
|
|
/**
|
|
|
|
* Get current event duration
|
|
|
|
*/
|
|
|
|
double GetDuration(){return wake_duration.front();}
|
|
|
|
/**
|
|
|
|
* Get next event timestamp
|
|
|
|
*/
|
|
|
|
double GetNextTS();
|
|
|
|
/**
|
|
|
|
* Get next event duration
|
|
|
|
*/
|
|
|
|
double GetNextDuration();
|
|
|
|
/**
|
|
|
|
* Time travel machine (note that this function is following the second principle
|
|
|
|
* of thermodynamics)
|
|
|
|
*/
|
|
|
|
void GotoNextEvent();
|
|
|
|
/**
|
|
|
|
* Allows to add a *FUTURE* event and merge overlapping events
|
|
|
|
*/
|
|
|
|
void AddEvent(double ts, double duration);
|
|
|
|
/**
|
|
|
|
* This is the timeline
|
|
|
|
*/
|
|
|
|
void DumpEvents();
|
2021-05-06 09:04:35 +02:00
|
|
|
|
2021-05-06 16:14:57 +02:00
|
|
|
/// @brief These are public attributes, please take care they are fragile
|
2021-05-06 09:04:35 +02:00
|
|
|
bool is_sender;
|
2021-05-06 11:57:50 +02:00
|
|
|
bool use_hint;
|
2021-05-06 17:46:34 +02:00
|
|
|
bool extended;
|
2021-05-06 11:57:50 +02:00
|
|
|
int data_size;
|
2021-05-11 08:53:11 +02:00
|
|
|
int hint_size;
|
2021-05-08 17:10:06 +02:00
|
|
|
int seed;
|
2021-05-09 11:07:16 +02:00
|
|
|
int n_nodes;
|
2021-05-14 10:25:51 +02:00
|
|
|
double latency;
|
2021-05-05 16:42:11 +02:00
|
|
|
};
|