Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
attempt to have parallel tasks in s4u.
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 30 Nov 2017 16:05:03 +0000 (17:05 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 30 Nov 2017 16:05:03 +0000 (17:05 +0100)
seems to work as a charm

include/simgrid/s4u/Actor.hpp
src/msg/msg_io.cpp
src/s4u/s4u_actor.cpp

index 92fc485..b43073f 100644 (file)
@@ -308,6 +308,8 @@ XBT_PUBLIC(void) execute(double flop);
  *  An execution of priority 2 computes twice as fast as an execution at priority 1. */
 XBT_PUBLIC(void) execute(double flop, double priority);
 
+XBT_PUBLIC(void) parallel_execute(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount);
+
 /** Block the actor until it gets a message from the given mailbox.
  *
  * See \ref Comm for the full communication API (including non blocking communications).
index 31c6ca0..2806561 100644 (file)
@@ -3,6 +3,7 @@
 /* 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 "simgrid/s4u/Actor.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Storage.hpp"
 #include "src/msg/msg_private.hpp"
@@ -146,22 +147,10 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa
   XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, src_host->getCname(),
             storage_dest->getHost()->getCname());
   msg_host_t m_host_list[] = {src_host, dst_host};
-  double flops_amount[]    = {0, 0};
-  double bytes_amount[]    = {0, static_cast<double>(read_size), 0, 0};
+  double* flops_amount     = new double[2]{0, 0};
+  double* bytes_amount     = new double[4]{0, static_cast<double>(read_size), 0, 0};
 
-  msg_task_t task =
-      MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, nullptr);
-  msg_error_t err = MSG_parallel_task_execute(task);
-  MSG_task_destroy(task);
-
-  if (err != MSG_OK) {
-    if (err == MSG_HOST_FAILURE)
-      XBT_WARN("Transfer error, %s remote host just turned off!", storage_dest->getHost()->getCname());
-    if (err == MSG_TASK_CANCELED)
-      XBT_WARN("Transfer error, task has been canceled!");
-
-    return err;
-  }
+  simgrid::s4u::this_actor::parallel_execute(2, m_host_list, flops_amount, bytes_amount);
 
   /* Create file on remote host, write it and close it */
   msg_file_t fd = new simgrid::s4u::File(fullpath, dst_host, nullptr);
index 86ea2e2..0a77a22 100644 (file)
@@ -238,6 +238,12 @@ void execute(double flops,double priority)
   simcall_execution_wait(s);
 }
 
+void parallel_execute(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount)
+{
+  smx_activity_t s = simcall_execution_parallel_start(nullptr, host_nb, host_list, flops_amount, bytes_amount, -1, -1);
+  simcall_execution_wait(s);
+}
+
 void* recv(MailboxPtr chan) // deprecated
 {
   return chan->get();