Simulation.h
1 
11 #ifndef WRENCH_SIMULATION_H
12 #define WRENCH_SIMULATION_H
13 
14 #include <string>
15 #include <vector>
16 #include <nlohmann/json.hpp>
17 
18 #include "wrench/services/file_registry/FileRegistryService.h"
19 #include "wrench/services/network_proximity/NetworkProximityService.h"
20 #include "wrench/simgrid_S4U_util/S4U_Simulation.h"
21 #include "wrench/simulation/SimulationOutput.h"
22 #include "wrench/wms/WMS.h"
23 #include "wrench/workflow/job/StandardJob.h"
24 #include "Version.h"
25 
26 
27 namespace wrench {
28 
29  class StorageService;
30 
34  class Simulation {
35 
36  public:
37  Simulation();
38 
39  ~Simulation();
40 
41  void init(int *, char **);
42 
43  void instantiatePlatform(std::string);
44 
45  std::vector<std::string> getHostnameList();
46  std::map<std::string, std::vector<std::string>> getHostnameListByCluster();
47 
48  void launch();
49 
53  WMS * add(WMS *);
55 
56  void stageFile(WorkflowFile *file, StorageService *storage_service);
57  void stageFile(WorkflowFile *file, StorageService *storage_service, std::string partition);
58 
59  void stageFiles(std::map<std::string, WorkflowFile *> files, StorageService *storage_service);
60  void stageFiles(std::map<std::string, WorkflowFile *> files, StorageService *storage_service, std::string partition);
61 
63 
64  static double getHostMemoryCapacity(std::string hostname);
65 
66  static unsigned long getHostNumCores(std::string hostname);
67 
68  static double getHostFlopRate(std::string hostname);
69 
70  //start energy related calls
71  double getEnergyConsumed(const std::string &hostname, bool record_as_time_stamp = false);
72  std::map<std::string, double> getEnergyConsumed(const std::vector<std::string> &hostnames, bool record_as_time_stamps = false);
73 // double getEnergyTimestamp(const std::string &hostname, bool can_record = false);
74 
75  // pstate related calls
76  void setPstate(const std::string &hostname, int pstate);
77  static int getNumberofPstates(const std::string &hostname);
78  static int getCurrentPstate(const std::string &hostname);
79  static double getMinPowerConsumption(const std::string &hostname);
80  static double getMaxPowerConsumption(const std::string &hostname);
81  static std::vector<int> getListOfPstates(const std::string &hostname);
82 
83 
84  /***********************/
86  /***********************/
87 
88 
89  ComputeService * startNewService(ComputeService *service);
90  StorageService * startNewService(StorageService *service);
91  NetworkProximityService * startNewService(NetworkProximityService *service);
92  FileRegistryService * startNewService(FileRegistryService *service);
93 
94 
95  static double getMemoryCapacity();
96  static unsigned long getNumCores();
97  static double getFlopRate();
98 
99  static double getCurrentSimulatedDate();
100 
101 
102 
103  static void sleep(double duration);
104  static void compute(double flops);
105 
106  /***********************/
108  /***********************/
109 
110  private:
111  SimulationOutput output;
112 
113  std::unique_ptr<S4U_Simulation> s4u_simulation;
114 
115  std::set<std::shared_ptr<WMS>> wmses;
116 
117  std::set<std::shared_ptr<FileRegistryService>> file_registry_services;
118 
119  std::set<std::shared_ptr<NetworkProximityService>> network_proximity_services;
120 
121  std::set<std::shared_ptr<ComputeService>> compute_services;
122 
123  std::set<std::shared_ptr<StorageService>> storage_services;
124 
125  void checkSimulationSetup();
126 
127  void startAllProcesses();
128 
129  std::string getWRENCHVersionString() { return WRENCH_VERSION_STRING; }
130 
131  bool is_running = false;
132 
133  };
134 
135 };
136 
137 #endif //WRENCH_SIMULATION_H
void stageFiles(std::map< std::string, WorkflowFile *> files, StorageService *storage_service)
Stage file copies on a storage service (to the "/" partition)
Definition: Simulation.cpp:546
ComputeService * add(ComputeService *)
Add a ComputeService to the simulation. The simulation takes ownership of the reference and will call...
Definition: Simulation.cpp:384
void instantiatePlatform(std::string)
Instantiate a simulated platform.
Definition: Simulation.cpp:187
std::vector< std::string > getHostnameList()
Get the list of names of all the hosts in the platform.
Definition: Simulation.cpp:206
std::map< std::string, std::vector< std::string > > getHostnameListByCluster()
Get the list of names of all the hosts in each cluster composing the platform.
Definition: Simulation.cpp:216
static double getHostMemoryCapacity(std::string hostname)
Get the memory capacity of a host given a hostname.
Definition: Simulation.cpp:606
static unsigned long getHostNumCores(std::string hostname)
Get the number of cores of a host given a hostname.
Definition: Simulation.cpp:615
~Simulation()
Destructor.
Definition: Simulation.cpp:68
void stageFile(WorkflowFile *file, StorageService *storage_service)
Stage a copy of a file on a storage service (to the "/" partition)
Definition: Simulation.cpp:482
static double getMaxPowerConsumption(const std::string &hostname)
Get the maximum power consumption for the host (i.e., 100% utilization) at its current pstate...
Definition: Simulation.cpp:776
A data file used/produced by a WorkflowTask in a Workflow.
Definition: WorkflowFile.h:26
A class that contains post-mortem simulation-generated data.
Definition: SimulationOutput.h:27
A class that provides basic simulation methods.
Definition: Simulation.h:34
static double getHostFlopRate(std::string hostname)
Get the flop rate of one core of a host given a hostname.
Definition: Simulation.cpp:624
The compute service base class.
Definition: ComputeService.h:35
SimulationOutput & getOutput()
Get the simulation output object.
Definition: Simulation.cpp:677
double getEnergyConsumed(const std::string &hostname, bool record_as_time_stamp=false)
Obtains the current energy consumption of a host and will add SimulationTimestampEnergyConsumption to...
Definition: Simulation.cpp:689
static int getCurrentPstate(const std::string &hostname)
Get the current power state of a host.
Definition: Simulation.cpp:748
A file registry service (a.k.a. replica catalog) that holds a database of which files are available a...
Definition: FileRegistryService.h:33
A network proximity service that continuously estimates inter-host latencies and can be queried for s...
Definition: NetworkProximityService.h:26
void launch()
Launch the simulation.
Definition: Simulation.cpp:225
static int getNumberofPstates(const std::string &hostname)
Get the total number of power states of a host.
Definition: Simulation.cpp:739
A workflow management system (WMS)
Definition: WMS.h:33
static double getMinPowerConsumption(const std::string &hostname)
Get the minimum power consumption for the host (i.e., idling) at its current pstate.
Definition: Simulation.cpp:767
Simulation()
Constructor.
Definition: Simulation.cpp:49
void setPstate(const std::string &hostname, int pstate)
Set the power state of the host.
Definition: Simulation.cpp:729
void init(int *, char **)
Initialize the simulation, which parses out WRENCH-specific and SimGrid-specific command-line argumen...
Definition: Simulation.cpp:82
The storage service base class.
Definition: StorageService.h:35
static std::vector< int > getListOfPstates(const std::string &hostname)
Get the list of power states available for a host.
Definition: Simulation.cpp:757
Definition: TerminalOutput.cpp:15