Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'python-repr' into 'master'
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 1 Jun 2023 11:20:43 +0000 (11:20 +0000)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 1 Jun 2023 11:20:43 +0000 (11:20 +0000)
add repr for many simgrid objects

See merge request simgrid/simgrid!156

20 files changed:
docs/source/Plugins.rst
examples/cpp/dag-simple/s4u-dag-simple.cpp
examples/cpp/dht-kademlia/message.hpp
include/simgrid/s4u/Activity.hpp
include/simgrid/s4u/Comm.hpp
include/simgrid/s4u/Exec.hpp
include/simgrid/s4u/Io.hpp
src/kernel/activity/ActivityImpl.cpp
src/kernel/activity/CommImpl.cpp
src/kernel/resource/models/ptask_L07.hpp
src/kernel/xml/platf_private.hpp
src/mc/api/strategy/BasicStrategy.hpp
src/mc/api/strategy/Strategy.hpp
src/mc/api/strategy/WaitStrategy.hpp
src/mc/explo/UdporChecker.hpp
src/s4u/s4u_Comm.cpp
src/s4u/s4u_Exec.cpp
src/s4u/s4u_Io.cpp
src/smpi/include/smpi_topo.hpp
tools/address_sanitizer.supp

index a0a4f48..7050246 100644 (file)
@@ -135,20 +135,35 @@ Partial list of existing signals in s4u:
   - :cpp:func:`Comm::on_send <simgrid::s4u::Comm::on_send_cb>`
     :cpp:func:`Comm::on_recv <simgrid::s4u::Comm::on_recv_cb>`
   - :cpp:func:`Comm::on_start <simgrid::s4u::Comm::on_start_cb>`
+    :cpp:func:`Comm::on_this_start <simgrid::s4u::Comm::on_this_start_cb>`
     :cpp:func:`Comm::on_completion <simgrid::s4u::Comm::on_completion_cb>`
+    :cpp:func:`Comm::on_this_completion <simgrid::s4u::Comm::on_this_completion_cb>`
     :cpp:func:`Comm::on_suspend <simgrid::s4u::Comm::on_suspend_cb>`
+    :cpp:func:`Comm::on_this_suspend <simgrid::s4u::Comm::on_this_suspend_cb>`
     :cpp:func:`Comm::on_resume <simgrid::s4u::Comm::on_resume_cb>`
+    :cpp:func:`Comm::on_this_resume <simgrid::s4u::Comm::on_this_resume_cb>`
     :cpp:func:`Comm::on_veto <simgrid::s4u::Comm::on_veto_cb>`
+    :cpp:func:`Comm::on_this_veto <simgrid::s4u::Comm::on_this_veto_cb>`
   - :cpp:func:`Exec::on_start <simgrid::s4u::Exec::on_start_cb>`
+    :cpp:func:`Exec::on_this_start <simgrid::s4u::Exec::on_this_start_cb>`
     :cpp:func:`Exec::on_completion <simgrid::s4u::Exec::on_completion_cb>`
+    :cpp:func:`Exec::on_this_completion <simgrid::s4u::Exec::on_this_completion_cb>`
     :cpp:func:`Exec::on_suspend <simgrid::s4u::Exec::on_suspend_cb>`
+    :cpp:func:`Exec::on_this_suspend <simgrid::s4u::Exec::on_this_suspend_cb>`
     :cpp:func:`Exec::on_resume <simgrid::s4u::Exec::on_resume_cb>`
+    :cpp:func:`Exec::on_this_resume <simgrid::s4u::Exec::on_this_resume_cb>`
     :cpp:func:`Exec::on_veto <simgrid::s4u::Exec::on_veto_cb>`
+    :cpp:func:`Exec::on_this_veto <simgrid::s4u::Exec::on_this_veto_cb>`
   - :cpp:func:`Io::on_start <simgrid::s4u::Io::on_start_cb>`
+    :cpp:func:`Io::on_this_start <simgrid::s4u::Io::on_this_start_cb>`
     :cpp:func:`Io::on_completion <simgrid::s4u::Io::on_completion_cb>`
+    :cpp:func:`Io::on_this_completion <simgrid::s4u::Io::on_this_completion_cb>`
     :cpp:func:`Io::on_suspend <simgrid::s4u::Io::on_suspend_cb>`
+    :cpp:func:`Io::on_this_suspend <simgrid::s4u::Io::on_this_suspend_cb>`
     :cpp:func:`Io::on_resume <simgrid::s4u::Io::on_resume_cb>`
