Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Give users a way to debug their barriers
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 19 Mar 2022 19:12:48 +0000 (20:12 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 19 Mar 2022 19:13:45 +0000 (20:13 +0100)
include/simgrid/s4u/Barrier.hpp
src/kernel/activity/BarrierImpl.hpp
src/s4u/s4u_Barrier.cpp

index 1e5e589..547f5d8 100644 (file)
@@ -34,6 +34,8 @@ public:
   static BarrierPtr create(unsigned int expected_actors);
   /** Blocks into the barrier. Every waiting actors will be unlocked once the expected amount of actors reaches the barrier */
   int wait();
+  /** Returns some debug information about the barrier */
+  std::string to_string();
 
 #ifndef DOXYGEN
   /* refcounting */
index e34ba73..b214e5f 100644 (file)
@@ -74,6 +74,11 @@ public:
   }
 
   s4u::Barrier& get_iface() { return piface_; }
+
+  std::string to_string()
+  {
+    return xbt::string_printf("Barrier %d: %zu of %u", id_, ongoing_acquisitions_.size(), expected_actors_);
+  }
 };
 } // namespace activity
 } // namespace kernel
index 8aa46d2..297109e 100644 (file)
@@ -53,6 +53,11 @@ int Barrier::wait()
   }
 }
 
+std::string Barrier::to_string()
+{
+  return pimpl_->to_string();
+}
+
 void intrusive_ptr_add_ref(Barrier* barrier)
 {
   intrusive_ptr_add_ref(barrier->pimpl_);