Skip to content
Permalink
Browse files

API changes

Documentation++
Typos--
  • Loading branch information...
henricasanova committed Feb 7, 2019
1 parent 3c69374 commit 162f282a2ef04fb95275f50e074a3c582a0bf933
@@ -48,8 +48,8 @@ namespace wrench {
static void setPstate(const std::string &hostname, int pstate);
static int getNumberofPstates(const std::string &hostname);
static int getCurrentPstate(const std::string &hostname);
static double getMinPowerAvailable(const std::string &hostname);
static double getMaxPowerPossible(const std::string &hostname);
static double getMinPowerConsumption(const std::string &hostname);
static double getMaxPowerConsumption(const std::string &hostname);
static std::vector<int> getListOfPstates(const std::string &hostname);
//end energy related calls

@@ -76,8 +76,8 @@ namespace wrench {
void setPstate(const std::string &hostname, int pstate);
static int getNumberofPstates(const std::string &hostname);
static int getCurrentPstate(const std::string &hostname);
static double getMinPowerAvailable(const std::string &hostname);
static double getMaxPowerPossible(const std::string &hostname);
static double getMinPowerConsumption(const std::string &hostname);
static double getMaxPowerConsumption(const std::string &hostname);
static std::vector<int> getListOfPstates(const std::string &hostname);


@@ -362,12 +362,12 @@ namespace wrench {
}

/**
* @brief Get the minimum power available for a host
* @brief Get the minimum power consumption (i.e., idling) for a host at its current pstate
* @param hostname: the host name
* @return The minimum power available for the host (as specified in the platform xml description file)
* @return The power consumption for this host if idle (as specified in the platform xml description file)
* @throw std::runtime_error
*/
double S4U_Simulation::getMinPowerAvailable(const std::string &hostname) {
double S4U_Simulation::getMinPowerConsumption(const std::string &hostname) {
try {
return sg_host_get_wattmin_at(simgrid::s4u::Host::by_name(hostname),
(simgrid::s4u::Host::by_name(hostname))->get_pstate());
@@ -380,12 +380,12 @@ namespace wrench {
}

/**
* @brief Get the maximum power available for a host
* @brief Get the maximum power consumption (i.e., 100% load) for a host at its current pstate
* @param hostname: the host name
* @return The maximum power available for the host (as specified in the platform xml description file)
* @return The power consumption for this host if 100% used (as specified in the platform xml description file)
* @throw std::runtime_error
*/
double S4U_Simulation::getMaxPowerPossible(const std::string &hostname) {
double S4U_Simulation::getMaxPowerConsumption(const std::string &hostname) {
try {
return sg_host_get_wattmax_at(simgrid::s4u::Host::by_name(hostname),
(simgrid::s4u::Host::by_name(hostname))->get_pstate());
@@ -674,24 +674,6 @@ namespace wrench {
return this->output;
}

// /**
// * @brief Get the energy consumed by the host up to now
// * @param hostname the host name
// * @return the energy consumed by the host in Joules
// */
// double Simulation::getEnergyConsumedByHost(const std::string &hostname) {
// return S4U_Simulation::getEnergyConsumedByHost(hostname);
// }
//
// /**
// * @brief Get the total energy consumed by a set of hosts
// * @param the list of hostnames
// * @return The total energy consumed by all the hosts in Joules
// */
// double Simulation::getTotalEnergyConsumed(const std::vector<std::string> &hostnames) {
// return S4U_Simulation::getTotalEnergyConsumed(hostnames);
// }

/**
* @brief Obtains the current energy consumption of a host and will add SimulationTimestampEnergyConsumption to
* simulation output if can_record is set to true
@@ -719,7 +701,7 @@ namespace wrench {
* @brief Obtains the current energy consumption of a host and will add SimulationTimestampEnergyConsumption to
* simulation output if can_record is set to true
* @param hostnames: the list of hostnames
* @param record_as_time_stamps: bool signaling whether or not to record a SimulationTimestampEnergyConsumption object for each host
* @param record_as_time_stamps: whether or not to record a SimulationTimestampEnergyConsumption object for each host when this method is called
* @return current energy consumption in joules for each host, as a map indexed by hostnames
* @throws std::invalid_argument
*/
@@ -738,7 +720,7 @@ namespace wrench {
/**
* @brief Set the power state of the host
* @param hostname: the host name
* @param pstate: the power state index (the power state index is specified in the platform xml description file)
* @param pstate: the power state index (as specified in the platform xml description file)
*/
void Simulation::setPstate(const std::string &hostname, int pstate) {
S4U_Simulation::setPstate(hostname, pstate);
@@ -763,35 +745,35 @@ namespace wrench {
return S4U_Simulation::getCurrentPstate(hostname);
}



/**
* @brief Get the minimum power available for a host
* @brief Get the list of power states available for a host
* @param hostname: the host name
* @return The minimum power available for the host (as specified in the platform xml description file)
* @return a list of power states available for the host (as specified in the platform xml description file)
*/
double Simulation::getMinPowerAvailable(const std::string &hostname) {
return S4U_Simulation::getMinPowerAvailable(hostname);
std::vector<int> Simulation::getListOfPstates(const std::string &hostname) {
return S4U_Simulation::getListOfPstates(hostname);
}


/**
* @brief Get the maximum power available for a host
* @brief Get the minimum power consumption for the host (i.e., idling) at its current pstate
* @param hostname: the host name
* @return The maximum power available for the host (as specified in the platform xml description file)
* @return The "idling" power consumption (as specified in the platform xml description file)
*/
double Simulation::getMaxPowerPossible(const std::string &hostname) {
return S4U_Simulation::getMaxPowerPossible(hostname);
double Simulation::getMinPowerConsumption(const std::string &hostname) {
return S4U_Simulation::getMinPowerConsumption(hostname);
}

/**
* @brief Get the list of power states available for a host
* @brief Get the maximum power consumption for the host (i.e., 100% utilization) at its current pstate
* @param hostname: the host name
* @return a list of power states available for the host (as specified in the platform xml description file)
* @return The "100% used" power consumption (as specified in the platform xml description file)
*/
std::vector<int> Simulation::getListOfPstates(const std::string &hostname) {
return S4U_Simulation::getListOfPstates(hostname);
double Simulation::getMaxPowerConsumption(const std::string &hostname) {
return S4U_Simulation::getMaxPowerConsumption(hostname);
}


/**
* @brief Starts a new compute service during WMS execution (i.e., one that was not passed to Simulation::add() before
* Simulation::launch() was called). The simulation takes ownership of
@@ -508,7 +508,7 @@ namespace wrench {
* consumed_energy_trace: [
* {
* time: <double>,
* watts: <double>
* joules: <double>
* }, ...
* ]
* }, ...
@@ -586,7 +586,7 @@ namespace wrench {
if (host->get_name() == energy_consumption_timestamp->getContent()->getHostname()) {
datum["consumed_energy_trace"].push_back({
{"time", energy_consumption_timestamp->getDate()},
{"watts", energy_consumption_timestamp->getContent()->getConsumption()}
{"joules", energy_consumption_timestamp->getContent()->getConsumption()}
});
}
}
@@ -199,7 +199,7 @@ class EnergyApiAccessExceptionsTestWMS : public wrench::WMS {
}

try {
double value = this->simulation->getMinPowerAvailable("dummy_unavailable_host");
double value = this->simulation->getMinPowerConsumption("dummy_unavailable_host");
throw std::runtime_error(
"Should not have been able to read the energy for dummy hosts"
);
@@ -208,7 +208,7 @@ class EnergyApiAccessExceptionsTestWMS : public wrench::WMS {
}

try {
double value = this->simulation->getMaxPowerPossible("dummy_unavailable_host");
double value = this->simulation->getMaxPowerConsumption("dummy_unavailable_host");
throw std::runtime_error(
"Should not have been able to read the energy for dummy hosts"
);
@@ -488,8 +488,8 @@ class EnergyAPICheckTestWMS : public wrench::WMS {
std::vector<std::string> simulation_hosts = test->simulation->getHostnameList();

int cur_pstate = this->simulation->getCurrentPstate(simulation_hosts[1]);
double cur_max_possible = this->simulation->getMaxPowerPossible(simulation_hosts[1]);
double cur_min_possible = this->simulation->getMinPowerAvailable(simulation_hosts[1]);
double cur_max_possible = this->simulation->getMaxPowerConsumption(simulation_hosts[1]);
double cur_min_possible = this->simulation->getMinPowerConsumption(simulation_hosts[1]);
//switch pstates right off the bat
std::vector<int> list_of_pstates = this->simulation->getListOfPstates(simulation_hosts[1]);
int max_num_pstate = list_of_pstates.size();
@@ -511,21 +511,21 @@ class EnergyAPICheckTestWMS : public wrench::WMS {
for (auto state:states) {
//check if max power is different in all the states as is in xml
this->simulation->setPstate(host,state);
if (prev_max_power == this->simulation->getMaxPowerPossible(host)) {
if (prev_max_power == this->simulation->getMaxPowerConsumption(host)) {
throw std::runtime_error(
"The max power from the xml and the APIs do not match"
);
}
prev_max_power = this->simulation->getMaxPowerPossible(host);
prev_max_power = this->simulation->getMaxPowerConsumption(host);

//check if the min power is different in all the states as is in xml
this->simulation->setPstate(host,state);
if (prev_min_power == this->simulation->getMinPowerAvailable(host)) {
if (prev_min_power == this->simulation->getMinPowerConsumption(host)) {
throw std::runtime_error(
"The min power from the xml and the APIs do not match"
);
}
prev_min_power = this->simulation->getMinPowerAvailable(host);
prev_min_power = this->simulation->getMinPowerConsumption(host);
}
}
//lets check if the energy consumed by host1 is less than the energy consumed by host1 + host2
@@ -751,7 +751,7 @@ class EnergyConsumptionPStateChangeTestWMS : public wrench::WMS {

double after_current_energy_consumed_by_host2 = this->simulation->getEnergyConsumed(simulation_hosts[1]);
double energy_consumed_while_running_with_lower_speed = after_current_energy_consumed_by_host2 - before_current_energy_consumed_by_host2;
double lower_speed_compuation_time = wrench::S4U_Simulation::getClock() - higher_speed_compuation_time;
double lower_speed_computation_time = wrench::S4U_Simulation::getClock() - higher_speed_compuation_time;

if (energy_consumed_while_running_with_lower_speed <= 0) {
throw std::runtime_error("Unexpectedly the energy consumed is less than 0 for a lower speed ??");
@@ -762,13 +762,13 @@ class EnergyConsumptionPStateChangeTestWMS : public wrench::WMS {
//in pstate 0, the min_power, according to xml is 100.0 and the max power is 200.0
//in pstate 2, the min_power, according to xml is 90.0 and the max power is 150.0
//so, energy_consumed/time_taken might give us an approximate wattage power which should be in between these ranges
//infact, we are using these hosts to the full power, so the power wattage should be near to max values
//in fact, we are using these hosts to the full power, so the power wattage should be near the max values

double exact_max_wattage_power_1 = this->simulation->getMaxPowerPossible(simulation_hosts[1]);
double exact_max_wattage_power_2 = this->simulation->getMaxPowerPossible(simulation_hosts[1]);
double exact_max_wattage_power_1 = this->simulation->getMaxPowerConsumption(simulation_hosts[1]);
double exact_max_wattage_power_2 = this->simulation->getMaxPowerConsumption(simulation_hosts[1]);
double EPSILON = 1.0;
double computed_wattage_power_1 = energy_consumed_while_running_with_higher_speed/higher_speed_compuation_time;
double computed_wattage_power_2 = energy_consumed_while_running_with_lower_speed/lower_speed_compuation_time;
double computed_wattage_power_2 = energy_consumed_while_running_with_lower_speed/lower_speed_computation_time;

if (abs(exact_max_wattage_power_1-computed_wattage_power_1) > EPSILON && abs(exact_max_wattage_power_2-computed_wattage_power_2) > EPSILON) {
throw std::runtime_error(
@@ -1171,19 +1171,19 @@ void SimulationDumpJSONTest::do_SimulationDumpHostEnergyConsumptionJSON_test() {
"consumed_energy_trace": [
{
"time": 0.0,
"watts": 0.0
"joules": 0.0
},
{
"time": 2.0,
"watts": 400.0
"joules": 400.0
},
{
"time": 4.0,
"watts": 800.0
"joules": 800.0
},
{
"time": 6.0,
"watts": 1200.0
"joules": 1200.0
}
],
"hostname": "host1",
@@ -1223,19 +1223,19 @@ void SimulationDumpJSONTest::do_SimulationDumpHostEnergyConsumptionJSON_test() {
"consumed_energy_trace": [
{
"time": 0.0,
"watts": 0.0
"joules": 0.0
},
{
"time": 2.0,
"watts": 200.0
"joules": 200.0
},
{
"time": 4.0,
"watts": 400.0
"joules": 400.0
},
{
"time": 6.0,
"watts": 600.0
"joules": 600.0
}
],
"hostname": "host2",

0 comments on commit 162f282

Please sign in to comment.
You can’t perform that action at this time.