include src/include/mc/datatypes.h
include src/include/mc/mc.h
include src/include/simgrid/sg_config.hpp
-include src/include/surf/surf.hpp
include src/include/xbt/coverage.h
include src/include/xbt/mmalloc.h
include src/include/xbt/parmap.hpp
include src/surf/ptask_L07.cpp
include src/surf/ptask_L07.hpp
include src/surf/sg_platf.cpp
-include src/surf/surf_c_bindings.cpp
include src/surf/surf_interface.cpp
include src/surf/surf_interface.hpp
include src/surf/surf_private.hpp
a new action that represents the task you have just created.
To execute the actions created with @a execute(), @a communicate() or @a execute_parallel_task(), call
- surf_solve(). The function surf_solve() is where the simulation takes place. It returns the
+ EngineImpl::solve(). This function is where the simulation takes place. It returns the
time elapsed to execute the actions. You can know what actions have changed their state thanks
to the states sets. For example, if your want to know what actions are finished,
extract them from @a surf_host_model->common_public->states.done_action_set.
- Depending on these results, you can schedule other tasks and call surf_solve() again.
+ Depending on these results, you can schedule other tasks and call solve() again.
Have a look at the implementation of @ref MSG_API "MSG" and @ref SD_API "Simdag" to see how these module
interact with SURF. But if you want to create a new API on top of SURF,
> [ 43.774742] (0:maestro@) Simulation time 43.7747
p NOT testing the mixture of failures and CpuTI:
-p This test leads to a deadlock because of a bug somewhere in surf_solve.
+p This test leads to a deadlock because of a bug somewhere in EngineImpl::solve.
p We should debug this instead of ignoring the issue, but it's utterly
p complex with such an integration test. One day, we will setup a set of
p unit tests for the surf solver, and such issues will be addressable again.
+++ /dev/null
-/* Copyright (c) 2004-2021. The SimGrid Team. All rights reserved. */
-
-/* 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. */
-
-#ifndef SURF_SURF_H
-#define SURF_SURF_H
-
-#include "simgrid/forward.h"
-
-/*** SURF Globals **************************/
-
-/** @ingroup SURF_simulation
- * @brief Finish simulation initialization
- *
- * This function must be called before the first call to surf_solve()
- */
-XBT_PUBLIC void surf_presolve();
-
-/** @ingroup SURF_simulation
- * @brief Performs a part of the simulation
- * @param max_date Maximum date to update the simulation to, or -1
- * @return the elapsed time, or -1.0 if no event could be executed
- *
- * This function execute all possible events, update the action states and returns the time elapsed.
- * When you call execute or communicate on a model, the corresponding actions are not executed immediately but only
- * when you call surf_solve.
- * Note that the returned elapsed time can be zero.
- */
-XBT_PUBLIC double surf_solve(double max_date);
-
-/** @ingroup SURF_simulation
- * @brief Return the current time
- *
- * Return the current time in millisecond.
- */
-XBT_PUBLIC double surf_get_clock();
-
-/* surf parse file related (public because called from a test suite) */
-XBT_PUBLIC void parse_platform_file(const std::string& file);
-
-#endif
#include "src/smpi/include/smpi_actor.hpp"
#include "src/surf/network_interface.hpp"
#include "src/surf/xml/platf.hpp"
-#include "surf/surf.hpp" //surf_presolve() and surf_solve()
#include "xbt/xbt_modinter.h" /* whether initialization was already done */
#include <boost/algorithm/string/predicate.hpp>
#include "src/mc/remote/AppSide.hpp"
#endif
+double NOW = 0;
+
XBT_LOG_NEW_DEFAULT_CATEGORY(ker_engine, "Logging specific to Engine (kernel)");
+
namespace simgrid {
namespace kernel {
EngineImpl* EngineImpl::instance_ = nullptr; /* That singleton is awful too. */
/* register a function to be called by SURF after the environment creation */
sg_platf_init();
- s4u::Engine::on_platform_created.connect(surf_presolve);
+ s4u::Engine::on_platform_created.connect([this]() { this->presolve(); });
if (config::get_value<bool>("debug/clean-atexit"))
atexit(shutdown);
}
}
+void EngineImpl::presolve()
+{
+ XBT_DEBUG("Consume all trace events occurring before the starting time.");
+ double next_event_date;
+ while ((next_event_date = profile::future_evt_set.next_date()) != -1.0) {
+ if (next_event_date > NOW)
+ break;
+
+ double value = -1.0;
+ resource::Resource* resource = nullptr;
+ while (auto* event = profile::future_evt_set.pop_leq(next_event_date, &value, &resource)) {
+ if (value >= 0)
+ resource->apply_event(event, value);
+ }
+ }
+
+ XBT_DEBUG("Set every models in the right state by updating them to 0.");
+ for (auto const& model : models_)
+ model->update_actions_state(NOW, 0.0);
+}
+
+double EngineImpl::solve(double max_date)
+{
+ double time_delta = -1.0; /* duration */
+ double value = -1.0;
+ resource::Resource* resource = nullptr;
+
+ if (max_date != -1.0) {
+ xbt_assert(max_date >= NOW, "You asked to simulate up to %f, but that's in the past already", max_date);
+
+ time_delta = max_date - NOW;
+ }
+
+ XBT_DEBUG("Looking for next event in all models");
+ for (auto model : models_) {
+ if (not model->next_occurring_event_is_idempotent()) {
+ continue;
+ }
+ double next_event = model->next_occurring_event(NOW);
+ if ((time_delta < 0.0 || next_event < time_delta) && next_event >= 0.0) {
+ time_delta = next_event;
+ }
+ }
+
+ XBT_DEBUG("Min for resources (remember that NS3 don't update that value): %f", time_delta);
+
+ XBT_DEBUG("Looking for next trace event");
+
+ while (true) { // Handle next occurring events until none remains
+ double next_event_date = profile::future_evt_set.next_date();
+ XBT_DEBUG("Next TRACE event: %f", next_event_date);
+
+ for (auto model : models_) {
+ /* Skip all idempotent models, they were already treated above
+ * NS3 is the one to handled here */
+ if (model->next_occurring_event_is_idempotent())
+ continue;
+
+ if (next_event_date != -1.0) {
+ time_delta = std::min(next_event_date - NOW, time_delta);
+ } else {
+ time_delta = std::max(next_event_date - NOW, time_delta); // Get the positive component
+ }
+
+ XBT_DEBUG("Run the NS3 network at most %fs", time_delta);
+ // run until min or next flow
+ double model_next_action_end = model->next_occurring_event(time_delta);
+
+ XBT_DEBUG("Min for network : %f", model_next_action_end);
+ if (model_next_action_end >= 0.0)
+ time_delta = model_next_action_end;
+ }
+
+ if (next_event_date < 0.0 || (next_event_date > NOW + time_delta)) {
+ // next event may have already occurred or will after the next resource change, then bail out
+ XBT_DEBUG("no next usable TRACE event. Stop searching for it");
+ break;
+ }
+
+ XBT_DEBUG("Updating models (min = %g, NOW = %g, next_event_date = %g)", time_delta, NOW, next_event_date);
+
+ while (auto* event = profile::future_evt_set.pop_leq(next_event_date, &value, &resource)) {
+ if (resource->is_used() || (watched_hosts().find(resource->get_cname()) != watched_hosts().end())) {
+ time_delta = next_event_date - NOW;
+ XBT_DEBUG("This event invalidates the next_occurring_event() computation of models. Next event set to %f",
+ time_delta);
+ }
+ // FIXME: I'm too lame to update NOW live, so I change it and restore it so that the real update with surf_min
+ // will work
+ double round_start = NOW;
+ NOW = next_event_date;
+ /* update state of the corresponding resource to the new value. Does not touch lmm.
+ It will be modified if needed when updating actions */
+ XBT_DEBUG("Calling update_resource_state for resource %s", resource->get_cname());
+ resource->apply_event(event, value);
+ NOW = round_start;
+ }
+ }
+
+ /* 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 < 0) {
+ XBT_DEBUG("No next event at all. Bail out now.");
+ return -1.0;
+ }
+
+ XBT_DEBUG("Duration set to %f", time_delta);
+
+ // Bump the time: jump into the future
+ NOW = NOW + time_delta;
+
+ // Inform the models of the date change
+ for (auto const& model : models_)
+ model->update_actions_state(NOW, time_delta);
+
+ s4u::Engine::on_time_advance(time_delta);
+
+ return time_delta;
+}
+
void EngineImpl::run()
{
if (MC_record_replay_is_active()) {
time = timer::Timer::next();
if (time > -1.0 || not actor_list_.empty()) {
- XBT_DEBUG("Calling surf_solve");
- time = surf_solve(time);
+ XBT_DEBUG("Calling solve");
+ time = solve(time);
XBT_DEBUG("Moving time ahead : %g", time);
}
simgrid::s4u::Engine::on_simulation_end();
}
+
+double EngineImpl::get_clock()
+{
+ return NOW;
+}
} // namespace kernel
} // namespace simgrid
void display_all_actor_status() const;
void run_all_actors();
+ /* @brief Finish simulation initialization
+ * This function must be called before the first call to solve()
+ */
+ void presolve();
+ /** @brief Performs a part of the simulation
+ * @param max_date Maximum date to update the simulation to, or -1
+ * @return the elapsed time, or -1.0 if no event could be executed
+ *
+ * This function execute all possible events, update the action states and returns the time elapsed.
+ * When you call execute or communicate on a model, the corresponding actions are not executed immediately but only
+ * when you call solve().
+ * Note that the returned elapsed time can be zero.
+ */
+ double solve(double max_date);
+
/** @brief Run the main simulation loop. */
void run();
+
+ /** @brief Return the current time in milliseconds. */
+ static double get_clock();
};
} // namespace kernel
#include "simgrid/kernel/resource/Action.hpp"
#include "simgrid/kernel/resource/Model.hpp"
+#include "src/kernel/EngineImpl.hpp"
#include "src/kernel/lmm/maxmin.hpp"
#include "src/surf/surf_interface.hpp"
-#include "surf/surf.hpp"
XBT_LOG_NEW_CATEGORY(kernel, "SimGrid internals");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_resource, kernel, "Resources, modeling the platform performance");
Action::Action(Model* model, double cost, bool failed) : Action(model, cost, failed, nullptr) {}
Action::Action(Model* model, double cost, bool failed, lmm::Variable* var)
- : remains_(cost), start_time_(surf_get_clock()), cost_(cost), model_(model), variable_(var)
+ : remains_(cost), start_time_(EngineImpl::get_clock()), cost_(cost), model_(model), variable_(var)
{
if (failed)
state_set_ = model_->get_failed_action_set();
void Action::finish(Action::State state)
{
- finish_time_ = surf_get_clock();
+ finish_time_ = EngineImpl::get_clock();
set_remains(0);
set_state(state);
}
if (variable_)
model_->get_maxmin_system()->update_variable_bound(variable_, bound);
- if (model_->is_update_lazy() && get_last_update() != surf_get_clock())
+ if (model_->is_update_lazy() && get_last_update() != EngineImpl::get_clock())
model_->get_action_heap().remove(this);
XBT_OUT();
}
model_->get_action_heap().remove(this);
if (state_set_ == model_->get_started_action_set() && sharing_penalty_ > 0) {
// If we have a lazy model, we need to update the remaining value accordingly
- update_remains_lazy(surf_get_clock());
+ update_remains_lazy(EngineImpl::get_clock());
}
}
suspended_ = SuspendStates::SUSPENDED;
XBT_IN("(%p)", this);
/* update remains before returning it */
if (model_->is_update_lazy()) /* update remains before return it */
- update_remains_lazy(surf_get_clock());
+ update_remains_lazy(EngineImpl::get_clock());
XBT_OUT();
return remains_;
}
void Action::set_last_update()
{
- last_update_ = surf_get_clock();
+ last_update_ = EngineImpl::get_clock();
}
double ActionHeap::top_date() const
lmm::System* vcpu_system = cpu->get_model()->get_maxmin_system();
vcpu_system->update_constraint_bound(cpu->get_constraint(), virt_overhead * solved_value);
}
- /* actual next occurring event is determined by VM CPU model at surf_solve */
+ /* actual next occurring event is determined by VM CPU model at EngineImpl::solve */
return -1.0;
}
#include "src/instr/instr_private.hpp"
#include "src/kernel/EngineImpl.hpp"
#include "src/mc/mc_replay.hpp"
-#include "surf/surf.hpp"
#include <algorithm>
#include <string>
if (MC_is_active() || MC_record_replay_is_active()) {
return MC_process_clock_get(kernel::actor::ActorImpl::self());
} else {
- return surf_get_clock();
+ return kernel::EngineImpl::get_clock();
}
}
std::set<SD_task_t>* simulate(double how_long)
{
XBT_VERB("Run simulation for %f seconds", how_long);
-
+ auto engine = sd_global->engine_->get_impl();
+ simgrid::kernel::EngineImpl::get_instance();
sd_global->watch_point_reached = false;
sd_global->return_set.clear();
not sd_global->watch_point_reached) {
XBT_DEBUG("Total time: %f", total_time);
- elapsed_time = surf_solve(how_long > 0 ? surf_get_clock() + how_long - total_time : -1.0);
- XBT_DEBUG("surf_solve() returns %f", elapsed_time);
+ elapsed_time = engine->solve(how_long > 0 ? simgrid_get_clock() + how_long - total_time : -1.0);
+ XBT_DEBUG("solve() returns %f", elapsed_time);
if (elapsed_time > 0.0)
total_time += elapsed_time;
/* let's see which tasks are done */
- for (auto const& model : simgrid::kernel::EngineImpl::get_instance()->get_all_models()) {
+ for (auto const& model : engine->get_all_models()) {
const simgrid::kernel::resource::Action* action = model->extract_done_action();
while (action != nullptr && action->get_data() != nullptr) {
auto* task = static_cast<SD_task_t>(action->get_data());
XBT_DEBUG("elapsed_time = %f, total_time = %f, watch_point_reached = %d", elapsed_time, total_time,
sd_global->watch_point_reached);
- XBT_DEBUG("current time = %f", surf_get_clock());
+ XBT_DEBUG("current time = %f", simgrid_get_clock());
return &sd_global->return_set;
}
jedule_sd_init();
#endif
XBT_VERB("Starting simulation...");
- surf_presolve(); /* Takes traces into account */
+ sd_global->engine_->get_impl()->presolve(); /* Takes traces into account */
}
/**
/** @brief Returns the current clock, in seconds */
double SD_get_clock()
{
- return surf_get_clock();
+ return simgrid_get_clock();
}
/**
jedule_log_sd_event(task);
#endif
} else
- task->finish_time = surf_get_clock();
+ task->finish_time = simgrid_get_clock();
task->surf_action->unref();
task->surf_action = nullptr;
task->allocation->clear();
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/simdag.h"
-#include "surf/surf.hpp"
#include <set>
#include <string>
#include <vector>
/* 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/kernel/EngineImpl.hpp"
#include "src/surf/LinkImpl.hpp"
-#include "simgrid/s4u/Engine.hpp"
-#include "surf/surf.hpp"
#include <numeric>
s4u::Link::on_state_change(piface_);
const kernel::lmm::Element* elem = nullptr;
- double now = surf_get_clock();
+ double now = EngineImpl::get_clock();
while (const auto* var = get_constraint()->get_variable(&elem)) {
Action* action = var->get_id();
if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED) {
#include "src/surf/cpu_cas01.hpp"
#include "src/surf/cpu_ti.hpp"
#include "src/surf/surf_interface.hpp"
-#include "surf/surf.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cpu_cas, res_cpu, "CPU resource, CAS01 model (used by default)");
}
} else {
const lmm::Element* elem = nullptr;
- double date = surf_get_clock();
+ double date = EngineImpl::get_clock();
get_iface()->turn_off();
#include "src/kernel/resource/profile/Event.hpp"
#include "src/kernel/resource/profile/Profile.hpp"
#include "src/surf/surf_interface.hpp"
-#include "surf/surf.hpp"
#include <algorithm>
#include <memory>
XBT_DEBUG("Action %p: finish", action);
action->finish(Action::State::FINISHED);
/* update remaining amount of all actions */
- action->cpu_->update_remaining_amount(surf_get_clock());
+ action->cpu_->update_remaining_amount(EngineImpl::get_clock());
}
}
XBT_DEBUG("Speed changed in trace! New fixed value: %f", value);
/* update remaining of actions and put in modified cpu list */
- update_remaining_amount(surf_get_clock());
+ update_remaining_amount(EngineImpl::get_clock());
set_modified(true);
}
} else {
get_iface()->turn_off();
- double date = surf_get_clock();
+ double date = EngineImpl::get_clock();
/* put all action running on cpu to failed */
for (CpuTiAction& action : action_set_) {
double CpuTi::get_speed_ratio()
{
- speed_.scale = speed_integrated_trace_->get_power_scale(surf_get_clock());
+ speed_.scale = speed_integrated_trace_->get_power_scale(EngineImpl::get_clock());
return CpuImpl::get_speed_ratio();
}
double CpuTiAction::get_remains()
{
XBT_IN("(%p)", this);
- cpu_->update_remaining_amount(surf_get_clock());
+ cpu_->update_remaining_amount(EngineImpl::get_clock());
XBT_OUT();
return get_remains_no_update();
}
double HostCLM03Model::next_occurring_event(double /*now*/)
{
/* nothing specific to be done here
- * surf_solve already calls all the models next_occurring_event properly */
+ * EngineImpl::solve already calls all the models next_occurring_event properly */
return -1.0;
}
#include "src/kernel/resource/profile/Event.hpp"
#include "src/surf/network_wifi.hpp"
#include "src/surf/surf_interface.hpp"
-#include "surf/surf.hpp"
#include <algorithm>
#include <numeric>
#include "src/kernel/EngineImpl.hpp"
#include "src/surf/surf_interface.hpp"
#include "src/surf/xml/platf_private.hpp" // ClusterCreationArgs
-#include "surf/surf.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_ns3, res_network, "Network model based on ns-3");
XBT_DEBUG("doing a ns3 simulation for a duration of %f", now);
ns3_simulator(now);
- time_to_next_flow_completion = ns3::Simulator::Now().GetSeconds() - surf_get_clock();
+ time_to_next_flow_completion = ns3::Simulator::Now().GetSeconds() - EngineImpl::get_clock();
// NS-3 stops as soon as a flow ends,
// but it does not process the other flows that may finish at the same (simulated) time.
// If another flow ends at the same time, time_to_next_flow_completion = 0
XBT_DEBUG("min : %f", now);
XBT_DEBUG("ns3 time : %f", ns3::Simulator::Now().GetSeconds());
- XBT_DEBUG("surf time : %f", surf_get_clock());
+ XBT_DEBUG("surf time : %f", EngineImpl::get_clock());
XBT_DEBUG("Next completion %f :", time_to_next_flow_completion);
return time_to_next_flow_completion;
// If there is no other started actions, we need to move NS-3 forward to be sync with SimGrid
if (model->get_started_action_set()->size() == 1) {
- while (double_positive(surf_get_clock() - ns3::Simulator::Now().GetSeconds(), sg_surf_precision)) {
+ while (double_positive(EngineImpl::get_clock() - ns3::Simulator::Now().GetSeconds(), sg_surf_precision)) {
XBT_DEBUG("Synchronizing NS-3 (time %f) with SimGrid (time %f)", ns3::Simulator::Now().GetSeconds(),
- surf_get_clock());
- ns3_simulator(surf_get_clock() - ns3::Simulator::Now().GetSeconds());
+ EngineImpl::get_clock());
+ ns3_simulator(EngineImpl::get_clock() - ns3::Simulator::Now().GetSeconds());
}
}
if (maxSeconds > 0.0) // If there is a maximum amount of time to run
id = ns3::Simulator::Schedule(ns3::Seconds(maxSeconds), &ns3::Simulator::Stop);
- XBT_DEBUG("Start simulator for at most %fs (current time: %f)", maxSeconds, surf_get_clock());
+ XBT_DEBUG("Start simulator for at most %fs (current time: %f)", maxSeconds, EngineImpl::get_clock());
ns3::Simulator::Run();
XBT_DEBUG("Simulator stopped at %fs", ns3::Simulator::Now().GetSeconds());
void update_actions_state(double /*now*/, double /*delta*/) override{
/* this action is done by HostL07Model which shares the LMM system with the CPU model
* Overriding to an empty function here allows us to handle the Cpu07Model as a regular
- * method in surf_presolve */
+ * method in EngineImpl::presolve */
};
CpuImpl* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
void update_actions_state(double /*now*/, double /*delta*/) override{
/* this action is done by HostL07Model which shares the LMM system with the CPU model
* Overriding to an empty function here allows us to handle the Cpu07Model as a regular
- * method in surf_presolve */
+ * method in EngineImpl::presolve */
};
HostL07Model* hostModel_;
#include "src/surf/HostImpl.hpp"
#include "src/surf/xml/platf.hpp"
#include "src/surf/xml/platf_private.hpp"
-#include "surf/surf.hpp"
#include <algorithm>
#include <string>
+++ /dev/null
-/* Copyright (c) 2013-2021. The SimGrid Team. All rights reserved. */
-
-/* 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.hpp"
-#include "src/kernel/EngineImpl.hpp"
-#include "src/kernel/resource/DiskImpl.hpp"
-#include "src/kernel/resource/VirtualMachineImpl.hpp"
-#include "src/kernel/resource/profile/FutureEvtSet.hpp"
-#include "surf/surf.hpp"
-
-#include <algorithm>
-
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel);
-
-/*********
- * TOOLS *
- *********/
-
-extern double NOW;
-
-void surf_presolve()
-{
- XBT_DEBUG("Consume all trace events occurring before the starting time.");
- double next_event_date;
- while ((next_event_date = simgrid::kernel::profile::future_evt_set.next_date()) != -1.0) {
- if (next_event_date > NOW)
- break;
-
- double value = -1.0;
- simgrid::kernel::resource::Resource* resource = nullptr;
- while (auto* event = simgrid::kernel::profile::future_evt_set.pop_leq(next_event_date, &value, &resource)) {
- if (value >= 0)
- resource->apply_event(event, value);
- }
- }
-
- XBT_DEBUG("Set every models in the right state by updating them to 0.");
- for (auto const& model : simgrid::kernel::EngineImpl::get_instance()->get_all_models())
- model->update_actions_state(NOW, 0.0);
-}
-
-double surf_solve(double max_date)
-{
- double time_delta = -1.0; /* duration */
- double value = -1.0;
- simgrid::kernel::resource::Resource* resource = nullptr;
-
- if (max_date != -1.0) {
- xbt_assert(max_date >= NOW, "You asked to simulate up to %f, but that's in the past already", max_date);
-
- time_delta = max_date - NOW;
- }
-
- XBT_DEBUG("Looking for next event in all models");
- auto engine = simgrid::kernel::EngineImpl::get_instance();
- for (auto model : engine->get_all_models()) {
- if (not model->next_occurring_event_is_idempotent()) {
- continue;
- }
- double next_event = model->next_occurring_event(NOW);
- if ((time_delta < 0.0 || next_event < time_delta) && next_event >= 0.0) {
- time_delta = next_event;
- }
- }
-
- XBT_DEBUG("Min for resources (remember that NS3 don't update that value): %f", time_delta);
-
- XBT_DEBUG("Looking for next trace event");
-
- while (true) { // Handle next occurring events until none remains
- double next_event_date = simgrid::kernel::profile::future_evt_set.next_date();
- XBT_DEBUG("Next TRACE event: %f", next_event_date);
-
- for (auto model : engine->get_all_models()) {
- /* Skip all idempotent models, they were already treated above
- * NS3 is the one to handled here */
- if (model->next_occurring_event_is_idempotent())
- continue;
-
- if (next_event_date != -1.0) {
- time_delta = std::min(next_event_date - NOW, time_delta);
- } else {
- time_delta = std::max(next_event_date - NOW, time_delta); // Get the positive component
- }
-
- XBT_DEBUG("Run the NS3 network at most %fs", time_delta);
- // run until min or next flow
- double model_next_action_end = model->next_occurring_event(time_delta);
-
- XBT_DEBUG("Min for network : %f", model_next_action_end);
- if (model_next_action_end >= 0.0)
- time_delta = model_next_action_end;
- }
-
- if (next_event_date < 0.0 || (next_event_date > NOW + time_delta)) {
- // next event may have already occurred or will after the next resource change, then bail out
- XBT_DEBUG("no next usable TRACE event. Stop searching for it");
- break;
- }
-
- XBT_DEBUG("Updating models (min = %g, NOW = %g, next_event_date = %g)", time_delta, NOW, next_event_date);
-
- while (auto* event = simgrid::kernel::profile::future_evt_set.pop_leq(next_event_date, &value, &resource)) {
- if (resource->is_used() || (watched_hosts().find(resource->get_cname()) != watched_hosts().end())) {
- time_delta = next_event_date - NOW;
- XBT_DEBUG("This event invalidates the next_occurring_event() computation of models. Next event set to %f",
- time_delta);
- }
- // FIXME: I'm too lame to update NOW live, so I change it and restore it so that the real update with surf_min
- // will work
- double round_start = NOW;
- NOW = next_event_date;
- /* update state of the corresponding resource to the new value. Does not touch lmm.
- It will be modified if needed when updating actions */
- XBT_DEBUG("Calling update_resource_state for resource %s", resource->get_cname());
- resource->apply_event(event, value);
- NOW = round_start;
- }
- }
-
- /* 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 < 0) {
- XBT_DEBUG("No next event at all. Bail out now.");
- return -1.0;
- }
-
- XBT_DEBUG("Duration set to %f", time_delta);
-
- // Bump the time: jump into the future
- NOW = NOW + time_delta;
-
- // Inform the models of the date change
- for (auto const& model : simgrid::kernel::EngineImpl::get_instance()->get_all_models())
- model->update_actions_state(NOW, time_delta);
-
- simgrid::s4u::Engine::on_time_advance(time_delta);
-
- return time_delta;
-}
#include "src/kernel/resource/profile/Profile.hpp"
#include "src/surf/HostImpl.hpp"
#include "src/surf/surf_interface.hpp"
-#include "surf/surf.hpp"
#include <fstream>
#include <string>
{"default", "Simplistic disk model.", &surf_disk_model_init_default},
};
-double NOW = 0;
-
-double surf_get_clock()
-{
- return NOW;
-}
-
/* returns whether #file_path is an absolute file path. Surprising, isn't it ? */
static bool is_absolute_file_path(const std::string& file_path)
{
XBT_PUBLIC int surf_parse_get_int(const std::string& s);
XBT_PUBLIC void surf_parse(); /* Entry-point to the parser */
+XBT_PUBLIC void parse_platform_file(const std::string& file);
#endif
#include "src/surf/surf_interface.hpp"
#include "src/surf/xml/platf.hpp"
#include "src/surf/xml/platf_private.hpp"
-#include "surf/surf.hpp"
#include <vector>
#include "simgrid/kernel/routing/NetZoneImpl.hpp" // full type for NetZoneImpl object
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/zone.h"
+#include "src/kernel/EngineImpl.hpp"
#include "src/kernel/resource/CpuImpl.hpp"
#include "src/surf/network_interface.hpp"
-#include "surf/surf.hpp"
#include "xbt/config.hpp"
XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
/* Let's do something on it */
net_model->communicate(hostA, hostB, 150.0, -1.0);
- surf_solve(-1.0);
+ e.get_impl()->solve(-1.0);
do {
XBT_INFO("Next Event : %g", simgrid::s4u::Engine::get_clock());
XBT_DEBUG("\t CPU actions");
action.unref();
}
} while ((net_model->get_started_action_set()->size() || cpu_model_pm->get_started_action_set()->size()) &&
- surf_solve(-1.0) >= 0.0);
+ e.get_impl()->solve(-1.0) >= 0.0);
XBT_DEBUG("Simulation Terminated");
#include "src/kernel/resource/CpuImpl.hpp"
#include "src/surf/network_interface.hpp"
#include "src/surf/surf_interface.hpp"
-#include "surf/surf.hpp"
#include "xbt/config.hpp"
XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
auto net_model = as_zone->get_impl()->get_network_model();
net_model->communicate(hostA, hostB, 150.0, -1.0);
- surf_solve(-1.0); /* Takes traces into account. Returns 0.0 */
+ e.get_impl()->solve(-1.0); /* Takes traces into account. Returns 0.0 */
do {
simgrid::kernel::resource::Action* action = nullptr;
running = 0;
action = model->extract_done_action();
}
}
- } while (running && surf_solve(-1.0) >= 0.0);
+ } while (running && e.get_impl()->solve(-1.0) >= 0.0);
XBT_INFO("Simulation Terminated");
return 0;
src/include/mc/datatypes.h
src/include/mc/mc.h
src/include/simgrid/sg_config.hpp
- src/include/surf/surf.hpp
src/include/xbt/coverage.h
src/include/xbt/parmap.hpp
src/include/xbt/mmalloc.h
src/surf/SplitDuplexLinkImpl.cpp
src/surf/network_wifi.cpp
src/surf/sg_platf.cpp
- src/surf/surf_c_bindings.cpp
src/surf/surf_interface.cpp
src/surf/xml/platf.hpp
src/surf/xml/platf_private.hpp