Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove the actor of the on_{start/completion} parameters as it is always initialized...
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 10 Jan 2021 12:59:38 +0000 (13:59 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 10 Jan 2021 12:59:38 +0000 (13:59 +0100)
12 files changed:
include/simgrid/s4u/Comm.hpp
include/simgrid/s4u/Exec.hpp
include/simgrid/s4u/Io.hpp
src/instr/instr_platform.cpp
src/plugins/dirty_page_tracking.cpp
src/plugins/host_dvfs.cpp
src/plugins/host_energy.cpp
src/plugins/host_load.cpp
src/plugins/vm/VirtualMachineImpl.cpp
src/s4u/s4u_Comm.cpp
src/s4u/s4u_Exec.cpp
src/s4u/s4u_Io.cpp

index d89f061..2c6be0f 100644 (file)
@@ -42,9 +42,8 @@ public:
 
   ~Comm() override;
 
 
   ~Comm() override;
 
-  static xbt::signal<void(Comm const&, Actor const&)> on_sender_start;
-  static xbt::signal<void(Comm const&, Actor const&)> on_receiver_start;
-  static xbt::signal<void(Comm const&, Actor const&)> on_completion;
+  static xbt::signal<void(Comm const&, bool is_sender)> on_start;
+  static xbt::signal<void(Comm const&)> on_completion;
 
   /*! take a vector s4u::CommPtr and return when one of them is finished.
    * The return value is the rank of the first finished CommPtr. */
 
   /*! take a vector s4u::CommPtr and return when one of them is finished.
    * The return value is the rank of the first finished CommPtr. */
index 38289a8..d2a6a12 100644 (file)
@@ -46,8 +46,8 @@ public:
   Exec& operator=(Exec const&) = delete;
 
 #endif
   Exec& operator=(Exec const&) = delete;
 
 #endif
-  static xbt::signal<void(Exec const&, Actor const&)> on_start;
-  static xbt::signal<void(Exec const&, Actor const&)> on_completion;
+  static xbt::signal<void(Exec const&)> on_start;
+  static xbt::signal<void(Exec const&)> on_completion;
 
   Exec* start() override;
   /** @brief On sequential executions, returns the amount of flops that remain to be done; This cannot be used on
 
   Exec* start() override;
   /** @brief On sequential executions, returns the amount of flops that remain to be done; This cannot be used on
index f51282b..854bee6 100644 (file)
@@ -40,8 +40,8 @@ public:
   ~Io() override = default;
 #endif
 
   ~Io() override = default;
 #endif
 
-  static xbt::signal<void(Io const&, Actor const&)> on_start;
-  static xbt::signal<void(Io const&, Actor const&)> on_completion;
+  static xbt::signal<void(Io const&)> on_start;
+  static xbt::signal<void(Io const&)> on_completion;
 
   Io* start() override;
   Io* wait() override;
 
   Io* start() override;
   Io* wait() override;
index e9bb5c4..c893641 100644 (file)
@@ -465,32 +465,33 @@ void define_callbacks()
     });
     s4u::Actor::on_wake_up.connect(
         [](s4u::Actor const& actor) { Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->pop_event(); });
     });
     s4u::Actor::on_wake_up.connect(
         [](s4u::Actor const& actor) { Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->pop_event(); });
-    s4u::Exec::on_start.connect([](s4u::Exec const&, simgrid::s4u::Actor const& actor) {
-      Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->push_event("execute");
+    s4u::Exec::on_start.connect([](s4u::Exec const&) {
+      Container::by_name(instr_pid(*s4u::Actor::self()))->get_state("ACTOR_STATE")->push_event("execute");
     });
     });
-    s4u::Exec::on_completion.connect([](s4u::Exec const&, s4u::Actor const& actor) {
-      Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->pop_event();
+    s4u::Exec::on_completion.connect([](s4u::Exec const&) {
+      Container::by_name(instr_pid(*s4u::Actor::self()))->get_state("ACTOR_STATE")->pop_event();
     });
     });
-    s4u::Comm::on_sender_start.connect([](s4u::Comm const&, s4u::Actor const& actor) {
-      Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->push_event("send");
+    s4u::Comm::on_start.connect([](s4u::Comm const&, bool is_sender) {
+      Container::by_name(instr_pid(*s4u::Actor::self()))
+          ->get_state("ACTOR_STATE")
+          ->push_event(is_sender ? "send" : "receive");
     });
     });
-    s4u::Comm::on_receiver_start.connect([](s4u::Comm const&, s4u::Actor const& actor) {
-      Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->push_event("receive");
-    });
-    s4u::Comm::on_completion.connect([](s4u::Comm const&, s4u::Actor const& actor) {
-      Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->pop_event();
+    s4u::Comm::on_completion.connect([](s4u::Comm const&) {
+      Container::by_name(instr_pid(*s4u::Actor::self()))->get_state("ACTOR_STATE")->pop_event();
     });
     s4u::Actor::on_host_change.connect(on_actor_host_change);
   }
 
   if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing()) {
     });
     s4u::Actor::on_host_change.connect(on_actor_host_change);
   }
 
   if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing()) {
-    s4u::Exec::on_start.connect([](s4u::Exec const& exec, simgrid::s4u::Actor const& actor) {
-      Container::by_name(std::string("rank-") + std::to_string(actor.get_pid()))
+    s4u::Exec::on_start.connect([](s4u::Exec const& exec) {
+      Container::by_name(std::string("rank-") + std::to_string(s4u::Actor::self()->get_pid()))
           ->get_state("MPI_STATE")
           ->push_event("computing", new CpuTIData("compute", exec.get_cost()));
     });
           ->get_state("MPI_STATE")
           ->push_event("computing", new CpuTIData("compute", exec.get_cost()));
     });
-    s4u::Exec::on_completion.connect([](s4u::Exec const&, s4u::Actor const& actor) {
-      Container::by_name(std::string("rank-") + std::to_string(actor.get_pid()))->get_state("MPI_STATE")->pop_event();
+    s4u::Exec::on_completion.connect([](s4u::Exec const&) {
+      Container::by_name(std::string("rank-") + std::to_string(s4u::Actor::self()->get_pid()))
+          ->get_state("MPI_STATE")
+          ->pop_event();
     });
   }
 
     });
   }
 
index 9bed1db..5b3613b 100644 (file)
@@ -73,7 +73,7 @@ static void on_virtual_machine_creation(simgrid::vm::VirtualMachineImpl& vm)
   vm.extension_set<simgrid::vm::DirtyPageTrackingExt>(new simgrid::vm::DirtyPageTrackingExt());
 }
 
   vm.extension_set<simgrid::vm::DirtyPageTrackingExt>(new simgrid::vm::DirtyPageTrackingExt());
 }
 
-static void on_exec_creation(simgrid::s4u::Exec const& e, simgrid::s4u::Actor const&)
+static void on_exec_creation(simgrid::s4u::Exec const& e)
 {
   auto exec                        = static_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
   const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
 {
   auto exec                        = static_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
   const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
@@ -87,7 +87,7 @@ static void on_exec_creation(simgrid::s4u::Exec const& e, simgrid::s4u::Actor co
   }
 }
 
   }
 }
 
-static void on_exec_completion(simgrid::s4u::Exec const& e, simgrid::s4u::Actor const&)
+static void on_exec_completion(simgrid::s4u::Exec const& e)
 {
   auto exec                        = static_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
   const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
 {
   auto exec                        = static_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
   const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
index edd21d2..4378b2b 100644 (file)
@@ -295,11 +295,11 @@ public:
         task_id           = 0;
       }
     });
         task_id           = 0;
       }
     });
-    simgrid::s4u::Exec::on_start.connect([this](simgrid::s4u::Exec const& activity, simgrid::s4u::Actor const&) {
+    simgrid::s4u::Exec::on_start.connect([this](simgrid::s4u::Exec const& activity) {
       if (activity.get_host() == get_host())
         pre_task();
     });
       if (activity.get_host() == get_host())
         pre_task();
     });
-    simgrid::s4u::Exec::on_completion.connect([this](simgrid::s4u::Exec const& activity, simgrid::s4u::Actor const&) {
+    simgrid::s4u::Exec::on_completion.connect([this](simgrid::s4u::Exec const& activity) {
       // For more than one host (not yet supported), we can access the host via
       // simcalls_.front()->issuer->get_iface()->get_host()
       if (activity.get_host() == get_host() && iteration_running) {
       // For more than one host (not yet supported), we can access the host via
       // simcalls_.front()->issuer->get_iface()->get_host()
       if (activity.get_host() == get_host() && iteration_running) {
index 06086ce..a09a39f 100644 (file)
@@ -551,7 +551,7 @@ void sg_host_energy_plugin_init()
   // that the next trigger would be the 2nd compute, hence ignoring the idle time
   // during the recv call. By updating at the beginning of a compute, we can
   // fix that. (If the cpu is not idle, this is not required.)
   // that the next trigger would be the 2nd compute, hence ignoring the idle time
   // during the recv call. By updating at the beginning of a compute, we can
   // fix that. (If the cpu is not idle, this is not required.)
-  simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Exec const& activity, simgrid::s4u::Actor const&) {
+  simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Exec const& activity) {
     if (activity.get_host_number() == 1) { // We only run on one host
       simgrid::s4u::Host* host         = activity.get_host();
       const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
     if (activity.get_host_number() == 1) { // We only run on one host
       simgrid::s4u::Host* host         = activity.get_host();
       const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
index 4011e98..c8b03e5 100644 (file)
@@ -231,7 +231,7 @@ void sg_host_load_plugin_init()
     host.extension_set(new HostLoad(&host));
   });
 
     host.extension_set(new HostLoad(&host));
   });
 
-  simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Exec const& activity, simgrid::s4u::Actor const&) {
+  simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Exec const& activity) {
     if (activity.get_host_number() == 1) { // We only run on one host
       simgrid::s4u::Host* host         = activity.get_host();
       const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
     if (activity.get_host_number() == 1) { // We only run on one host
       simgrid::s4u::Host* host         = activity.get_host();
       const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
@@ -247,7 +247,7 @@ void sg_host_load_plugin_init()
       XBT_WARN("HostLoad plugin currently does not support executions on several hosts");
     }
   });
       XBT_WARN("HostLoad plugin currently does not support executions on several hosts");
     }
   });
-  simgrid::s4u::Exec::on_completion.connect([](simgrid::s4u::Exec const& activity, simgrid::s4u::Actor const&) {
+  simgrid::s4u::Exec::on_completion.connect([](simgrid::s4u::Exec const& activity) {
     if (activity.get_host_number() == 1) { // We only run on one host
       simgrid::s4u::Host* host         = activity.get_host();
       const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
     if (activity.get_host_number() == 1) { // We only run on one host
       simgrid::s4u::Host* host         = activity.get_host();
       const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
index 640d91d..20a7dce 100644 (file)
@@ -55,7 +55,7 @@ static void host_state_change(s4u::Host const& host)
   }
 }
 
   }
 }
 
-static void add_active_exec(s4u::Exec const& task, s4u::Actor const&)
+static void add_active_exec(s4u::Exec const& task)
 {
   const s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
   if (vm != nullptr) {
 {
   const s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
   if (vm != nullptr) {
@@ -65,7 +65,7 @@ static void add_active_exec(s4u::Exec const& task, s4u::Actor const&)
   }
 }
 
   }
 }
 
-static void remove_active_exec(s4u::Exec const& task, s4u::Actor const&)
+static void remove_active_exec(s4u::Exec const& task)
 {
   const s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
   if (vm != nullptr) {
 {
   const s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
   if (vm != nullptr) {
index 7f77ab4..55a79e5 100644 (file)
@@ -16,9 +16,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_comm, s4u_activity, "S4U asynchronous commun
 
 namespace simgrid {
 namespace s4u {
 
 namespace simgrid {
 namespace s4u {
-xbt::signal<void(Comm const&, Actor const&)> Comm::on_sender_start;
-xbt::signal<void(Comm const&, Actor const&)> Comm::on_receiver_start;
-xbt::signal<void(Comm const&, Actor const&)> Comm::on_completion;
+xbt::signal<void(Comm const&, bool is_sender)> Comm::on_start;
+xbt::signal<void(Comm const&)> Comm::on_completion;
 
 Comm::~Comm()
 {
 
 Comm::~Comm()
 {
@@ -119,12 +118,12 @@ Comm* Comm::start()
              "You cannot use %s() once your communication started (not implemented)", __FUNCTION__);
 
   if (src_buff_ != nullptr) { // Sender side
              "You cannot use %s() once your communication started (not implemented)", __FUNCTION__);
 
   if (src_buff_ != nullptr) { // Sender side
-    on_sender_start(*this, *Actor::self());
+    on_start(*this, true /* is_sender*/);
     pimpl_ = simcall_comm_isend(sender_, mailbox_->get_impl(), remains_, rate_, src_buff_, src_buff_size_, match_fun_,
                                 clean_fun_, copy_data_function_, get_user_data(), detached_);
   } else if (dst_buff_ != nullptr) { // Receiver side
     xbt_assert(not detached_, "Receive cannot be detached");
     pimpl_ = simcall_comm_isend(sender_, mailbox_->get_impl(), remains_, rate_, src_buff_, src_buff_size_, match_fun_,
                                 clean_fun_, copy_data_function_, get_user_data(), detached_);
   } else if (dst_buff_ != nullptr) { // Receiver side
     xbt_assert(not detached_, "Receive cannot be detached");
-    on_receiver_start(*this, *Actor::self());
+    on_start(*this, false /*is_sender*/);
     pimpl_ = simcall_comm_irecv(receiver_, mailbox_->get_impl(), dst_buff_, &dst_buff_size_, match_fun_,
                                 copy_data_function_, get_user_data(), rate_);
 
     pimpl_ = simcall_comm_irecv(receiver_, mailbox_->get_impl(), dst_buff_, &dst_buff_size_, match_fun_,
                                 copy_data_function_, get_user_data(), rate_);
 
@@ -160,12 +159,12 @@ Comm* Comm::wait_for(double timeout)
     case State::INITED:
     case State::STARTING: // It's not started yet. Do it in one simcall
       if (src_buff_ != nullptr) {
     case State::INITED:
     case State::STARTING: // It's not started yet. Do it in one simcall
       if (src_buff_ != nullptr) {
-        on_sender_start(*this, *Actor::self());
+        on_start(*this, true /*is_sender*/);
         simcall_comm_send(sender_, mailbox_->get_impl(), remains_, rate_, src_buff_, src_buff_size_, match_fun_,
                           copy_data_function_, get_user_data(), timeout);
 
       } else { // Receiver
         simcall_comm_send(sender_, mailbox_->get_impl(), remains_, rate_, src_buff_, src_buff_size_, match_fun_,
                           copy_data_function_, get_user_data(), timeout);
 
       } else { // Receiver
-        on_receiver_start(*this, *Actor::self());
+        on_start(*this, false /*is_sender*/);
         simcall_comm_recv(receiver_, mailbox_->get_impl(), dst_buff_, &dst_buff_size_, match_fun_, copy_data_function_,
                           get_user_data(), timeout, rate_);
       }
         simcall_comm_recv(receiver_, mailbox_->get_impl(), dst_buff_, &dst_buff_size_, match_fun_, copy_data_function_,
                           get_user_data(), timeout, rate_);
       }
@@ -185,7 +184,7 @@ Comm* Comm::wait_for(double timeout)
     default:
       THROW_IMPOSSIBLE;
   }
     default:
       THROW_IMPOSSIBLE;
   }
