Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
changing the way the tracing category is passed to ExecImpl
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 25 Jul 2018 14:00:38 +0000 (16:00 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 25 Jul 2018 14:00:38 +0000 (16:00 +0200)
the former version implied to set the category AFTER the start()
because the ExecImpl had to exist. It was against the idea of "do all
the sets and then starts". Now, the category is set at user level and
then passed to the Impl within the start simcall. Setting a category
after the start is now forbidden.

include/simgrid/s4u/Exec.hpp
include/simgrid/simix.h
src/msg/msg_gos.cpp
src/s4u/s4u_Exec.cpp
src/s4u/s4u_Host.cpp
src/simix/ActorImpl.cpp
src/simix/libsmx.cpp
src/simix/smx_host.cpp
src/simix/smx_host_private.hpp
src/smpi/internals/smpi_bench.cpp

index d4411ef..9616bfe 100644 (file)
@@ -57,11 +57,12 @@ public:
   }
 
 private:
   }
 
 private:
-  Host* host_          = nullptr;
-  double flops_amount_ = 0.0;
-  double priority_     = 1.0;
-  double bound_        = 0.0;
-  std::string name_    = "";
+  Host* host_                   = nullptr;
+  double flops_amount_          = 0.0;
+  double priority_              = 1.0;
+  double bound_                 = 0.0;
+  std::string name_             = "";
+  std::string tracing_category_ = "";
   std::atomic_int_fast32_t refcount_{0};
 }; // class
 }
   std::atomic_int_fast32_t refcount_{0};
 }; // class
 }
index ea767d0..4f5047b 100644 (file)
@@ -191,8 +191,8 @@ XBT_PUBLIC void SIMIX_comm_finish(smx_activity_t synchro);
 
 /******************************* Host simcalls ********************************/
 #ifdef __cplusplus
 
 /******************************* Host simcalls ********************************/
 #ifdef __cplusplus
-XBT_PUBLIC smx_activity_t simcall_execution_start(std::string name, double flops_amount, double priority, double bound,
-                                                  sg_host_t host);
+XBT_PUBLIC smx_activity_t simcall_execution_start(std::string name, std::string category, double flops_amount,
+                                                  double priority, double bound, sg_host_t host);
 XBT_PUBLIC smx_activity_t simcall_execution_parallel_start(std::string name, int host_nb, sg_host_t* host_list,
                                                            double* flops_amount, double* bytes_amount, double rate,
                                                            double timeout);
 XBT_PUBLIC smx_activity_t simcall_execution_parallel_start(std::string name, int host_nb, sg_host_t* host_list,
                                                            double* flops_amount, double* bytes_amount, double rate,
                                                            double timeout);
index 62bed03..84d1c06 100644 (file)
@@ -65,13 +65,14 @@ msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeo
               task->name ?: "", simdata->host_nb, simdata->host_list, simdata->flops_parallel_amount,
               simdata->bytes_parallel_amount, -1.0, timeout));
       XBT_DEBUG("Parallel execution action created: %p", simdata->compute.get());
               task->name ?: "", simdata->host_nb, simdata->host_list, simdata->flops_parallel_amount,
               simdata->bytes_parallel_amount, -1.0, timeout));
       XBT_DEBUG("Parallel execution action created: %p", simdata->compute.get());
+      if (task->category != nullptr)
+        simcall_set_category(simdata->compute, task->category);
     } else {
       simdata->compute = boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(
     } else {
       simdata->compute = boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(
-          simcall_execution_start(task->name ?: "", simdata->flops_amount, simdata->priority, simdata->bound,
-                                  MSG_process_get_host(MSG_process_self())));
+          simcall_execution_start(task->name ?: "", task->category ?: "", simdata->flops_amount, simdata->priority,
+                                  simdata->bound, MSG_process_get_host(MSG_process_self())));
     }
     }
-    if (task->category != nullptr)
-      simcall_set_category(simdata->compute, task->category);
+
     comp_state = simcall_execution_wait(simdata->compute);
 
     simdata->setNotUsed();
     comp_state = simcall_execution_wait(simdata->compute);
 
     simdata->setNotUsed();
index 4d6ec06..dc9c7a9 100644 (file)
@@ -15,7 +15,7 @@ namespace s4u {
 
 Activity* Exec::start()
 {
 
 Activity* Exec::start()
 {
-  pimpl_ = simcall_execution_start(name_, flops_amount_, 1. / priority_, bound_, host_);
+  pimpl_ = simcall_execution_start(name_, tracing_category_, flops_amount_, 1. / priority_, bound_, host_);
   state_ = State::STARTED;
   return this;
 }
   state_ = State::STARTED;
   return this;
 }
@@ -98,12 +98,8 @@ ExecPtr Exec::set_name(std::string name)
 
 ExecPtr Exec::set_tracing_category(std::string category)
 {
 
 ExecPtr Exec::set_tracing_category(std::string category)
 {
-  if (category.empty())
-    return this;
-
-  simgrid::simix::simcall([this, category] {
-    boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->set_category(category);
-  });
+  xbt_assert(state_ == State::INITED, "Cannot change the tracing category of an exec after its start");
+  tracing_category_ = category;
   return this;
 }
 
   return this;
 }
 
index ceed115..77ab45f 100644 (file)
@@ -289,7 +289,7 @@ void Host::execute(double flops)
 }
 void Host::execute(double flops, double priority)
 {
 }
 void Host::execute(double flops, double priority)
 {
-  smx_activity_t s = simcall_execution_start("", flops, 1 / priority /*priority*/, 0. /*bound*/, this);
+  smx_activity_t s = simcall_execution_start("", "", flops, 1 / priority /*priority*/, 0. /*bound*/, this);
   simcall_execution_wait(s);
 }
 
   simcall_execution_wait(s);
 }
 
