WRENCH  1.10
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
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 setupPlatform(const std::function<void()>& creation_function);
38  void runSimulation();
39  static double getClock();
40  static std::string getHostName();
41  static bool hostExists(std::string hostname);
42  static bool linkExists(std::string linkname);
43  static std::vector<std::string> getRoute(std::string &src_host, std::string &dst_host);
44  static unsigned int getHostNumCores(std::string hostname);
45  static unsigned int getNumCores();
46  static double getHostFlopRate(std::string hostname);
47  static bool isHostOn(std::string hostname);
48  static void turnOffHost(std::string hostname);
49  static void turnOnHost(std::string hostname);
50  static bool isLinkOn(std::string linkname);
51  static void turnOffLink(std::string linkname);
52  static void turnOnLink(std::string linkname);
53  static double getFlopRate();
54  static double getHostMemoryCapacity(std::string hostname);
55  static double getMemoryCapacity();
56  static void compute(double);
57  static void sleep(double);
58  static void computeZeroFlop();
59  static void writeToDisk(double num_bytes, std::string hostname, std::string mount_point);
60  static void readFromDisk(double num_bytes, std::string hostname, std::string mount_point);
61  static void readFromDiskAndWriteToDiskConcurrently(double num_bytes_to_read, double num_bytes_to_write,
62  std::string hostname,
63  std::string read_mount_point,
64  std::string write_mount_point);
65 
66  static double getDiskCapacity(std::string hostname, std::string mount_point);
67  static std::vector<std::string> getDisks(std::string hostname);
68  static bool hostHasMountPoint(std::string hostname, std::string mount_point);
69 
70  void checkLinkBandwidths();
71 
72  static void yield();
73  static std::string getHostProperty(std::string hostname, std::string property_name);
74 
75  //start energy related calls
76  static double getEnergyConsumedByHost(const std::string &hostname);
77 // static double getTotalEnergyConsumed(const std::vector<std::string> &hostnames);
78  static void setPstate(const std::string &hostname, int pstate);
79  static int getNumberofPstates(const std::string &hostname);
80  static int getCurrentPstate(const std::string &hostname);
81  static double getMinPowerConsumption(const std::string &hostname);
82  static double getMaxPowerConsumption(const std::string &hostname);
83  static std::vector<int> getListOfPstates(const std::string &hostname);
84  //end energy related calls
85 
86  bool isInitialized();
87  bool isPlatformSetup();
88  static std::vector<std::string> getAllHostnames();
89  static std::vector<std::string> getAllLinknames();
90  static double getLinkBandwidth(std::string name);
91  static double getLinkUsage(std::string name);
92  static std::map<std::string, std::vector<std::string>> getAllHostnamesByCluster();
93  void shutdown();
94 
95  private:
96  static double getHostMemoryCapacity(simgrid::s4u::Host *host);
97  simgrid::s4u::Engine *engine;
98  bool initialized = false;
99  bool platform_setup = false;
100 
101  };
102 
103  /***********************/
105  /***********************/
106 };
107 
108 #endif //WRENCH_S4U_SIMULATION_H
wrench::S4U_Simulation::getLinkBandwidth
static double getLinkBandwidth(std::string name)
Get a link's bandwidth.
Definition: S4U_Simulation.cpp:180
wrench::S4U_Simulation::getDiskCapacity
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:905
wrench::S4U_Simulation::readFromDiskAndWriteToDiskConcurrently
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:449
wrench::S4U_Simulation::getCurrentPstate
static int getCurrentPstate(const std::string &hostname)
Get the current power state of a host.
Definition: S4U_Simulation.cpp:705
wrench::S4U_Simulation::getAllLinknames
static std::vector< std::string > getAllLinknames()
Get the list of link names.
Definition: S4U_Simulation.cpp:164
wrench::S4U_Simulation::turnOffHost
static void turnOffHost(std::string hostname)
Turn off a host.
Definition: S4U_Simulation.cpp:313
wrench::S4U_Simulation::initialize
void initialize(int *argc, char **argv)
Initialize the Simgrid simulation.
Definition: S4U_Simulation.cpp:34
wrench::S4U_Simulation::linkExists
static bool linkExists(std::string linkname)
Determines whether a link exists for a given linkname.
Definition: S4U_Simulation.cpp:246
wrench::S4U_Simulation::getHostFlopRate
static double getHostFlopRate(std::string hostname)
Get the flop rate of a host.
Definition: S4U_Simulation.cpp:282
wrench::S4U_Simulation::getAllHostnamesByCluster
static std::map< std::string, std::vector< std::string > > getAllHostnamesByCluster()
Get the by-cluster structure of the platform.
Definition: S4U_Simulation.cpp:212
wrench::S4U_Simulation::setPstate
static void setPstate(const std::string &hostname, int pstate)
Set the power state of the host.
Definition: S4U_Simulation.cpp:657
wrench::S4U_Simulation::getRoute
static std::vector< std::string > getRoute(std::string &src_host, std::string &dst_host)
Get the list of link names on the route between two hosts.
Definition: S4U_Simulation.cpp:875
wrench::S4U_Simulation::getNumberofPstates
static int getNumberofPstates(const std::string &hostname)
Get the total number of power states of a host.
Definition: S4U_Simulation.cpp:684
wrench::S4U_Simulation::getFlopRate
static double getFlopRate()
Get the flop rate of the current host.
Definition: S4U_Simulation.cpp:389
wrench::S4U_Simulation::turnOffLink
static void turnOffLink(std::string linkname)
Turn off a link.
Definition: S4U_Simulation.cpp:359
wrench::S4U_Simulation::getListOfPstates
static std::vector< int > getListOfPstates(const std::string &hostname)
Get the list of power states available for a host.
Definition: S4U_Simulation.cpp:773
wrench::S4U_Simulation::getEnergyConsumedByHost
static double getEnergyConsumedByHost(const std::string &hostname)
Get the energy consumed by the host up to now.
Definition: S4U_Simulation.cpp:609
wrench::S4U_Simulation::getMemoryCapacity
static double getMemoryCapacity()
Get the memory_manager_service capacity of the current host.
Definition: S4U_Simulation.cpp:551
wrench::S4U_Simulation::getNumCores
static unsigned int getNumCores()
Get the number of cores of the current host.
Definition: S4U_Simulation.cpp:270
wrench::S4U_Simulation::setupPlatform
void setupPlatform(std::string &)
Initialize the simulated platform. Must only be called once.
Definition: S4U_Simulation.cpp:100
wrench
Definition: Alarm.cpp:20
wrench::S4U_Simulation::compute
static void compute(double)
Simulates a computation on host on which the calling actor is running.
Definition: S4U_Simulation.cpp:406
wrench::S4U_Simulation::computeZeroFlop
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:800
wrench::S4U_Simulation::hostHasMountPoint
static bool hostHasMountPoint(std::string hostname, std::string mount_point)
Determines whether a mount point is defined at a host.
Definition: S4U_Simulation.cpp:843
wrench::S4U_Simulation::shutdown
void shutdown()
Shutdown the simulation.
Definition: S4U_Simulation.cpp:74
wrench::S4U_Simulation::isPlatformSetup
bool isPlatformSetup()
Returns true if S4U_Simulation::setupPlatform() has been called successfully previously.
Definition: S4U_Simulation.cpp:54
wrench::S4U_Simulation::turnOnLink
static void turnOnLink(std::string linkname)
Turn on a link.
Definition: S4U_Simulation.cpp:374
wrench::S4U_Simulation::isInitialized
bool isInitialized()
Returns true if S4U_Simulation::initialize() has been called successfully previously.
Definition: S4U_Simulation.cpp:46
wrench::S4U_Simulation::getMinPowerConsumption
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:727
wrench::S4U_Simulation::getHostName
static std::string getHostName()
Get the hostname on which the calling actor is running.
Definition: S4U_Simulation.cpp:136
wrench::S4U_Simulation::getHostNumCores
static unsigned int getHostNumCores(std::string hostname)
Get the number of cores of a host.
Definition: S4U_Simulation.cpp:258
wrench::S4U_Simulation::getDisks
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:814
wrench::S4U_Simulation::yield
static void yield()
Simulates a yield.
Definition: S4U_Simulation.cpp:530
wrench::S4U_Simulation::writeToDisk
static void writeToDisk(double num_bytes, std::string hostname, std::string mount_point)
Simulates a disk write.
Definition: S4U_Simulation.cpp:417
wrench::S4U_Simulation::sleep
static void sleep(double)
Simulates a sleep.
Definition: S4U_Simulation.cpp:523
wrench::S4U_Simulation::getAllHostnames
static std::vector< std::string > getAllHostnames()
Get the list of physical hostnames.
Definition: S4U_Simulation.cpp:146
wrench::S4U_Simulation::readFromDisk
static void readFromDisk(double num_bytes, std::string hostname, std::string mount_point)
Simulates a disk read.
Definition: S4U_Simulation.cpp:493
wrench::S4U_Simulation::getHostProperty
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:591
wrench::S4U_Simulation::turnOnHost
static void turnOnHost(std::string hostname)
Turn on a host.
Definition: S4U_Simulation.cpp:328
wrench::S4U_Simulation::isLinkOn
static bool isLinkOn(std::string linkname)
Returns whether a link is on or not.
Definition: S4U_Simulation.cpp:344
wrench::S4U_Simulation::getMaxPowerConsumption
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:749
wrench::S4U_Simulation::getLinkUsage
static double getLinkUsage(std::string name)
Get a link's bandwidth usage.
Definition: S4U_Simulation.cpp:196
wrench::S4U_Simulation::checkLinkBandwidths
void checkLinkBandwidths()
Method to check that all link bandwidths are >0.
Definition: S4U_Simulation.cpp:83
wrench::S4U_Simulation::getClock
static double getClock()
Get the current simulation date.
Definition: S4U_Simulation.cpp:398
wrench::S4U_Simulation::isHostOn
static bool isHostOn(std::string hostname)
Returns whether a host is on or not.
Definition: S4U_Simulation.cpp:298
wrench::S4U_Simulation
Wrappers around S4U's basic simulation methods.
Definition: S4U_Simulation.h:28
wrench::S4U_Simulation::runSimulation
void runSimulation()
Start the simulation.
Definition: S4U_Simulation.cpp:63
wrench::S4U_Simulation::DEFAULT_RAM
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
wrench::S4U_Simulation::getHostMemoryCapacity
static double getHostMemoryCapacity(std::string hostname)
Get the memory_manager_service capacity of a host given a hostname.
Definition: S4U_Simulation.cpp:539
wrench::S4U_Simulation::hostExists
static bool hostExists(std::string hostname)
Determines whether a host exists for a given hostname.
Definition: S4U_Simulation.cpp:237