Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update ptask example to also test energy on parallel tasks.
authorDavid Glesser <david.glesser@imag.fr>
Wed, 16 Mar 2016 18:09:51 +0000 (19:09 +0100)
committerDavid Glesser <david.glesser@imag.fr>
Wed, 16 Mar 2016 18:09:51 +0000 (19:09 +0100)
examples/msg/parallel_task/CMakeLists.txt
examples/msg/parallel_task/parallel_task.c
examples/msg/parallel_task/parallel_task_energy.tesh [new file with mode: 0644]

index 257ddc3..a8a8bb7 100644 (file)
@@ -3,5 +3,8 @@ target_link_libraries(parallel_task simgrid)
 
 ADD_TESH_FACTORIES(msg-ptask "thread;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/parallel_task/parallel_task.tesh)
 
+ADD_TESH_FACTORIES(msg-ptask-energy "thread;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/parallel_task/parallel_task_energy.tesh)
+
+set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/parallel_task.tesh  PARENT_SCOPE)
 set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/parallel_task.tesh  PARENT_SCOPE)
 set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/parallel_task.c     PARENT_SCOPE)
index 3308119..46990fa 100644 (file)
@@ -5,6 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
+#include "simgrid/plugins/energy.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
@@ -70,7 +71,12 @@ int main(int argc, char *argv[])
   MSG_init(&argc, argv);
   MSG_config("host/model", "ptask_L07");
 
-  xbt_assert(argc > 1, "Usage: %s <platform file>", argv[0]);
+  xbt_assert(argc <= 3, "1Usage: %s <platform file> [--energy]", argv[0]);
+  xbt_assert(argc >= 2, "2Usage: %s <platform file> [--energy]", argv[0]);
+
+  if(argc == 3 && argv[2][2] == 'e')
+    sg_energy_plugin_init();
+
   MSG_create_environment(argv[1]);
 
   /* Pick a process, no matter which, from the platform file */
diff --git a/examples/msg/parallel_task/parallel_task_energy.tesh b/examples/msg/parallel_task/parallel_task_energy.tesh
new file mode 100644 (file)
index 0000000..d0d2d91
--- /dev/null
@@ -0,0 +1,12 @@
+#! ./tesh
+
+$ $SG_TEST_EXENV parallel_task/parallel_task$EXEEXT ${srcdir:=.}/../platforms/energy_platform.xml --energy "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (0:maestro@) Switching to the L07 model to handle parallel tasks.
+> [  0.000000] (1:test@MyHost1) First, build a classical parallel task, with 1 Gflop to execute on each node, and 10MB to exchange between each pair
+> [300.000000] (1:test@MyHost1) Then, build a parallel task involving only computations and no communication (1 Gflop per node)
+> [310.000000] (1:test@MyHost1) Finally, trick the ptask to do a 'remote execution', on host MyHost2
+> [320.000000] (1:test@MyHost1) Goodbye now!
+> [320.000000] (0:maestro@) Simulation done.
+> [320.000000] (0:maestro@) Total energy of host MyHost1: 34000.000000 Joules
+> [320.000000] (0:maestro@) Total energy of host MyHost2: 35000.000000 Joules
+> [320.000000] (0:maestro@) Total energy of host MyHost3: 34000.000000 Joules