Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sed -i -e 's/\t/ /g' [sources] Please people, stop using tabs
[simgrid.git] / examples / msg / energy / pstate / pstate.c
index f7e7cad..cd37f4d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2010, 2013-2014. The SimGrid Team.
+/* Copyright (c) 2007-2010, 2013-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
 /** @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 accessed/changed
- *             with @ref MSG_get_host_current_power_peak and @ref
- *             MSG_set_host_power_peak_at.
- *             Make sure to read the platform XML file for details on how
- *             to declare the CPU capacity for each pstate.
+ *     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.
  *
  */
 
@@ -38,8 +38,8 @@ int dvfs(int argc, char *argv[])
   int new_peak_index=2;
   host = MSG_host_self();; //MSG_get_host_by_name("MyHost1");
 
-  int nb = MSG_host_get_pstate_number(host);
-  XBT_INFO("Number of Processor states=%d", nb);
+  int nb = MSG_host_get_nb_pstates(host);
+  XBT_INFO("Count of Processor states=%d", nb);
 
   double current_peak = MSG_host_get_current_power_peak(host);
   XBT_INFO("Current power peak=%f", current_peak);
@@ -54,10 +54,10 @@ int dvfs(int argc, char *argv[])
 
   // 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;
-         }
+    {
+    XBT_INFO("Cannot set pstate %d, host supports only %d pstates", new_peak_index, nb);
+    return 0;
+    }
 
   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);
@@ -77,9 +77,9 @@ int dvfs(int argc, char *argv[])
 
 
   // Verify the default pstate is set to 0
-  host = MSG_get_host_by_name("MyHost2");
-  int nb2 = MSG_host_get_pstate_number(host);
-  XBT_INFO("Number of Processor states=%d", nb2);
+  host = MSG_host_by_name("MyHost2");
+  int nb2 = MSG_host_get_nb_pstates(host);
+  XBT_INFO("Count of Processor states=%d", nb2);
 
   double current_peak2 = MSG_host_get_current_power_peak(host);
   XBT_INFO("Current power peak=%f", current_peak2);
@@ -92,15 +92,10 @@ int main(int argc, char *argv[])
 
   MSG_init(&argc, argv);
 
-  if (argc != 3) {
-    XBT_CRITICAL("Usage: %s platform_file deployment_file\n",
-              argv[0]);
-    XBT_CRITICAL
-        ("example: %s msg_platform.xml msg_deployment.xml\n",
-         argv[0]);
-    exit(1);
-  }
-
+  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
+            "\tExample: %s msg_platform.xml msg_deployment.xml\n", 
+            argv[0], argv[0]);
+  
   MSG_create_environment(argv[1]);
 
   /*   Application deployment */
@@ -112,9 +107,6 @@ int main(int argc, char *argv[])
 
   XBT_INFO("Total simulation time: %e", MSG_get_clock());
 
-  if (res == MSG_OK)
-    return 0;
-  else
-    return 1;
+  return res != MSG_OK;
 }