Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Modernize simcall execution_waitany_for.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 18 Mar 2021 08:29:58 +0000 (09:29 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 18 Mar 2021 09:24:53 +0000 (10:24 +0100)
include/simgrid/simix.h
src/kernel/activity/ExecImpl.cpp
src/mc/checker/SimcallObserver.cpp
src/mc/checker/SimcallObserver.hpp
src/s4u/s4u_Exec.cpp
src/simix/libsmx.cpp
src/simix/popping_accessors.hpp
src/simix/popping_bodies.cpp
src/simix/popping_enum.hpp
src/simix/popping_generated.cpp
src/simix/simcalls.in

index c4ef37c..33e01d5 100644 (file)
@@ -117,8 +117,9 @@ XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Exec::wait_for()") XBT_PUBLIC simgri
     simcall_execution_wait(simgrid::kernel::activity::ActivityImpl* execution, double timeout);
 XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Exec::wait_for()") XBT_PUBLIC simgrid::kernel::activity::State
     simcall_execution_wait(const simgrid::kernel::activity::ActivityImplPtr& execution, double timeout);
-XBT_PUBLIC unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl* execs[], size_t count,
-                                                      double timeout);
+XBT_ATTRIB_DEPRECATED_v331("Please use s4u::Exec::wait_any_for()") XBT_PUBLIC
+    unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl* execs[], size_t count,
+                                               double timeout);
 XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Exec::test()") XBT_PUBLIC
     bool simcall_execution_test(simgrid::kernel::activity::ActivityImpl* execution);
 XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Exec::test()") XBT_PUBLIC
index 4d9f023..0c4686c 100644 (file)
@@ -8,6 +8,7 @@
 #include "simgrid/kernel/routing/NetPoint.hpp"
 #include "simgrid/modelchecker.h"
 #include "simgrid/s4u/Exec.hpp"
+#include "src/mc/checker/SimcallObserver.hpp"
 #include "src/mc/mc_replay.hpp"
 #include "src/surf/HostImpl.hpp"
 #include "src/surf/cpu_interface.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
 
-void simcall_HANDLER_execution_waitany_for(smx_simcall_t simcall,
-                                           const std::vector<simgrid::kernel::activity::ExecImpl*>* execs,
-                                           double timeout)
-{
-  simgrid::kernel::activity::ExecImpl::wait_any_for(simcall->issuer_, execs, timeout);
-}
-
 namespace simgrid {
 namespace kernel {
 namespace activity {
@@ -173,9 +167,8 @@ void ExecImpl::finish()
 
     if (simcall->call_ == simix::Simcall::NONE) // FIXME: maybe a better way to handle this case
       continue;                                 // if process handling comm is killed
-    if (simcall->call_ == simix::Simcall::EXECUTION_WAITANY_FOR) {
-      const std::vector<simgrid::kernel::activity::ExecImpl*>* execs =
-          simcall_execution_waitany_for__get__execs(simcall);
+    if (const auto* observer = dynamic_cast<mc::ExecutionWaitanySimcall*>(simcall->observer_)) {
+      const auto* execs = observer->get_execs();
 
       for (auto* exec : *execs) {
         // Remove the first occurrence of simcall:
@@ -192,7 +185,7 @@ void ExecImpl::finish()
       if (not MC_is_active() && not MC_record_replay_is_active()) {
         auto element = std::find(execs->begin(), execs->end(), this);
         int rank     = (element != execs->end()) ? std::distance(execs->begin(), element) : -1;
-        simcall_execution_waitany_for__set__result(simcall, rank);
+        simix::marshal<int>(simcall->result_, rank);
       }
     }
     switch (state_) {
@@ -267,7 +260,7 @@ void ExecImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<ExecImpl
         if (j != exec->simcalls_.end())
           exec->simcalls_.erase(j);
       }
-      simcall_execution_waitany_for__set__result(&issuer->simcall_, -1);
+      simix::marshal<int>(issuer->simcall_.result_, -1);
       issuer->simcall_answer();
     });
   }
index e4ec65d..8252905 100644 (file)
@@ -119,5 +119,17 @@ bool SemAcquireSimcall::is_enabled() const
   }
   return true;
 }
+
+std::string ExecutionWaitanySimcall::to_string(int time_considered) const
+{
+  std::string res = SimcallObserver::to_string(time_considered) + "Execution WAITANY";
+  res += "(" + (timeout_ == -1.0 ? "" : std::to_string(timeout_)) + ")";
+  return res;
+}
+
+std::string ExecutionWaitanySimcall::dot_label() const
+{
+  return SimcallObserver::dot_label() + "Execution WAITANY";
+}
 } // namespace mc
 } // namespace simgrid
