Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Deprecate SIMIX_get_clock().
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 27 May 2021 08:35:46 +0000 (10:35 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 27 May 2021 09:43:13 +0000 (11:43 +0200)
Use simgrid_get_clock() or Engine::get_clock().

25 files changed:
ChangeLog
doc/doxygen/uhood_switch.doc
include/simgrid/chrono.hpp
include/simgrid/s4u/ConditionVariable.hpp
include/simgrid/simix.h
src/instr/instr_config.cpp
src/instr/instr_paje_containers.cpp
src/instr/instr_paje_events.cpp
src/instr/instr_paje_events.hpp
src/instr/instr_platform.cpp
src/kernel/activity/CommImpl.cpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/IoImpl.cpp
src/kernel/actor/ActorImpl.cpp
src/kernel/timer/Timer.cpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_ConditionVariable.cpp
src/s4u/s4u_Engine.cpp
src/simix/smx_global.cpp
src/smpi/colls/smpi_automatic_selector.cpp
src/smpi/internals/smpi_actor.cpp
src/smpi/internals/smpi_bench.cpp
src/smpi/internals/smpi_utils.cpp
src/surf/sg_platf.cpp
teshsuite/kernel/stack-overflow/stack-overflow.cpp

index 1b9c21c..44d6cd4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,8 +3,8 @@
 SimGrid (3.27.1) NOT RELEASED YET (v3.28 expected June 21. 2021, 03:32 UTC)
 
 New features:
- - New plugin: Producer-Consumer with monitor. Just requires to include the 
-   include/simgrid/plugins/ProducerConsumer.hpp header to be used. See the 
+ - New plugin: Producer-Consumer with monitor. Just requires to include the
+   include/simgrid/plugins/ProducerConsumer.hpp header to be used. See the
    associated example (examples/cpp/plugin-prodcons).
 
 S4U:
@@ -19,6 +19,9 @@ SMPI:
 LUA:
  - Lua platform files are deprecated. Their support will be dropped after v3.31.
 
+Simix:
+ - Legacy functions deprecated in this release: SIMIX_get_clock(), SIMIX_run().
+
 XBT:
  - xbt_assert is not disabled anymore, even when built with enable_debug=off.
 
index 4521722..3f3dc80 100644 (file)
@@ -747,7 +747,7 @@ bool ConditionVariable::wait_for(std::unique_lock<Mutex>& lock,
   double duration, P pred)
 {
   return this->wait_until(lock,
-    SIMIX_get_clock() + duration, std::move(pred));
+    simgrid::s4u::Engine::get_clock() + duration, std::move(pred));
 }
 @endcode
 
index 2410d66..84bbd2b 100644 (file)
@@ -15,7 +15,7 @@
 #include <chrono>
 #include <ratio>
 
-#include <simgrid/simix.h>
+#include <simgrid/engine.h>
 
 namespace simgrid {
 
@@ -44,10 +44,7 @@ public:
   using duration   = std::chrono::duration<rep, period>;
   using time_point = std::chrono::time_point<SimulationClock, duration>;
   static constexpr bool is_steady = true;
-  static time_point now()
-  {
-    return time_point(duration(SIMIX_get_clock()));
-  }
+  static time_point now() { return time_point(duration(simgrid_get_clock())); }
 };
 
 /** Default duration for simulated time */
index de52bde..184c4c9 100644 (file)
@@ -9,6 +9,7 @@
 #include <simgrid/forward.h>
 
 #include <simgrid/chrono.hpp>
+#include <simgrid/s4u/Engine.hpp>
 #include <simgrid/s4u/Mutex.hpp>
 
 #include <future>
@@ -74,7 +75,7 @@ public:
   /// As long as the predicate is false, wait for the given amount of seconds (specified as a plain double)
   template <class P> bool wait_for(const std::unique_lock<s4u::Mutex>& lock, double duration, P pred)
   {
-    return this->wait_until(lock, SIMIX_get_clock() + duration, std::move(pred));
+    return this->wait_until(lock, Engine::get_clock() + duration, std::move(pred));
   }
 
   // Wait function taking a C++ style time:
index 89daa70..2f805f2 100644 (file)
@@ -46,7 +46,7 @@ XBT_PUBLIC void SIMIX_set_maestro(void (*code)(void*), void* data);
 
 /* Simulation execution */
 XBT_ATTRIB_DEPRECATED_v332("Please use EngineImpl:run()") XBT_PUBLIC void SIMIX_run();
