1 /* Copyright (c) 2004-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "surf_private.h"
8 #include "surf_interface.hpp"
9 #include "network_interface.hpp"
10 #include "cpu_interface.hpp"
11 #include "host_interface.hpp"
12 #include "src/simix/smx_host_private.h"
13 #include "surf_routing.hpp"
14 #include "simgrid/sg_config.h"
16 #include "virtual_machine.hpp"
18 XBT_LOG_NEW_CATEGORY(surf, "All SURF categories");
19 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf,
20 "Logging specific to SURF (kernel)");
26 /* model_list_invoke contains only surf_host and surf_vm.
27 * The callback functions of cpu_model and network_model will be called from
28 * those of these host models. */
29 xbt_dynar_t all_existing_models = NULL; /* to destroy models correctly */
30 xbt_dynar_t model_list_invoke = NULL; /* to invoke callbacks */
32 tmgr_fes_t history = NULL;
33 xbt_dynar_t surf_path = NULL;
34 xbt_dynar_t host_that_restart = NULL;
35 xbt_dict_t watched_hosts_lib;
40 simgrid::xbt::signal<void(void)> surfExitCallbacks;
45 #include <simgrid/plugins/energy.h> // FIXME: this plugin should not be linked to the core
47 s_surf_model_description_t surf_plugin_description[] = {
48 {"Energy", "Cpu energy consumption.", sg_energy_plugin_init},
49 {NULL, NULL, NULL} /* this array must be NULL terminated */
52 /* Don't forget to update the option description in smx_config when you change
54 s_surf_model_description_t surf_network_model_description[] = {
56 "Realistic network analytic model (slow-start modeled by multiplying latency by 10.4, bandwidth by .92; bottleneck sharing uses a payload of S=8775 for evaluating RTT). ",
57 surf_network_model_init_LegrandVelho},
59 "Simplistic network model where all communication take a constant time (one second). This model provides the lowest realism, but is (marginally) faster.",
60 surf_network_model_init_Constant},
62 "Realistic network model specifically tailored for HPC settings (accurate modeling of slow start with correction factors on three intervals: < 1KiB, < 64 KiB, >= 64 KiB)",
63 surf_network_model_init_SMPI},
65 "Realistic network model specifically tailored for HPC settings, with Infiniband contention model",
66 surf_network_model_init_IB},
68 "Legacy network analytic model (Very similar to LV08, but without corrective factors. The timings of small messages are thus poorly modeled).",
69 surf_network_model_init_CM02},
72 "Network pseudo-model using the NS3 tcp model instead of an analytic model",
73 surf_network_model_init_NS3},
76 "Model from Steven H. Low using lagrange_solve instead of lmm_solve (experts only; check the code for more info).",
77 surf_network_model_init_Reno},
79 "Model from Steven H. Low using lagrange_solve instead of lmm_solve (experts only; check the code for more info).",
80 surf_network_model_init_Reno2},
82 "Model from Steven H. Low using lagrange_solve instead of lmm_solve (experts only; check the code for more info).",
83 surf_network_model_init_Vegas},
84 {NULL, NULL, NULL} /* this array must be NULL terminated */
87 s_surf_model_description_t surf_cpu_model_description[] = {
89 "Simplistic CPU model (time=size/power).",
90 surf_cpu_model_init_Cas01},
91 {NULL, NULL, NULL} /* this array must be NULL terminated */
94 s_surf_model_description_t surf_host_model_description[] = {
96 "Default host model. Currently, CPU:Cas01 and network:LV08 (with cross traffic enabled)",
97 surf_host_model_init_current_default},
99 "Host model that is automatically chosen if you change the network and CPU models",
100 surf_host_model_init_compound},
101 {"ptask_L07", "Host model somehow similar to Cas01+CM02 but allowing parallel tasks",
102 surf_host_model_init_ptask_L07},
103 {NULL, NULL, NULL} /* this array must be NULL terminated */
106 s_surf_model_description_t surf_vm_model_description[] = {
109 surf_vm_model_init_HL13},
110 {NULL, NULL, NULL} /* this array must be NULL terminated */
113 s_surf_model_description_t surf_optimization_mode_description[] = {
115 "Lazy action management (partial invalidation in lmm + heap in action remaining).",
118 "Trace integration. Highly optimized mode when using availability traces (only available for the Cas01 CPU model for now).",
121 "Full update of remaining and variables. Slow but may be useful when debugging.",
123 {NULL, NULL, NULL} /* this array must be NULL terminated */
126 s_surf_model_description_t surf_storage_model_description[] = {
128 "Simplistic storage model.",
129 surf_storage_model_init_default},
130 {NULL, NULL, NULL} /* this array must be NULL terminated */
133 #ifdef CONTEXT_THREADS
134 static xbt_parmap_t surf_parmap = NULL; /* parallel map on models */
139 double surf_get_clock(void)
145 # define FILE_DELIM "\\"
147 # define FILE_DELIM "/" /* FIXME: move to better location */
150 FILE *surf_fopen(const char *name, const char *mode)
153 char *path_elm = NULL;
159 if (__surf_is_absolute_file_path(name)) /* don't mess with absolute file names */
160 return fopen(name, mode);
162 /* search relative files in the path */
163 xbt_dynar_foreach(surf_path, cpt, path_elm) {
164 buff = bprintf("%s" FILE_DELIM "%s", path_elm, name);
165 file = fopen(buff, mode);
177 static const char *disk_drives_letter_table[MAX_DRIVE] = {
178 "A:\\","B:\\","C:\\","D:\\","E:\\","F:\\","G:\\","H:\\","I:\\","J:\\","K:\\","L:\\","M:\\",
179 "N:\\","O:\\","P:\\","Q:\\","R:\\","S:\\","T:\\","U:\\","V:\\","W:\\","X:\\","Y:\\","Z:\\"
184 * Returns the initial path. On Windows the initial path is
185 * the current directory for the current process in the other
186 * case the function returns "./" that represents the current
187 * directory on Unix/Linux platforms.
190 const char *__surf_get_initial_path(void)
195 char current_directory[MAX_PATH + 1] = { 0 };
196 unsigned int len = GetCurrentDirectory(MAX_PATH + 1, current_directory);
197 char root[4] = { 0 };
202 strncpy(root, current_directory, 3);
204 for (i = 0; i < MAX_DRIVE; i++) {
205 if (toupper(root[0]) == disk_drives_letter_table[i][0])
206 return disk_drives_letter_table[i];
215 /* The __surf_is_absolute_file_path() returns 1 if
216 * file_path is a absolute file path, in the other
217 * case the function returns 0.
219 int __surf_is_absolute_file_path(const char *file_path)
222 WIN32_FIND_DATA wfd = { 0 };
223 HANDLE hFile = FindFirstFile(file_path, &wfd);
225 if (INVALID_HANDLE_VALUE == hFile)
231 return (file_path[0] == '/');
235 /** Displays the long description of all registered models, and quit */
236 void model_help(const char *category, s_surf_model_description_t * table)
239 printf("Long description of the %s models accepted by this simulator:\n",
241 for (i = 0; table[i].name; i++)
242 printf(" %s: %s\n", table[i].name, table[i].description);
245 int find_model_description(s_surf_model_description_t * table,
249 char *name_list = NULL;
251 for (i = 0; table[i].name; i++)
252 if (!strcmp(name, table[i].name)) {
256 xbt_die("No model is valid! This is a bug.");
257 name_list = xbt_strdup(table[0].name);
258 for (i = 1; table[i].name; i++) {
259 name_list = (char *) xbt_realloc(name_list, strlen(name_list) + strlen(table[i].name) + 3);
260 strcat(name_list, ", ");
261 strcat(name_list, table[i].name);
263 xbt_die("Model '%s' is invalid! Valid models are: %s.", name, name_list);
267 static XBT_INLINE void routing_asr_prop_free(void *p)
269 //xbt_dict_t elm = (xbt_dict_t) p;
270 //xbt_dict_free(&elm); FIXME: leaking in some case? That's a sometimes double-free with AsCluster::~AsCluster
273 static XBT_INLINE void surf_storage_free(void *r)
275 delete static_cast<simgrid::surf::Storage*>(r);
278 void sg_version_check(int lib_version_major,int lib_version_minor,int lib_version_patch) {
279 if ((lib_version_major != SIMGRID_VERSION_MAJOR) || (lib_version_minor != SIMGRID_VERSION_MINOR)) {
281 "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, "
282 "and then linked against SimGrid %d.%d.%d. Please fix this.\n",
283 SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH,
284 lib_version_major,lib_version_minor,lib_version_patch);
287 if (lib_version_patch != SIMGRID_VERSION_PATCH) {
289 "Warning: Your program was compiled with SimGrid version %d.%d.%d, "
290 "and then linked against SimGrid %d.%d.%d. Proceeding anyway.\n",
291 SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH,
292 lib_version_major,lib_version_minor,lib_version_patch);
296 void sg_version(int *ver_major,int *ver_minor,int *ver_patch) {
297 *ver_major = SIMGRID_VERSION_MAJOR;
298 *ver_minor = SIMGRID_VERSION_MINOR;
299 *ver_patch = SIMGRID_VERSION_PATCH;
302 void surf_init(int *argc, char **argv)
304 XBT_DEBUG("Create all Libs");
305 host_list = xbt_dict_new_homogeneous([](void*p) {
306 simgrid::s4u::Host* host = static_cast<simgrid::s4u::Host*>(p);
307 simgrid::s4u::Host::onDestruction(*host);
310 as_router_lib = xbt_lib_new();
311 storage_lib = xbt_lib_new();
312 storage_type_lib = xbt_lib_new();
313 file_lib = xbt_lib_new();
314 watched_hosts_lib = xbt_dict_new_homogeneous(NULL);
318 XBT_DEBUG("Add routing levels");
319 ROUTING_PROP_ASR_LEVEL = xbt_lib_add_level(as_router_lib,routing_asr_prop_free);
321 XBT_DEBUG("Add SURF levels");
322 simgrid::surf::Host::classInit();
323 SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_free);
325 xbt_init(argc, argv);
326 if (!all_existing_models)
327 all_existing_models = xbt_dynar_new(sizeof(simgrid::surf::Model*), NULL);
328 if (!model_list_invoke)
329 model_list_invoke = xbt_dynar_new(sizeof(simgrid::surf::Model*), NULL);
331 history = tmgr_history_new();
333 TRACE_add_start_function(TRACE_surf_alloc);
334 TRACE_add_end_function(TRACE_surf_release);
336 sg_config_init(argc, argv);
345 simgrid::surf::Model *model = NULL;
347 TRACE_end(); /* Just in case it was not called by the upper
348 * layer (or there is no upper layer) */
350 sg_config_finalize();
352 xbt_dynar_free(&host_that_restart);
353 xbt_dynar_free(&surf_path);
355 xbt_dict_free(&host_list);
356 xbt_lib_free(&as_router_lib);
357 xbt_lib_free(&storage_lib);
359 xbt_lib_free(&storage_type_lib);
360 xbt_lib_free(&file_lib);
361 xbt_dict_free(&watched_hosts_lib);
363 xbt_dynar_foreach(all_existing_models, iter, model)
365 xbt_dynar_free(&all_existing_models);
366 xbt_dynar_free(&model_list_invoke);
369 simgrid::surf::surfExitCallbacks();
372 tmgr_history_free(history);
376 #ifdef CONTEXT_THREADS
377 xbt_parmap_destroy(surf_parmap);
381 surf_parse_lex_destroy();
382 surf_parse_free_callbacks();
384 NOW = 0; /* Just in case the user plans to restart the simulation afterward */
395 : p_maxminSystem(NULL)
397 p_readyActionSet = new ActionList();
398 p_runningActionSet = new ActionList();
399 p_failedActionSet = new ActionList();
400 p_doneActionSet = new ActionList();
402 p_modifiedSet = NULL;
404 p_updateMechanism = UM_UNDEFINED;
405 m_selectiveUpdate = 0;
409 delete p_readyActionSet;
410 delete p_runningActionSet;
411 delete p_failedActionSet;
412 delete p_doneActionSet;
415 double Model::shareResources(double now)
417 //FIXME: set the good function once and for all
418 if (p_updateMechanism == UM_LAZY)
419 return shareResourcesLazy(now);
420 else if (p_updateMechanism == UM_FULL)
421 return shareResourcesFull(now);
423 xbt_die("Invalid cpu update mechanism!");
426 double Model::shareResourcesLazy(double now)
428 Action *action = NULL;
433 ("Before share resources, the size of modified actions set is %zd",
434 p_modifiedSet->size());
436 lmm_solve(p_maxminSystem);
439 ("After share resources, The size of modified actions set is %zd",
440 p_modifiedSet->size());
442 while(!p_modifiedSet->empty()) {
443 action = &(p_modifiedSet->front());
444 p_modifiedSet->pop_front();
445 int max_dur_flag = 0;
447 if (action->getStateSet() != p_runningActionSet)
450 /* bogus priority, skip it */
451 if (action->getPriority() <= 0 || action->getHat()==LATENCY)
454 action->updateRemainingLazy(now);
457 share = lmm_variable_getvalue(action->getVariable());
460 double time_to_completion;
461 if (action->getRemains() > 0) {
462 time_to_completion = action->getRemainsNoUpdate() / share;
464 time_to_completion = 0.0;
466 min = now + time_to_completion; // when the task will complete if nothing changes
469 if ((action->getMaxDuration() != NO_MAX_DURATION)
471 || action->getStartTime() +
472 action->getMaxDuration() < min)) {
473 min = action->getStartTime() +
474 action->getMaxDuration(); // when the task will complete anyway because of the deadline if any
479 XBT_DEBUG("Action(%p) corresponds to variable %d", action, action->getVariable()->id_int);
481 XBT_DEBUG("Action(%p) Start %f. May finish at %f (got a share of %f). Max_duration %f", action,
482 action->getStartTime(), min, share,
483 action->getMaxDuration());
486 action->heapUpdate(p_actionHeap, min, max_dur_flag ? MAX_DURATION : NORMAL);
487 XBT_DEBUG("Insert at heap action(%p) min %f now %f", action, min,
489 } else DIE_IMPOSSIBLE;
492 //hereafter must have already the min value for this resource model
493 if (xbt_heap_size(p_actionHeap) > 0)
494 min = xbt_heap_maxkey(p_actionHeap) - now;
498 XBT_DEBUG("The minimum with the HEAP %f", min);
503 double Model::shareResourcesFull(double /*now*/) {
507 double Model::shareResourcesMaxMin(ActionList *running_actions,
509 void (*solve) (lmm_system_t))
511 Action *action = NULL;
517 ActionList::iterator it(running_actions->begin()), itend(running_actions->end());
518 for(; it != itend ; ++it) {
520 value = lmm_variable_getvalue(action->getVariable());
521 if ((value > 0) || (action->getMaxDuration() >= 0))
529 if (action->getRemains() > 0)
530 min = action->getRemainsNoUpdate() / value;
533 if ((action->getMaxDuration() >= 0) && (action->getMaxDuration() < min))
534 min = action->getMaxDuration();
536 min = action->getMaxDuration();
539 for (++it; it != itend; ++it) {
541 value = lmm_variable_getvalue(action->getVariable());
543 if (action->getRemains() > 0)
544 value = action->getRemainsNoUpdate() / value;
549 XBT_DEBUG("Updating min (value) with %p: %f", action, min);
552 if ((action->getMaxDuration() >= 0) && (action->getMaxDuration() < min)) {
553 min = action->getMaxDuration();
554 XBT_DEBUG("Updating min (duration) with %p: %f", action, min);
557 XBT_DEBUG("min value : %f", min);
562 void Model::updateActionsState(double now, double delta)
564 if (p_updateMechanism == UM_FULL)
565 updateActionsStateFull(now, delta);
566 else if (p_updateMechanism == UM_LAZY)
567 updateActionsStateLazy(now, delta);
569 xbt_die("Invalid cpu update mechanism!");
572 void Model::updateActionsStateLazy(double /*now*/, double /*delta*/)
577 void Model::updateActionsStateFull(double /*now*/, double /*delta*/)
592 Resource::Resource(Model *model, const char *name)
593 : Resource(model, name, 1/*ON*/)
596 Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint)
597 : Resource(model, name, constraint, 1/*ON*/)
600 Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint, int initiallyOn)
601 : p_name(xbt_strdup(name))
603 , m_isOn(initiallyOn)
604 , p_constraint(constraint)
607 Resource::Resource(Model *model, const char *name, int initiallyOn)
608 : p_name(xbt_strdup(name))
610 , m_isOn(initiallyOn)
614 Resource::~Resource() {
615 xbt_free((void*)p_name);
618 bool Resource::isOn() {
621 bool Resource::isOff() {
625 void Resource::turnOn()
632 void Resource::turnOff()
639 Model *Resource::getModel() {
643 const char *Resource::getName() {
647 lmm_constraint_t Resource::getConstraint() {
658 const char *surf_action_state_names[6] = {
660 "SURF_ACTION_RUNNING",
661 "SURF_ACTION_FAILED",
663 "SURF_ACTION_TO_FREE",
664 "SURF_ACTION_NOT_IN_THE_SYSTEM"
667 /* added to manage the communication action's heap */
668 void surf_action_lmm_update_index_heap(void *action, int i) {
669 static_cast<simgrid::surf::Action*>(action)->updateIndexHeap(i);
675 void Action::initialize(simgrid::surf::Model *model, double cost, bool failed,
679 m_start = surf_get_clock();
684 p_stateSet = getModel()->getFailedActionSet();
686 p_stateSet = getModel()->getRunningActionSet();
688 p_stateSet->push_back(*this);
691 Action::Action(simgrid::surf::Model *model, double cost, bool failed)
693 initialize(model, cost, failed);
696 Action::Action(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var)
698 initialize(model, cost, failed, var);
702 xbt_free(p_category);
705 void Action::finish() {
706 m_finish = surf_get_clock();
709 e_surf_action_state_t Action::getState()
711 if (p_stateSet == getModel()->getReadyActionSet())
712 return SURF_ACTION_READY;
713 if (p_stateSet == getModel()->getRunningActionSet())
714 return SURF_ACTION_RUNNING;
715 if (p_stateSet == getModel()->getFailedActionSet())
716 return SURF_ACTION_FAILED;
717 if (p_stateSet == getModel()->getDoneActionSet())
718 return SURF_ACTION_DONE;
719 return SURF_ACTION_NOT_IN_THE_SYSTEM;
722 void Action::setState(e_surf_action_state_t state)
724 //surf_action_state_t action_state = &(action->model_type->states);
725 XBT_IN("(%p,%s)", this, surf_action_state_names[state]);
726 p_stateSet->erase(p_stateSet->iterator_to(*this));
727 if (state == SURF_ACTION_READY)
728 p_stateSet = getModel()->getReadyActionSet();
729 else if (state == SURF_ACTION_RUNNING)
730 p_stateSet = getModel()->getRunningActionSet();
731 else if (state == SURF_ACTION_FAILED)
732 p_stateSet = getModel()->getFailedActionSet();
733 else if (state == SURF_ACTION_DONE)
734 p_stateSet = getModel()->getDoneActionSet();
739 p_stateSet->push_back(*this);
743 double Action::getBound()
745 return (p_variable) ? lmm_variable_getbound(p_variable) : 0;
748 void Action::setBound(double bound)
750 XBT_IN("(%p,%g)", this, bound);
752 lmm_update_variable_bound(getModel()->getMaxminSystem(), p_variable, bound);
754 if (getModel()->getUpdateMechanism() == UM_LAZY && getLastUpdate()!=surf_get_clock())
755 heapRemove(getModel()->getActionHeap());
759 double Action::getStartTime()
764 double Action::getFinishTime()
766 /* keep the function behavior, some models (cpu_ti) change the finish time before the action end */
767 return m_remains == 0 ? m_finish : -1;
770 void Action::setData(void* data)
775 void Action::setCategory(const char *category)
777 XBT_IN("(%p,%s)", this, category);
778 p_category = xbt_strdup(category);
786 void Action::setMaxDuration(double duration)
788 XBT_IN("(%p,%g)", this, duration);
789 m_maxDuration = duration;
790 if (getModel()->getUpdateMechanism() == UM_LAZY) // remove action from the heap
791 heapRemove(getModel()->getActionHeap());
795 void Action::gapRemove() {}
797 void Action::setPriority(double priority)
799 XBT_IN("(%p,%g)", this, priority);
800 m_priority = priority;
801 lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), priority);
803 if (getModel()->getUpdateMechanism() == UM_LAZY)
804 heapRemove(getModel()->getActionHeap());
808 void Action::cancel(){
809 setState(SURF_ACTION_FAILED);
810 if (getModel()->getUpdateMechanism() == UM_LAZY) {
811 if (action_lmm_hook.is_linked())
812 getModel()->getModifiedSet()->erase(getModel()->getModifiedSet()->iterator_to(*this));
813 heapRemove(getModel()->getActionHeap());
820 if (action_hook.is_linked())
821 p_stateSet->erase(p_stateSet->iterator_to(*this));
823 lmm_variable_free(getModel()->getMaxminSystem(), getVariable());
824 if (getModel()->getUpdateMechanism() == UM_LAZY) {
825 /* remove from heap */
826 heapRemove(getModel()->getActionHeap());
827 if (action_lmm_hook.is_linked())
828 getModel()->getModifiedSet()->erase(getModel()->getModifiedSet()->iterator_to(*this));
836 void Action::suspend()
838 XBT_IN("(%p)", this);
839 if (m_suspended != 2) {
840 lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0);
842 if (getModel()->getUpdateMechanism() == UM_LAZY)
843 heapRemove(getModel()->getActionHeap());
848 void Action::resume()
850 XBT_IN("(%p)", this);
851 if (m_suspended != 2) {
852 lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), m_priority);
854 if (getModel()->getUpdateMechanism() == UM_LAZY)
855 heapRemove(getModel()->getActionHeap());
860 bool Action::isSuspended()
862 return m_suspended == 1;
864 /* insert action on heap using a given key and a hat (heap_action_type)
865 * a hat can be of three types for communications:
867 * NORMAL = this is a normal heap entry stating the date to finish transmitting
868 * LATENCY = this is a heap entry to warn us when the latency is payed
869 * MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached
871 void Action::heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat)
874 xbt_heap_push(heap, this, key);
877 void Action::heapRemove(xbt_heap_t heap)
880 if (m_indexHeap >= 0) {
881 xbt_heap_remove(heap, m_indexHeap);
885 void Action::heapUpdate(xbt_heap_t heap, double key, enum heap_action_type hat)
888 if (m_indexHeap >= 0) {
889 xbt_heap_update(heap, m_indexHeap, key);
891 xbt_heap_push(heap, this, key);
895 void Action::updateIndexHeap(int i) {
899 double Action::getRemains()
901 XBT_IN("(%p)", this);
902 /* update remains before return it */
903 if (getModel()->getUpdateMechanism() == UM_LAZY) /* update remains before return it */
904 updateRemainingLazy(surf_get_clock());
909 double Action::getRemainsNoUpdate()
914 //FIXME split code in the right places
915 void Action::updateRemainingLazy(double now)
919 if(getModel() == surf_network_model)
921 if (m_suspended != 0)
926 xbt_assert(p_stateSet == getModel()->getRunningActionSet(),
927 "You're updating an action that is not running.");
929 /* bogus priority, skip it */
930 xbt_assert(m_priority > 0,
931 "You're updating an action that seems suspended.");
934 delta = now - m_lastUpdate;
937 XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, m_remains, m_lastUpdate);
938 double_update(&m_remains, m_lastValue * delta, sg_surf_precision*sg_maxmin_precision);
940 if (getModel() == surf_cpu_model_pm && TRACE_is_enabled()) {
941 simgrid::surf::Resource *cpu = static_cast<simgrid::surf::Resource*>(
942 lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)));
943 TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), m_lastValue, m_lastUpdate, now - m_lastUpdate);
945 XBT_DEBUG("Updating action(%p): remains is now %f", this, m_remains);
948 if(getModel() == surf_network_model)
950 if (m_maxDuration != NO_MAX_DURATION)
951 double_update(&m_maxDuration, delta, sg_surf_precision);
953 //FIXME: duplicated code
954 if ((m_remains <= 0) &&
955 (lmm_get_variable_weight(getVariable()) > 0)) {
957 setState(SURF_ACTION_DONE);
958 heapRemove(getModel()->getActionHeap());
959 } else if (((m_maxDuration != NO_MAX_DURATION)
960 && (m_maxDuration <= 0))) {
962 setState(SURF_ACTION_DONE);
963 heapRemove(getModel()->getActionHeap());
968 m_lastValue = lmm_variable_getvalue(getVariable());