Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
no need to test if hard coded value is in a range
[simgrid.git] / examples / msg / energy-pstate / energy-pstate.c
index ff9e2e7..9906c1f 100644 (file)
@@ -8,7 +8,8 @@
 
 /** @addtogroup MSG_examples
  *
 
 /** @addtogroup MSG_examples
  *
- * - <b>energy/e1/e1.c</b> Shows how a set of pstates can be defined for a host and how the current pstate can be
+ * - <b>energy-pstate/energy-pstate.c</b> Shows how a set of pstates can be defined for a host and how the current
+ * pstate can be
  *     accessed/changed with @ref MSG_get_host_current_power_peak and @ref  MSG_set_host_pstate.
  *     Make sure to read the platform XML file for details on how to declare the CPU capacity for each pstate.
  */
  *     accessed/changed with @ref MSG_get_host_current_power_peak and @ref  MSG_set_host_pstate.
  *     Make sure to read the platform XML file for details on how to declare the CPU capacity for each pstate.
  */
@@ -18,8 +19,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Pstate properties test");
 static int dvfs(int argc, char *argv[])
 {
   double workload = 100E6;
 static int dvfs(int argc, char *argv[])
 {
   double workload = 100E6;
-  int new_peak_index=2;
-  msg_host_t host = MSG_host_self();; //MSG_get_host_by_name("MyHost1");
+  msg_host_t host = MSG_host_self();
 
   int nb = MSG_host_get_nb_pstates(host);
   XBT_INFO("Count of Processor states=%d", nb);
 
   int nb = MSG_host_get_nb_pstates(host);
   XBT_INFO("Count of Processor states=%d", nb);
@@ -36,15 +36,12 @@ static int dvfs(int argc, char *argv[])
   XBT_INFO("Task1 simulation time: %e", task_time);
 
   // Change power peak
   XBT_INFO("Task1 simulation time: %e", task_time);
 
   // Change power peak
-  if ((new_peak_index >= nb) || (new_peak_index < 0)){
-    XBT_INFO("Cannot set pstate %d, host supports only %d pstates", new_peak_index, nb);
-    return 0;
-  }
+  int new_pstate = 2;
 
 
-  double peak_at = MSG_host_get_power_peak_at(host, new_peak_index);
-  XBT_INFO("Changing power peak value to %f (at index %d)", peak_at, new_peak_index);
+  double peak_at = MSG_host_get_power_peak_at(host, new_pstate);
+  XBT_INFO("Changing power peak value to %f (at index %d)", peak_at, new_pstate);
 
 
-  MSG_host_set_pstate(host, new_peak_index);
+  MSG_host_set_pstate(host, new_pstate);
 
   current_peak = MSG_host_get_current_power_peak(host);
   XBT_INFO("Current power peak=%f", current_peak);
 
   current_peak = MSG_host_get_current_power_peak(host);
   XBT_INFO("Current power peak=%f", current_peak);
@@ -69,8 +66,6 @@ static int dvfs(int argc, char *argv[])
 
 int main(int argc, char *argv[])
 {
 
 int main(int argc, char *argv[])
 {
-  msg_error_t res = MSG_OK;
-
   MSG_init(&argc, argv);
 
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
   MSG_init(&argc, argv);
 
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
@@ -80,7 +75,7 @@ int main(int argc, char *argv[])
   MSG_process_create("dvfs_test", dvfs, NULL, MSG_get_host_by_name("MyHost1"));
   MSG_process_create("dvfs_test", dvfs, NULL, MSG_get_host_by_name("MyHost2"));
 
   MSG_process_create("dvfs_test", dvfs, NULL, MSG_get_host_by_name("MyHost1"));
   MSG_process_create("dvfs_test", dvfs, NULL, MSG_get_host_by_name("MyHost2"));
 
-  res = MSG_main();
+  msg_error_t res = MSG_main();
 
   XBT_INFO("Total simulation time: %e", MSG_get_clock());
 
 
   XBT_INFO("Total simulation time: %e", MSG_get_clock());