blob: 50ce8e2454e4a0b560951f055e7fd6619adddee8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#include <rapidjson/document.h>
#include <rapidjson/filereadstream.h>
#include <cstdio>
#include <string>
#include <vector>
#include <iomanip>
#define INPUTS_FILE "inputs.json"
/// @brief Pay attention to this strange number, you could tear your hairs out
#define JSON_BUFFER_SIZE 65536
using namespace rapidjson;
class Inputs {
/// @brief RapidJSON
Document d;
/// @brief Current node associated with the Inputs
std::string node_name;
/// @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;
/// @brief To handle unschedule_on_rcv
std::vector<double> wake_ts_backup;
std::vector<double> wake_duration_backup;
/**
* Recursively merge overlapping events
*/
void MergeEvents();
public:
/**
* Load node_name configuration
*/
Inputs(std::string node_name);
/**
* Generate a SimGrid platform file from the json configuration
*/
static void GeneratePlatform(std::string p);
/**
* Is there any event that remains in the queue ?
*/
bool ShouldContinue(){return wake_ts.size()!=0;}
/**
* Is there another event to process ?
*/
bool HasNext(){return wake_ts.size()>1 ;}
/**
* Get current event timestamp
*/
double GetTS(){return wake_ts.front();}
double GetHintTS(double clock);
/**
* Get current event duration
*/
double GetDuration(){return wake_duration.front();}
double GetHintDuration(double clock);
/**
* 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();
/**
* Reset the initial event list
*/
void ResetEvents(double clock);
/**
* Allows to add a *FUTURE* event and merge overlapping events
*/
void AddEvent(double ts, double duration);
/**
* This is the timeline
*/
void DumpEvents();
/// @brief These are public attributes, please take care they are fragile
bool is_sender;
bool use_hint;
bool extended;
bool farhint;
bool unschedule_on_rcv;
bool shutdown_on_rcv;
int data_size;
int hint_size;
int seed;
int n_nodes;
double latency;
double hintdist;
};
|