Several tools can be used to visualize the result of SimGrid
simulations and get a better understanding of simulations.
-- [viva][fn:1] will be useful to make fancy graph or treemap visualizations.
- [pajeng][fn:5] provides a Gantt-chart visualization.
- [Vite][fn:6] also provides a Gantt-chart visualization.
documentation of each software for more details.
~~~~{.sh}
-sudo apt-get install viva pajeng vite
+sudo apt-get install pajeng vite
~~~~
\section intro_start Let's get started
\c /opt/simgrid/bin/simgrid-colorizer. If you did not install it at all,
you can find it in <simgrid_root_directory>/bin/colorize.
-For a really fancy output, you should use [viva/triva][fn:1]:
-
-~~~~{.sh}
-./masterworker0 platforms/platform.xml deployment0.xml --cfg=tracing:yes \
- --cfg=tracing/uncategorized:yes --cfg=viva/uncategorized:uncat.plist
-LANG=C ; viva simgrid.trace uncat.plist
-~~~~
-
-For a more classical Gantt-Chart visualization, you can produce a
-[Paje][fn:5] trace:
+For a classical Gantt-Chart visualization, you can produce a [Paje][fn:5] trace:
~~~~{.sh}
./masterworker0 platforms/platform.xml deployment0.xml --cfg=tracing:yes \
## Using the Tracing Mechanism
SimGrid can trace all resource consumption and the outcome can be
-displayed with viva as illustrated in the section \ref intro_setup. However, when several
+displayed as illustrated in the section \ref intro_setup. However, when several
masters are deployed, it is hard to understand what happens.
~~~~{.xml}
void MSG_task_set_category (msg_task_t task, const char *category);
~~~~
-The outcome can then be visualized as follows:
-
-~~~~{.sh}
-./masterworker3 platforms/platform.xml deployment3.xml --cfg=tracing:yes\
- --cfg=tracing/categorized:yes --cfg=viva/categorized:viva_cat.plist
-LANG=C; viva simgrid.trace viva_cat.plist
-~~~~
-
-Right now, you should realize that nothing is behaving like you
-expect. Most workers are idle even though input data are ridiculous
-and there are several masters deployed on the platform. Using a
-Gantt-chart visualization may help:
+The outcome can then be visualized as a Gantt-chart as follows:
~~~~{.sh}
./masterworker3 platforms/platform.xml deployment3.xml --cfg=tracing:yes \
pajeng simgrid.trace
~~~~
-OK, so it should now be obvious that round robin is actually
-very bad.
+Right now, you should realize that nothing is behaving like you expect. Most
+workers are idle even though input data are ridiculous and there are several
+masters deployed on the platform. So it should now be obvious that round robin
+is actually very bad.
## Improving the Scheduling
\section intro_todo TODO: Points to improve for the next time
- Propose equivalent exercises and skeleton in java.
-- Propose a virtualbox image with everything (simgrid, pajeng, viva,
- ...) already set up.
+- Propose a virtualbox image with everything (simgrid, pajeng, ...) already set
+ up.
- Ease the installation on mac OS X (binary installer) and
windows.
- Explain that programming in C or java and having a working
\fB\-trace-resource\fR
Trace resource utilization.
.TP
-\fB\-trace-viva\fR
-Generate configuration for Viva's GraphView.
-.TP
\fB\-trace-file\fR <tracefile>
Name of the tracefile
-/* Copyright (c) 2010, 2012-2016. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010, 2012-2017. 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. */
xbt_dynar_free (&link_variables);
}
- //create a customized viva graph configuration file
- FILE *fp = fopen ("viva_graph.plist", "w");
- if (fp == NULL){
- return 1;
- }
- fprintf (fp, "{\n node = (");
xbt_dynar_t nodes_type = TRACE_get_node_types ();
if (nodes_type){
XBT_INFO ("Node types in the trace:");
char *node_type;
xbt_dynar_foreach (nodes_type, cursor, node_type){
XBT_INFO ("%s", node_type);
- fprintf (fp, "%s, ", node_type);
}
xbt_dynar_free (&nodes_type);
}
- fprintf (fp, ");\n edge = (");
xbt_dynar_t edges_type = TRACE_get_edge_types ();
if (edges_type){
XBT_INFO ("Node types in the trace:");
char *edge_type;
xbt_dynar_foreach (edges_type, cursor, edge_type){
XBT_INFO ("%s", edge_type);
- fprintf (fp, "%s, ", edge_type);
}
xbt_dynar_free (&edges_type);
}
- fprintf (fp, ");\n");
- fprintf (fp, " host = {\n type = square;\n size = HDD_capacity; \n values = (HDD_utilization);\n };\n");
- fprintf (fp, " link = {\n type = rhombus;\n size = bandwidth;\n };\n");
- fprintf (fp, "}\n");
- fclose (fp);
return 0;
}
> [0.004078] [msg_test/INFO] 0-LINK3-HOST1
> [0.004078] [msg_test/INFO] 0-LINK3-LINK3
-$ rm -f viva_graph.plist
+$ rm -f simgrid.trace
p Not tracing user variables
$ $SG_TEST_EXENV ${bindir:=.}/trace-host-user-variables$EXEEXT ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
-
-$ rm -f simgrid.trace viva_graph.plist
auto res = allocs.insert(std::make_pair(loc, shared_data_t()));
auto data = res.first;
if (res.second) {
- // The insertion did not take place.
+ // The new element was inserted.
// Generate a shared memory name from the address of the shared_data:
char shmname[32]; // cannot be longer than PSHMNAMLEN = 31 on Mac OS X (shm_open raises ENAMETOOLONG otherwise)
snprintf(shmname, 31, "/shmalloc%p", &*data);
//defining the last timestamp that we can safely dump to trace file
//without losing the event ascending order (considering all CPU's)
double smaller = -1;
- ActionList *actionSet = getRunningActionSet();
- ActionList::iterator it(actionSet->begin());
- ActionList::iterator itend(actionSet->end());
- for (; it != itend; ++it) {
- CpuAction *action = static_cast<CpuAction*>(&*it);
- if (smaller < 0 || action->getLastUpdate() < smaller)
- smaller = action->getLastUpdate();
+ for (Action const& action : *getRunningActionSet()) {
+ if (smaller < 0 || action.getLastUpdate() < smaller)
+ smaller = action.getLastUpdate();
}
if (smaller > 0) {
TRACE_last_timestamp_to_dump = smaller;
void CpuModel::updateActionsStateFull(double now, double delta)
{
- CpuAction *action = nullptr;
- ActionList *running_actions = getRunningActionSet();
- ActionList::iterator it(running_actions->begin());
- ActionList::iterator itNext = it;
- ActionList::iterator itend(running_actions->end());
- for (; it != itend; it = itNext) {
- ++itNext;
- action = static_cast<CpuAction*>(&*it);
+ for (auto it = std::begin(*getRunningActionSet()); it != std::end(*getRunningActionSet());) {
+ CpuAction& action = static_cast<CpuAction&>(*it);
+ ++it; // increment iterator here since the following calls to action.finish() may invalidate it
if (TRACE_is_enabled()) {
- Cpu *cpu = static_cast<Cpu*> (lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)) );
+ Cpu* cpu =
+ static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action.getVariable(), 0)));
- TRACE_surf_host_set_utilization(cpu->getCname(), action->getCategory(),
- lmm_variable_getvalue(action->getVariable()), now - delta, delta);
+ TRACE_surf_host_set_utilization(cpu->getCname(), action.getCategory(),
+ lmm_variable_getvalue(action.getVariable()), now - delta, delta);
TRACE_last_timestamp_to_dump = now - delta;
}
- action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
+ action.updateRemains(lmm_variable_getvalue(action.getVariable()) * delta);
- if (action->getMaxDuration() != NO_MAX_DURATION)
- action->updateMaxDuration(delta);
+ if (action.getMaxDuration() != NO_MAX_DURATION)
+ action.updateMaxDuration(delta);
- if (((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
- ((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
- action->finish(Action::State::done);
+ if (((action.getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action.getVariable()) > 0)) ||
+ ((action.getMaxDuration() != NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
+ action.finish(Action::State::done);
}
}
}
{
double min_action_duration = -1;
-/* iterates over modified cpus to update share resources */
- CpuTiList::iterator itend(modifiedCpu_->end());
- CpuTiList::iterator it(modifiedCpu_->begin());
- while (it != itend) {
- CpuTi *ti = &*it;
- ++it;
- ti->updateActionsFinishTime(now);
+ /* iterates over modified cpus to update share resources */
+ for (auto it = std::begin(*modifiedCpu_); it != std::end(*modifiedCpu_);) {
+ CpuTi& ti = *it;
+ ++it; // increment iterator here since the following call to ti.updateActionsFinishTime() may invalidate it
+ ti.updateActionsFinishTime(now);
}
-/* get the min next event if heap not empty */
+ /* get the min next event if heap not empty */
if (not actionHeapIsEmpty())
min_action_duration = actionHeapTopDate() - now;
double date = surf_get_clock();
/* put all action running on cpu to failed */
- ActionTiList::iterator itend(actionSet_->end());
- for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) {
- CpuTiAction *action = &*it;
- if (action->getState() == Action::State::running
- || action->getState() == Action::State::ready
- || action->getState() == Action::State::not_in_the_system) {
- action->setFinishTime(date);
- action->setState(Action::State::failed);
- action->heapRemove(model()->getActionHeap());
+ for (CpuTiAction& action : *actionSet_) {
+ if (action.getState() == Action::State::running || action.getState() == Action::State::ready ||
+ action.getState() == Action::State::not_in_the_system) {
+ action.setFinishTime(date);
+ action.setState(Action::State::failed);
+ action.heapRemove(model()->getActionHeap());
}
}
}
void CpuTi::updateActionsFinishTime(double now)
{
- CpuTiAction *action;
double sum_priority = 0.0;
double total_area;
/* update remaining amount of actions */
updateRemainingAmount(now);
- ActionTiList::iterator itend(actionSet_->end());
- for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) {
- action = &*it;
+ for (CpuTiAction const& action : *actionSet_) {
/* action not running, skip it */
- if (action->getStateSet() != surf_cpu_model_pm->getRunningActionSet())
+ if (action.getStateSet() != surf_cpu_model_pm->getRunningActionSet())
continue;
/* bogus priority, skip it */
- if (action->getPriority() <= 0)
+ if (action.getPriority() <= 0)
continue;
/* action suspended, skip it */
- if (action->suspended_ != 0)
+ if (action.suspended_ != 0)
continue;
- sum_priority += 1.0 / action->getPriority();
+ sum_priority += 1.0 / action.getPriority();
}
sumPriority_ = sum_priority;
- for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) {
- action = &*it;
+ for (CpuTiAction& action : *actionSet_) {
double min_finish = -1;
/* action not running, skip it */
- if (action->getStateSet() != surf_cpu_model_pm->getRunningActionSet())
+ if (action.getStateSet() != surf_cpu_model_pm->getRunningActionSet())
continue;
/* verify if the action is really running on cpu */
- if (action->suspended_ == 0 && action->getPriority() > 0) {
+ if (action.suspended_ == 0 && action.getPriority() > 0) {
/* total area needed to finish the action. Used in trace integration */
- total_area = (action->getRemains()) * sum_priority * action->getPriority();
+ total_area = (action.getRemains()) * sum_priority * action.getPriority();
total_area /= speed_.peak;
- action->setFinishTime(speedIntegratedTrace_->solve(now, total_area));
+ action.setFinishTime(speedIntegratedTrace_->solve(now, total_area));
/* verify which event will happen before (max_duration or finish time) */
- if (action->getMaxDuration() > NO_MAX_DURATION &&
- action->getStartTime() + action->getMaxDuration() < action->getFinishTime())
- min_finish = action->getStartTime() + action->getMaxDuration();
+ if (action.getMaxDuration() > NO_MAX_DURATION &&
+ action.getStartTime() + action.getMaxDuration() < action.getFinishTime())
+ min_finish = action.getStartTime() + action.getMaxDuration();
else
- min_finish = action->getFinishTime();
+ min_finish = action.getFinishTime();
} else {
/* put the max duration time on heap */
- if (action->getMaxDuration() > NO_MAX_DURATION)
- min_finish = action->getStartTime() + action->getMaxDuration();
+ if (action.getMaxDuration() > NO_MAX_DURATION)
+ min_finish = action.getStartTime() + action.getMaxDuration();
}
/* add in action heap */
if (min_finish > NO_MAX_DURATION)
- action->heapUpdate(model()->getActionHeap(), min_finish, NOTSET);
+ action.heapUpdate(model()->getActionHeap(), min_finish, NOTSET);
else
- action->heapRemove(model()->getActionHeap());
+ action.heapRemove(model()->getActionHeap());
XBT_DEBUG("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f", getCname(),
- action, action->getStartTime(), action->getFinishTime(), action->getMaxDuration());
+ &action, action.getStartTime(), action.getFinishTime(), action.getMaxDuration());
}
/* remove from modified cpu */
modified(false);
/* compute the integration area */
double area_total = speedIntegratedTrace_->integrate(lastUpdate_, now) * speed_.peak;
XBT_DEBUG("Flops total: %f, Last update %f", area_total, lastUpdate_);
- ActionTiList::iterator itend(actionSet_->end());
- for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) {
- CpuTiAction *action = &*it;
+ for (CpuTiAction& action : *actionSet_) {
/* action not running, skip it */
- if (action->getStateSet() != model()->getRunningActionSet())
+ if (action.getStateSet() != model()->getRunningActionSet())
continue;
/* bogus priority, skip it */
- if (action->getPriority() <= 0)
+ if (action.getPriority() <= 0)
continue;
/* action suspended, skip it */
- if (action->suspended_ != 0)
+ if (action.suspended_ != 0)
continue;
/* action don't need update */
- if (action->getStartTime() >= now)
+ if (action.getStartTime() >= now)
continue;
/* skip action that are finishing now */
- if (action->getFinishTime() >= 0 && action->getFinishTime() <= now)
+ if (action.getFinishTime() >= 0 && action.getFinishTime() <= now)
continue;
/* update remaining */
- action->updateRemains(area_total / (sumPriority_ * action->getPriority()));
- XBT_DEBUG("Update remaining action(%p) remaining %f", action, action->getRemainsNoUpdate());
+ action.updateRemains(area_total / (sumPriority_ * action.getPriority()));
+ XBT_DEBUG("Update remaining action(%p) remaining %f", &action, action.getRemainsNoUpdate());
}
lastUpdate_ = now;
}
void NetworkCm02Model::updateActionsStateFull(double now, double delta)
{
- ActionList *running_actions = getRunningActionSet();
- ActionList::iterator it(running_actions->begin());
- ActionList::iterator itend(running_actions->end());
- while (it != itend) {
- NetworkCm02Action *action = static_cast<NetworkCm02Action*> (&*it);
- ++it;
- XBT_DEBUG("Something happened to action %p", action);
- double deltap = delta;
- if (action->latency_ > 0) {
- if (action->latency_ > deltap) {
- double_update(&(action->latency_), deltap, sg_surf_precision);
- deltap = 0.0;
- } else {
- double_update(&(deltap), action->latency_, sg_surf_precision);
- action->latency_ = 0.0;
- }
- if (action->latency_ <= 0.0 && not action->isSuspended())
- lmm_update_variable_weight(maxminSystem_, action->getVariable(), action->weight_);
- }
- if (TRACE_is_enabled()) {
- int n = lmm_get_number_of_cnst_from_var(maxminSystem_, action->getVariable());
- for (int i = 0; i < n; i++){
- lmm_constraint_t constraint = lmm_get_cnst_from_var(maxminSystem_, action->getVariable(), i);
-
- NetworkCm02Link* link = static_cast<NetworkCm02Link*>(lmm_constraint_id(constraint));
- TRACE_surf_link_set_utilization(link->getCname(), action->getCategory(),
- (lmm_variable_getvalue(action->getVariable()) *
- lmm_get_cnst_weight_from_var(maxminSystem_, action->getVariable(), i)),
- action->getLastUpdate(), now - action->getLastUpdate());
- }
+ for (auto it = std::begin(*getRunningActionSet()); it != std::end(*getRunningActionSet());) {
+ NetworkCm02Action& action = static_cast<NetworkCm02Action&>(*it);
+ ++it; // increment iterator here since the following calls to action.finish() may invalidate it
+ XBT_DEBUG("Something happened to action %p", &action);
+ double deltap = delta;
+ if (action.latency_ > 0) {
+ if (action.latency_ > deltap) {
+ double_update(&action.latency_, deltap, sg_surf_precision);
+ deltap = 0.0;
+ } else {
+ double_update(&deltap, action.latency_, sg_surf_precision);
+ action.latency_ = 0.0;
}
- if (not lmm_get_number_of_cnst_from_var(maxminSystem_, action->getVariable())) {
- /* There is actually no link used, hence an infinite bandwidth. This happens often when using models like
- * vivaldi. In such case, just make sure that the action completes immediately.
- */
- action->updateRemains(action->getRemains());
+ if (action.latency_ <= 0.0 && not action.isSuspended())
+ lmm_update_variable_weight(maxminSystem_, action.getVariable(), action.weight_);
+ }
+ if (TRACE_is_enabled()) {
+ int n = lmm_get_number_of_cnst_from_var(maxminSystem_, action.getVariable());
+ for (int i = 0; i < n; i++) {
+ lmm_constraint_t constraint = lmm_get_cnst_from_var(maxminSystem_, action.getVariable(), i);
+
+ NetworkCm02Link* link = static_cast<NetworkCm02Link*>(lmm_constraint_id(constraint));
+ TRACE_surf_link_set_utilization(link->getCname(), action.getCategory(),
+ (lmm_variable_getvalue(action.getVariable()) *
+ lmm_get_cnst_weight_from_var(maxminSystem_, action.getVariable(), i)),
+ action.getLastUpdate(), now - action.getLastUpdate());
}
- action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
+ }
+ if (not lmm_get_number_of_cnst_from_var(maxminSystem_, action.getVariable())) {
+ /* There is actually no link used, hence an infinite bandwidth. This happens often when using models like
+ * vivaldi. In such case, just make sure that the action completes immediately.
+ */
+ action.updateRemains(action.getRemains());
+ }
+ action.updateRemains(lmm_variable_getvalue(action.getVariable()) * delta);
- if (action->getMaxDuration() > NO_MAX_DURATION)
- action->updateMaxDuration(delta);
+ if (action.getMaxDuration() > NO_MAX_DURATION)
+ action.updateMaxDuration(delta);
- if (((action->getRemains() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
- ((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
- action->finish(Action::State::done);
+ if (((action.getRemains() <= 0) && (lmm_get_variable_weight(action.getVariable()) > 0)) ||
+ ((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
+ action.finish(Action::State::done);
}
}
}
double NetworkConstantModel::nextOccuringEvent(double /*now*/)
{
double min = -1.0;
-
- ActionList* actionSet = getRunningActionSet();
- ActionList::iterator it(actionSet->begin());
- ActionList::iterator itend(actionSet->end());
- for (; it != itend; ++it) {
- NetworkConstantAction* action = static_cast<NetworkConstantAction*>(&*it);
- if (action->latency_ > 0 && (min < 0 || action->latency_ < min))
- min = action->latency_;
+ for (Action const& action : *getRunningActionSet()) {
+ const NetworkConstantAction& net_action = static_cast<const NetworkConstantAction&>(action);
+ if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min))
+ min = net_action.latency_;
}
-
return min;
}
void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
{
- NetworkConstantAction* action = nullptr;
- ActionList* actionSet = getRunningActionSet();
- ActionList::iterator it(actionSet->begin());
- ActionList::iterator itNext = it;
- ActionList::iterator itend(actionSet->end());
- for (; it != itend; it = itNext) {
- ++itNext;
- action = static_cast<NetworkConstantAction*>(&*it);
- if (action->latency_ > 0) {
- if (action->latency_ > delta) {
- double_update(&(action->latency_), delta, sg_surf_precision);
+ for (auto it = std::begin(*getRunningActionSet()); it != std::end(*getRunningActionSet());) {
+ NetworkConstantAction& action = static_cast<NetworkConstantAction&>(*it);
+ ++it; // increment iterator here since the following calls to action.finish() may invalidate it
+ if (action.latency_ > 0) {
+ if (action.latency_ > delta) {
+ double_update(&action.latency_, delta, sg_surf_precision);
} else {
- action->latency_ = 0.0;
+ action.latency_ = 0.0;
}
}
- action->updateRemains(action->getCost() * delta / action->initialLatency_);
- if (action->getMaxDuration() != NO_MAX_DURATION)
- action->updateMaxDuration(delta);
+ action.updateRemains(action.getCost() * delta / action.initialLatency_);
+ if (action.getMaxDuration() != NO_MAX_DURATION)
+ action.updateMaxDuration(delta);
- if ((action->getRemainsNoUpdate() <= 0) ||
- ((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
- action->finish(Action::State::done);
+ if ((action.getRemainsNoUpdate() <= 0) ||
+ ((action.getMaxDuration() != NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
+ action.finish(Action::State::done);
}
}
}
{
double minRes = Model::nextOccuringEventFull(now);
- for (auto it(getRunningActionSet()->begin()); it != getRunningActionSet()->end(); it++) {
- NetworkAction *action = static_cast<NetworkAction*>(&*it);
- if (action->latency_ > 0)
- minRes = (minRes < 0) ? action->latency_ : std::min(minRes, action->latency_);
+ for (Action const& action : *getRunningActionSet()) {
+ const NetworkAction& net_action = static_cast<const NetworkAction&>(action);
+ if (net_action.latency_ > 0)
+ minRes = (minRes < 0) ? net_action.latency_ : std::min(minRes, net_action.latency_);
}
XBT_DEBUG("Min of share resources %f", minRes);
double HostL07Model::nextOccuringEvent(double now)
{
double min = HostModel::nextOccuringEventFull(now);
- ActionList::iterator it(getRunningActionSet()->begin());
- ActionList::iterator itend(getRunningActionSet()->end());
- for (; it != itend; ++it) {
- L07Action *action = static_cast<L07Action*>(&*it);
- if (action->latency_ > 0 && (min < 0 || action->latency_ < min)) {
- min = action->latency_;
- XBT_DEBUG("Updating min with %p (start %f): %f", action, action->getStartTime(), min);
+ for (Action const& action : *getRunningActionSet()) {
+ const L07Action& net_action = static_cast<const L07Action&>(action);
+ if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min)) {
+ min = net_action.latency_;
+ XBT_DEBUG("Updating min with %p (start %f): %f", &net_action, net_action.getStartTime(), min);
}
}
XBT_DEBUG("min value: %f", min);
return min;
}
-void HostL07Model::updateActionsState(double /*now*/, double delta) {
-
- L07Action *action;
- ActionList *actionSet = getRunningActionSet();
- ActionList::iterator it(actionSet->begin());
- ActionList::iterator itNext = it;
- ActionList::iterator itend(actionSet->end());
-
- for (; it != itend; it = itNext) {
- ++itNext;
- action = static_cast<L07Action*>(&*it);
- if (action->latency_ > 0) {
- if (action->latency_ > delta) {
- double_update(&(action->latency_), delta, sg_surf_precision);
+void HostL07Model::updateActionsState(double /*now*/, double delta)
+{
+ for (auto it = std::begin(*getRunningActionSet()); it != std::end(*getRunningActionSet());) {
+ L07Action& action = static_cast<L07Action&>(*it);
+ ++it; // increment iterator here since the following calls to action.finish() may invalidate it
+ if (action.latency_ > 0) {
+ if (action.latency_ > delta) {
+ double_update(&(action.latency_), delta, sg_surf_precision);
} else {
- action->latency_ = 0.0;
+ action.latency_ = 0.0;
}
- if ((action->latency_ <= 0.0) && (action->isSuspended() == 0)) {
- action->updateBound();
- lmm_update_variable_weight(maxminSystem_, action->getVariable(), 1.0);
+ if ((action.latency_ <= 0.0) && (action.isSuspended() == 0)) {
+ action.updateBound();
+ lmm_update_variable_weight(maxminSystem_, action.getVariable(), 1.0);
}
}
- XBT_DEBUG("Action (%p) : remains (%g) updated by %g.",
- action, action->getRemains(), lmm_variable_getvalue(action->getVariable()) * delta);
- action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
+ XBT_DEBUG("Action (%p) : remains (%g) updated by %g.", &action, action.getRemains(),
+ lmm_variable_getvalue(action.getVariable()) * delta);
+ action.updateRemains(lmm_variable_getvalue(action.getVariable()) * delta);
- if (action->getMaxDuration() > NO_MAX_DURATION)
- action->updateMaxDuration(delta);
+ if (action.getMaxDuration() > NO_MAX_DURATION)
+ action.updateMaxDuration(delta);
- XBT_DEBUG("Action (%p) : remains (%g).", action, action->getRemains());
+ XBT_DEBUG("Action (%p) : remains (%g).", &action, action.getRemains());
/* In the next if cascade, the action can be finished either because:
* - The amount of remaining work reached 0
* If it's not done, it may have failed.
*/
- if (((action->getRemains() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
- ((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
- action->finish(Action::State::done);
+ if (((action.getRemains() <= 0) && (lmm_get_variable_weight(action.getVariable()) > 0)) ||
+ ((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
+ action.finish(Action::State::done);
} else {
/* Need to check that none of the model has failed */
int i = 0;
- lmm_constraint_t cnst = lmm_get_cnst_from_var(maxminSystem_, action->getVariable(), i);
+ lmm_constraint_t cnst = lmm_get_cnst_from_var(maxminSystem_, action.getVariable(), i);
while (cnst != nullptr) {
i++;
void *constraint_id = lmm_constraint_id(cnst);
if (static_cast<simgrid::surf::Resource*>(constraint_id)->isOff()) {
- XBT_DEBUG("Action (%p) Failed!!", action);
- action->finish(Action::State::failed);
+ XBT_DEBUG("Action (%p) Failed!!", &action);
+ action.finish(Action::State::failed);
break;
}
- cnst = lmm_get_cnst_from_var(maxminSystem_, action->getVariable(), i);
+ cnst = lmm_get_cnst_from_var(maxminSystem_, action.getVariable(), i);
}
}
}
void StorageN11Model::updateActionsState(double /*now*/, double delta)
{
- ActionList *actionSet = getRunningActionSet();
- ActionList::iterator it(actionSet->begin());
- ActionList::iterator itend(actionSet->end());
- while (it != itend) {
- StorageAction *action = static_cast<StorageAction*>(&*it);
- ++it;
- double current_progress = lrint(lmm_variable_getvalue(action->getVariable()) * delta);
-
- action->updateRemains(current_progress);
- if (action->type_ == WRITE) {
- action->storage_->usedSize_ += current_progress;
+ for (auto it = std::begin(*getRunningActionSet()); it != std::end(*getRunningActionSet());) {
+ StorageAction& action = static_cast<StorageAction&>(*it);
+ ++it; // increment iterator here since the following calls to action.finish() may invalidate it
+ double current_progress = lrint(lmm_variable_getvalue(action.getVariable()) * delta);
+ action.updateRemains(current_progress);
+ if (action.type_ == WRITE) {
+ action.storage_->usedSize_ += current_progress;
}
- if (action->getMaxDuration() > NO_MAX_DURATION)
- action->updateMaxDuration(delta);
+ if (action.getMaxDuration() > NO_MAX_DURATION)
+ action.updateMaxDuration(delta);
- if (action->getRemainsNoUpdate() > 0 && lmm_get_variable_weight(action->getVariable()) > 0 &&
- action->storage_->usedSize_ == action->storage_->getSize()) {
- action->finish(Action::State::failed);
- } else if (((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
- ((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
- action->finish(Action::State::done);
+ if (action.getRemainsNoUpdate() > 0 && lmm_get_variable_weight(action.getVariable()) > 0 &&
+ action.storage_->usedSize_ == action.storage_->getSize()) {
+ action.finish(Action::State::failed);
+ } else if (((action.getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action.getVariable()) > 0)) ||
+ ((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
+ action.finish(Action::State::done);
}
}
}
double min = -1;
- for (auto it(getRunningActionSet()->begin()); it != getRunningActionSet()->end(); ++it) {
- Action *action = &*it;
- double value = lmm_variable_getvalue(action->getVariable());
+ for (Action& action : *getRunningActionSet()) {
+ double value = lmm_variable_getvalue(action.getVariable());
if (value > 0) {
- if (action->getRemains() > 0)
- value = action->getRemainsNoUpdate() / value;
+ if (action.getRemains() > 0)
+ value = action.getRemainsNoUpdate() / value;
else
value = 0.0;
if (min < 0 || value < min) {
min = value;
- XBT_DEBUG("Updating min (value) with %p: %f", action, min);
+ XBT_DEBUG("Updating min (value) with %p: %f", &action, min);
}
}
- if ((action->getMaxDuration() >= 0) && (min<0 || action->getMaxDuration() < min)) {
- min = action->getMaxDuration();
- XBT_DEBUG("Updating min (duration) with %p: %f", action, min);
+ if ((action.getMaxDuration() >= 0) && (min < 0 || action.getMaxDuration() < min)) {
+ min = action.getMaxDuration();
+ XBT_DEBUG("Updating min (duration) with %p: %f", &action, min);
}
}
XBT_DEBUG("min value : %f", min);
simgrid::surf::ActionList* action_list = surf_cpu_model_pm->getFailedActionSet();
while (not action_list->empty()) {
- simgrid::surf::Action* action = &*action_list->begin();
+ simgrid::surf::Action& action = action_list->front();
XBT_INFO(" CPU Failed action");
- XBT_DEBUG("\t * Failed : %p", action);
- action->unref();
+ XBT_DEBUG("\t * Failed : %p", &action);
+ action.unref();
}
action_list = surf_cpu_model_pm->getDoneActionSet();
while (not action_list->empty()) {
- simgrid::surf::Action* action = &*action_list->begin();
+ simgrid::surf::Action& action = action_list->front();
XBT_INFO(" CPU Done action");
- XBT_DEBUG("\t * Done : %p", action);
- action->unref();
+ XBT_DEBUG("\t * Done : %p", &action);
+ action.unref();
}
action_list = surf_network_model->getFailedActionSet();
while (not action_list->empty()) {
- simgrid::surf::Action* action = &*action_list->begin();
+ simgrid::surf::Action& action = action_list->front();
XBT_INFO(" Network Failed action");
- XBT_DEBUG("\t * Failed : %p", action);
- action->unref();
+ XBT_DEBUG("\t * Failed : %p", &action);
+ action.unref();
}
action_list = surf_network_model->getDoneActionSet();
while (not action_list->empty()) {
- simgrid::surf::Action* action = &*action_list->begin();
+ simgrid::surf::Action& action = action_list->front();
XBT_INFO(" Network Done action");
- XBT_DEBUG("\t * Done : %p", action);
- action->unref();
+ XBT_DEBUG("\t * Done : %p", &action);
+ action.unref();
}
} while ((surf_network_model->getRunningActionSet()->size() ||