Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update ptask example to also test energy on parallel tasks.
[simgrid.git] / examples / msg / parallel_task / parallel_task.c
index e291efd..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");
 
@@ -16,7 +17,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example")
  *   interfaces, but it's not possible ATM).
  */
 
-
 static int runner(int argc, char *argv[])
 {
   /* Retrieve the list of all hosts as an array of hosts */
@@ -24,7 +24,8 @@ static int runner(int argc, char *argv[])
   int slaves_count = xbt_dynar_length(slaves_dynar);
   msg_host_t *slaves = xbt_dynar_to_array(slaves_dynar);
 
-  XBT_INFO("First, build a classical parallel task, with 1 Gflop to execute on each node, and 10MB to exchange between each pair");
+  XBT_INFO("First, build a classical parallel task, with 1 Gflop to execute on each node, "
+           "and 10MB to exchange between each pair");
   double *computation_amounts = xbt_new0(double, slaves_count);
   double *communication_amounts = xbt_new0(double, slaves_count * slaves_count);
 
@@ -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 */