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 
21  /***********************/
23  /***********************/
24 
29 
30  public:
32  static constexpr double DEFAULT_RAM = (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0); // 1 PiB
33 
34  public:
35  void initialize(int *argc, char **argv);
36  void setupPlatform(std::string&);
37  void runSimulation();
38  static double getClock();
39  static std::string getHostName();
40  static bool hostExists(std::string hostname);
41  static bool linkExists(std::string linkname);
42  static unsigned int getHostNumCores(std::string hostname);
43  static unsigned int getNumCores();
44  static double getHostFlopRate(std::string hostname);
45  static bool isHostOn(std::string hostname);
46  static void turnOffHost(std::string hostname);
47  static void turnOnHost(std::string hostname);
48  static bool isLinkOn(std::string linkname);
49  static void turnOffLink(std::string linkname);
50  static void turnOnLink(std::string linkname);
51  static double getFlopRate();
52  static double getHostMemoryCapacity(std::string hostname);
53  static double getMemoryCapacity();
54  static void compute(double);
55  static void sleep(double);
56  static void computeZeroFlop();
57  static void writeToDisk(double num_bytes, std::string hostname, std::string mount_point);
58  static void readFromDisk(double num_bytes, std::string hostname, std::string mount_point);
59  static void readFromDiskAndWriteToDiskConcurrently(double num_bytes_to_read, double num_bytes_to_write,
60  std::string hostname,
61  std::string read_mount_point,
62  std::string write_mount_point);
63 
64  static double getDiskCapacity(std::string hostname, std::string mount_point);
65  static std::vector<std::string> getDisks(std::string hostname);
66  static bool hostHasMountPoint(std::string hostname, std::string mount_point);
67 
68  void checkLinkBandwidths();
69 
70  static void yield();
71  static std::string getHostProperty(std::string hostname, std::string property_name);
72 
73  //start energy related calls
74  static double getEnergyConsumedByHost(const std::string &hostname);
75 // static double getTotalEnergyConsumed(const std::vector<std::string> &hostnames);
76  static 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  //end energy related calls
83 
84  bool isInitialized();
85  bool isPlatformSetup();
86  static std::vector<std::string> getAllHostnames();
87  static std::vector<std::string> getAllLinknames();
88  static double getLinkBandwidth(std::string name);
89  static double getLinkUsage(std::string name);
90  static std::map<std::string, std::vector<std::string>> getAllHostnamesByCluster();
91  void shutdown();
92 
93  private:
94  static double getHostMemoryCapacity(simgrid::s4u::Host *host);
95  simgrid::s4u::Engine *engine;
96  bool initialized = false;
97  bool platform_setup = false;
98 
99  };
100 
101  /***********************/
103  /***********************/
104 };
105 
106 #endif //WRENCH_S4U_SIMULATION_H
static double getLinkBandwidth(std::string name)
Get a link's bandwidth.
Definition: S4U_Simulation.cpp:158
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:855
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:427
static int getCurrentPstate(const std::string &hostname)
Get the current power state of a host.
Definition: S4U_Simulation.cpp:683
static std::vector< std::string > getAllLinknames()
Get the list of link names.
Definition: S4U_Simulation.cpp:142
static void turnOffHost(std::string hostname)
Turn off a host.
Definition: S4U_Simulation.cpp:291
void initialize(int *argc, char **argv)
Initialize the Simgrid simulation.
Definition: S4U_Simulation.cpp:33
static bool linkExists(std::string linkname)
Determines whether a link exists for a given linkname.
Definition: S4U_Simulation.cpp:224
static double getHostFlopRate(std::string hostname)
Get the flop rate of a host.
Definition: S4U_Simulation.cpp:260
static std::map< std::string, std::vector< std::string > > getAllHostnamesByCluster()
Get the by-cluster structure of the platform.
Definition: S4U_Simulation.cpp:190
static void setPstate(const std::string &hostname, int pstate)
Set the power state of the host.
Definition: S4U_Simulation.cpp:635
static int getNumberofPstates(const std::string &hostname)
Get the total number of power states of a host.
Definition: S4U_Simulation.cpp:662
static double getFlopRate()
Get the flop rate of the current host.
Definition: S4U_Simulation.cpp:367
static void turnOffLink(std::string linkname)
Turn off a link.
Definition: S4U_Simulation.cpp:337
static std::vector< int > getListOfPstates(const std::string &hostname)
Get the list of power states available for a host.
Definition: S4U_Simulation.cpp:751
static double getEnergyConsumedByHost(const std::string &hostname)
Get the energy consumed by the host up to now.
Definition: S4U_Simulation.cpp:587
static double getMemoryCapacity()
Get the memory capacity of the current host.
Definition: S4U_Simulation.cpp:529
static unsigned int getNumCores()
Get the number of cores of the current host.
Definition: S4U_Simulation.cpp:248
void setupPlatform(std::string &)
Initialize the simulated platform. Must only be called once.
Definition: S4U_Simulation.cpp:99
Definition: Alarm.cpp:20
static void compute(double)
Simulates a computation on host on which the calling actor is running.
Definition: S4U_Simulation.cpp:384
static void computeZeroFlop()
Compute zero flop, which take zero time but will block if the host's pstate has a zero flop/sec speed...
Definition: S4U_Simulation.cpp:778
static bool hostHasMountPoint(std::string hostname, std::string mount_point)
Determines whether a mount point is defined at a host.
Definition: S4U_Simulation.cpp:821
void shutdown()
Shutdown the simulation.
Definition: S4U_Simulation.cpp:73
bool isPlatformSetup()
Returns true if S4U_Simulation::setupPlatform() has been called successfully previously.
Definition: S4U_Simulation.cpp:53
static void turnOnLink(std::string linkname)
Turn on a link.
Definition: S4U_Simulation.cpp:352
bool isInitialized()
Returns true if S4U_Simulation::initialize() has been called successfully previously.
Definition: S4U_Simulation.cpp:45
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:705
static std::string getHostName()
Get the hostname on which the calling actor is running.
Definition: S4U_Simulation.cpp:117
static unsigned int getHostNumCores(std::string hostname)
Get the number of cores of a host.
Definition: S4U_Simulation.cpp:236
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:792
static void yield()
Simulates a yield.
Definition: S4U_Simulation.cpp:508
static void writeToDisk(double num_bytes, std::string hostname, std::string mount_point)
Simulates a disk write.
Definition: S4U_Simulation.cpp:395
static void sleep(double)
Simulates a sleep.
Definition: S4U_Simulation.cpp:501
static std::vector< std::string > getAllHostnames()
Get the list of hostnames.
Definition: S4U_Simulation.cpp:127
static void readFromDisk(double num_bytes, std::string hostname, std::string mount_point)
Simulates a disk read.
Definition: S4U_Simulation.cpp:471
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:569
static void turnOnHost(std::string hostname)
Turn on a host.
Definition: S4U_Simulation.cpp:306
static bool isLinkOn(std::string linkname)
Returns whether a link is on or not.
Definition: S4U_Simulation.cpp:322
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:727
static double getLinkUsage(std::string name)
Get a link's bandwidth usage.
Definition: S4U_Simulation.cpp:174
void checkLinkBandwidths()
Method to check that all link bandwidths are >0.
Definition: S4U_Simulation.cpp:82
static double getClock()
Get the current simulation date.
Definition: S4U_Simulation.cpp:376
static bool isHostOn(std::string hostname)
Returns whether a host is on or not.
Definition: S4U_Simulation.cpp:276
Wrappers around S4U's basic simulation methods.
Definition: S4U_Simulation.h:28
void runSimulation()
Start the simulation.
Definition: S4U_Simulation.cpp:62
static constexpr double DEFAULT_RAM
The ram capacity of a physical host whenever not specified in the platform description file.
Definition: S4U_Simulation.h:32
static double getHostMemoryCapacity(std::string hostname)
Get the memory capacity of a host given a hostname.
Definition: S4U_Simulation.cpp:517
static bool hostExists(std::string hostname)
Determines whether a host exists for a given hostname.
Definition: S4U_Simulation.cpp:215