-XBT_PUBLIC double SIMIX_get_clock();
+XBT_ATTRIB_DEPRECATED_v332("Please use simgrid_get_clock() or Engine::get_clock()") XBT_PUBLIC double SIMIX_get_clock();
 
 XBT_ATTRIB_DEPRECATED_v329("Please use simgrid::kernel::timer::Timer::set()") XBT_PUBLIC smx_timer_t
     SIMIX_timer_set(double date, void (*function)(void*), void* arg);
index 65d5a63..a8df9b1 100644 (file)
@@ -227,7 +227,7 @@ xbt::signal<void(EntityValue const&)> EntityValue::on_creation;
 
 static void on_container_creation_paje(const Container& c)
 {
-  double timestamp = SIMIX_get_clock();
+  double timestamp = simgrid_get_clock();
   std::stringstream stream;
 
   XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, static_cast<unsigned>(PajeEventType::CreateContainer),
@@ -250,7 +250,7 @@ static void on_container_destruction_paje(const Container& c)
   // trace my destruction, but not if user requests so or if the container is root
   if (not trace_disable_destroy && &c != Container::get_root()) {
     std::stringstream stream;
-    double timestamp = SIMIX_get_clock();
+    double timestamp = simgrid_get_clock();
 
     XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, static_cast<unsigned>(PajeEventType::DestroyContainer),
               timestamp);
@@ -265,7 +265,7 @@ static void on_container_destruction_paje(const Container& c)
 static void on_container_creation_ti(const Container& c)
 {
   XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, static_cast<unsigned>(PajeEventType::CreateContainer),
-            SIMIX_get_clock());
+            simgrid_get_clock());
   // if we are in the mode with only one file
   static std::ofstream* ti_unique_file = nullptr;
   static double prefix                 = 0.0;
index f7ae0b5..f97d975 100644 (file)
@@ -81,7 +81,7 @@ Container::~Container()
   all_containers_.erase(name_);
 
   // obligation to dump previous events because they might reference the container that is about to be destroyed
-  last_timestamp_to_dump = SIMIX_get_clock();
+  last_timestamp_to_dump = simgrid_get_clock();
   dump_buffer(true);
 
   on_destruction(*this);
index d32bb12..78ac8a9 100644 (file)
@@ -26,7 +26,7 @@ PajeEvent::~PajeEvent()
 }
 
 StateEvent::StateEvent(Container* container, Type* type, PajeEventType event_type, EntityValue* value, TIData* extra)
-    : PajeEvent::PajeEvent(container, type, SIMIX_get_clock(), event_type), value(value), extra_(extra)
+    : PajeEvent::PajeEvent(container, type, simgrid_get_clock(), event_type), value(value), extra_(extra)
 {
 #if HAVE_SMPI
   if (smpi_cfg_trace_call_location()) {
index bfb79da..17aab29 100644 (file)
@@ -100,7 +100,7 @@ class LinkEvent : public PajeEvent {
 public:
   LinkEvent(Container* container, Type* type, PajeEventType event_type, Container* sourceContainer,
             const std::string& value, const std::string& key, size_t size = static_cast<size_t>(-1))
-      : PajeEvent(container, type, SIMIX_get_clock(), event_type)
+      : PajeEvent(container, type, simgrid_get_clock(), event_type)
       , endpoint_(sourceContainer)
       , value_(value)
       , key_(key)
index 908d7b8..3d81743 100644 (file)
@@ -344,13 +344,13 @@ static void on_action_state_change(kernel::resource::Action const& action,
 
     if (cpu != nullptr)
       resource_set_utilization("HOST", "speed_used", cpu->get_cname(), action.get_category(), value,
-                               action.get_last_update(), SIMIX_get_clock() - action.get_last_update());
+                               action.get_last_update(), simgrid_get_clock() - action.get_last_update());
 
     const kernel::resource::LinkImpl* link = dynamic_cast<kernel::resource::LinkImpl*>(resource);
 
     if (link != nullptr)
       resource_set_utilization("LINK", "bandwidth_used", link->get_cname(), action.get_category(), value,
-                               action.get_last_update(), SIMIX_get_clock() - action.get_last_update());
+                               action.get_last_update(), simgrid_get_clock() - action.get_last_update());
   }
 }
 
