From: Frederic Suter Date: Sat, 23 Feb 2019 12:46:01 +0000 (+0100) Subject: play with (parallel) execs. still not satisfying X-Git-Tag: v3_22~255 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d70f8e758b34f51465c538b127f9cc8c40634603?ds=sidebyside play with (parallel) execs. still not satisfying --- diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index d6796c2be3..a55c1f3483 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -51,15 +51,22 @@ namespace simgrid { namespace kernel { namespace activity { -ExecImpl::ExecImpl(std::string name, std::string tracing_category, resource::Action* timeout_detector, s4u::Host* host) - : ActivityImpl(std::move(name)), host_(host), timeout_detector_(timeout_detector) +ExecImpl::ExecImpl(std::string name, std::string tracing_category, s4u::Host* host) + : ActivityImpl(std::move(name)), host_(host) { this->state_ = SIMIX_RUNNING; this->set_category(std::move(tracing_category)); - if (timeout_detector != nullptr) - timeout_detector_->set_data(this); + XBT_DEBUG("Create exec %p", this); +} +ExecImpl::ExecImpl(std::string name, std::string tracing_category, s4u::Host* host, double timeout) + : ExecImpl(std::move(name), std::move(tracing_category), nullptr) +{ + if (timeout > 0 && not MC_is_active() && not MC_record_replay_is_active()) { + timeout_detector_ = host->pimpl_cpu->sleep(timeout); + timeout_detector_->set_data(this); + } XBT_DEBUG("Create exec %p", this); } diff --git a/src/kernel/activity/ExecImpl.hpp b/src/kernel/activity/ExecImpl.hpp index 117831ad92..cda277cd9b 100644 --- a/src/kernel/activity/ExecImpl.hpp +++ b/src/kernel/activity/ExecImpl.hpp @@ -18,8 +18,8 @@ class XBT_PUBLIC ExecImpl : public ActivityImpl { ~ExecImpl() override; public: - explicit ExecImpl(std::string name, std::string tracing_category, resource::Action* timeout_detector, - s4u::Host* host); + explicit ExecImpl(std::string name, std::string tracing_category, s4u::Host* host); + explicit ExecImpl(std::string name, std::string tracing_category, s4u::Host* host, double timeout); ExecImpl* start(double flops_amount, double priority, double bound); void cancel(); void post() override; diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index 6fe6cbd024..3bc5eb330e 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -73,8 +73,7 @@ msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeo sg_host_t host = MSG_process_get_host(MSG_process_self()); simdata->compute = simgrid::simix::simcall([task, host] { return simgrid::kernel::activity::ExecImplPtr( - new simgrid::kernel::activity::ExecImpl(task->name ?: "", task->category ?: "", - /*timeout_detector*/ nullptr, host)); + new simgrid::kernel::activity::ExecImpl(task->name ?: "", task->category ?: "", host)); }); /* checking for infinite values */ xbt_assert(std::isfinite(simdata->flops_amount), "flops_amount is not finite!"); diff --git a/src/s4u/s4u_Exec.cpp b/src/s4u/s4u_Exec.cpp index 1860395c3f..0e69a7b159 100644 --- a/src/s4u/s4u_Exec.cpp +++ b/src/s4u/s4u_Exec.cpp @@ -19,8 +19,7 @@ Exec::Exec(sg_host_t host, double flops_amount) : Activity(), host_(host), flops { Activity::set_remaining(flops_amount_); pimpl_ = simix::simcall([this] { - return kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl(name_, tracing_category_, - /*timeout_detector*/ nullptr, host_)); + return kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl(name_, tracing_category_, host_)); }); } diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index e0a2043b1d..00e499d2d9 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -342,7 +342,7 @@ activity::ActivityImplPtr ActorImpl::suspend(ActorImpl* issuer) return nullptr; } else { - return activity::ExecImplPtr(new activity::ExecImpl("suspend", "", nullptr, this->host_))->start(0.0, 1.0, 0.0); + return activity::ExecImplPtr(new activity::ExecImpl("suspend", "", this->host_))->start(0.0, 1.0, 0.0); } } diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index a7461149a4..d488f6c953 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -45,6 +45,13 @@ smx_activity_t simcall_execution_parallel_start(const std::string& name, int hos const double* flops_amount, const double* bytes_amount, double rate, double timeout) { + /* Check that we are not mixing VMs and PMs in the parallel task */ + bool is_a_vm = (nullptr != dynamic_cast(host_list[0])); + for (int i = 1; i < host_nb; i++) { + bool tmp_is_a_vm = (nullptr != dynamic_cast(host_list[i])); + xbt_assert(is_a_vm == tmp_is_a_vm, "parallel_execute: mixing VMs and PMs is not supported (yet)."); + } + /* checking for infinite values */ for (int i = 0 ; i < host_nb ; ++i) { if (flops_amount != nullptr) @@ -424,7 +431,7 @@ smx_activity_t simcall_execution_start(const std::string& name, const std::strin { return simgrid::simix::simcall([name, category, flops_amount, priority, bound, host] { return simgrid::kernel::activity::ExecImplPtr( - new simgrid::kernel::activity::ExecImpl(std::move(name), std::move(category), nullptr, host)) + new simgrid::kernel::activity::ExecImpl(std::move(name), std::move(category), host)) ->start(flops_amount, priority, bound); }); } diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 37c3479b7b..42e65026ac 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -17,30 +17,17 @@ simgrid::kernel::activity::ExecImplPtr SIMIX_execution_parallel_start(std::string name, int host_nb, const sg_host_t* host_list, const double* flops_amount, const double* bytes_amount, double rate, double timeout) { - - /* Check that we are not mixing VMs and PMs in the parallel task */ - bool is_a_vm = (nullptr != dynamic_cast(host_list[0])); - for (int i = 1; i < host_nb; i++) { - bool tmp_is_a_vm = (nullptr != dynamic_cast(host_list[i])); - xbt_assert(is_a_vm == tmp_is_a_vm, "parallel_execute: mixing VMs and PMs is not supported (yet)."); - } + simgrid::kernel::activity::ExecImplPtr exec = simgrid::kernel::activity::ExecImplPtr( + new simgrid::kernel::activity::ExecImpl(std::move(name), "", host_list[0], timeout)); /* set surf's synchro */ - simgrid::kernel::resource::Action* surf_action = nullptr; - simgrid::kernel::resource::Action* timeout_detector = nullptr; if (not MC_is_active() && not MC_record_replay_is_active()) { - surf_action = surf_host_model->execute_parallel(host_nb, host_list, flops_amount, bytes_amount, rate); - if (timeout > 0) { - timeout_detector = host_list[0]->pimpl_cpu->sleep(timeout); + exec->surf_action_ = surf_host_model->execute_parallel(host_nb, host_list, flops_amount, bytes_amount, rate); + if (exec->surf_action_ != nullptr) { + exec->surf_action_->set_data(exec.get()); } } - simgrid::kernel::activity::ExecImplPtr exec = simgrid::kernel::activity::ExecImplPtr( - new simgrid::kernel::activity::ExecImpl(std::move(name), "", timeout_detector, nullptr)); - if (surf_action != nullptr) { - exec->surf_action_ = surf_action; - exec->surf_action_->set_data(exec.get()); - } XBT_DEBUG("Create parallel execute synchro %p", exec.get()); return exec;