S4U_Simulation.h
1 
11 #ifndef WRENCH_S4U_SIMULATION_H
12 #define WRENCH_S4U_SIMULATION_H
13 
14 #include <set>
15 #include <simgrid/s4u.hpp>
16 #include <simgrid/kernel/routing/ClusterZone.hpp>
17 
18 namespace wrench {
19 
20  /***********************/
22  /***********************/
23 
28 
29  public:
31  static constexpr double DEFAULT_RAM = (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0); // 1 PiB
32 
33  public:
34  void initialize(int *argc, char **argv);
35  void setupPlatform(std::string&);
36  void runSimulation();
37  static double getClock();
38  static std::string getHostName();
39  static bool hostExists(std::string hostname);
40  static unsigned int getHostNumCores(std::string hostname);
41  static unsigned int getNumCores();
42  static double getHostFlopRate(std::string hostname);
43  static bool isHostOn(std::string hostname);
44  static void turnOffHost(std::string hostname);
45  static void turnOnHost(std::string hostname);
46  static bool isLinkOn(std::string linkname);
47  static void turnOffLink(std::string linkname);
48  static void turnOnLink(std::string linkname);
49  static double getFlopRate();
50  static double getHostMemoryCapacity(std::string hostname);
51  static double getMemoryCapacity();
52  static void compute(double);
53  static void sleep(double);
54  static void computeZeroFlop();
55  static void writeToDisk(double num_bytes, std::string hostname, std::string mount_point);
56  static void readFromDisk(double num_bytes, std::string hostname, std::string mount_point);
57  static void readFromDiskAndWriteToDiskConcurrently(double num_bytes_to_read, double num_bytes_to_write,
58  std::string hostname,
59  std::string read_mount_point,
60  std::string write_mount_point);
61 
62  static double getDiskCapacity(std::string hostname, std::string mount_point);
63  static std::vector<std::string> getDisks(std::string hostname);
64  static bool hostHasMountPoint(std::string hostname, std::string mount_point);
65 
66  static void yield();
67  static std::string getHostProperty(std::string hostname, std::string property_name);
68 
69  //start energy related calls
70  static double getEnergyConsumedByHost(const std::string &hostname);
71 // static double getTotalEnergyConsumed(const std::vector<std::string> &hostnames);
72  static void setPstate(const std::string &hostname, int pstate);
73  static int getNumberofPstates(const std::string &hostname);
74  static int getCurrentPstate(const std::string &hostname);
75  static double getMinPowerConsumption(const std::string &hostname);
76  static double getMaxPowerConsumption(const std::string &hostname);
77  static std::vector<int> getListOfPstates(const std::string &hostname);
78  //end energy related calls
79 
80  bool isInitialized();
81  bool isPlatformSetup();
82  static std::vector<std::string> getAllHostnames();
83  static std::map<std::string, std::vector<std::string>> getAllHostnamesByCluster();
84  void shutdown();
85 
86  private:
87  static double getHostMemoryCapacity(simgrid::s4u::Host *host);
88  simgrid::s4u::Engine *engine;
89  bool initialized = false;
90  bool platform_setup = false;
91 
92  };
93 
94  /***********************/
96  /***********************/
97 };
98 
99 #endif //WRENCH_S4U_SIMULATION_H
static std::string getHostProperty(std::string hostname, std::string property_name)
Get the property associated to the host specified in the platform file.
Definition: S4U_Simulation.cpp:498
static std::vector< std::string > getAllHostnames()
Get the list of hostnames.
Definition: S4U_Simulation.cpp:114
static void turnOnHost(std::string hostname)
Turn on a host.
Definition: S4U_Simulation.cpp:236
Wrappers around S4U&#39;s basic simulation methods.
Definition: S4U_Simulation.h:27
static void computeZeroFlop()
Compute zero flop, which take zero time but will block if the host&#39;s pstate has a zero flop/sec speed...
Definition: S4U_Simulation.cpp:703
static void readFromDisk(double num_bytes, std::string hostname, std::string mount_point)
Simulates a disk read.
Definition: S4U_Simulation.cpp:400
static bool isLinkOn(std::string linkname)
Returns whether a link is on or not.
Definition: S4U_Simulation.cpp:252
void shutdown()
Shutdown the simulation.
Definition: S4U_Simulation.cpp:74
static bool hostHasMountPoint(std::string hostname, std::string mount_point)
Determines whether a mount point is defined at a host.
Definition: S4U_Simulation.cpp:746
bool isInitialized()
Returns true if S4U_Simulation::initialize() has been called successfully previously.
Definition: S4U_Simulation.cpp:46
static std::string getHostName()
Get the hostname on which the calling actor is running.
Definition: S4U_Simulation.cpp:105
static double getClock()
Get the current simulation date.
Definition: S4U_Simulation.cpp:306
static bool hostExists(std::string hostname)
Determines whether a host exists for a given hostname.
Definition: S4U_Simulation.cpp:153
bool isPlatformSetup()
Returns true if S4U_Simulation::setupPlatform() has been called successfully previously.
Definition: S4U_Simulation.cpp:54
static void writeToDisk(double num_bytes, std::string hostname, std::string mount_point)
Simulates a disk write.
Definition: S4U_Simulation.cpp:325
static double getDiskCapacity(std::string hostname, std::string mount_point)
Gets the capacity of a disk attached to some host for a given mount point.
Definition: S4U_Simulation.cpp:780
static constexpr double DEFAULT_RAM
The ram capacity of a physical host whenever not specified in the platform description file...
Definition: S4U_Simulation.h:31
static double getHostMemoryCapacity(std::string hostname)
Get the memory capacity of a host given a hostname.
Definition: S4U_Simulation.cpp:446
static std::vector< std::string > getDisks(std::string hostname)
Gets set of disks, i.e., mount points, available at a host.
Definition: S4U_Simulation.cpp:717
static void readFromDiskAndWriteToDiskConcurrently(double num_bytes_to_read, double num_bytes_to_write, std::string hostname, std::string read_mount_point, std::string write_mount_point)
Read from a local disk and write to a local disk concurrently.
Definition: S4U_Simulation.cpp:357
void initialize(int *argc, char **argv)
Initialize the Simgrid simulation.
Definition: S4U_Simulation.cpp:35
static void turnOffHost(std::string hostname)
Turn off a host.
Definition: S4U_Simulation.cpp:220
static void turnOffLink(std::string linkname)
Turn off a link.
Definition: S4U_Simulation.cpp:267
static double getMaxPowerConsumption(const std::string &hostname)
Get the maximum power consumption (i.e., 100% load) for a host at its current pstate.
Definition: S4U_Simulation.cpp:652
static std::vector< int > getListOfPstates(const std::string &hostname)
Get the list of power states available for a host.
Definition: S4U_Simulation.cpp:676
void runSimulation()
Start the simulation.
Definition: S4U_Simulation.cpp:63
static double getHostFlopRate(std::string hostname)
Get the flop rate of a host.
Definition: S4U_Simulation.cpp:189
static void setPstate(const std::string &hostname, int pstate)
Set the power state of the host.
Definition: S4U_Simulation.cpp:564
static int getNumberofPstates(const std::string &hostname)
Get the total number of power states of a host.
Definition: S4U_Simulation.cpp:587
static double getFlopRate()
Get the flop rate of the current host.
Definition: S4U_Simulation.cpp:297
static bool isHostOn(std::string hostname)
Returns whether a host is on or not.
Definition: S4U_Simulation.cpp:205
static unsigned int getNumCores()
Get the number of cores of the current host.
Definition: S4U_Simulation.cpp:177
static void compute(double)
Simulates a computation on host on which the calling actor is running.
Definition: S4U_Simulation.cpp:314
static double getMemoryCapacity()
Get the memory capacity of the current host.
Definition: S4U_Simulation.cpp:458
void setupPlatform(std::string &)
Initialize the simulated platform. Must only be called once.
Definition: S4U_Simulation.cpp:87
static void turnOnLink(std::string linkname)
Turn on a link.
Definition: S4U_Simulation.cpp:282
static int getCurrentPstate(const std::string &hostname)
Get the current power state of a host.
Definition: S4U_Simulation.cpp:608
static std::map< std::string, std::vector< std::string > > getAllHostnamesByCluster()
Get the by-cluster structure of the platform.
Definition: S4U_Simulation.cpp:128
static double getMinPowerConsumption(const std::string &hostname)
Get the minimum power consumption (i.e., idling) for a host at its current pstate.
Definition: S4U_Simulation.cpp:630
static void yield()
Simulates a yield.
Definition: S4U_Simulation.cpp:437
static unsigned int getHostNumCores(std::string hostname)
Get the number of cores of a host.
Definition: S4U_Simulation.cpp:165
static void sleep(double)
Simulates a sleep.
Definition: S4U_Simulation.cpp:430
static double getEnergyConsumedByHost(const std::string &hostname)
Get the energy consumed by the host up to now.
Definition: S4U_Simulation.cpp:516
Definition: Alarm.cpp:19