SimulationOutput.h
1 
10 #ifndef WRENCH_SIMULATIONOUTPUT_H
11 #define WRENCH_SIMULATIONOUTPUT_H
12 
13 #include <typeinfo>
14 #include <typeindex>
15 #include <iostream>
16 
17 #include "wrench/simulation/SimulationTimestamp.h"
18 #include "wrench/simulation/SimulationTrace.h"
19 
20 
21 namespace wrench {
22  class Simulation;
23 
28 
29  public:
37  template<class T>
38  std::vector<SimulationTimestamp<T> *> getTrace() {
39  std::type_index type_index = std::type_index(typeid(T));
40 
41  // Is the trace empty?
42  if (this->traces.find(type_index) == this->traces.end()) {
43  return {};
44  }
45 
46  std::vector<SimulationTimestamp<T> *> non_generic_vector;
47  auto trace = (SimulationTrace<T> *) (this->traces[type_index]);
48  for (auto ts : trace->getTrace()) {
49  non_generic_vector.push_back((SimulationTimestamp<T> *) ts);
50  }
51  return non_generic_vector;
52  }
53 
54  void dumpWorkflowExecutionJSON(Workflow *workflow, std::string file_path,
55  bool generate_host_utilization_layout = false, bool writing_file = true);
56 
57  void dumpWorkflowGraphJSON(wrench::Workflow *workflow, std::string file_path, bool writing_file = true);
58 
59  void dumpHostEnergyConsumptionJSON(std::string file_path, bool writing_file = true);
60 
61  void dumpPlatformGraphJSON(std::string file_path, bool writing_file = true);
62 
63  void dumpDiskOperationsJSON(std::string file_path, bool writing_file = true);
64 
65  void dumpLinkUsageJSON(std::string file_path, bool writing_file = true);
66 
67  void dumpUnifiedJSON(Workflow *workflow, std::string file_path,
68  bool include_platform = false,
69  bool include_workflow_exec = true,
70  bool include_workflow_graph = false,
71  bool include_energy = false,
72  bool generate_host_utilization_layout = false,
73  bool include_disk = false,
74  bool include_bandwidth = false);
75 
76  void enableWorkflowTaskTimestamps(bool enabled);
77 
78  void enableFileReadWriteCopyTimestamps(bool enabled);
79 
80  void enableEnergyTimestamps(bool enabled);
81 
82  void enableDiskTimestamps(bool enabled);
83 
84  void enableBandwidthTimestamps(bool enabled);
85 
86  /***********************/
88  /***********************/
89 
90  void addTimestampTaskStart(WorkflowTask *task);
91 
92  void addTimestampTaskFailure(WorkflowTask *task);
93 
94  void addTimestampTaskCompletion(WorkflowTask *task);
95 
96  void addTimestampTaskTermination(WorkflowTask *task);
97 
98  void addTimestampFileReadStart(WorkflowFile *file, FileLocation *src, StorageService *service,
99  WorkflowTask *task = nullptr);
100 
101  void addTimestampFileReadFailure(WorkflowFile *file, FileLocation *src, StorageService *service,
102  WorkflowTask *task = nullptr);
103 
104  void addTimestampFileReadCompletion(WorkflowFile *file, FileLocation *src, StorageService *service,
105  WorkflowTask *task = nullptr);
106 
107  void addTimestampFileWriteStart(WorkflowFile *file, FileLocation *src, StorageService *service,
108  WorkflowTask *task = nullptr);
109 
110  void addTimestampFileWriteFailure(WorkflowFile *file, FileLocation *src, StorageService *service,
111  WorkflowTask *task = nullptr);
112 
113  void addTimestampFileWriteCompletion(WorkflowFile *file, FileLocation *src, StorageService *service,
114  WorkflowTask *task = nullptr);
115 
116  void addTimestampFileCopyStart(WorkflowFile *file, std::shared_ptr<FileLocation> src,
117  std::shared_ptr<FileLocation> dst);
118 
119  void addTimestampFileCopyFailure(WorkflowFile *file, std::shared_ptr<FileLocation> src,
120  std::shared_ptr<FileLocation> dst);
121 
122  void addTimestampFileCopyCompletion(WorkflowFile *file, std::shared_ptr<FileLocation> src,
123  std::shared_ptr<FileLocation> dst);
124 
125  void
126  addTimestampDiskReadStart(std::string hostname, std::string mount, double bytes, int unique_sequence_number);
127 
128  void
129  addTimestampDiskReadFailure(std::string hostname, std::string mount, double bytes, int unique_sequence_number);
130 
131  void addTimestampDiskReadCompletion(std::string hostname, std::string mount, double bytes,
132  int unique_sequence_number);
133 
134  void
135  addTimestampDiskWriteStart(std::string hostname, std::string mount, double bytes, int unique_sequence_number);
136 
137  void
138  addTimestampDiskWriteFailure(std::string hostname, std::string mount, double bytes, int unique_sequence_number);
139 
140  void addTimestampDiskWriteCompletion(std::string hostname, std::string mount, double bytes,
141  int unique_sequence_number);
142 
143  void addTimestampPstateSet(std::string hostname, int pstate);
144 
145  void addTimestampEnergyConsumption(std::string hostname, double joules);
146 
147  void addTimestampLinkUsage(std::string linkname, double bytes_per_second);
148 
155  template<class T>
156  void addTimestamp(T *timestamp) {
157  std::type_index type_index = std::type_index(typeid(T));
158  if (this->traces.find(type_index) == this->traces.end()) {
159  this->traces[type_index] = new SimulationTrace<T>();
160  }
161  ((SimulationTrace<T> *) (this->traces[type_index]))->addTimestamp(new SimulationTimestamp<T>(timestamp));
162  }
163 
164  /***********************/
166  /***********************/
167 
168  /***********************/
170  /***********************/
171 
172  ~SimulationOutput();
173 
174  SimulationOutput();
175 
176  /***********************/
178  /***********************/
179 
180  private:
181  std::map<std::type_index, GenericSimulationTrace *> traces;
182  nlohmann::json platform_json_part;
183  nlohmann::json workflow_exec_json_part;
184  nlohmann::json workflow_graph_json_part;
185  nlohmann::json energy_json_part;
186  nlohmann::json disk_json_part;
187  nlohmann::json bandwidth_json_part;
188 
189  std::map<std::type_index, bool> enabledStatus;
190 
196  template<class T>
197  bool isEnabled() {
198  std::type_index type_index = std::type_index(typeid(T));
199  return this->enabledStatus[type_index];
200  }
201 
207  template<class T>
208  void setEnabled(bool enabled) {
209  std::type_index type_index = std::type_index(typeid(T));
210  this->enabledStatus[type_index] = enabled;
211  }
212  };
213 };
214 
215 #endif //WRENCH_SIMULATIONOUTPUT_H
void enableFileReadWriteCopyTimestamps(bool enabled)
Enable or Disable the insertion of file-related timestamps in the simulation output (enabled by defau...
Definition: SimulationOutput.cpp:1911
void dumpWorkflowExecutionJSON(Workflow *workflow, std::string file_path, bool generate_host_utilization_layout=false, bool writing_file=true)
Writes WorkflowTask execution history for each task to a file, formatted as a JSON array.
Definition: SimulationOutput.cpp:515
void dumpUnifiedJSON(Workflow *workflow, std::string file_path, bool include_platform=false, bool include_workflow_exec=true, bool include_workflow_graph=false, bool include_energy=false, bool generate_host_utilization_layout=false, bool include_disk=false, bool include_bandwidth=false)
Function that generates a unified JSON file containing the information specified by boolean arguments...
Definition: SimulationOutput.cpp:150
void enableBandwidthTimestamps(bool enabled)
Enable or Disable the insertion of link-usage-related timestamps in the simulation output (enabled by...
Definition: SimulationOutput.cpp:1938
void enableDiskTimestamps(bool enabled)
Enable or Disable the insertion of disk-related timestamps in the simulation output (enabled by defau...
Definition: SimulationOutput.cpp:1897
A time-stamped simulation event stored in SimulationOutput.
Definition: SimulationTimestamp.h:26
void dumpPlatformGraphJSON(std::string file_path, bool writing_file=true)
Writes a JSON file containing all hosts, network links, and the routes between each host.
Definition: SimulationOutput.cpp:1000
The storage service base class.
Definition: StorageService.h:36
std::vector< SimulationTimestamp< T > * > getTrace()
Retrieve a copy of a simulation output trace once the simulation has completed.
Definition: SimulationOutput.h:38
Definition: Alarm.cpp:20
A workflow (to be executed by a WMS)
Definition: Workflow.h:34
void enableEnergyTimestamps(bool enabled)
Enable or Disable the insertion of energy-related timestamps in the simulation output (enabled by def...
Definition: SimulationOutput.cpp:1928
void dumpHostEnergyConsumptionJSON(std::string file_path, bool writing_file=true)
Writes a JSON file containing host energy consumption information as a JSON array.
Definition: SimulationOutput.cpp:852
A computational task in a Workflow.
Definition: WorkflowTask.h:31
void dumpLinkUsageJSON(std::string file_path, bool writing_file=true)
Definition: SimulationOutput.cpp:1465
A class that contains post-mortem simulation-generated data.
Definition: SimulationOutput.h:27
void enableWorkflowTaskTimestamps(bool enabled)
Enable or Disable the insertion of task-related timestamps in the simulation output (enabled by defau...
Definition: SimulationOutput.cpp:1885
void dumpDiskOperationsJSON(std::string file_path, bool writing_file=true)
Writes a JSON file containing disk operation information as a JSON array.
Definition: SimulationOutput.cpp:1300
void dumpWorkflowGraphJSON(wrench::Workflow *workflow, std::string file_path, bool writing_file=true)
Writes a JSON graph representation of the Workflow to a file.
Definition: SimulationOutput.cpp:727
A data file used/produced by a WorkflowTask in a Workflow.
Definition: WorkflowFile.h:26