From: Martin Quinson Date: Sat, 9 Dec 2017 21:32:59 +0000 (+0100) Subject: allow remote exec: s4u::Exec->setHost() X-Git-Tag: v3.18~64 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/533b09bd161a7a8bef036a14bbcb8793286b9d9f allow remote exec: s4u::Exec->setHost() --- diff --git a/include/simgrid/s4u/Exec.hpp b/include/simgrid/s4u/Exec.hpp index 5db47226eb..8896f0e12e 100644 --- a/include/simgrid/s4u/Exec.hpp +++ b/include/simgrid/s4u/Exec.hpp @@ -31,12 +31,13 @@ public: bool test(); ExecPtr setPriority(double priority); + ExecPtr setHost(Host * host); double getRemains() override; double getRemainingRatio(); private: - smx_actor_t runner_ = nullptr; + Host* host_ = nullptr; double flops_amount_ = 0.0; double priority_ = 1.0; diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 7d9245dd67..ba24e6824d 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -186,9 +186,8 @@ XBT_PUBLIC(void) simcall_call(smx_actor_t process); /******************************* Host simcalls ********************************/ XBT_PUBLIC(void) simcall_host_set_data(sg_host_t host, void *data); -XBT_PUBLIC(smx_activity_t) simcall_execution_start(const char *name, - double flops_amount, - double priority, double bound); +XBT_PUBLIC(smx_activity_t) +simcall_execution_start(const char* name, double flops_amount, double priority, double bound, sg_host_t host); XBT_PUBLIC(smx_activity_t) simcall_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, double rate, double timeout); diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index 8b72d65f69..e5dc66070a 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -74,7 +74,8 @@ msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeo XBT_DEBUG("Parallel execution action created: %p", simdata->compute.get()); } else { simdata->compute = boost::static_pointer_cast( - simcall_execution_start(task->name, simdata->flops_amount, simdata->priority, simdata->bound)); + simcall_execution_start(task->name, simdata->flops_amount, simdata->priority, simdata->bound, + MSG_process_get_host(MSG_process_self()))); } simcall_set_category(simdata->compute, task->category); comp_state = simcall_execution_wait(simdata->compute); diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index cfa7de2e19..a437de0b6b 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -201,7 +201,7 @@ Actor* Actor::restart() ExecPtr Actor::exec_init(double flops_amount) { ExecPtr res = ExecPtr(new Exec()); - res->runner_ = SIMIX_process_self(); + res->host_ = this->getHost(); res->flops_amount_ = flops_amount; res->setRemains(flops_amount); return res; @@ -253,13 +253,13 @@ XBT_PUBLIC(void) sleep_until(double timeout) void execute(double flops) { - smx_activity_t s = simcall_execution_start(nullptr,flops,1.0/*priority*/,0./*bound*/); + smx_activity_t s = simcall_execution_start(nullptr, flops, 1.0 /*priority*/, 0. /*bound*/, getHost()); simcall_execution_wait(s); } void execute(double flops, double priority) { - smx_activity_t s = simcall_execution_start(nullptr,flops,1 / priority/*priority*/,0./*bound*/); + smx_activity_t s = simcall_execution_start(nullptr, flops, 1 / priority /*priority*/, 0. /*bound*/, getHost()); simcall_execution_wait(s); } diff --git a/src/s4u/s4u_exec.cpp b/src/s4u/s4u_exec.cpp index 1fb2e5b6d8..222ca130f7 100644 --- a/src/s4u/s4u_exec.cpp +++ b/src/s4u/s4u_exec.cpp @@ -15,7 +15,7 @@ namespace s4u { void Exec::start() { - pimpl_ = simcall_execution_start(nullptr, flops_amount_, 1 / priority_, 0.); + pimpl_ = simcall_execution_start(nullptr, flops_amount_, 1 / priority_, 0., host_); state_ = started; } @@ -49,6 +49,11 @@ ExecPtr Exec::setPriority(double priority) priority_ = priority; return this; } +ExecPtr Exec::setHost(Host* host) +{ + host_ = host; + return this; +} double Exec::getRemains() { diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index fdcb034d23..87965c9fda 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -221,7 +221,7 @@ smx_activity_t ActorImpl::suspend(ActorImpl* issuer) return nullptr; } else { - return SIMIX_execution_start(this, "suspend", 0.0, 1.0, 0.0); + return SIMIX_execution_start(this, "suspend", 0.0, 1.0, 0.0, this->host); } } diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 9281dca7b6..9662361389 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -55,15 +55,14 @@ void simcall_call(smx_actor_t actor) * \param bound * \return A new SIMIX execution synchronization */ -smx_activity_t simcall_execution_start(const char *name, - double flops_amount, - double priority, double bound) +smx_activity_t simcall_execution_start(const char* name, double flops_amount, double priority, double bound, + simgrid::s4u::Host* host) { /* checking for infinite values */ xbt_assert(std::isfinite(flops_amount), "flops_amount is not finite!"); xbt_assert(std::isfinite(priority), "priority is not finite!"); - return simcall_BODY_execution_start(name, flops_amount, priority, bound); + return simcall_BODY_execution_start(name, flops_amount, priority, bound, host); } /** diff --git a/src/simix/popping_accessors.hpp b/src/simix/popping_accessors.hpp index 020056e3f0..1ec713273b 100644 --- a/src/simix/popping_accessors.hpp +++ b/src/simix/popping_accessors.hpp @@ -164,6 +164,18 @@ static inline void simcall_execution_start__set__bound(smx_simcall_t simcall, do { simgrid::simix::marshal(simcall->args[3], arg); } +static inline sg_host_t simcall_execution_start__get__host(smx_simcall_t simcall) +{ + return simgrid::simix::unmarshal(simcall->args[4]); +} +static inline sg_host_t simcall_execution_start__getraw__host(smx_simcall_t simcall) +{ + return simgrid::simix::unmarshal_raw(simcall->args[4]); +} +static inline void simcall_execution_start__set__host(smx_simcall_t simcall, sg_host_t arg) +{ + simgrid::simix::marshal(simcall->args[4], arg); +} static inline boost::intrusive_ptr simcall_execution_start__get__result(smx_simcall_t simcall) { return simgrid::simix::unmarshal>(simcall->result); @@ -1363,7 +1375,9 @@ XBT_PRIVATE void simcall_HANDLER_process_killall(smx_simcall_t simcall, int rese XBT_PRIVATE void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_actor_t process); XBT_PRIVATE void simcall_HANDLER_process_join(smx_simcall_t simcall, smx_actor_t process, double timeout); XBT_PRIVATE void simcall_HANDLER_process_sleep(smx_simcall_t simcall, double duration); -XBT_PRIVATE boost::intrusive_ptr simcall_HANDLER_execution_start(smx_simcall_t simcall, const char* name, double flops_amount, double priority, double bound); +XBT_PRIVATE boost::intrusive_ptr +simcall_HANDLER_execution_start(smx_simcall_t simcall, const char* name, double flops_amount, double priority, + double bound, sg_host_t host); XBT_PRIVATE void simcall_HANDLER_execution_wait(smx_simcall_t simcall, boost::intrusive_ptr execution); XBT_PRIVATE boost::intrusive_ptr simcall_HANDLER_comm_iprobe(smx_simcall_t simcall, smx_mailbox_t mbox, int type, simix_match_func_t match_fun, void* data); XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout); diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index dd9b622781..e464ce2267 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -71,11 +71,13 @@ inline static int simcall_BODY_process_sleep(double duration) return simcall(SIMCALL_PROCESS_SLEEP, duration); } -inline static boost::intrusive_ptr simcall_BODY_execution_start(const char* name, double flops_amount, double priority, double bound) +inline static boost::intrusive_ptr +simcall_BODY_execution_start(const char* name, double flops_amount, double priority, double bound, sg_host_t host) { if (0) /* Go to that function to follow the code flow through the simcall barrier */ - simcall_HANDLER_execution_start(&SIMIX_process_self()->simcall, name, flops_amount, priority, bound); - return simcall, const char*, double, double, double>(SIMCALL_EXECUTION_START, name, flops_amount, priority, bound); + simcall_HANDLER_execution_start(&SIMIX_process_self()->simcall, name, flops_amount, priority, bound, host); + return simcall, const char*, double, double, double, + sg_host_t>(SIMCALL_EXECUTION_START, name, flops_amount, priority, bound, host); } inline static boost::intrusive_ptr simcall_BODY_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, double rate, double timeout) diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index 1d6a4a6ddc..21e72227b9 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -95,7 +95,12 @@ case SIMCALL_PROCESS_SLEEP: break; case SIMCALL_EXECUTION_START: - simgrid::simix::marshal>(simcall->result, simcall_HANDLER_execution_start(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1]), simgrid::simix::unmarshal(simcall->args[2]), simgrid::simix::unmarshal(simcall->args[3]))); + simgrid::simix::marshal>( + simcall->result, + simcall_HANDLER_execution_start( + simcall, simgrid::simix::unmarshal(simcall->args[0]), + simgrid::simix::unmarshal(simcall->args[1]), simgrid::simix::unmarshal(simcall->args[2]), + simgrid::simix::unmarshal(simcall->args[3]), simgrid::simix::unmarshal(simcall->args[4]))); SIMIX_simcall_answer(simcall); break; diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 99e748f348..4faaeed745 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2016. The SimGrid Team. All rights reserved. +# Copyright (c) 2014-2017. The SimGrid Team. All rights reserved. # 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. @@ -41,7 +41,7 @@ void process_suspend(smx_actor_t process) [[block]]; int process_join(smx_actor_t process, double timeout) [[block]]; int process_sleep(double duration) [[block]]; -boost::intrusive_ptr execution_start(const char* name, double flops_amount, double priority, double bound); +boost::intrusive_ptr execution_start(const char* name, double flops_amount, double priority, double bound, sg_host_t host); boost::intrusive_ptr execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, double rate, double timeout) [[nohandler]]; int execution_wait(boost::intrusive_ptr execution) [[block]]; diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 3808ea6de9..00b5bb45fa 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -145,21 +145,21 @@ void SIMIX_host_autorestart(sg_host_t host) process_list.clear(); } -boost::intrusive_ptr simcall_HANDLER_execution_start(smx_simcall_t simcall, - const char* name, - double flops_amount, - double priority, double bound) +boost::intrusive_ptr +simcall_HANDLER_execution_start(smx_simcall_t simcall, const char* name, double flops_amount, double priority, + double bound, sg_host_t host) { - return SIMIX_execution_start(simcall->issuer, name,flops_amount,priority,bound); + return SIMIX_execution_start(simcall->issuer, name, flops_amount, priority, bound, host); } -boost::intrusive_ptr -SIMIX_execution_start(smx_actor_t issuer, const char* name, double flops_amount, double priority, double bound) +boost::intrusive_ptr SIMIX_execution_start(smx_actor_t issuer, const char* name, + double flops_amount, double priority, + double bound, sg_host_t host) { /* alloc structures and initialize */ simgrid::kernel::activity::ExecImplPtr exec = - simgrid::kernel::activity::ExecImplPtr(new simgrid::kernel::activity::ExecImpl(name, issuer->host)); + simgrid::kernel::activity::ExecImplPtr(new simgrid::kernel::activity::ExecImpl(name, host)); /* set surf's action */ if (not MC_is_active() && not MC_record_replay_is_active()) { diff --git a/src/simix/smx_host_private.hpp b/src/simix/smx_host_private.hpp index 50a6f5f6c8..b90f1896ed 100644 --- a/src/simix/smx_host_private.hpp +++ b/src/simix/smx_host_private.hpp @@ -55,7 +55,8 @@ XBT_PRIVATE void SIMIX_set_category(smx_activity_t synchro, const char* category } XBT_PRIVATE boost::intrusive_ptr -SIMIX_execution_start(smx_actor_t issuer, const char* name, double flops_amount, double priority, double bound); +SIMIX_execution_start(smx_actor_t issuer, const char* name, double flops_amount, double priority, double bound, + sg_host_t host); XBT_PRIVATE boost::intrusive_ptr SIMIX_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, double rate, double timeout); diff --git a/src/smpi/internals/smpi_bench.cpp b/src/smpi/internals/smpi_bench.cpp index 21fe9740d2..8077214243 100644 --- a/src/smpi/internals/smpi_bench.cpp +++ b/src/smpi/internals/smpi_bench.cpp @@ -4,12 +4,13 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "private.hpp" +#include "simgrid/host.h" #include "simgrid/modelchecker.h" #include "smpi_comm.hpp" -#include "simgrid/host.h" #include "smpi_process.hpp" #include "src/internal_config.h" #include "src/mc/mc_replay.hpp" +#include "src/simix/ActorImpl.hpp" #include #ifndef WIN32 @@ -43,7 +44,7 @@ void smpi_execute_(double *duration) void smpi_execute_flops(double flops) { XBT_DEBUG("Handle real computation time: %f flops", flops); - smx_activity_t action = simcall_execution_start("computation", flops, 1, 0); + smx_activity_t action = simcall_execution_start("computation", flops, 1, 0, smpi_process()->process()->host); simcall_set_category (action, TRACE_internal_smpi_get_category()); simcall_execution_wait(action); smpi_switch_data_segment(smpi_process()->index()); diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index 64c35749a2..6219f430c9 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -14,6 +14,7 @@ #include "smpi_process.hpp" #include "src/kernel/activity/CommImpl.hpp" #include "src/mc/mc_replay.hpp" +#include "src/simix/ActorImpl.hpp" #include @@ -629,7 +630,9 @@ void Request::iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* MPI_Request request = new Request(nullptr, 0, MPI_CHAR, source == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->index(source), comm->rank(), tag, comm, PERSISTENT | RECV); if (smpi_iprobe_sleep > 0) { - smx_activity_t iprobe_sleep = simcall_execution_start("iprobe", /* flops to executek*/nsleeps*smpi_iprobe_sleep*speed*maxrate, /* priority */1.0, /* performance bound */maxrate*speed); + smx_activity_t iprobe_sleep = simcall_execution_start( + "iprobe", /* flops to executek*/ nsleeps * smpi_iprobe_sleep * speed * maxrate, /* priority */ 1.0, + /* performance bound */ maxrate * speed, smpi_process()->process()->host); simcall_execution_wait(iprobe_sleep); } // behave like a receive, but don't do it