Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
added tesh tests for dvfs
authoracarpena <alexandra.carpen-amarie@inria.fr>
Thu, 4 Jul 2013 20:19:31 +0000 (13:19 -0700)
committeracarpena <alexandra.carpen-amarie@inria.fr>
Thu, 4 Jul 2013 20:19:31 +0000 (13:19 -0700)
buildtools/Cmake/AddTests.cmake
examples/msg/energy/e1/deployment_e1.xml
examples/msg/energy/e1/e1.c
examples/msg/energy/e1/platform_e1.xml
examples/msg/energy/e1/pstate.tesh [new file with mode: 0644]

index a176701..4137ef7 100644 (file)
@@ -135,6 +135,8 @@ if(NOT enable_memcheck)
   ADD_TEST(msg-masterslave-cpu-ti-thread        ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:thread --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/masterslave --cd ${CMAKE_HOME_DIRECTORY}/examples/msg masterslave/masterslave_cpu_ti_crosstraffic.tesh)
 
   ADD_TEST(msg-masterslave-virtual-machines     ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:thread --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg --cd ${CMAKE_HOME_DIRECTORY}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/masterslave_virtual_machines.tesh)
   ADD_TEST(msg-masterslave-cpu-ti-thread        ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:thread --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/masterslave --cd ${CMAKE_HOME_DIRECTORY}/examples/msg masterslave/masterslave_cpu_ti_crosstraffic.tesh)
 
   ADD_TEST(msg-masterslave-virtual-machines     ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:thread --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg --cd ${CMAKE_HOME_DIRECTORY}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/masterslave_virtual_machines.tesh)
+  
+  ADD_TEST(msg-energy-pstates ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:thread --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_HOME_DIRECTORY}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy/e1/pstate.tesh )
 
   if(CONTEXT_UCONTEXT)
     ADD_TEST(msg-sendrecv-CLM03-ucontext        ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/sendrecv/sendrecv_CLM03.tesh)
 
   if(CONTEXT_UCONTEXT)
     ADD_TEST(msg-sendrecv-CLM03-ucontext        ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/sendrecv/sendrecv_CLM03.tesh)
index b9c8941..8997fbc 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0'?>
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
 <platform version="3">
 <?xml version='1.0'?>
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
 <platform version="3">
-
   <process host="MyHost1" function="dvfs_test" />
   <process host="MyHost1" function="dvfs_test" />
+  <process host="MyHost2" function="dvfs_test" />
 
 </platform>
 
 </platform>
index b22013d..ae2425d 100644 (file)
@@ -3,9 +3,6 @@
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include<stdio.h>
-
 #include "msg/msg.h"
 #include "xbt/sysdep.h"         /* calloc */
 
 #include "msg/msg.h"
 #include "xbt/sysdep.h"         /* calloc */
 
 #include "xbt/log.h"
 #include "xbt/asserts.h"
 
 #include "xbt/log.h"
 #include "xbt/asserts.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-                             "Messages specific for this msg example");
+
+/** @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.
+ *
+ */
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(test,
+                             "Pstate properties test");
 
 int dvfs(int argc, char *argv[]);
 
 
 int dvfs(int argc, char *argv[]);
 
@@ -24,9 +33,9 @@ int dvfs(int argc, char *argv[])
   msg_host_t host = NULL;
   msg_task_t task1 = NULL;
   double task_time = 0;
   msg_host_t host = NULL;
   msg_task_t task1 = NULL;
   double task_time = 0;
-  host = MSG_get_host_by_name("MyHost1");
-
-  XBT_INFO("dvfs start");
+  double workload = 100E6;
+  int new_peak_index=2;
+  host = MSG_host_self();; //MSG_get_host_by_name("MyHost1");
 
   int nb = MSG_get_host_nb_pstates(host);
   XBT_INFO("Number of Processor states=%d", nb);
 
   int nb = MSG_get_host_nb_pstates(host);
   XBT_INFO("Number of Processor states=%d", nb);
@@ -35,31 +44,44 @@ int dvfs(int argc, char *argv[])
   XBT_INFO("Current power peak=%lf", current_peak);
 
   // Run a task
   XBT_INFO("Current power peak=%lf", current_peak);
 
   // Run a task
-  task1 = MSG_task_create ("t1", 100E6, 0, NULL);
+  task1 = MSG_task_create ("t1", workload, 0, NULL);
   MSG_task_execute (task1);
   MSG_task_destroy(task1);
 
   task_time = MSG_get_clock();
   XBT_INFO("Task1 simulation time: %le", task_time);
 
   MSG_task_execute (task1);
   MSG_task_destroy(task1);
 
   task_time = MSG_get_clock();
   XBT_INFO("Task1 simulation time: %le", task_time);
 