-  on_completion(*this, *Actor::self());
+  on_completion(*this);
   return this;
 }
 
   return this;
 }
 
index 704506a..9bbf840 100644 (file)
@@ -14,8 +14,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_exec, s4u_activity, "S4U asynchronous execut
 
 namespace simgrid {
 namespace s4u {
 
 namespace simgrid {
 namespace s4u {
-xbt::signal<void(Exec const&, Actor const&)> Exec::on_start;
-xbt::signal<void(Exec const&, Actor const&)> Exec::on_completion;
+xbt::signal<void(Exec const&)> Exec::on_start;
+xbt::signal<void(Exec const&)> Exec::on_completion;
 
 Exec::Exec()
 {
 
 Exec::Exec()
 {
@@ -35,7 +35,7 @@ Exec* Exec::wait_for(double timeout)
   kernel::actor::ActorImpl* issuer = Actor::self()->get_impl();
   kernel::actor::simcall_blocking<void>([this, issuer, timeout] { this->get_impl()->wait_for(issuer, timeout); });
   state_ = State::FINISHED;
   kernel::actor::ActorImpl* issuer = Actor::self()->get_impl();
   kernel::actor::simcall_blocking<void>([this, issuer, timeout] { this->get_impl()->wait_for(issuer, timeout); });
   state_ = State::FINISHED;
-  on_completion(*this, *Actor::self());
+  on_completion(*this);
   this->release_dependencies();
   return this;
 }
   this->release_dependencies();
   return this;
 }
@@ -185,7 +185,7 @@ Exec* Exec::start()
     pimpl_->suspend();
 
   state_ = State::STARTED;
     pimpl_->suspend();
 
   state_ = State::STARTED;
-  on_start(*this, *Actor::self());
+  on_start(*this);
   return this;
 }
 
   return this;
 }
 
index acd9a0d..736336a 100644 (file)
@@ -12,8 +12,8 @@
 
 namespace simgrid {
 namespace s4u {
 
 namespace simgrid {
 namespace s4u {
-xbt::signal<void(Io const&, Actor const&)> Io::on_start;
-xbt::signal<void(Io const&, Actor const&)> Io::on_completion;
+xbt::signal<void(Io const&)> Io::on_start;
+xbt::signal<void(Io const&)> Io::on_completion;
 
 Io::Io(sg_disk_t disk, sg_size_t size, OpType type) : disk_(disk), size_(size), type_(type)
 {
 
 Io::Io(sg_disk_t disk, sg_size_t size, OpType type) : disk_(disk), size_(size), type_(type)
 {
@@ -51,7 +51,7 @@ Io* Io::start()
     pimpl_->suspend();
 
   state_ = State::STARTED;
     pimpl_->suspend();
 
   state_ = State::STARTED;
-  on_start(*this, *Actor::self());
+  on_start(*this);
   return this;
 }
 
   return this;
 }
 
@@ -77,7 +77,7 @@ Io* Io::wait_for(double timeout)
   state_ = State::FINISHED;
   this->release_dependencies();
 
   state_ = State::FINISHED;
   this->release_dependencies();
 
-  on_completion(*this, *Actor::self());
+  on_completion(*this);
   return this;
 }
 
   return this;
 }