* Utils *
*********/
-/* model_list_invoke contains only surf_host and surf_vm.
- * The callback functions of cpu_model and network_model will be called from those of these host models. */
std::vector<surf_model_t> * all_existing_models = nullptr; /* to destroy models correctly */
-xbt_dynar_t model_list_invoke = nullptr; /* to invoke callbacks */
simgrid::trace_mgr::future_evt_set *future_evt_set = nullptr;
-xbt_dynar_t surf_path = nullptr;
+std::vector<std::string> surf_path;
std::vector<simgrid::s4u::Host*> host_that_restart;
xbt_dict_t watched_hosts_lib;
}
#include <simgrid/plugins/energy.h> // FIXME: this plugin should not be linked to the core
+#include <simgrid/plugins/load.h> // FIXME: this plugin should not be linked to the core
s_surf_model_description_t surf_plugin_description[] = {
- {"Energy", "Cpu energy consumption.", &sg_energy_plugin_init},
- {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
+ {"Energy", "Cpu energy consumption.", &sg_host_energy_plugin_init},
+ {"Load", "Cpu load.", &sg_host_load_plugin_init},
+ {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
};
/* Don't forget to update the option description in smx_config when you change this */
FILE *surf_fopen(const char *name, const char *mode)
{
- unsigned int cpt;
- char *path_elm = nullptr;
char *buff;
FILE *file = nullptr;
return fopen(name, mode);
/* search relative files in the path */
- xbt_dynar_foreach(surf_path, cpt, path_elm) {
- buff = bprintf("%s" FILE_DELIM "%s", path_elm, name);
+ for (auto path_elm : surf_path) {
+ buff = bprintf("%s" FILE_DELIM "%s", path_elm.c_str(), name);
file = fopen(buff, mode);
free(buff);
xbt_init(argc, argv);
if (!all_existing_models)
all_existing_models = new std::vector<simgrid::surf::Model*>();
- if (!model_list_invoke)
- model_list_invoke = xbt_dynar_new(sizeof(simgrid::surf::Model*), nullptr);
if (!future_evt_set)
future_evt_set = new simgrid::trace_mgr::future_evt_set();
{
TRACE_end(); /* Just in case it was not called by the upper layer (or there is no upper layer) */
- xbt_dynar_free(&surf_path);
-
sg_host_exit();
xbt_lib_free(&storage_lib);
sg_link_exit();
for (auto model : *all_existing_models)
delete model;
delete all_existing_models;
- xbt_dynar_free(&model_list_invoke);
simgrid::surf::surfExitCallbacks();
min = now + time_to_completion; // when the task will complete if nothing changes
}
- if ((action->getMaxDuration() != NO_MAX_DURATION)
- && (min == -1
- || action->getStartTime() +
- action->getMaxDuration() < min)) {
- min = action->getStartTime() +
- action->getMaxDuration(); // when the task will complete anyway because of the deadline if any
+ if ((action->getMaxDuration() != NO_MAX_DURATION) &&
+ (min == -1 || action->getStartTime() + action->getMaxDuration() < min)) {
+ // when the task will complete anyway because of the deadline if any
+ min = action->getStartTime() + action->getMaxDuration();
max_dur_flag = 1;
}
isOn_ = false;
}
-Model *Resource::getModel() const {
+Model* Resource::model() const
+{
return model_;
}
-const char *Resource::getName() const {
+const char* Resource::cname() const
+{
return name_.c_str();
}
return name_ == other.name_;
}
-lmm_constraint_t Resource::getConstraint() const {
+lmm_constraint_t Resource::constraint() const
+{
return constraint_;
}
Action::State Action::getState()
{
- if (stateSet_ == getModel()->getReadyActionSet())
+ if (stateSet_ == model_->getReadyActionSet())
return Action::State::ready;
- if (stateSet_ == getModel()->getRunningActionSet())
+ if (stateSet_ == model_->getRunningActionSet())
return Action::State::running;
- if (stateSet_ == getModel()->getFailedActionSet())
+ if (stateSet_ == model_->getFailedActionSet())
return Action::State::failed;
- if (stateSet_ == getModel()->getDoneActionSet())
+ if (stateSet_ == model_->getDoneActionSet())
return Action::State::done;
return Action::State::not_in_the_system;
}
stateSet_->erase(stateSet_->iterator_to(*this));
switch (state) {
case Action::State::ready:
- stateSet_ = getModel()->getReadyActionSet();
+ stateSet_ = model_->getReadyActionSet();
break;
case Action::State::running:
- stateSet_ = getModel()->getRunningActionSet();
+ stateSet_ = model_->getRunningActionSet();
break;
case Action::State::failed:
- stateSet_ = getModel()->getFailedActionSet();
+ stateSet_ = model_->getFailedActionSet();
break;
case Action::State::done:
- stateSet_ = getModel()->getDoneActionSet();
+ stateSet_ = model_->getDoneActionSet();
break;
default:
stateSet_ = nullptr;
if (getModel() == surf_cpu_model_pm && TRACE_is_enabled()) {
simgrid::surf::Resource *cpu = static_cast<simgrid::surf::Resource*>(
lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)));
- TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), lastValue_, lastUpdate_, now - lastUpdate_);
+ TRACE_surf_host_set_utilization(cpu->cname(), getCategory(), lastValue_, lastUpdate_, now - lastUpdate_);
}
XBT_DEBUG("Updating action(%p): remains is now %f", this, remains_);
}