index 2970aa7..6aa8dfa 100644 (file)
@@ -202,7 +202,7 @@ smx_activity_t ActorImpl::suspend(ActorImpl* issuer)
 
     return nullptr;
   } else {
 
     return nullptr;
   } else {
-    return SIMIX_execution_start("suspend", 0.0, 1.0, 0.0, this->host_);
+    return SIMIX_execution_start("suspend", "", 0.0, 1.0, 0.0, this->host_);
   }
 }
 
   }
 }
 
index cab0bf8..51b08fa 100644 (file)
@@ -38,15 +38,15 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
  * @param host host where the synchro will be executed
  * @return A new SIMIX execution synchronization
  */
  * @param host host where the synchro will be executed
  * @return A new SIMIX execution synchronization
  */
-smx_activity_t simcall_execution_start(std::string name, double flops_amount, double priority, double bound,
-                                       simgrid::s4u::Host* host)
+smx_activity_t simcall_execution_start(std::string name, std::string category, 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!");
 
 {
   /* 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 simgrid::simix::simcall([name, flops_amount, priority, bound, host] {
-    return SIMIX_execution_start(name, flops_amount, priority, bound, host);
+  return simgrid::simix::simcall([name, category, flops_amount, priority, bound, host] {
+    return SIMIX_execution_start(name, category, flops_amount, priority, bound, host);
   });
 }
 
   });
 }
 
index f9bbc48..91da469 100644 (file)
@@ -60,8 +60,9 @@ void SIMIX_host_autorestart(sg_host_t host)
   process_list.clear();
 }
 
   process_list.clear();
 }
 
-boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
-SIMIX_execution_start(std::string name, double flops_amount, double priority, double bound, sg_host_t host)
+boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl> SIMIX_execution_start(std::string name, std::string category,
+                                                                                double flops_amount, double priority,
+                                                                                double bound, sg_host_t host)
 {
   /* set surf's action */
   simgrid::kernel::resource::Action* surf_action = nullptr;
 {
   /* set surf's action */
   simgrid::kernel::resource::Action* surf_action = nullptr;
@@ -75,6 +76,7 @@ SIMIX_execution_start(std::string name, double flops_amount, double priority, do
   simgrid::kernel::activity::ExecImplPtr exec = simgrid::kernel::activity::ExecImplPtr(
       new simgrid::kernel::activity::ExecImpl(name, surf_action, /*timeout_detector*/ nullptr, host));
 
   simgrid::kernel::activity::ExecImplPtr exec = simgrid::kernel::activity::ExecImplPtr(
       new simgrid::kernel::activity::ExecImpl(name, surf_action, /*timeout_detector*/ nullptr, host));
 
+  exec->set_category(name);
   XBT_DEBUG("Create execute synchro %p: %s", exec.get(), exec->name_.c_str());
   simgrid::kernel::activity::ExecImpl::on_creation(exec);
 
   XBT_DEBUG("Create execute synchro %p: %s", exec.get(), exec->name_.c_str());
   simgrid::kernel::activity::ExecImpl::on_creation(exec);
 
index 91f84ab..22aec6d 100644 (file)
@@ -18,7 +18,8 @@ XBT_PRIVATE void SIMIX_execution_finish(smx_activity_t synchro);
 XBT_PRIVATE void SIMIX_set_category(smx_activity_t synchro, std::string category);
 
 XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
 XBT_PRIVATE void SIMIX_set_category(smx_activity_t synchro, std::string category);
 
 XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
-SIMIX_execution_start(std::string name, double flops_amount, double priority, double bound, sg_host_t host);
+SIMIX_execution_start(std::string name, std::string category, double flops_amount, double priority, double bound,
+                      sg_host_t host);
 XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
 SIMIX_execution_parallel_start(std::string name, int host_nb, sg_host_t* host_list, double* flops_amount,
                                double* bytes_amount, double rate, double timeout);
 XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
 SIMIX_execution_parallel_start(std::string name, int host_nb, sg_host_t* host_list, double* flops_amount,
                                double* bytes_amount, double rate, double timeout);
index bc55483..85191c7 100644 (file)
@@ -49,10 +49,11 @@ void smpi_execute_(double *duration)
 void smpi_execute_flops(double flops) {
   xbt_assert(flops >= 0, "You're trying to execute a negative amount of flops (%f)!", flops);
   XBT_DEBUG("Handle real computation time: %f flops", flops);
 void smpi_execute_flops(double flops) {
   xbt_assert(flops >= 0, "You're trying to execute a negative amount of flops (%f)!", flops);
   XBT_DEBUG("Handle real computation time: %f flops", flops);
-  simgrid::s4u::ExecPtr e = simgrid::s4u::this_actor::exec_init(flops)->set_name("computation");
-  e->start();
-  e->set_tracing_category(TRACE_internal_smpi_get_category());
-  e->wait();
+  simgrid::s4u::this_actor::exec_init(flops)
+      ->set_name("computation")
+      ->set_tracing_category(TRACE_internal_smpi_get_category())
+      ->start()
+      ->wait();
   smpi_switch_data_segment(simgrid::s4u::Actor::self());
 }
 
   smpi_switch_data_segment(simgrid::s4u::Actor::self());
 }