index 7f8b8c3..edd3e5f 100644 (file)
@@ -453,7 +453,7 @@ void CommImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<CommImpl
   if (timeout < 0.0) {
     issuer->simcall_.timeout_cb_ = nullptr;
   } else {
-    issuer->simcall_.timeout_cb_ = timer::Timer::set(SIMIX_get_clock() + timeout, [issuer, comms]() {
+    issuer->simcall_.timeout_cb_ = timer::Timer::set(s4u::Engine::get_clock() + timeout, [issuer, comms]() {
       // FIXME: Vector `comms' is copied here. Use a reference once its lifetime is extended (i.e. when the simcall is
       // modernized).
       issuer->simcall_.timeout_cb_ = nullptr;
index c1d2583..a687d1d 100644 (file)
@@ -7,6 +7,7 @@
 #include "simgrid/Exception.hpp"
 #include "simgrid/kernel/routing/NetPoint.hpp"
 #include "simgrid/modelchecker.h"
+#include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Exec.hpp"
 #include "src/kernel/actor/SimcallObserver.hpp"
 #include "src/mc/mc_replay.hpp"
@@ -241,7 +242,7 @@ void ExecImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<ExecImpl
   if (timeout < 0.0) {
     issuer->simcall_.timeout_cb_ = nullptr;
   } else {
-    issuer->simcall_.timeout_cb_ = timer::Timer::set(SIMIX_get_clock() + timeout, [issuer, &execs]() {
+    issuer->simcall_.timeout_cb_ = timer::Timer::set(s4u::Engine::get_clock() + timeout, [issuer, &execs]() {
       issuer->simcall_.timeout_cb_ = nullptr;
       for (auto* exec : execs)
         exec->unregister_simcall(&issuer->simcall_);
index 034099d..6f77d52 100644 (file)
@@ -7,6 +7,7 @@
 #include "simgrid/Exception.hpp"
 #include "simgrid/kernel/resource/Action.hpp"
 #include "simgrid/kernel/routing/NetPoint.hpp"
+#include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Io.hpp"
 #include "src/kernel/actor/SimcallObserver.hpp"
@@ -152,7 +153,7 @@ void IoImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<IoImpl*>&
   if (timeout < 0.0) {
     issuer->simcall_.timeout_cb_ = nullptr;
   } else {
-    issuer->simcall_.timeout_cb_ = timer::Timer::set(SIMIX_get_clock() + timeout, [issuer, &ios]() {
+    issuer->simcall_.timeout_cb_ = timer::Timer::set(s4u::Engine::get_clock() + timeout, [issuer, &ios]() {
       issuer->simcall_.timeout_cb_ = nullptr;
       for (auto* io : ios)
         io->unregister_simcall(&issuer->simcall_);
index edfd15c..78f5be7 100644 (file)
@@ -260,7 +260,7 @@ void ActorImpl::kill_all() const
 
 void ActorImpl::set_kill_time(double kill_time)
 {
-  if (kill_time <= SIMIX_get_clock())
+  if (kill_time <= s4u::Engine::get_clock())
     return;
   XBT_DEBUG("Set kill time %f for actor %s@%s", kill_time, get_cname(), host_->get_cname());
   kill_timer_ = timer::Timer::set(kill_time, [this] {
index df005ca..c0f475f 100644 (file)
@@ -5,6 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <simgrid/kernel/Timer.hpp>
+#include <simgrid/s4u/Engine.hpp>
 #include <simgrid/simix.h>
 
 namespace simgrid {
@@ -29,7 +30,7 @@ void Timer::remove()
 bool Timer::execute_all()
 {
   bool result = false;
-  while (not kernel_timers().empty() && SIMIX_get_clock() >= kernel_timers().top().first) {
+  while (not kernel_timers().empty() && s4u::Engine::get_clock() >= kernel_timers().top().first) {
     result = true;
     // FIXME: make the timers being real callbacks (i.e. provide dispatchers that read and expand the args)
     Timer* timer = kernel_timers().top().second;
index c0666ad..35b7070 100644 (file)
@@ -352,7 +352,7 @@ void yield()
 
 XBT_PUBLIC void sleep_until(double wakeup_time)
 {
-  double now = SIMIX_get_clock();
+  double now = s4u::Engine::get_clock();
   if (wakeup_time > now)
     sleep_for(wakeup_time - now);
 }
index 7244cf8..cfced69 100644 (file)
@@ -66,7 +66,7 @@ std::cv_status s4u::ConditionVariable::wait_for(const std::unique_lock<Mutex>& l
 
 std::cv_status ConditionVariable::wait_until(const std::unique_lock<Mutex>& lock, double timeout_time)
 {
-  double now = SIMIX_get_clock();
+  double now = Engine::get_clock();
   double timeout;
   if (timeout_time < now)
     timeout = 0.0;
index 6cdb275..9898b81 100644 (file)
@@ -16,6 +16,7 @@
 #include "simgrid/simix.h"
 #include "src/instr/instr_private.hpp"
 #include "src/kernel/EngineImpl.hpp"
+#include "src/mc/mc_replay.hpp"
 #include "src/surf/network_interface.hpp"
 #include "surf/surf.hpp" // routing_platf. FIXME:KILLME. SOON
 #include <simgrid/Exception.hpp>
@@ -80,7 +81,11 @@ void Engine::shutdown()
 
 double Engine::get_clock()
 {
-  return SIMIX_get_clock();
+  if (MC_is_active() || MC_record_replay_is_active()) {
+    return MC_process_clock_get(SIMIX_process_self());
+  } else {
+    return surf_get_clock();
+  }
 }
 
 void Engine::add_model(std::shared_ptr<kernel::resource::Model> model,
index 40055f0..82e38cc 100644 (file)
@@ -201,7 +201,7 @@ void SIMIX_clean()
   smx_cleaned = true;
   XBT_DEBUG("SIMIX_clean called. Simulation's over.");
   auto* engine = simgrid::kernel::EngineImpl::get_instance();
-  if (engine->has_actors_to_run() && SIMIX_get_clock() <= 0.0) {
+  if (engine->has_actors_to_run() && simgrid::s4u::Engine::get_clock() <= 0.0) {
     XBT_CRITICAL("   ");
     XBT_CRITICAL("The time is still 0, and you still have processes ready to run.");
     XBT_CRITICAL("It seems that you forgot to run the simulation that you setup.");
@@ -241,13 +241,9 @@ void SIMIX_clean()
  *
  * @return Return the clock.
  */
-double SIMIX_get_clock()
+double SIMIX_get_clock() // XBT_ATTRIB_DEPRECATED_v332
 {
-  if (MC_is_active() || MC_record_replay_is_active()) {
-    return MC_process_clock_get(SIMIX_process_self());
-  } else {
-    return surf_get_clock();
-  }
+  return simgrid::s4u::Engine::get_clock();
 }
 
 void SIMIX_run() // XBT_ATTRIB_DEPRECATED_v332
index 4a8b5ab..a84cd1e 100644 (file)
@@ -7,6 +7,7 @@
 #include <exception>
 
 #include "colls_private.hpp"
+#include "simgrid/s4u/Engine.hpp"
 #include "src/smpi/include/smpi_actor.hpp"
 
 //attempt to do a quick autotuning version of the collective,
                                                                                                                        \
         std::string cont_name = std::string("rank-" + std::to_string(simgrid::s4u::this_actor::get_pid()));            \
         type->add_entity_value(desc->name, "1.0 1.0 1.0");                                                             \
-        new simgrid::instr::NewEvent(SIMIX_get_clock(), simgrid::instr::Container::by_name(cont_name), type,           \
-                                     type->get_entity_value(desc->name));                                              \
+        new simgrid::instr::NewEvent(simgrid::s4u::Engine::get_clock(), simgrid::instr::Container::by_name(cont_name), \
+                                     type, type->get_entity_value(desc->name));                                        \
       }                                                                                                                \
-      time1 = SIMIX_get_clock();                                                                                       \
+      time1 = simgrid::s4u::Engine::get_clock();                                                                       \
       try {                                                                                                            \
         ((int(*) args)desc->coll) args2;                                                                               \
       } catch (std::exception & ex) {                                                                                  \
         continue;                                                                                                      \
       }                                                                                                                \
-      time2   = SIMIX_get_clock();                                                                                     \
+      time2   = simgrid::s4u::Engine::get_clock();                                                                     \
       buf_out = time2 - time1;                                                                                         \
       reduce__default((void*)&buf_out, (void*)&buf_in, 1, MPI_DOUBLE, MPI_MAX, 0, comm);                               \
       if (time2 - time1 < time_min) {                                                                                  \
index f18b476..bdb72ce 100644 (file)
@@ -5,11 +5,12 @@
 
 #include "src/smpi/include/smpi_actor.hpp"
 #include "mc/mc.h"
+#include "simgrid/s4u/Engine.hpp"
+#include "simgrid/s4u/Mutex.hpp"
 #include "smpi_comm.hpp"
 #include "smpi_info.hpp"
 #include "src/mc/mc_replay.hpp"
 #include "src/simix/smx_private.hpp"
-#include "simgrid/s4u/Mutex.hpp"
 
 #if HAVE_PAPI
 #include "papi.h"
@@ -164,12 +165,12 @@ xbt_os_timer_t ActorExt::timer()
 
 void ActorExt::simulated_start()
 {
-  simulated_ = SIMIX_get_clock();
+  simulated_ = s4u::Engine::get_clock();
 }
 
 double ActorExt::simulated_elapsed() const
 {
-  return SIMIX_get_clock() - simulated_;
+  return s4u::Engine::get_clock() - simulated_;
 }
 
 MPI_Comm ActorExt::comm_self()
index 277da71..d05db4d 100644 (file)
@@ -7,6 +7,7 @@
 #include "private.hpp"
 #include "simgrid/host.h"
 #include "simgrid/modelchecker.h"
+#include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Exec.hpp"
 #include "smpi_comm.hpp"
 #include "smpi_utils.hpp"
@@ -156,7 +157,7 @@ void smpi_bench_end()
     const papi_counter_t& counter_data = smpi_process()->papi_counters();
 
     for (auto const& pair : counter_data) {
-      container->get_variable(pair.first)->set_event(SIMIX_get_clock(), pair.second);
+      container->get_variable(pair.first)->set_event(simgrid::s4u::Engine::get_clock(), pair.second);
     }
   }
 #endif
@@ -210,7 +211,7 @@ int smpi_gettimeofday(struct timeval* tv, struct timezone* tz)
     return gettimeofday(tv, tz);
 
   smpi_bench_end();
-  double now = SIMIX_get_clock();
+  double now = simgrid::s4u::Engine::get_clock();
   if (tv) {
     tv->tv_sec = static_cast<time_t>(now);
 #ifdef WIN32
@@ -236,7 +237,7 @@ int smpi_clock_gettime(clockid_t clk_id, struct timespec* tp)
     return clock_gettime(clk_id, tp);
   //there is only one time in SMPI, so clk_id is ignored.
   smpi_bench_end();
-  double now = SIMIX_get_clock();
+  double now  = simgrid::s4u::Engine::get_clock();
   tp->tv_sec  = static_cast<time_t>(now);
   tp->tv_nsec = static_cast<long int>((now - tp->tv_sec) * 1e9);
   if (smpi_wtime_sleep > 0)
@@ -251,12 +252,12 @@ double smpi_mpi_wtime()
   double time;
   if (smpi_process()->initialized() && not smpi_process()->finalized() && not smpi_process()->sampling()) {
     smpi_bench_end();
-    time = SIMIX_get_clock();
+    time = simgrid::s4u::Engine::get_clock();
     if (smpi_wtime_sleep > 0)
       simgrid::s4u::this_actor::sleep_for(smpi_wtime_sleep);
     smpi_bench_begin();
   } else {
-    time = SIMIX_get_clock();
+    time = simgrid::s4u::Engine::get_clock();
   }
   return time;
 }
@@ -273,7 +274,7 @@ unsigned long long smpi_rastro_resolution ()
 unsigned long long smpi_rastro_timestamp ()
 {
   smpi_bench_end();
-  double now = SIMIX_get_clock();
+  double now = simgrid::s4u::Engine::get_clock();
 
   auto sec               = static_cast<unsigned long long>(now);
   unsigned long long pre = (now - sec) * smpi_rastro_resolution();
index 012988f..aec528f 100644 (file)
@@ -144,9 +144,9 @@ void account_shared_size(size_t size){
 void print_time_analysis(double global_time){
   if (simgrid::config::get_value<bool>("smpi/display-timing")) {
     XBT_INFO("Simulated time: %g seconds. \n\n"
-        "The simulation took %g seconds (after parsing and platform setup)\n"
-        "%g seconds were actual computation of the application",
-        SIMIX_get_clock(), global_time , total_benched_time);
+             "The simulation took %g seconds (after parsing and platform setup)\n"
+             "%g seconds were actual computation of the application",
+             simgrid_get_clock(), global_time, total_benched_time);
     if (total_benched_time/global_time>=0.75)
       XBT_INFO("More than 75%% of the time was spent inside the application code.\n"
     "You may want to use sampling functions or trace replay to reduce this.");
index ca49082..8cebc8f 100644 (file)
@@ -495,7 +495,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
 
   host->get_impl()->add_actor_at_boot(arg);
 
-  if (start_time > SIMIX_get_clock()) {
+  if (start_time > simgrid::s4u::Engine::get_clock()) {
     arg = new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, actor->properties,
                                                  auto_restart);
 
@@ -510,7 +510,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
         new_actor->set_auto_restart(auto_restart);
       delete arg;
     });
-  } else { // start_time <= SIMIX_get_clock()
+  } else { // start_time <= simgrid::s4u::Engine::get_clock()
     XBT_DEBUG("Starting Process %s(%s) right now", arg->name.c_str(), host->get_cname());
 
     try {
index ef98226..3b3f015 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "simgrid/s4u/Actor.hpp"
 #include "simgrid/s4u/Engine.hpp"
+#include "xbt/asserts.h"
 #include "xbt/log.h"
 
 #include <string>