11 #ifndef WRENCH_SIMULATION_H
12 #define WRENCH_SIMULATION_H
16 #include <nlohmann/json.hpp>
19 #include <wrench/simulation/SimulationOutput.h>
26 class NetworkProximityService;
27 class FileRegistryService;
28 class EnergyMeterService;
30 class BatchComputeService;
31 class BareMetalComputeService;
32 class CloudComputeService;
33 class VirtualizedClusterComputeService;
36 class SimulationOutput;
52 void init(
int *,
char **);
71 std::shared_ptr<T>
add(T *t) {
72 auto s = std::shared_ptr<T>(t);
81 std::map<std::string, double>
getEnergyConsumed(
const std::vector<std::string> &hostnames);
91 void stageFile(
WorkflowFile *file, std::shared_ptr<StorageService> ss, std::string directory_absolute_path);
97 std::map<std::string, double>
getEnergyConsumed(
const std::vector<std::string> &hostnames,
bool record_as_time_stamps);
99 static bool doesHostExist(std::string hostname);
100 static bool isHostOn(std::string hostname);
101 static void turnOnHost(std::string hostname);
102 static void turnOffHost(std::string hostname);
103 static bool isLinkOn(std::string linkname);
104 static void turnOnLink(std::string linkname);
105 static void turnOffLink(std::string linkname);
108 void setPstate(
const std::string &hostname,
int pstate);
109 static int getCurrentPstate(
const std::string &hostname);
111 std::shared_ptr<ComputeService> startNewService(
ComputeService *service);
112 std::shared_ptr<StorageService> startNewService(
StorageService *service);
116 static double getCurrentSimulatedDate();
118 static void sleep(
double duration);
119 static void compute(
double flops);
127 void readFromDisk(
double num_bytes, std::string hostname, std::string mount_point);
128 void readFromDiskAndWriteToDiskConcurrently(
double num_bytes_to_read,
double num_bytes_to_write,
129 std::string hostname,
130 std::string read_mount_point,
131 std::string write_mount_point);
132 void writeToDisk(
double num_bytes, std::string hostname, std::string mount_point);
134 static double getMemoryCapacity();
135 static unsigned long getNumCores();
136 static double getFlopRate();
137 static std::string getHostName();
145 std::unique_ptr<S4U_Simulation> s4u_simulation;
147 std::set<std::shared_ptr<WMS>> wmses;
149 std::set<std::shared_ptr<FileRegistryService>> file_registry_services;
151 std::set<std::shared_ptr<EnergyMeterService>> energy_meter_services;
153 std::set<std::shared_ptr<NetworkProximityService>> network_proximity_services;
155 std::set<std::shared_ptr<ComputeService>> compute_services;
157 std::set<std::shared_ptr<StorageService>> storage_services;
159 static int unique_disk_sequence_number;
163 void platformSanityCheck();
164 void checkSimulationSetup();
167 void startAllProcesses();
168 void addService(std::shared_ptr<ComputeService> service);
169 void addService(std::shared_ptr<StorageService> service);
170 void addService(std::shared_ptr<NetworkProximityService> service);
171 void addService(std::shared_ptr<WMS> service);
172 void addService(std::shared_ptr<FileRegistryService> service);
173 void addService(std::shared_ptr<EnergyMeterService> service);
175 std::string getWRENCHVersionString() {
return WRENCH_VERSION_STRING; }
177 bool is_running =
false;
179 unsigned int on_state_change_callback_id;
184 #endif //WRENCH_SIMULATION_H
static 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:241
std::shared_ptr< T > add(T *t)
Method to add a service to the simulation.
Definition: Simulation.h:71
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:907
void instantiatePlatform(std::string)
Instantiate a simulated platform.
Definition: Simulation.cpp:205
A file registry service (a.k.a. replica catalog) that holds a database of which files are available a...
Definition: FileRegistryService.h:36
The storage service base class.
Definition: StorageService.h:36
The compute service base class.
Definition: ComputeService.h:35
static std::vector< int > getListOfPstates(const std::string &hostname)
Get the list of power states available for a host.
Definition: Simulation.cpp:898
void launch()
Launch the simulation.
Definition: Simulation.cpp:250
void init(int *, char **)
Initialize the simulation, which parses out WRENCH-specific and SimGrid-specific command-line argumen...
Definition: Simulation.cpp:92
static double getHostMemoryCapacity(std::string hostname)
Get the memory capacity of a host given a hostname.
Definition: Simulation.cpp:673
static std::vector< std::string > getHostnameList()
Get the list of names of all the hosts in the platform.
Definition: Simulation.cpp:231
static unsigned long getHostNumCores(std::string hostname)
Get the number of cores of a host given a hostname.
Definition: Simulation.cpp:682
double getEnergyConsumed(const std::string &hostname)
Obtains the current energy consumption of a host.
Definition: Simulation.cpp:807
Simulation()
Constructor.
Definition: Simulation.cpp:58
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:45
void stageFile(WorkflowFile *file, std::shared_ptr< StorageService > ss)
Stage a copy of a file at a storage service in the root of the (unique) mount point.
Definition: Simulation.cpp:509
~Simulation()
Destructor.
Definition: Simulation.cpp:75
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:916
static double getHostFlopRate(std::string hostname)
Get the flop rate of one core of a host given a hostname.
Definition: Simulation.cpp:691
static int getNumberofPstates(const std::string &hostname)
Get the total number of power states of a host.
Definition: Simulation.cpp:880
SimulationOutput & getOutput()
Get the simulation output object.
Definition: Simulation.cpp:797
A network proximity service that continuously estimates inter-host latencies and can be queried for s...
Definition: NetworkProximityService.h:26
A class that contains post-mortem simulation-generated data.
Definition: SimulationOutput.h:27
A data file used/produced by a WorkflowTask in a Workflow.
Definition: WorkflowFile.h:26