-  // ========= Change power peak =========
-  int peak_index=2;
-  double peak_at = MSG_get_host_power_peak_at(host, peak_index);
-  XBT_INFO("=========Changing power peak value to %lf (at index %d)", peak_at, peak_index);
+  // 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;
+         }
+
+  double peak_at = MSG_get_host_power_peak_at(host, new_peak_index);
+  XBT_INFO("Changing power peak value to %lf (at index %d)", peak_at, new_peak_index);
 
 
-  MSG_set_host_power_peak_at(host, peak_index);
+  MSG_set_host_power_peak_at(host, new_peak_index);
 
   current_peak = MSG_get_host_current_power_peak(host);
   XBT_INFO("Current power peak=%lf", current_peak);
 
   // Run a second task
 
   current_peak = MSG_get_host_current_power_peak(host);
   XBT_INFO("Current power peak=%lf", current_peak);
 
   // Run a second task
-  task1 = MSG_task_create ("t1", 100E6, 0, NULL);
+  task1 = MSG_task_create ("t1", workload, 0, NULL);
   MSG_task_execute (task1);
   MSG_task_destroy(task1);
 
   task_time = MSG_get_clock() - task_time;
   XBT_INFO("Task2 simulation time: %le", task_time);
 
   MSG_task_execute (task1);
   MSG_task_destroy(task1);
 
   task_time = MSG_get_clock() - task_time;
   XBT_INFO("Task2 simulation time: %le", task_time);
 
+
+  // Verify the default pstate is set to 0
+  host = MSG_get_host_by_name("MyHost2");
+  int nb2 = MSG_get_host_nb_pstates(host);
+  XBT_INFO("Number of Processor states=%d", nb2);
+
+  double current_peak2 = MSG_get_host_current_power_peak(host);
+  XBT_INFO("Current power peak=%lf", current_peak2);
   return 0;
 }
 
   return 0;
 }
 
index 3d04bd2..7edb768 100644 (file)
@@ -2,9 +2,10 @@
  <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
  <platform version="3">
  <AS  id="AS0"  routing="Full">
  <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
  <platform version="3">
  <AS  id="AS0"  routing="Full">
-   <host id="MyHost1" power="100.0Mf,50.0Mf,20.0Mf, 10Gf" pstate="3">
-     <!--  in Watts -->
-        <prop id="power_per_state" value="200:250,200:220,100.0:150.0,120:250" />
-   </host>
+   <!-- Multiple pstate processor capacities can be defined as a list of powers specified for a given host -->
+   <!-- The enabled pstate can be set through the "pstate" attribute (lowest pstate corresponds to the highest processor power) -->
+   <host id="MyHost1" power="100.0Mf,50.0Mf,20.0Mf" pstate="0" />
+   <host id="MyHost2" power="100.0Mf" />
+  
  </AS>
  </platform>
  </AS>
  </platform>
diff --git a/examples/msg/energy/e1/pstate.tesh b/examples/msg/energy/e1/pstate.tesh
new file mode 100644 (file)
index 0000000..cc2d47d
--- /dev/null
@@ -0,0 +1,19 @@
+#! ./tesh
+
+p Testing the DVFS-related functions
+
+! output sort
+$ $SG_TEST_EXENV energy/e1/e1$EXEEXT ${srcdir:=.}/energy/e1/platform_e1.xml ${srcdir:=.}/energy/e1/deployment_e1.xml --log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n
+> [  0.000000] (1:dvfs_test@MyHost1) Number of Processor states=3
+> [  0.000000] (2:dvfs_test@MyHost2) Number of Processor states=1
+> [  0.000000] (1:dvfs_test@MyHost1) Current power peak=100000000.000000
+> [  0.000000] (2:dvfs_test@MyHost2) Current power peak=100000000.000000
+> [  1.000000] (1:dvfs_test@MyHost1) Task1 simulation time: 1.000000e+00
+> [  1.000000] (2:dvfs_test@MyHost2) Task1 simulation time: 1.000000e+00
+> [  1.000000] (2:dvfs_test@MyHost2) Cannot set pstate 2, host supports only 1 pstates
+> [  1.000000] (1:dvfs_test@MyHost1) Changing power peak value to 20000000.000000 (at index 2)
+> [  1.000000] (1:dvfs_test@MyHost1) Current power peak=20000000.000000
+> [  6.000000] (1:dvfs_test@MyHost1) Task2 simulation time: 5.000000e+00
+> [  6.000000] (1:dvfs_test@MyHost1) Number of Processor states=1
+> [  6.000000] (1:dvfs_test@MyHost1) Current power peak=100000000.000000
+> [  6.000000] (0:@) Total simulation time: 6.000000e+00
\ No newline at end of file