11 #ifndef WRENCH_SIMULATION_H
12 #define WRENCH_SIMULATION_H
16 #include <nlohmann/json.hpp>
17 #include <wrench/services/compute/bare_metal/BareMetalComputeServiceOneShot.h>
20 #include "wrench/simulation/SimulationOutput.h"
27 class NetworkProximityService;
28 class FileRegistryService;
29 class EnergyMeterService;
30 class BandwidthMeterService;
32 class BatchComputeService;
33 class BareMetalComputeService;
34 class CloudComputeService;
35 class VirtualizedClusterComputeService;
36 class ExecutionController;
38 class SimulationOutput;
56 void init(
int *,
char **);
69 static std::map<std::string, std::shared_ptr<DataFile>> &
getFileMap();
70 static void removeFile(std::shared_ptr<DataFile>file);
71 static std::shared_ptr<DataFile>
getFileByID(
const std::string &
id);
72 static std::shared_ptr<DataFile>
addFile(std::string,
double);
85 std::shared_ptr<T>
add(T *t) {
86 auto s = std::shared_ptr<T>(t);
95 std::map<std::string, double>
getEnergyConsumed(
const std::vector<std::string> &hostnames);
104 void stageFile(std::shared_ptr<DataFile>file, std::shared_ptr<StorageService> ss);
105 void stageFile(std::shared_ptr<DataFile>file, std::shared_ptr<StorageService> ss, std::string directory_absolute_path);
110 double getEnergyConsumed(
const std::string &hostname,
bool record_as_time_stamp);
112 static std::vector<std::string> getRoute(std::string &src_host, std::string &dst_host);
114 double getLinkUsage(
const std::string &link_name,
bool record_as_time_stamp);
115 std::map<std::string, double>
getEnergyConsumed(
const std::vector<std::string> &hostnames,
bool record_as_time_stamps);
117 static bool doesHostExist(std::string hostname);
118 static bool isHostOn(std::string hostname);
119 static void turnOnHost(std::string hostname);
120 static void turnOffHost(std::string hostname);
121 static bool doesLinkExist(std::string linkname);
122 static bool isLinkOn(std::string linkname);
123 static void turnOnLink(std::string linkname);
124 static void turnOffLink(std::string linkname);
127 void setPstate(
const std::string &hostname,
int pstate);
128 static int getCurrentPstate(
const std::string &hostname);
130 std::shared_ptr<ComputeService> startNewService(
ComputeService *service);
131 std::shared_ptr<StorageService> startNewService(
StorageService *service);
134 std::shared_ptr<MemoryManager> startNewService(MemoryManager *service);
136 static double getCurrentSimulatedDate();
138 static void sleep(
double duration);
139 static void compute(
double flops);
147 void readFromDisk(
double num_bytes, std::string hostname, std::string mount_point);
148 void readFromDiskAndWriteToDiskConcurrently(
double num_bytes_to_read,
double num_bytes_to_write,
149 std::string hostname,
150 std::string read_mount_point,
151 std::string write_mount_point);
152 void writeToDisk(
double num_bytes, std::string hostname, std::string mount_point);
154 void readWithMemoryCache(std::shared_ptr<DataFile>file,
double n_bytes, std::shared_ptr<FileLocation> location);
155 void writebackWithMemoryCache(std::shared_ptr<DataFile>file,
double n_bytes, std::shared_ptr<FileLocation> location,
bool is_dirty);
156 void writeThroughWithMemoryCache(std::shared_ptr<DataFile>file,
double n_bytes, std::shared_ptr<FileLocation> location);
157 MemoryManager* getMemoryManagerByHost(std::string hostname);
159 static double getMemoryCapacity();
160 static unsigned long getNumCores();
161 static double getFlopRate();
162 static std::string getHostName();
164 static std::vector<std::string> getLinknameList();
165 static double getLinkUsage(std::string linkname);
166 static double getLinkBandwidth(std::string linkname);
167 static bool isPageCachingEnabled();
168 static bool isHostShutdownSimulationEnabled();
169 static bool isEnergySimulationEnabled();
182 std::unique_ptr<S4U_Simulation> s4u_simulation;
184 std::set<std::shared_ptr<ExecutionController>> execution_controllers;
186 std::set<std::shared_ptr<FileRegistryService>> file_registry_services;
188 std::set<std::shared_ptr<EnergyMeterService>> energy_meter_services;
190 std::set<std::shared_ptr<BandwidthMeterService>> bandwidth_meter_services;
192 std::set<std::shared_ptr<NetworkProximityService>> network_proximity_services;
194 std::set<std::shared_ptr<ComputeService>> compute_services;
196 std::set<std::shared_ptr<StorageService>> storage_services;
198 std::set<std::shared_ptr<MemoryManager>> memory_managers;
200 static int unique_disk_sequence_number;
202 void stageFile(std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> location);
204 void platformSanityCheck();
205 void checkSimulationSetup();
208 void startAllProcesses();
209 void addService(std::shared_ptr<ComputeService> service);
210 void addService(std::shared_ptr<StorageService> service);
211 void addService(std::shared_ptr<NetworkProximityService> service);
212 void addService(std::shared_ptr<ExecutionController> service);
213 void addService(std::shared_ptr<FileRegistryService> service);
214 void addService(std::shared_ptr<EnergyMeterService> service);
215 void addService(std::shared_ptr<BandwidthMeterService> service);
216 void addService(std::shared_ptr<MemoryManager> memory_manager);
218 std::string getWRENCHVersionString() {
return WRENCH_VERSION_STRING; }
220 bool is_running =
false;
222 bool already_setup =
false;
224 unsigned int on_state_change_callback_id;
227 static bool energy_enabled;
228 static bool host_shutdown_enabled;
229 static bool pagecache_enabled;
231 static bool initialized;
235 static std::map<std::string, std::shared_ptr<DataFile>> data_files;
243 #endif //WRENCH_SIMULATION_H