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 "src/internal_config.h"
8 #include "surf_private.h"
9 #include "surf_interface.hpp"
10 #include "network_interface.hpp"
11 #include "cpu_interface.hpp"
12 #include "src/surf/HostImpl.hpp"
13 #include "src/simix/smx_host_private.h"
14 #include "surf_routing.hpp"
15 #include "simgrid/sg_config.h"
17 #include "virtual_machine.hpp"
18 #include "src/instr/instr_private.h" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
19 #include "simgrid/s4u/engine.hpp"
22 XBT_LOG_NEW_CATEGORY(surf, "All SURF categories");
23 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (kernel)");
29 /* model_list_invoke contains only surf_host and surf_vm.
30 * The callback functions of cpu_model and network_model will be called from those of these host models. */
31 std::vector<surf_model_t> * all_existing_models = nullptr; /* to destroy models correctly */
32 xbt_dynar_t model_list_invoke = nullptr; /* to invoke callbacks */
34 simgrid::trace_mgr::future_evt_set *future_evt_set = nullptr;
35 xbt_dynar_t surf_path = nullptr;
36 std::vector<sg_host_t> host_that_restart;
37 xbt_dict_t watched_hosts_lib;
42 simgrid::xbt::signal<void(void)> surfExitCallbacks;
47 #include <simgrid/plugins/energy.h> // FIXME: this plugin should not be linked to the core
49 s_surf_model_description_t surf_plugin_description[] = {
50 {"Energy", "Cpu energy consumption.", sg_energy_plugin_init},
51 {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
54 /* Don't forget to update the option description in smx_config when you change this */
55 s_surf_model_description_t surf_network_model_description[] = {
56 {"LV08", "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},
61 {"SMPI", "Realistic network model specifically tailored for HPC settings (accurate modeling of slow start with correction factors on three intervals: < 1KiB, < 64 KiB, >= 64 KiB)",
62 surf_network_model_init_SMPI},
63 {"IB", "Realistic network model specifically tailored for HPC settings, with Infiniband contention model",
64 surf_network_model_init_IB},
65 {"CM02", "Legacy network analytic model (Very similar to LV08, but without corrective factors. The timings of small messages are thus poorly modeled).",
66 surf_network_model_init_CM02},
68 {"NS3", "Network pseudo-model using the NS3 tcp model instead of an analytic model", surf_network_model_init_NS3},
70 {"Reno", "Model from Steven H. Low using lagrange_solve instead of lmm_solve (experts only; check the code for more info).",
71 surf_network_model_init_Reno},
72 {"Reno2", "Model from Steven H. Low using lagrange_solve instead of lmm_solve (experts only; check the code for more info).",
73 surf_network_model_init_Reno2},
74 {"Vegas", "Model from Steven H. Low using lagrange_solve instead of lmm_solve (experts only; check the code for more info).",
75 surf_network_model_init_Vegas},
76 {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
79 s_surf_model_description_t surf_cpu_model_description[] = {
80 {"Cas01", "Simplistic CPU model (time=size/power).", surf_cpu_model_init_Cas01},
81 {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
84 s_surf_model_description_t surf_host_model_description[] = {
85 {"default", "Default host model. Currently, CPU:Cas01 and network:LV08 (with cross traffic enabled)", surf_host_model_init_current_default},
86 {"compound", "Host model that is automatically chosen if you change the network and CPU models", surf_host_model_init_compound},
87 {"ptask_L07", "Host model somehow similar to Cas01+CM02 but allowing parallel tasks", surf_host_model_init_ptask_L07},
88 {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
91 s_surf_model_description_t surf_vm_model_description[] = {
92 {"default", "Default vm model.", surf_vm_model_init_HL13},
93 {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
96 s_surf_model_description_t surf_optimization_mode_description[] = {
97 {"Lazy", "Lazy action management (partial invalidation in lmm + heap in action remaining).", nullptr},
98 {"TI", "Trace integration. Highly optimized mode when using availability traces (only available for the Cas01 CPU model for now).", nullptr},
99 {"Full", "Full update of remaining and variables. Slow but may be useful when debugging.", nullptr},
100 {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
103 s_surf_model_description_t surf_storage_model_description[] = {
104 {"default", "Simplistic storage model.", surf_storage_model_init_default},
105 {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
108 #if HAVE_THREAD_CONTEXTS
109 static xbt_parmap_t surf_parmap = nullptr; /* parallel map on models */
114 double surf_get_clock()
120 # define FILE_DELIM "\\"
122 # define FILE_DELIM "/" /* FIXME: move to better location */
125 FILE *surf_fopen(const char *name, const char *mode)
128 char *path_elm = nullptr;
130 FILE *file = nullptr;
134 if (__surf_is_absolute_file_path(name)) /* don't mess with absolute file names */
135 return fopen(name, mode);
137 /* search relative files in the path */
138 xbt_dynar_foreach(surf_path, cpt, path_elm) {
139 buff = bprintf("%s" FILE_DELIM "%s", path_elm, name);
140 file = fopen(buff, mode);
152 static const char *disk_drives_letter_table[MAX_DRIVE] = {
153 "A:\\","B:\\","C:\\","D:\\","E:\\","F:\\","G:\\","H:\\","I:\\","J:\\","K:\\","L:\\","M:\\",
154 "N:\\","O:\\","P:\\","Q:\\","R:\\","S:\\","T:\\","U:\\","V:\\","W:\\","X:\\","Y:\\","Z:\\"
159 * Returns the initial path. On Windows the initial path is
160 * the current directory for the current process in the other
161 * case the function returns "./" that represents the current
162 * directory on Unix/Linux platforms.
165 const char *__surf_get_initial_path()
170 char current_directory[MAX_PATH + 1] = { 0 };
171 unsigned int len = GetCurrentDirectory(MAX_PATH + 1, current_directory);
172 char root[4] = { 0 };
177 strncpy(root, current_directory, 3);
179 for (i = 0; i < MAX_DRIVE; i++) {
180 if (toupper(root[0]) == disk_drives_letter_table[i][0])
181 return disk_drives_letter_table[i];
190 /* The __surf_is_absolute_file_path() returns 1 if
191 * file_path is a absolute file path, in the other
192 * case the function returns 0.
194 int __surf_is_absolute_file_path(const char *file_path)
197 WIN32_FIND_DATA wfd = { 0 };
198 HANDLE hFile = FindFirstFile(file_path, &wfd);
200 if (INVALID_HANDLE_VALUE == hFile)
206 return (file_path[0] == '/');
210 /** Displays the long description of all registered models, and quit */
211 void model_help(const char *category, s_surf_model_description_t * table)
213 printf("Long description of the %s models accepted by this simulator:\n", category);
214 for (int i = 0; table[i].name; i++)
215 printf(" %s: %s\n", table[i].name, table[i].description);
218 int find_model_description(s_surf_model_description_t * table,
222 char *name_list = nullptr;
224 for (i = 0; table[i].name; i++)
225 if (!strcmp(name, table[i].name)) {
229 xbt_die("No model is valid! This is a bug.");
230 name_list = xbt_strdup(table[0].name);
231 for (i = 1; table[i].name; i++) {
232 name_list = (char *) xbt_realloc(name_list, strlen(name_list) + strlen(table[i].name) + 3);
233 strncat(name_list, ", ", 2);
234 strncat(name_list, table[i].name, strlen(table[i].name));
236 xbt_die("Model '%s' is invalid! Valid models are: %s.", name, name_list);
240 static inline void surf_storage_free(void *r)
242 delete static_cast<simgrid::surf::Storage*>(r);
245 void sg_version_check(int lib_version_major,int lib_version_minor,int lib_version_patch) {
246 if ((lib_version_major != SIMGRID_VERSION_MAJOR) || (lib_version_minor != SIMGRID_VERSION_MINOR)) {
248 "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, "
249 "and then linked against SimGrid %d.%d.%d. Please fix this.\n",
250 lib_version_major,lib_version_minor,lib_version_patch,
251 SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH);
254 if (lib_version_patch != SIMGRID_VERSION_PATCH) {
255 if(SIMGRID_VERSION_PATCH >= 90 || lib_version_patch >=90){
257 "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, "
258 "and then linked against SimGrid %d.%d.%d. \n"
259 "One of them is a development version, and should not be mixed with the stable release. Please fix this.\n",
260 lib_version_major,lib_version_minor,lib_version_patch,
261 SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH);
265 "Warning: Your program was compiled with SimGrid version %d.%d.%d, "
266 "and then linked against SimGrid %d.%d.%d. Proceeding anyway.\n",
267 lib_version_major,lib_version_minor,lib_version_patch,
268 SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH);
272 void sg_version(int *ver_major,int *ver_minor,int *ver_patch) {
273 *ver_major = SIMGRID_VERSION_MAJOR;
274 *ver_minor = SIMGRID_VERSION_MINOR;
275 *ver_patch = SIMGRID_VERSION_PATCH;
278 void surf_init(int *argc, char **argv)
280 if (host_list != nullptr) // Already initialized
283 XBT_DEBUG("Create all Libs");
284 host_list = xbt_dict_new_homogeneous([](void*p) {
285 simgrid::s4u::Host* host = static_cast<simgrid::s4u::Host*>(p);
286 simgrid::s4u::Host::onDestruction(*host);
289 USER_HOST_LEVEL = simgrid::s4u::Host::extension_create(nullptr);
291 as_router_lib = xbt_lib_new();
292 storage_lib = xbt_lib_new();
293 storage_type_lib = xbt_lib_new();
294 file_lib = xbt_lib_new();
295 watched_hosts_lib = xbt_dict_new_homogeneous(nullptr);
297 XBT_DEBUG("Add routing levels");
298 ROUTING_PROP_ASR_LEVEL = xbt_lib_add_level(as_router_lib, nullptr);
299 ROUTING_ASR_LEVEL = xbt_lib_add_level(as_router_lib, [](void* p) {
300 delete static_cast<simgrid::kernel::routing::NetCard*>(p);
303 XBT_DEBUG("Add SURF levels");
304 simgrid::surf::HostImpl::classInit();
305 SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_free);
307 xbt_init(argc, argv);
308 if (!all_existing_models)
309 all_existing_models = new std::vector<simgrid::surf::Model*>();
310 if (!model_list_invoke)
311 model_list_invoke = xbt_dynar_new(sizeof(simgrid::surf::Model*), nullptr);
313 future_evt_set = new simgrid::trace_mgr::future_evt_set();
315 TRACE_add_start_function(TRACE_surf_alloc);
316 TRACE_add_end_function(TRACE_surf_release);
318 sg_config_init(argc, argv);
326 TRACE_end(); /* Just in case it was not called by the upper layer (or there is no upper layer) */
328 xbt_dynar_free(&surf_path);
330 xbt_dict_free(&host_list);
331 xbt_lib_free(&as_router_lib);
332 xbt_lib_free(&storage_lib);
334 xbt_lib_free(&storage_type_lib);
335 xbt_lib_free(&file_lib);
336 xbt_dict_free(&watched_hosts_lib);
338 for (auto model : *all_existing_models)
340 delete all_existing_models;
341 xbt_dynar_free(&model_list_invoke);
344 simgrid::surf::surfExitCallbacks();
346 if (future_evt_set) {
347 delete future_evt_set;
348 future_evt_set = nullptr;
351 #if HAVE_THREAD_CONTEXTS
352 xbt_parmap_destroy(surf_parmap);
357 simgrid::s4u::Engine::shutdown();
359 NOW = 0; /* Just in case the user plans to restart the simulation afterward */
370 : maxminSystem_(nullptr)
372 readyActionSet_ = new ActionList();
373 runningActionSet_ = new ActionList();
374 failedActionSet_ = new ActionList();
375 doneActionSet_ = new ActionList();
377 modifiedSet_ = nullptr;
378 actionHeap_ = nullptr;
379 updateMechanism_ = UM_UNDEFINED;
380 selectiveUpdate_ = 0;
384 delete readyActionSet_;
385 delete runningActionSet_;
386 delete failedActionSet_;
387 delete doneActionSet_;
390 double Model::next_occuring_event(double now)
392 //FIXME: set the good function once and for all
393 if (updateMechanism_ == UM_LAZY)
394 return next_occuring_event_lazy(now);
395 else if (updateMechanism_ == UM_FULL)
396 return next_occuring_event_full(now);
398 xbt_die("Invalid cpu update mechanism!");
401 double Model::next_occuring_event_lazy(double now)
403 Action *action = nullptr;
408 ("Before share resources, the size of modified actions set is %zd",
409 modifiedSet_->size());
411 lmm_solve(maxminSystem_);
414 ("After share resources, The size of modified actions set is %zd",
415 modifiedSet_->size());
417 while(!modifiedSet_->empty()) {
418 action = &(modifiedSet_->front());
419 modifiedSet_->pop_front();
420 int max_dur_flag = 0;
422 if (action->getStateSet() != runningActionSet_)
425 /* bogus priority, skip it */
426 if (action->getPriority() <= 0 || action->getHat()==LATENCY)
429 action->updateRemainingLazy(now);
432 share = lmm_variable_getvalue(action->getVariable());
435 double time_to_completion;
436 if (action->getRemains() > 0) {
437 time_to_completion = action->getRemainsNoUpdate() / share;
439 time_to_completion = 0.0;
441 min = now + time_to_completion; // when the task will complete if nothing changes
444 if ((action->getMaxDuration() != NO_MAX_DURATION)
446 || action->getStartTime() +
447 action->getMaxDuration() < min)) {
448 min = action->getStartTime() +
449 action->getMaxDuration(); // when the task will complete anyway because of the deadline if any
454 XBT_DEBUG("Action(%p) corresponds to variable %d", action, action->getVariable()->id_int);
456 XBT_DEBUG("Action(%p) Start %f. May finish at %f (got a share of %f). Max_duration %f", action,
457 action->getStartTime(), min, share,
458 action->getMaxDuration());
461 action->heapUpdate(actionHeap_, min, max_dur_flag ? MAX_DURATION : NORMAL);
462 XBT_DEBUG("Insert at heap action(%p) min %f now %f", action, min,
464 } else DIE_IMPOSSIBLE;
467 //hereafter must have already the min value for this resource model
468 if (xbt_heap_size(actionHeap_) > 0)
469 min = xbt_heap_maxkey(actionHeap_) - now;
473 XBT_DEBUG("The minimum with the HEAP %f", min);
478 double Model::next_occuring_event_full(double /*now*/) {
483 double Model::shareResourcesMaxMin(ActionList *running_actions,
485 void (*solve) (lmm_system_t))
487 Action *action = nullptr;
493 ActionList::iterator it(running_actions->begin()), itend(running_actions->end());
494 for(; it != itend ; ++it) {
496 value = lmm_variable_getvalue(action->getVariable());
497 if ((value > 0) || (action->getMaxDuration() >= 0))
505 if (action->getRemains() > 0)
506 min = action->getRemainsNoUpdate() / value;
509 if ((action->getMaxDuration() >= 0) && (action->getMaxDuration() < min))
510 min = action->getMaxDuration();
512 min = action->getMaxDuration();
515 for (++it; it != itend; ++it) {
517 value = lmm_variable_getvalue(action->getVariable());
519 if (action->getRemains() > 0)
520 value = action->getRemainsNoUpdate() / value;
525 XBT_DEBUG("Updating min (value) with %p: %f", action, min);
528 if ((action->getMaxDuration() >= 0) && (action->getMaxDuration() < min)) {
529 min = action->getMaxDuration();
530 XBT_DEBUG("Updating min (duration) with %p: %f", action, min);
533 XBT_DEBUG("min value : %f", min);
538 void Model::updateActionsState(double now, double delta)
540 if (updateMechanism_ == UM_FULL)
541 updateActionsStateFull(now, delta);
542 else if (updateMechanism_ == UM_LAZY)
543 updateActionsStateLazy(now, delta);
545 xbt_die("Invalid cpu update mechanism!");
548 void Model::updateActionsStateLazy(double /*now*/, double /*delta*/)
553 void Model::updateActionsStateFull(double /*now*/, double /*delta*/)
568 Resource::Resource(Model *model, const char *name)
569 : name_(xbt_strdup(name))
573 Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint)
574 : name_(xbt_strdup(name))
576 , constraint_(constraint)
579 Resource::~Resource() {
580 xbt_free((void*)name_);
583 bool Resource::isOn() const {
586 bool Resource::isOff() const {
590 void Resource::turnOn()
595 void Resource::turnOff()
600 Model *Resource::getModel() const {
604 const char *Resource::getName() const {
608 bool Resource::operator==(const Resource &other) const {
609 return strcmp(name_, other.name_);
612 lmm_constraint_t Resource::getConstraint() const {
623 const char *surf_action_state_names[6] = {
625 "SURF_ACTION_RUNNING",
626 "SURF_ACTION_FAILED",
628 "SURF_ACTION_TO_FREE",
629 "SURF_ACTION_NOT_IN_THE_SYSTEM"
632 /* added to manage the communication action's heap */
633 void surf_action_lmm_update_index_heap(void *action, int i) {
634 static_cast<simgrid::surf::Action*>(action)->updateIndexHeap(i);
640 void Action::initialize(simgrid::surf::Model *model, double cost, bool failed,
644 start_ = surf_get_clock();
649 stateSet_ = getModel()->getFailedActionSet();
651 stateSet_ = getModel()->getRunningActionSet();
653 stateSet_->push_back(*this);
656 Action::Action(simgrid::surf::Model *model, double cost, bool failed)
658 initialize(model, cost, failed);
661 Action::Action(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var)
663 initialize(model, cost, failed, var);
670 void Action::finish() {
671 finishTime_ = surf_get_clock();
674 Action::State Action::getState()
676 if (stateSet_ == getModel()->getReadyActionSet())
677 return Action::State::ready;
678 if (stateSet_ == getModel()->getRunningActionSet())
679 return Action::State::running;
680 if (stateSet_ == getModel()->getFailedActionSet())
681 return Action::State::failed;
682 if (stateSet_ == getModel()->getDoneActionSet())
683 return Action::State::done;
684 return Action::State::not_in_the_system;
687 void Action::setState(Action::State state)
689 stateSet_->erase(stateSet_->iterator_to(*this));
691 case Action::State::ready:
692 stateSet_ = getModel()->getReadyActionSet();
694 case Action::State::running:
695 stateSet_ = getModel()->getRunningActionSet();
697 case Action::State::failed:
698 stateSet_ = getModel()->getFailedActionSet();
700 case Action::State::done:
701 stateSet_ = getModel()->getDoneActionSet();
708 stateSet_->push_back(*this);
711 double Action::getBound()
713 return (variable_) ? lmm_variable_getbound(variable_) : 0;
716 void Action::setBound(double bound)
718 XBT_IN("(%p,%g)", this, bound);
720 lmm_update_variable_bound(getModel()->getMaxminSystem(), variable_, bound);
722 if (getModel()->getUpdateMechanism() == UM_LAZY && getLastUpdate()!=surf_get_clock())
723 heapRemove(getModel()->getActionHeap());
727 double Action::getStartTime()
732 double Action::getFinishTime()
734 /* keep the function behavior, some models (cpu_ti) change the finish time before the action end */
735 return remains_ == 0 ? finishTime_ : -1;
738 void Action::setData(void* data)
743 void Action::setCategory(const char *category)
745 XBT_IN("(%p,%s)", this, category);
746 category_ = xbt_strdup(category);
754 void Action::setMaxDuration(double duration)
756 XBT_IN("(%p,%g)", this, duration);
757 maxDuration_ = duration;
758 if (getModel()->getUpdateMechanism() == UM_LAZY) // remove action from the heap
759 heapRemove(getModel()->getActionHeap());
763 void Action::gapRemove() {}
765 void Action::setPriority(double priority)
767 XBT_IN("(%p,%g)", this, priority);
768 priority_ = priority;
769 lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), priority);
771 if (getModel()->getUpdateMechanism() == UM_LAZY)
772 heapRemove(getModel()->getActionHeap());
776 void Action::cancel(){
777 setState(Action::State::failed);
778 if (getModel()->getUpdateMechanism() == UM_LAZY) {
779 if (action_lmm_hook.is_linked())
780 getModel()->getModifiedSet()->erase(getModel()->getModifiedSet()->iterator_to(*this));
781 heapRemove(getModel()->getActionHeap());
788 if (action_hook.is_linked())
789 stateSet_->erase(stateSet_->iterator_to(*this));
791 lmm_variable_free(getModel()->getMaxminSystem(), getVariable());
792 if (getModel()->getUpdateMechanism() == UM_LAZY) {
793 /* remove from heap */
794 heapRemove(getModel()->getActionHeap());
795 if (action_lmm_hook.is_linked())
796 getModel()->getModifiedSet()->erase(getModel()->getModifiedSet()->iterator_to(*this));
804 void Action::suspend()
806 XBT_IN("(%p)", this);
807 if (suspended_ != 2) {
808 lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0);
810 if (getModel()->getUpdateMechanism() == UM_LAZY)
811 heapRemove(getModel()->getActionHeap());
816 void Action::resume()
818 XBT_IN("(%p)", this);
819 if (suspended_ != 2) {
820 lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), priority_);
822 if (getModel()->getUpdateMechanism() == UM_LAZY)
823 heapRemove(getModel()->getActionHeap());
828 bool Action::isSuspended()
830 return suspended_ == 1;
832 /* insert action on heap using a given key and a hat (heap_action_type)
833 * a hat can be of three types for communications:
835 * NORMAL = this is a normal heap entry stating the date to finish transmitting
836 * LATENCY = this is a heap entry to warn us when the latency is payed
837 * MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached
839 void Action::heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat)
842 xbt_heap_push(heap, this, key);
845 void Action::heapRemove(xbt_heap_t heap)
848 if (indexHeap_ >= 0) {
849 xbt_heap_remove(heap, indexHeap_);
853 void Action::heapUpdate(xbt_heap_t heap, double key, enum heap_action_type hat)
856 if (indexHeap_ >= 0) {
857 xbt_heap_update(heap, indexHeap_, key);
859 xbt_heap_push(heap, this, key);
863 void Action::updateIndexHeap(int i) {
867 double Action::getRemains()
869 XBT_IN("(%p)", this);
870 /* update remains before return it */
871 if (getModel()->getUpdateMechanism() == UM_LAZY) /* update remains before return it */
872 updateRemainingLazy(surf_get_clock());
877 double Action::getRemainsNoUpdate()
882 //FIXME split code in the right places
883 void Action::updateRemainingLazy(double now)
887 if(getModel() == surf_network_model)
894 xbt_assert(stateSet_ == getModel()->getRunningActionSet(), "You're updating an action that is not running.");
895 xbt_assert(priority_ > 0, "You're updating an action that seems suspended.");
898 delta = now - lastUpdate_;
901 XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, remains_, lastUpdate_);
902 double_update(&remains_, lastValue_ * delta, sg_surf_precision*sg_maxmin_precision);
904 if (getModel() == surf_cpu_model_pm && TRACE_is_enabled()) {
905 simgrid::surf::Resource *cpu = static_cast<simgrid::surf::Resource*>(
906 lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)));
907 TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), lastValue_, lastUpdate_, now - lastUpdate_);
909 XBT_DEBUG("Updating action(%p): remains is now %f", this, remains_);
912 if(getModel() == surf_network_model)
914 if (maxDuration_ != NO_MAX_DURATION)
915 double_update(&maxDuration_, delta, sg_surf_precision);
917 //FIXME: duplicated code
918 if ((remains_ <= 0) &&
919 (lmm_get_variable_weight(getVariable()) > 0)) {
921 setState(Action::State::done);
922 heapRemove(getModel()->getActionHeap());
923 } else if (((maxDuration_ != NO_MAX_DURATION)
924 && (maxDuration_ <= 0))) {
926 setState(Action::State::done);
927 heapRemove(getModel()->getActionHeap());
932 lastValue_ = lmm_variable_getvalue(getVariable());