+    :cpp:func:`Io::on_this_resume <simgrid::s4u::Io::on_this_resume_cb>`
     :cpp:func:`Io::on_veto <simgrid::s4u::Io::on_veto_cb>`
+    :cpp:func:`Io::on_this_veto <simgrid::s4u::Io::on_this_veto_cb>`
 
 Existing Plugins
 ****************
index 8179729..78a0158 100644 (file)
@@ -19,9 +19,7 @@ int main(int argc, char* argv[])
   auto fafard = e.host_by_name("Fafard");
 
   // Display the details on vetoed activities
-  sg4::Exec::on_veto_cb([](sg4::Exec const& a) {
-    const auto& exec = static_cast<const sg4::Exec&>(a); // all activities are execs in this example
-
+  sg4::Exec::on_veto_cb([](sg4::Exec const& exec) {
     XBT_INFO("Execution '%s' vetoed. Dependencies: %s; Ressources: %s", exec.get_cname(),
              (exec.dependencies_solved() ? "solved" : "NOT solved"),
              (exec.is_assigned() ? "assigned" : "NOT assigned"));
index 926b692..4840f29 100644 (file)
@@ -6,6 +6,7 @@
 
 #ifndef _KADEMLIA_TASK_HPP_
 #define _KADEMLIA_TASK_HPP_
+#include "answer.hpp"
 #include "s4u-dht-kademlia.hpp"
 #include "simgrid/s4u.hpp"
 
index fb157dd..8204458 100644 (file)
@@ -105,9 +105,13 @@ protected:
   Activity* set_remaining(double remains);
 
   virtual void fire_on_completion() const = 0;
-  virtual void fire_on_veto() const = 0;
+  virtual void fire_on_this_completion() const = 0;
   virtual void fire_on_suspend() const = 0;
+  virtual void fire_on_this_suspend() const = 0;
   virtual void fire_on_resume() const = 0;
+  virtual void fire_on_this_resume() const = 0;
+  virtual void fire_on_veto() const = 0;
+  virtual void fire_on_this_veto() const = 0;
 
 public:
   XBT_ATTRIB_DEPRECATED_v334("All start() are vetoable now. Please use start() ") void vetoable_start()
@@ -124,6 +128,7 @@ public:
       if (vetoed_activities_ != nullptr)
         vetoed_activities_->insert(this);
       fire_on_veto();
+      fire_on_this_veto();
     }
   }
 
@@ -134,6 +139,7 @@ public:
     ActivityPtr keepalive(this);
     state_ = state;
     fire_on_completion();
+    fire_on_this_completion();
     if (state == State::FINISHED)
       release_dependencies();
   }
@@ -233,20 +239,28 @@ template <class AnyActivity> class Activity_T : public Activity {
 
 protected:
   inline static xbt::signal<void(AnyActivity const&)> on_completion;
-  inline static xbt::signal<void(AnyActivity&)> on_veto;
+  xbt::signal<void(AnyActivity const&)> on_this_completion;
   inline static xbt::signal<void(AnyActivity const&)> on_suspend;
+  xbt::signal<void(AnyActivity const&)> on_this_suspend;
   inline static xbt::signal<void(AnyActivity const&)> on_resume;
+  xbt::signal<void(AnyActivity const&)> on_this_resume;
+  inline static xbt::signal<void(AnyActivity&)> on_veto;
+  xbt::signal<void(AnyActivity&)> on_this_veto;
 
 public:
   /*! Add a callback fired when the activity completes (either normally, cancelled or failed) */
   static void on_completion_cb(const std::function<void(AnyActivity const&)>& cb) { on_completion.connect(cb); }
-  /*! Add a callback fired each time that the activity fails to start because of a veto (e.g., unsolved dependency or no
-   * resource assigned) */
-  static void on_veto_cb(const std::function<void(AnyActivity&)>& cb) { on_veto.connect(cb); }
+  void on_this_completion_cb(const std::function<void(AnyActivity const&)>& cb) { on_this_completion.connect(cb); }
   /*! Add a callback fired when the activity is suspended */
   static void on_suspend_cb(const std::function<void(AnyActivity const&)>& cb) { on_suspend.connect(cb); }
+  void on_this_suspend_cb(const std::function<void(AnyActivity const&)>& cb) { on_this_suspend.connect(cb); }
   /*! Add a callback fired when the activity is resumed after being suspended */
   static void on_resume_cb(const std::function<void(AnyActivity const&)>& cb) { on_resume.connect(cb); }
+  void on_this_resume_cb(const std::function<void(AnyActivity const&)>& cb) { on_this_resume.connect(cb); }
+  /*! Add a callback fired each time that the activity fails to start because of a veto (e.g., unsolved dependency or no
+   * resource assigned) */
+  static void on_veto_cb(const std::function<void(AnyActivity&)>& cb) { on_veto.connect(cb); }
+  void on_this_veto_cb(const std::function<void(AnyActivity&)>& cb) { on_this_veto.connect(cb); }
 
   XBT_ATTRIB_DEPRECATED_v337("Please use on_suspend_cb() instead") static void on_suspended_cb(
       const std::function<void(Activity const&)>& cb) { on_suspend.connect(cb); }
index 2577c88..393b48a 100644 (file)
@@ -42,17 +42,31 @@ class XBT_PUBLIC Comm : public Activity_T<Comm> {
 protected:
   static xbt::signal<void(Comm const&)> on_send;
   static xbt::signal<void(Comm const&)> on_recv;
-  static xbt::signal<void(Comm const&)> on_start;
+  inline static xbt::signal<void(Comm const&)> on_start;
+  xbt::signal<void(Comm const&)> on_this_start;
 
-  void fire_on_completion() const override { /* Do nothing */ }
-  void fire_on_veto() const override { on_veto(const_cast<Comm&>(*this)); }
+  void fire_on_completion() const override {
+    /* The completion signal of a Comm has to be thrown only once and not by the sender AND the receiver.
+       then Comm::on_completion is thrown in the kernel in CommImpl::finish.
+     */
+  }
+  void fire_on_this_completion() const override {
+    /* The completion signal of a Comm has to be thrown only once and not by the sender AND the receiver.
+       then Comm::on_completion is thrown in the kernel in CommImpl::finish.
+     */
+  }
   void fire_on_suspend() const override { on_suspend(*this); }
+  void fire_on_this_suspend() const override { on_this_suspend(*this); }
   void fire_on_resume() const override { on_resume(*this); }
+  void fire_on_this_resume() const override { on_this_resume(*this); }
+  void fire_on_veto() const override { on_veto(const_cast<Comm&>(*this)); }
+  void fire_on_this_veto() const override { on_this_veto(const_cast<Comm&>(*this)); }
 
 public:
   static void on_send_cb(const std::function<void(Comm const&)>& cb) { on_send.connect(cb); }
   static void on_recv_cb(const std::function<void(Comm const&)>& cb) { on_recv.connect(cb); }
   static void on_start_cb(const std::function<void(Comm const&)>& cb) { on_start.connect(cb); }
+  void on_this_start_cb(const std::function<void(Comm const&)>& cb) { on_this_start.connect(cb); }
 
   CommPtr set_copy_data_callback(const std::function<void(kernel::activity::CommImpl*, void*, size_t)>& callback);
   XBT_ATTRIB_DEPRECATED_v337("Please manifest if you actually need this function") static void copy_buffer_callback(
index 1f5d519..720731b 100644 (file)
@@ -42,11 +42,16 @@ protected:
 
   void reset() const;
 
-  static xbt::signal<void(Exec const&)> on_start;
+  inline static xbt::signal<void(Exec const&)> on_start;
+  xbt::signal<void(Exec const&)> on_this_start;
   void fire_on_completion() const override { on_completion(*this); }
-  void fire_on_veto() const override { on_veto(const_cast<Exec&>(*this)); }
+  void fire_on_this_completion() const override { on_this_completion(*this); }
   void fire_on_suspend() const override { on_suspend(*this); }
+  void fire_on_this_suspend() const override { on_this_suspend(*this); }
   void fire_on_resume() const override { on_resume(*this); }
+  void fire_on_this_resume() const override { on_this_resume(*this); }
+  void fire_on_veto() const override { on_veto(const_cast<Exec&>(*this)); }
+  void fire_on_this_veto() const override { on_this_veto(const_cast<Exec&>(*this)); }
 
 public:
 #ifndef DOXYGEN
@@ -55,6 +60,7 @@ public:
 #endif
   /*! Signal fired each time that an execution actually starts (no veto) */
   static void on_start_cb(const std::function<void(Exec const&)>& cb) { on_start.connect(cb); }
+  void on_this_start_cb(const std::function<void(Exec const&)>& cb) { on_this_start.connect(cb); }
 
   static ExecPtr init();
 
index ec34612..cb75b50 100644 (file)
@@ -24,20 +24,26 @@ class XBT_PUBLIC Io : public Activity_T<Io> {
   friend kernel::EngineImpl;
 #endif
 
-  static xbt::signal<void(Io const&)> on_start;
+  inline static xbt::signal<void(Io const&)> on_start;
+  xbt::signal<void(Io const&)> on_this_start;
 
 protected:
   explicit Io(kernel::activity::IoImplPtr pimpl);
   Io* do_start() override;
   void fire_on_completion() const override { on_completion(*this); }
-  void fire_on_veto() const override { on_veto(const_cast<Io&>(*this)); }
+  void fire_on_this_completion() const override { on_this_completion(*this); }
   void fire_on_suspend() const override { on_suspend(*this); }
+  void fire_on_this_suspend() const override { on_this_suspend(*this); }
   void fire_on_resume() const override { on_resume(*this); }
+  void fire_on_this_resume() const override { on_this_resume(*this); }
+  void fire_on_veto() const override { on_veto(const_cast<Io&>(*this)); }
+  void fire_on_this_veto() const override { on_this_veto(const_cast<Io&>(*this)); }
 
 public:
   enum class OpType { READ, WRITE };
 
   static void on_start_cb(const std::function<void(Io const&)>& cb) { on_start.connect(cb); }
+  void on_this_start_cb(const std::function<void(Io const&)>& cb) { on_this_start.connect(cb); }
 
   static IoPtr init();
   /*! take a vector of s4u::IoPtr and return when one of them is finished.
index d1bafa9..a81face 100644 (file)
@@ -182,6 +182,7 @@ void ActivityImpl::suspend()
   }
   XBT_VERB("This activity is suspended (remain: %f)", model_action_->get_remains());
   get_iface()->fire_on_suspend();
+  get_iface()->fire_on_this_suspend();
   model_action_->suspend();
 }
 
@@ -191,6 +192,7 @@ void ActivityImpl::resume()
     return;
   XBT_VERB("This activity is resumed (remain: %f)", model_action_->get_remains());
   get_iface()->fire_on_resume();
+  get_iface()->fire_on_this_resume();
   model_action_->resume();
 }
 
index 7a9ef04..dbf9510 100644 (file)
@@ -470,7 +470,9 @@ void CommImpl::finish()
   XBT_DEBUG("CommImpl::finish() comm %p, state %s, src_proc %p, dst_proc %p, detached: %d", this, get_state_str(),
             src_actor_.get(), dst_actor_.get(), detached_);
 
-  s4u::Comm::on_completion(static_cast<const s4u::Comm&>(*this->get_iface()));
+  const s4u::Comm& piface = static_cast<const s4u::Comm&>(*this->get_iface());
+  s4u::Comm::on_completion(piface);
+  //piface.on_this_completion(piface);
 
   /* Update synchro state */
   if (src_timeout_ && src_timeout_->get_state() == resource::Action::State::FINISHED)
index d7db18f..7bac5d6 100644 (file)
@@ -3,15 +3,16 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#ifndef HOST_L07_HPP_
+#define HOST_L07_HPP_
+
 #include "src/kernel/resource/HostImpl.hpp"
 #include "src/kernel/resource/NetworkModel.hpp"
+#include "src/simgrid/math_utils.h"
 #include <cstdlib>
 #include <vector>
 #include <xbt/base.h>
 
-#ifndef HOST_L07_HPP_
-#define HOST_L07_HPP_
-
 namespace simgrid::kernel::resource {
 
 /***********
index be3a2d1..64f1627 100644 (file)
@@ -13,6 +13,7 @@
 #include "src/kernel/xml/simgrid_dtd.h"
 
 #include <map>
+#include <memory>
 #include <string>
 #include <vector>
 
index f06d86c..452efd4 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef SIMGRID_MC_BASICSTRATEGY_HPP
 #define SIMGRID_MC_BASICSTRATEGY_HPP
 
+#include "Strategy.hpp"
+
 namespace simgrid::mc {
 
 /** Basic MC guiding class which corresponds to no guide at all (random choice) */
index a530789..de2f941 100644 (file)
@@ -3,11 +3,15 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "xbt/asserts.h"
-
 #ifndef SIMGRID_MC_STRATEGY_HPP
 #define SIMGRID_MC_STRATEGY_HPP
 
+#include "simgrid/forward.h"
+#include "src/mc/api/RemoteApp.hpp"
+#include "xbt/asserts.h"
+#include <map>
+#include <utility>
+
 namespace simgrid::mc {
 
 class Strategy {
index f1b2a85..ed5b9a0 100644 (file)
@@ -6,6 +6,7 @@
 #ifndef SIMGRID_MC_WAITSTRATEGY_HPP
 #define SIMGRID_MC_WAITSTRATEGY_HPP
 
+#include "Strategy.hpp"
 #include "src/mc/transition/Transition.hpp"
 
 namespace simgrid::mc {
@@ -19,7 +20,7 @@ class WaitStrategy : public Strategy {
 public:
   WaitStrategy()                     = default;
   ~WaitStrategy() override           = default;
-  WaitStrategy(const BasicStrategy&) = delete;
+  WaitStrategy(const WaitStrategy&)  = delete;
   WaitStrategy& operator=(const WaitStrategy& guide)
   {
     taken_wait_ = guide.taken_wait_;
index 0e23ab0..02f2a8e 100644 (file)
@@ -7,6 +7,7 @@
 #ifndef SIMGRID_MC_UDPOR_CHECKER_HPP
 #define SIMGRID_MC_UDPOR_CHECKER_HPP
 
+#include "src/mc/api/State.hpp"
 #include "src/mc/explo/Exploration.hpp"
 #include "src/mc/explo/udpor/Configuration.hpp"
 #include "src/mc/explo/udpor/EventSet.hpp"
index 376d18d..c4b8bb4 100644 (file)
@@ -21,7 +21,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_comm, s4u_activity, "S4U asynchronous commun
 namespace simgrid::s4u {
 xbt::signal<void(Comm const&)> Comm::on_send;
 xbt::signal<void(Comm const&)> Comm::on_recv;
-xbt::signal<void(Comm const&)> Comm::on_start;
 
 CommPtr Comm::set_copy_data_callback(const std::function<void(kernel::activity::CommImpl*, void*, size_t)>& callback)
 {
@@ -358,8 +357,10 @@ Comm* Comm::do_start()
     pimpl_->set_iface(this);
     pimpl_->set_actor(sender_);
     // Only throw the signal when both sides are here and the status is READY
-    if (pimpl_->get_state() != kernel::activity::State::WAITING)
+    if (pimpl_->get_state() != kernel::activity::State::WAITING) {
       on_start(*this);
+      on_this_start(*this);
+    }
   }
 
   state_ = State::STARTED;
index 3a87ef2..a6fd9cb 100644 (file)
@@ -16,7 +16,6 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_exec, s4u_activity, "S4U asynchronous executions");
 
 namespace simgrid::s4u {
-xbt::signal<void(Exec const&)> Exec::on_start;
 
 Exec::Exec(kernel::activity::ExecImplPtr pimpl)
 {
@@ -48,6 +47,7 @@ Exec* Exec::do_start()
 
   state_      = State::STARTED;
   on_start(*this);
+  on_this_start(*this);
   return this;
 }
 
index 191abc1..691be4a 100644 (file)
@@ -14,7 +14,6 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_io, s4u_activity, "S4U asynchronous I/Os");
 
 namespace simgrid::s4u {
-xbt::signal<void(Io const&)> Io::on_start;
 
 Io::Io(kernel::activity::IoImplPtr pimpl)
 {
@@ -91,6 +90,7 @@ Io* Io::do_start()
 
   state_ = State::STARTED;
   on_start(*this);
+  on_this_start(*this);
   return this;
 }
 
index f1b6524..e46d67e 100644 (file)
@@ -6,7 +6,6 @@
 #ifndef SMPI_TOPO_HPP_INCLUDED
 #define SMPI_TOPO_HPP_INCLUDED
 
-#include "smpi_comm.hpp"
 #include "smpi_status.hpp"
 #include <memory>
 
index 1572d22..f478e89 100644 (file)
@@ -34,3 +34,7 @@ odr_violation:^on_veto$
 odr_violation:^on_suspend$
 # size=56 'on_resume' ../include/simgrid/s4u/Activity.hpp:238:55
 odr_violation:^on_resume$
+
+# size=56 'on_start' ../include/simgrid/s4u/Comm.hpp:45:48
+# size=56 'on_start' ../include/simgrid/s4u/Exec.hpp:45:48
+odr_violation:^on_start$