Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use signals for smpi tracing of execs
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 27 Apr 2020 11:28:14 +0000 (13:28 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 27 Apr 2020 11:28:14 +0000 (13:28 +0200)
src/instr/instr_platform.cpp
src/instr/instr_smpi.hpp
src/smpi/internals/instr_smpi.cpp
src/smpi/internals/smpi_bench.cpp

index 8885781..b2d214c 100644 (file)
@@ -492,6 +492,17 @@ void define_callbacks()
     s4u::Actor::on_host_change.connect(on_actor_host_change);
   }
 
+  if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing()) {
+    s4u::Exec::on_start.connect([](simgrid::s4u::Actor const& actor, s4u::Exec const& exec) {
+      Container::by_name(std::string("rank-") + std::to_string(actor.get_pid()))
+          ->get_state("MPI_STATE")
+          ->push_event("computing", new CpuTIData("compute", exec.get_cost()));
+    });
+    s4u::Exec::on_completion.connect([](s4u::Actor const& actor, s4u::Exec const&) {
+      Container::by_name(std::string("rank-") + std::to_string(actor.get_pid()))->get_state("MPI_STATE")->pop_event();
+    });
+  }
+
   if (TRACE_vm_is_enabled()) {
     s4u::Host::on_creation.connect(on_vm_creation);
     s4u::VirtualMachine::on_start.connect([](s4u::VirtualMachine const& vm) {
index 2a24491..1a9ecf9 100644 (file)
@@ -14,8 +14,6 @@
 XBT_PRIVATE container_t smpi_container(int rank);
 XBT_PRIVATE void TRACE_smpi_setup_container(int rank, const_sg_host_t host);
 
-XBT_PRIVATE void TRACE_smpi_computing_out(int rank);
-XBT_PRIVATE void TRACE_smpi_computing_in(int rank, double amount);
 XBT_PRIVATE void TRACE_smpi_sleeping_out(int rank);
 XBT_PRIVATE void TRACE_smpi_sleeping_in(int rank, double duration);
 XBT_PRIVATE void TRACE_smpi_comm_in(int rank, const char* operation, simgrid::instr::TIData* extra);
index dd5b325..5dba5c2 100644 (file)
@@ -180,20 +180,6 @@ void TRACE_smpi_init(int rank, std::string calling_func)
 #endif
 }
 
-void TRACE_smpi_computing_in(int rank, double amount)
-{
-  if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing())
-    smpi_container(rank)
-        ->get_state("MPI_STATE")
-        ->push_event("computing", new simgrid::instr::CpuTIData("compute", amount));
-}
-
-void TRACE_smpi_computing_out(int rank)
-{
-  if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing())
-    smpi_container(rank)->get_state("MPI_STATE")->pop_event();
-}
-
 void TRACE_smpi_sleeping_in(int rank, double duration)
 {
   if (TRACE_smpi_is_enabled() && TRACE_smpi_is_sleeping())
index 6eb4ab1..c28f90a 100644 (file)
@@ -47,27 +47,16 @@ void private_execute_flops(double flops) {
   smpi_switch_data_segment(simgrid::s4u::Actor::self());
 }
 
-void smpi_execute_flops(double flops) {
-  int rank     = simgrid::s4u::this_actor::get_pid();
-  TRACE_smpi_computing_in(rank, flops);
-
+void smpi_execute_flops(double flops)
+{
   private_execute_flops(flops);
-
-  TRACE_smpi_computing_out(rank);
 }
 
 void smpi_execute(double duration)
 {
   if (duration >= smpi_cfg_cpu_thresh()) {
     XBT_DEBUG("Sleep for %g to handle real computation time", duration);
-    double flops = duration * smpi_cfg_host_speed();
-    int rank     = simgrid::s4u::this_actor::get_pid();
-    TRACE_smpi_computing_in(rank, flops);
-
-    private_execute_flops(flops);
-
-    TRACE_smpi_computing_out(rank);
-
+    private_execute_flops(duration * smpi_cfg_host_speed());
   } else {
     XBT_DEBUG("Real computation took %g while option smpi/cpu-threshold is set to %g => ignore it", duration,
               smpi_cfg_cpu_thresh());