Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
new callback: s4u::onTimeAdvance
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 15 Feb 2017 15:31:53 +0000 (16:31 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 15 Feb 2017 15:31:53 +0000 (16:31 +0100)
ChangeLog
include/simgrid/s4u/engine.hpp
src/s4u/s4u_engine.cpp
src/surf/surf_c_bindings.cpp

index b84978d..eb0827b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,6 +19,7 @@ SimGrid (3.15) UNRELEASED; urgency=low
  - New callbacks:
    - s4u::onPlatformCreated: right before the simulation starts
    - s4u::onSimulationEnd: right after the main simulation loop
+   - s4u::onTimeAdvance: right after a clock change (time is discrete)
    - s4u::Host::onSpeedChange: when the pstate is changed, or when an
      event from the availability_file changes the avail speed.
  - Links are now usable from s4u
index 71d5df2..413f7ef 100644 (file)
@@ -105,13 +105,15 @@ private:
   static s4u::Engine *instance_;
 };
 
-/** Callback called when the platform is created (ie, the xml file parsed),
- * right before the actual simulation starts.
- */
+/** Callback fired when the platform is created (ie, the xml file parsed),
+ * right before the actual simulation starts. */
 extern XBT_PRIVATE xbt::signal<void()> onPlatformCreated;
 
-/** Callback called when the main simulation loop ends, just before MSG_run (or similar) ends */
+/** Callback fired when the main simulation loop ends, just before MSG_run (or similar) ends */
 extern XBT_PRIVATE xbt::signal<void()> onSimulationEnd;
+
+/** Callback fired when the time jumps into the future */
+extern XBT_PRIVATE xbt::signal<void(double)> onTimeAdvance;
 }} // namespace simgrid::s4u
 
 #endif /* SIMGRID_S4U_ENGINE_HPP */
index a39f436..085e4e6 100644 (file)
@@ -25,6 +25,7 @@ namespace simgrid {
 namespace s4u {
 xbt::signal<void()> onPlatformCreated;
 xbt::signal<void()> onSimulationEnd;
+xbt::signal<void(double)> onTimeAdvance;
 
 Engine *Engine::instance_ = nullptr; /* That singleton is awful, but I don't see no other solution right now. */
 
index 35b61cb..1b00946 100644 (file)
@@ -4,6 +4,7 @@
 /* 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 "simgrid/s4u/engine.hpp"
 #include "src/instr/instr_private.h"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
 
@@ -120,7 +121,7 @@ double surf_solve(double max_date)
   /* FIXME: Moved this test to here to avoid stopping simulation if there are actions running on cpus and all cpus are with availability = 0.
    * This may cause an infinite loop if one cpu has a trace with periodicity = 0 and the other a trace with periodicity > 0.
    * The options are: all traces with same periodicity(0 or >0) or we need to change the way how the events are managed */
-  if (time_delta == -1.0) {
+  if (time_delta 0) {
     XBT_DEBUG("No next event at all. Bail out now.");
     return -1.0;
   }
@@ -134,6 +135,7 @@ double surf_solve(double max_date)
   for (auto model : *all_existing_models) {
     model->updateActionsState(NOW, time_delta);
   }
+  simgrid::s4u::onTimeAdvance(time_delta);
 
   TRACE_paje_dump_buffer (0);