From 9caefc9fd82f338d9f8b9eede38a171aaff5f4bc Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 25 Feb 2020 11:51:05 +0100 Subject: [PATCH] add sg_actor_parallel_exec_init() --- include/simgrid/actor.h | 2 ++ src/s4u/s4u_Actor.cpp | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/simgrid/actor.h b/include/simgrid/actor.h index b006a2495e..220b449f23 100644 --- a/include/simgrid/actor.h +++ b/include/simgrid/actor.h @@ -73,6 +73,8 @@ XBT_PUBLIC void* sg_actor_data(const_sg_actor_t actor); XBT_PUBLIC void sg_actor_data_set(sg_actor_t actor, void* userdata); XBT_PUBLIC sg_exec_t sg_actor_exec_init(double computation_amount); +XBT_PUBLIC sg_exec_t sg_actor_parallel_exec_init(int host_nb, const sg_host_t* host_list, double* flops_amount, + double* bytes_amount); XBT_PUBLIC sg_exec_t sg_actor_exec_async(double computation_amount); SG_END_DECL diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index b539dbd284..aaa86862fa 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -799,6 +799,23 @@ sg_exec_t sg_actor_exec_init(double computation_amount) return exec.get(); } +sg_exec_t sg_actor_parallel_exec_init(int host_nb, const sg_host_t* host_list, double* flops_amount, + double* bytes_amount) +{ + std::vector hosts(host_list, host_list + host_nb); + std::vector flops; + std::vector bytes; + if (flops_amount != nullptr) + flops = std::vector(flops_amount, flops_amount + host_nb); + if (bytes_amount != nullptr) + bytes = std::vector(bytes_amount, bytes_amount + host_nb * host_nb); + + simgrid::s4u::ExecPtr exec = simgrid::s4u::ExecPtr(new simgrid::s4u::Exec()); + exec->set_flops_amounts(flops)->set_bytes_amounts(bytes)->set_hosts(hosts); + exec->add_ref(); + return exec.get(); +} + sg_exec_t sg_actor_exec_async(double computation_amount) { simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_async(computation_amount); -- 2.20.1