From: Frederic Suter Date: Thu, 30 Nov 2017 16:05:03 +0000 (+0100) Subject: attempt to have parallel tasks in s4u. X-Git-Tag: v3.18~203 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/054e99cfa11b5002ec33550e59ba97712626f26f attempt to have parallel tasks in s4u. seems to work as a charm --- diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 92fc4852ce..b43073fe4d 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -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). diff --git a/src/msg/msg_io.cpp b/src/msg/msg_io.cpp index 31c6ca082f..2806561aad 100644 --- a/src/msg/msg_io.cpp +++ b/src/msg/msg_io.cpp @@ -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(read_size), 0, 0}; + double* flops_amount = new double[2]{0, 0}; + double* bytes_amount = new double[4]{0, static_cast(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); diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index 86ea2e2fb4..0a77a229a2 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -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();