11 #ifndef WRENCH_SIMULATION_H
12 #define WRENCH_SIMULATION_H
16 #include <nlohmann/json.hpp>
18 #include <wrench/simulation/SimulationOutput.h>
25 class NetworkProximityService;
26 class FileRegistryService;
27 class EnergyMeterService;
28 class BandwidthMeterService;
30 class BatchComputeService;
31 class BareMetalComputeService;
32 class CloudComputeService;
33 class VirtualizedClusterComputeService;
36 class SimulationOutput;
53 void init(
int *,
char **);
74 std::shared_ptr<T>
add(T *t) {
75 auto s = std::shared_ptr<T>(t);
84 std::map<std::string, double>
getEnergyConsumed(
const std::vector<std::string> &hostnames);
94 void stageFile(
WorkflowFile *file, std::shared_ptr<StorageService> ss, std::string directory_absolute_path);
101 static std::vector<std::string> getRoute(std::string &src_host, std::string &dst_host);
103 double getLinkUsage(
const std::string &link_name,
bool record_as_time_stamp);
104 std::map<std::string, double>
getEnergyConsumed(
const std::vector<std::string> &hostnames,
bool record_as_time_stamps);
106 static bool doesHostExist(std::string hostname);
107 static bool isHostOn(std::string hostname);
108 static void turnOnHost(std::string hostname);
109 static void turnOffHost(std::string hostname);
110 static bool doesLinkExist(std::string linkname);
111 static bool isLinkOn(std::string linkname);
112 static void turnOnLink(std::string linkname);
113 static void turnOffLink(std::string linkname);
116 void setPstate(
const std::string &hostname,
int pstate);
117 static int getCurrentPstate(
const std::string &hostname);
119 std::shared_ptr<ComputeService> startNewService(
ComputeService *service);
120 std::shared_ptr<StorageService> startNewService(
StorageService *service);
123 std::shared_ptr<MemoryManager> startNewService(MemoryManager *service);
125 static double getCurrentSimulatedDate();
127 static void sleep(
double duration);
128 static void compute(
double flops);
136 void readFromDisk(
double num_bytes, std::string hostname, std::string mount_point);
137 void readFromDiskAndWriteToDiskConcurrently(
double num_bytes_to_read,
double num_bytes_to_write,
138 std::string hostname,
139 std::string read_mount_point,
140 std::string write_mount_point);
141 void writeToDisk(
double num_bytes, std::string hostname, std::string mount_point);
143 void readWithMemoryCache(
WorkflowFile *file,
double n_bytes, std::shared_ptr<FileLocation> location);
144 void writebackWithMemoryCache(
WorkflowFile *file,
double n_bytes, std::shared_ptr<FileLocation> location,
bool is_dirty);
145 void writeThroughWithMemoryCache(
WorkflowFile *file,
double n_bytes, std::shared_ptr<FileLocation> location);
146 MemoryManager* getMemoryManagerByHost(std::string hostname);
148 static double getMemoryCapacity();
149 static unsigned long getNumCores();
150 static double getFlopRate();
151 static std::string getHostName();
153 static std::vector<std::string> getLinknameList();
154 static double getLinkUsage(std::string linkname);
155 static double getLinkBandwidth(std::string linkname);
156 static bool isPageCachingEnabled();
157 static bool isHostShutdownSimulationEnabled();
158 static bool isEnergySimulationEnabled();
168 std::unique_ptr<S4U_Simulation> s4u_simulation;
170 std::set<std::shared_ptr<WMS>> wmses;
172 std::set<std::shared_ptr<FileRegistryService>> file_registry_services;
174 std::set<std::shared_ptr<EnergyMeterService>> energy_meter_services;
176 std::set<std::shared_ptr<BandwidthMeterService>> bandwidth_meter_services;
178 std::set<std::shared_ptr<NetworkProximityService>> network_proximity_services;
180 std::set<std::shared_ptr<ComputeService>> compute_services;
182 std::set<std::shared_ptr<StorageService>> storage_services;
184 std::set<std::shared_ptr<MemoryManager>> memory_managers;
186 static int unique_disk_sequence_number;
190 void platformSanityCheck();
191 void checkSimulationSetup();
194 void startAllProcesses();
195 void addService(std::shared_ptr<ComputeService> service);
196 void addService(std::shared_ptr<StorageService> service);
197 void addService(std::shared_ptr<NetworkProximityService> service);
198 void addService(std::shared_ptr<WMS> service);
199 void addService(std::shared_ptr<FileRegistryService> service);
200 void addService(std::shared_ptr<EnergyMeterService> service);
201 void addService(std::shared_ptr<BandwidthMeterService> service);
202 void addService(std::shared_ptr<MemoryManager> memory_manager);
204 std::string getWRENCHVersionString() {
return WRENCH_VERSION_STRING; }
206 bool is_running =
false;
208 bool already_setup =
false;
210 unsigned int on_state_change_callback_id;
212 static bool energy_enabled;
213 static bool host_shutdown_enabled;
214 static bool pagecache_enabled;
219 #endif //WRENCH_SIMULATION_H