Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
snake_case (and document) s4u::Exec
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 9 May 2018 23:22:08 +0000 (01:22 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 9 May 2018 23:22:08 +0000 (01:22 +0200)
examples/s4u/cloud-capping/s4u-cloud-capping.cpp
examples/s4u/exec-async/s4u-exec-async.cpp
examples/s4u/exec-remote/s4u-exec-remote.cpp
include/simgrid/s4u/Exec.hpp
src/s4u/s4u_Exec.cpp

index 7d35e58..8d3872d 100644 (file)
@@ -18,7 +18,7 @@ static void worker(double computation_amount, bool use_bound, double bound)
   if (use_bound) {
     if (bound < 1e-12) /* close enough to 0 without any floating precision surprise */
       XBT_INFO("bound == 0 means no capping (i.e., unlimited).");
-    exec->setBound(bound);
+    exec->set_bound(bound);
   }
   exec->start();
   exec->wait();
index a47acce..6794d5b 100644 (file)
@@ -11,7 +11,7 @@ static void test(double computation_amount, double priority)
 {
   XBT_INFO("Hello! Execute %g flops with priority %g", computation_amount, priority);
   simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_init(computation_amount);
-  activity->setPriority(priority);
+  activity->set_priority(priority);
   activity->start();
   activity->wait();
 
index d9c43af..8044e17 100644 (file)
@@ -15,7 +15,7 @@ static void wizard()
 
   XBT_INFO("I'm a wizard! I can run a task on the Fafard host from the Ginette one! Look!");
   simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_init(48.492e6);
-  exec->setHost(ginette);
+  exec->set_host(ginette);
   exec->start();
   XBT_INFO("It started. Running 48.492Mf takes exactly one second on Ginette (but not on Fafard).");
 
@@ -27,14 +27,14 @@ static void wizard()
 
   XBT_INFO("Done!");
   XBT_INFO("And now, harder. Start a remote task on Ginette and move it to Boivin after 0.5 sec");
-  exec = simgrid::s4u::this_actor::exec_init(73293500)->setHost(ginette);
+  exec = simgrid::s4u::this_actor::exec_init(73293500)->set_host(ginette);
   exec->start();
 
   simgrid::s4u::this_actor::sleep_for(0.5);
   XBT_INFO("Loads before the move: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f",
       boivin->getLoad(), fafard->getLoad(), ginette->getLoad());
 
-  exec->setHost(boivin);
+  exec->set_host(boivin);
 
   simgrid::s4u::this_actor::sleep_for(0.1);
   XBT_INFO("Loads after the move: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f",
index a023a74..bcf774a 100644 (file)
@@ -28,14 +28,23 @@ public:
   Activity* wait(double timeout) override;
   bool test();
 
-  ExecPtr setPriority(double priority);
-  ExecPtr setBound(double bound);
-  ExecPtr setHost(Host * host);
-  Host* getHost() { return host_; }
+  ExecPtr set_priority(double priority);
+  ExecPtr set_bound(double bound);
+  ExecPtr set_host(Host* host);
+  Host* get_host();
 
   double get_remaining() override;
   double getRemainingRatio();
 
+  //////////////// Deprecated functions
+  XBT_ATTRIB_DEPRECATED_v323("Please use Exec::set_priority()") ExecPtr setPriority(double priority)
+  {
+    return set_priority(priority);
+  }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Exec::set_bound()") ExecPtr setBound(double bound) { return set_bound(bound); }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Exec::set_host()") ExecPtr setHost(Host* host) { return set_host(host); }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Exec::get_host()") Host* getHost() { return get_host(); }
+
 private:
   Host* host_          = nullptr;
   double flops_amount_ = 0.0;
index 03afd33..4c31f6f 100644 (file)
@@ -15,7 +15,7 @@ namespace s4u {
 
 Activity* Exec::start()
 {
-  pimpl_ = simcall_execution_start(nullptr, flops_amount_, 1 / priority_, 0., host_);
+  pimpl_ = simcall_execution_start(nullptr, flops_amount_, 1. / priority_, 0., host_);
   boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->setBound(bound_);
   state_ = State::started;
   return this;
@@ -34,6 +34,7 @@ Activity* Exec::wait(double timeout)
   return this;
 }
 
+/** @brief Returns whether the state of the exec is finished */
 bool Exec::test()
 {
   xbt_assert(state_ == State::inited || state_ == State::started || state_ == State::finished);
@@ -52,21 +53,34 @@ bool Exec::test()
   return false;
 }
 
-ExecPtr Exec::setPriority(double priority)
+/** @brief  Change the execution priority, don't you think?
+ *
+ * An execution with twice the priority will get twice the amount of flops when the resource is shared.
+ * The default priority is 1.
+ *
+ * Currently, this cannot be changed once the exec started. */
+ExecPtr Exec::set_priority(double priority)
 {
   xbt_assert(state_ == State::inited, "Cannot change the priority of an exec after its start");
   priority_ = priority;
   return this;
 }
 
-ExecPtr Exec::setBound(double bound)
+/** @brief change the execution bound, ie the maximal amount of flops per second that it may consume, regardless of what
+ * the host may deliver
+ *
+ * Currently, this cannot be changed once the exec started. */
+ExecPtr Exec::set_bound(double bound)
 {
   xbt_assert(state_ == State::inited, "Cannot change the bound of an exec after its start");
   bound_ = bound;
   return this;
 }
 
-ExecPtr Exec::setHost(Host* host)
+/** @brief Change the host on which this activity takes place.
+ *
+ * The activity cannot be terminated already (but it may be started). */
+ExecPtr Exec::set_host(Host* host)
 {
   xbt_assert(state_ == State::inited || state_ == State::started,
              "Cannot change the host of an exec once it's done (state: %d)", (int)state_);
@@ -76,6 +90,12 @@ ExecPtr Exec::setHost(Host* host)
   return this;
 }
 
+/** @brief Retrieve the host on which this activity takes place. */
+Host* Exec::get_host()
+{
+  return host_;
+}
+
 double Exec::get_remaining()
 {
   return simgrid::simix::kernelImmediate(