Use simgrid_get_clock() or Engine::get_clock().
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:
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.
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
#include <chrono>
#include <ratio>
-#include <simgrid/simix.h>
+#include <simgrid/engine.h>
namespace simgrid {
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 */
#include <simgrid/forward.h>
#include <simgrid/chrono.hpp>
+#include <simgrid/s4u/Engine.hpp>
#include <simgrid/s4u/Mutex.hpp>
#include <future>
/// 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:
/* 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);
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),
// 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);
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;
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);
}
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()) {
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)
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());
}
}
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;
#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"
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_);
#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"
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_);
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] {
* 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 {
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;
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);
}
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;
#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>
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,
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.");
*
* @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
#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) { \
#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"
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()
#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"
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
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
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)
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;
}
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();
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.");
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);
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 {
#include "simgrid/s4u/Actor.hpp"
#include "simgrid/s4u/Engine.hpp"
+#include "xbt/asserts.h"
#include "xbt/log.h"
#include <string>