index 578edd8..bc1f0bf 100644 (file)
@@ -125,6 +125,22 @@ public:
   kernel::activity::SemaphoreImpl* get_sem() const { return sem_; }
   double get_timeout() const { return timeout_; }
 };
+
+class ExecutionWaitanySimcall : public SimcallObserver {
+  const std::vector<kernel::activity::ExecImpl*>* const execs_;
+  const double timeout_;
+
+public:
+  ExecutionWaitanySimcall(smx_actor_t actor, const std::vector<kernel::activity::ExecImpl*>* execs, double timeout)
+      : SimcallObserver(actor), execs_(execs), timeout_(timeout)
+  {
+  }
+  bool is_visible() const override { return false; }
+  std::string to_string(int times_considered) const override;
+  std::string dot_label() const override;
+  const std::vector<kernel::activity::ExecImpl*>* get_execs() const { return execs_; }
+  double get_timeout() const { return timeout_; }
+};
 } // namespace mc
 } // namespace simgrid
 
index 335fe01..8b94719 100644 (file)
@@ -9,6 +9,7 @@
 #include "simgrid/s4u/Exec.hpp"
 #include "src/kernel/activity/ExecImpl.hpp"
 #include "src/kernel/actor/ActorImpl.hpp"
+#include "src/mc/checker/SimcallObserver.hpp"
 #include "xbt/log.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_exec, s4u_activity, "S4U asynchronous executions");
@@ -53,7 +54,14 @@ int Exec::wait_any_for(std::vector<ExecPtr>* execs, double timeout)
   std::transform(begin(*execs), end(*execs), begin(rexecs),
                  [](const ExecPtr& exec) { return static_cast<kernel::activity::ExecImpl*>(exec->pimpl_.get()); });
 
-  int changed_pos = simcall_execution_waitany_for(rexecs.data(), rexecs.size(), timeout);
+  kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
+  mc::ExecutionWaitanySimcall observer{issuer, &rexecs, timeout};
+  kernel::actor::simcall_blocking<void>(
+      [&observer] {
+        kernel::activity::ExecImpl::wait_any_for(observer.get_issuer(), observer.get_execs(), observer.get_timeout());
+      },
+      &observer);
+  int changed_pos = simgrid::simix::unmarshal<int>(issuer->simcall_.result_);
   if (changed_pos != -1) {
     on_completion(*(execs->at(changed_pos)));
     execs->at(changed_pos)->release_dependencies();
index 4dcfc05..31541ed 100644 (file)
@@ -60,10 +60,19 @@ bool simcall_execution_test(const simgrid::kernel::activity::ActivityImplPtr& ex
   return simgrid::kernel::actor::simcall([execution] { return execution->test(); });
 }
 
-unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl* execs[], size_t count, double timeout)
+unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl* execs[], size_t count,
+                                           double timeout) // XBT_ATTRIB_DEPRECATED_v331
 {
   std::vector<simgrid::kernel::activity::ExecImpl*> execsv(execs, execs + count);
-  return simcall_BODY_execution_waitany_for(&execsv, timeout);
+  simgrid::kernel::actor::ActorImpl* issuer = simgrid::kernel::actor::ActorImpl::self();
+  simgrid::mc::ExecutionWaitanySimcall observer{issuer, &execsv, timeout};
+  simgrid::kernel::actor::simcall_blocking<void>(
+      [&observer] {
+        simgrid::kernel::activity::ExecImpl::wait_any_for(observer.get_issuer(), observer.get_execs(),
+                                                          observer.get_timeout());
+      },
+      &observer);
+  return simgrid::simix::unmarshal<int>(issuer->simcall_.result_);
 }
 
 void simcall_process_join(smx_actor_t process, double timeout) // XBT_ATTRIB_DEPRECATED_v328
index 90b307e..39ecf1d 100644 (file)
  */
 
 #include "src/simix/popping_private.hpp"
