Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
play with (parallel) execs. still not satisfying
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Sat, 23 Feb 2019 12:46:01 +0000 (13:46 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Sat, 23 Feb 2019 12:46:01 +0000 (13:46 +0100)
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/msg/msg_gos.cpp
src/s4u/s4u_Exec.cpp
src/simix/ActorImpl.cpp
src/simix/libsmx.cpp
src/simix/smx_host.cpp

index d6796c2..a55c1f3 100644 (file)
@@ -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);
 }
 
index 117831a..cda277c 100644 (file)
@@ -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;
index 6fe6cbd..3bc5eb3 100644 (file)
@@ -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!");
index 1860395..0e69a7b 100644 (file)
@@ -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_));
   });
 }
 
index e0a2043..00e499d 100644 (file)
@@ -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);
   }
 }
 
index a746114..d488f6c 100644 (file)
@@ -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<simgrid::s4u::VirtualMachine*>(host_list[0]));
+  for (int i = 1; i < host_nb; i++) {
+    bool tmp_is_a_vm = (nullptr != dynamic_cast<simgrid::s4u::VirtualMachine*>(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);
   });
 }
index 37c3479..42e6502 100644 (file)
@@ -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<simgrid::s4u::VirtualMachine*>(host_list[0]));
-  for (int i = 1; i < host_nb; i++) {
-    bool tmp_is_a_vm = (nullptr != dynamic_cast<simgrid::s4u::VirtualMachine*>(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;