-static inline const std::vector<simgrid::kernel::activity::ExecImpl*>* simcall_execution_waitany_for__get__execs(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<const std::vector<simgrid::kernel::activity::ExecImpl*>*>(simcall->args_[0]);
-}
-static inline const std::vector<simgrid::kernel::activity::ExecImpl*>* simcall_execution_waitany_for__getraw__execs(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<const std::vector<simgrid::kernel::activity::ExecImpl*>*>(simcall->args_[0]);
-}
-static inline void simcall_execution_waitany_for__set__execs(smx_simcall_t simcall, const std::vector<simgrid::kernel::activity::ExecImpl*>* arg)
-{
-  simgrid::simix::marshal<const std::vector<simgrid::kernel::activity::ExecImpl*>*>(simcall->args_[0], arg);
-}
-static inline double simcall_execution_waitany_for__get__timeout(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<double>(simcall->args_[1]);
-}
-static inline double simcall_execution_waitany_for__getraw__timeout(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<double>(simcall->args_[1]);
-}
-static inline void simcall_execution_waitany_for__set__timeout(smx_simcall_t simcall, double arg)
-{
-  simgrid::simix::marshal<double>(simcall->args_[1], arg);
-}
-static inline int simcall_execution_waitany_for__get__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<int>(simcall->result_);
-}
-static inline int simcall_execution_waitany_for__getraw__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<int>(simcall->result_);
-}
-static inline void simcall_execution_waitany_for__set__result(smx_simcall_t simcall, int result)
-{
-  simgrid::simix::marshal<int>(simcall->result_, result);
-}
-
 static inline smx_actor_t simcall_comm_recv__get__receiver(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<smx_actor_t>(simcall->args_[0]);
@@ -700,7 +663,6 @@ static inline void simcall_run_blocking__set__code(smx_simcall_t simcall, std::f
 
 /* The prototype of all simcall handlers, automatically generated for you */
 
-XBT_PRIVATE void simcall_HANDLER_execution_waitany_for(smx_simcall_t simcall, const std::vector<simgrid::kernel::activity::ExecImpl*>* execs, double timeout);
 XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate);
 XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_HANDLER_comm_irecv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double rate);
 XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* 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);
index 83a3ec4..1bcba0a 100644 (file)
@@ -41,13 +41,6 @@ inline static R simcall(Simcall call, T const&... t)
   return simgrid::simix::unmarshal<R>(self->simcall_.result_);
 }
 
-inline static int simcall_BODY_execution_waitany_for(const std::vector<simgrid::kernel::activity::ExecImpl*>* execs, double timeout)
-{
-  if (false) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_execution_waitany_for(&SIMIX_process_self()->simcall_, execs, timeout);
-  return simcall<int, const std::vector<simgrid::kernel::activity::ExecImpl*>*, double>(Simcall::EXECUTION_WAITANY_FOR, execs, timeout);
-}
-
 inline static void simcall_BODY_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
index 1f19164..4b81b84 100644 (file)
@@ -21,7 +21,6 @@ namespace simix {
  */
 enum class Simcall {
   NONE,
-  EXECUTION_WAITANY_FOR,
   COMM_RECV,
   COMM_IRECV,
   COMM_SEND,
@@ -34,6 +33,6 @@ enum class Simcall {
   RUN_BLOCKING,
 };
 
-constexpr int NUM_SIMCALLS = 12;
+constexpr int NUM_SIMCALLS = 11;
 } // namespace simix
 } // namespace simgrid
index 122b248..b252502 100644 (file)
@@ -29,7 +29,6 @@ using simgrid::simix::Simcall;
 /** @brief Simcalls' names (generated from src/simix/simcalls.in) */
 constexpr std::array<const char*, simgrid::simix::NUM_SIMCALLS> simcall_names{{
     "Simcall::NONE",
-    "Simcall::EXECUTION_WAITANY_FOR",
     "Simcall::COMM_RECV",
     "Simcall::COMM_IRECV",
     "Simcall::COMM_SEND",
@@ -56,10 +55,6 @@ void simgrid::kernel::actor::ActorImpl::simcall_handle(int times_considered_)
   if (context_->wannadie())
     return;
   switch (simcall_.call_) {
-    case Simcall::EXECUTION_WAITANY_FOR:
-      simcall_HANDLER_execution_waitany_for(&simcall_, simgrid::simix::unmarshal<const std::vector<simgrid::kernel::activity::ExecImpl*>*>(simcall_.args_[0]), simgrid::simix::unmarshal<double>(simcall_.args_[1]));
-      break;
-
     case Simcall::COMM_RECV:
       simcall_HANDLER_comm_recv(&simcall_, simgrid::simix::unmarshal<smx_actor_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mailbox_t>(simcall_.args_[1]), simgrid::simix::unmarshal<unsigned char*>(simcall_.args_[2]), simgrid::simix::unmarshal<size_t*>(simcall_.args_[3]), simgrid::simix::unmarshal<simix_match_func_t>(simcall_.args_[4]), simgrid::simix::unmarshal<simix_copy_data_func_t>(simcall_.args_[5]), simgrid::simix::unmarshal<void*>(simcall_.args_[6]), simgrid::simix::unmarshal<double>(simcall_.args_[7]), simgrid::simix::unmarshal<double>(simcall_.args_[8]));
       break;
index ecbb39f..405056c 100644 (file)
@@ -35,8 +35,6 @@
 # Last but not the least, you should declare the new simix call in
 # ./include/simgrid/simix.h (otherwise you will get a warning at compile time)
 
-int           execution_waitany_for(const std::vector<simgrid::kernel::activity::ExecImpl*>* execs, double timeout) [[block]];
-
 void           comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate) [[block]];
 boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double rate);
 void           comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* 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) [[block]];