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<simgrid::s4u::Host*> 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},
67 {"NS3", "Network pseudo-model using the NS3 tcp model instead of an analytic model", &surf_network_model_init_NS3},
68 {"Reno", "Model from Steven H. Low using lagrange_solve instead of lmm_solve (experts only; check the code for more info).",
69 &surf_network_model_init_Reno},
70 {"Reno2", "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_Reno2},
72 {"Vegas", "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_Vegas},
74 {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
78 void surf_network_model_init_SMPI() {
79 xbt_die("Please activate SMPI support in cmake to use the SMPI network model.");
81 void surf_network_model_init_IB() {
82 xbt_die("Please activate SMPI support in cmake to use the IB network model.");
86 void surf_network_model_init_NS3() {
87 xbt_die("Please activate NS3 support in cmake and install the dependencies to use the NS3 network model.");
91 s_surf_model_description_t surf_cpu_model_description[] = {
92 {"Cas01", "Simplistic CPU model (time=size/power).", &surf_cpu_model_init_Cas01},
93 {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
96 s_surf_model_description_t surf_host_model_description[] = {
97 {"default", "Default host model. Currently, CPU:Cas01 and network:LV08 (with cross traffic enabled)", &surf_host_model_init_current_default},
98 {"compound", "Host model that is automatically chosen if you change the network and CPU models", &surf_host_model_init_compound},
99 {"ptask_L07", "Host model somehow similar to Cas01+CM02 but allowing parallel tasks", &surf_host_model_init_ptask_L07},
100 {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
103 s_surf_model_description_t surf_vm_model_description[] = {
104 {"default", "Default vm model.", &surf_vm_model_init_HL13},
105 {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
108 s_surf_model_description_t surf_optimization_mode_description[] = {
109 {"Lazy", "Lazy action management (partial invalidation in lmm + heap in action remaining).", nullptr},
110 {"TI", "Trace integration. Highly optimized mode when using availability traces (only available for the Cas01 CPU model for now).", nullptr},
111 {"Full", "Full update of remaining and variables. Slow but may be useful when debugging.", nullptr},
112 {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
115 s_surf_model_description_t surf_storage_model_description[] = {
116 {"default", "Simplistic storage model.", &surf_storage_model_init_default},
117 {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
120 #if HAVE_THREAD_CONTEXTS
121 static xbt_parmap_t surf_parmap = nullptr; /* parallel map on models */
126 double surf_get_clock()
132 # define FILE_DELIM "\\"
134 # define FILE_DELIM "/" /* FIXME: move to better location */
137 FILE *surf_fopen(const char *name, const char *mode)
140 char *path_elm = nullptr;
142 FILE *file = nullptr;
146 if (__surf_is_absolute_file_path(name)) /* don't mess with absolute file names */
147 return fopen(name, mode);
149 /* search relative files in the path */
150 xbt_dynar_foreach(surf_path, cpt, path_elm) {
151 buff = bprintf("%s" FILE_DELIM "%s", path_elm, name);
152 file = fopen(buff, mode);
164 static const char *disk_drives_letter_table[MAX_DRIVE] = {
165 "A:\\","B:\\","C:\\","D:\\","E:\\","F:\\","G:\\","H:\\","I:\\","J:\\","K:\\","L:\\","M:\\",
166 "N:\\","O:\\","P:\\","Q:\\","R:\\","S:\\","T:\\","U:\\","V:\\","W:\\","X:\\","Y:\\","Z:\\"
171 * Returns the initial path. On Windows the initial path is
172 * the current directory for the current process in the other
173 * case the function returns "./" that represents the current
174 * directory on Unix/Linux platforms.
177 const char *__surf_get_initial_path()
182 char current_directory[MAX_PATH + 1] = { 0 };
183 unsigned int len = GetCurrentDirectory(MAX_PATH + 1, current_directory);
184 char root[4] = { 0 };
189 strncpy(root, current_directory, 3);
191 for (i = 0; i < MAX_DRIVE; i++) {
192 if (toupper(root[0]) == disk_drives_letter_table[i][0])
193 return disk_drives_letter_table[i];
202 /* The __surf_is_absolute_file_path() returns 1 if
203 * file_path is a absolute file path, in the other
204 * case the function returns 0.
206 int __surf_is_absolute_file_path(const char *file_path)
209 WIN32_FIND_DATA wfd = { 0 };
210 HANDLE hFile = FindFirstFile(file_path, &wfd);
212 if (INVALID_HANDLE_VALUE == hFile)
218 return (file_path[0] == '/');
222 /** Displays the long description of all registered models, and quit */
223 void model_help(const char *category, s_surf_model_description_t * table)
225 printf("Long description of the %s models accepted by this simulator:\n", category);
226 for (int i = 0; table[i].name; i++)
227 printf(" %s: %s\n", table[i].name, table[i].description);
230 int find_model_description(s_surf_model_description_t * table,
234 char *name_list = nullptr;
236 for (i = 0; table[i].name; i++)
237 if (!strcmp(name, table[i].name)) {
241 xbt_die("No model is valid! This is a bug.");
242 name_list = xbt_strdup(table[0].name);
243 for (i = 1; table[i].name; i++) {
244 name_list = (char *) xbt_realloc(name_list, strlen(name_list) + strlen(table[i].name) + 3);
245 strncat(name_list, ", ", 2);
246 strncat(name_list, table[i].name, strlen(table[i].name));
248 xbt_die("Model '%s' is invalid! Valid models are: %s.", name, name_list);
252 static inline void surf_storage_free(void *r)
254 delete static_cast<simgrid::surf::Storage*>(r);
257 void sg_version_check(int lib_version_major,int lib_version_minor,int lib_version_patch) {
258 if ((lib_version_major != SIMGRID_VERSION_MAJOR) || (lib_version_minor != SIMGRID_VERSION_MINOR)) {
260 "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, "
261 "and then linked against SimGrid %d.%d.%d. Please fix this.\n",
262 lib_version_major,lib_version_minor,lib_version_patch,
263 SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH);
266 if (lib_version_patch != SIMGRID_VERSION_PATCH) {
267 if(SIMGRID_VERSION_PATCH >= 90 || lib_version_patch >=90){
269 "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, "
270 "and then linked against SimGrid %d.%d.%d. \n"
271 "One of them is a development version, and should not be mixed with the stable release. Please fix this.\n",
272 lib_version_major,lib_version_minor,lib_version_patch,
273 SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH);
277 "Warning: Your program was compiled with SimGrid version %d.%d.%d, "
278 "and then linked against SimGrid %d.%d.%d. Proceeding anyway.\n",
279 lib_version_major,lib_version_minor,lib_version_patch,
280 SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH);
284 void sg_version(int *ver_major,int *ver_minor,int *ver_patch) {
285 *ver_major = SIMGRID_VERSION_MAJOR;
286 *ver_minor = SIMGRID_VERSION_MINOR;
287 *ver_patch = SIMGRID_VERSION_PATCH;
290 void surf_init(int *argc, char **argv)
292 if (USER_HOST_LEVEL != -1) // Already initialized
295 XBT_DEBUG("Create all Libs");
296 USER_HOST_LEVEL = simgrid::s4u::Host::extension_create(nullptr);
298 as_router_lib = xbt_lib_new();
299 storage_lib = xbt_lib_new();
300 storage_type_lib = xbt_lib_new();
301 file_lib = xbt_lib_new();
302 watched_hosts_lib = xbt_dict_new_homogeneous(nullptr);
304 XBT_DEBUG("Add routing levels");
305 ROUTING_PROP_ASR_LEVEL = xbt_lib_add_level(as_router_lib, nullptr);
306 ROUTING_ASR_LEVEL = xbt_lib_add_level(as_router_lib, [](void* p) {
307 delete static_cast<simgrid::kernel::routing::NetCard*>(p);
310 XBT_DEBUG("Add SURF levels");
311 SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_free);
313 xbt_init(argc, argv);
314 if (!all_existing_models)
315 all_existing_models = new std::vector<simgrid::surf::Model*>();
316 if (!model_list_invoke)
317 model_list_invoke = xbt_dynar_new(sizeof(simgrid::surf::Model*), nullptr);
319 future_evt_set = new simgrid::trace_mgr::future_evt_set();
321 TRACE_add_start_function(TRACE_surf_alloc);
322 TRACE_add_end_function(TRACE_surf_release);
324 sg_config_init(argc, argv);
332 TRACE_end(); /* Just in case it was not called by the upper layer (or there is no upper layer) */
334 xbt_dynar_free(&surf_path);
337 xbt_lib_free(&as_router_lib);
338 xbt_lib_free(&storage_lib);
340 xbt_lib_free(&storage_type_lib);
341 xbt_lib_free(&file_lib);
342 xbt_dict_free(&watched_hosts_lib);
344 for (auto model : *all_existing_models)
346 delete all_existing_models;
347 xbt_dynar_free(&model_list_invoke);
350 simgrid::surf::surfExitCallbacks();
352 if (future_evt_set) {
353 delete future_evt_set;
354 future_evt_set = nullptr;
357 #if HAVE_THREAD_CONTEXTS
358 xbt_parmap_destroy(surf_parmap);
363 simgrid::s4u::Engine::shutdown();
365 NOW = 0; /* Just in case the user plans to restart the simulation afterward */
376 : maxminSystem_(nullptr)
378 readyActionSet_ = new ActionList();
379 runningActionSet_ = new ActionList();
380 failedActionSet_ = new ActionList();
381 doneActionSet_ = new ActionList();
383 modifiedSet_ = nullptr;
384 actionHeap_ = nullptr;
385 updateMechanism_ = UM_UNDEFINED;
386 selectiveUpdate_ = 0;
390 delete readyActionSet_;
391 delete runningActionSet_;
392 delete failedActionSet_;
393 delete doneActionSet_;
396 double Model::next_occuring_event(double now)
398 //FIXME: set the good function once and for all
399 if (updateMechanism_ == UM_LAZY)
400 return next_occuring_event_lazy(now);
401 else if (updateMechanism_ == UM_FULL)
402 return next_occuring_event_full(now);
404 xbt_die("Invalid cpu update mechanism!");
407 double Model::next_occuring_event_lazy(double now)
409 XBT_DEBUG("Before share resources, the size of modified actions set is %zd", modifiedSet_->size());
410 lmm_solve(maxminSystem_);
411 XBT_DEBUG("After share resources, The size of modified actions set is %zd", modifiedSet_->size());
413 while(!modifiedSet_->empty()) {
414 Action *action = &(modifiedSet_->front());
415 modifiedSet_->pop_front();
416 int max_dur_flag = 0;
418 if (action->getStateSet() != runningActionSet_)
421 /* bogus priority, skip it */
422 if (action->getPriority() <= 0 || action->getHat()==LATENCY)
425 action->updateRemainingLazy(now);
428 double share = lmm_variable_getvalue(action->getVariable());
431 double time_to_completion;
432 if (action->getRemains() > 0) {
433 time_to_completion = action->getRemainsNoUpdate() / share;
435 time_to_completion = 0.0;
437 min = now + time_to_completion; // when the task will complete if nothing changes
440 if ((action->getMaxDuration() != NO_MAX_DURATION)
442 || action->getStartTime() +
443 action->getMaxDuration() < min)) {
444 min = action->getStartTime() +
445 action->getMaxDuration(); // when the task will complete anyway because of the deadline if any
450 XBT_DEBUG("Action(%p) corresponds to variable %d", action, action->getVariable()->id_int);
452 XBT_DEBUG("Action(%p) Start %f. May finish at %f (got a share of %f). Max_duration %f", action,
453 action->getStartTime(), min, share,
454 action->getMaxDuration());
457 action->heapUpdate(actionHeap_, min, max_dur_flag ? MAX_DURATION : NORMAL);
458 XBT_DEBUG("Insert at heap action(%p) min %f now %f", action, min,
460 } else DIE_IMPOSSIBLE;
463 //hereafter must have already the min value for this resource model
464 if (xbt_heap_size(actionHeap_) > 0) {
465 double min = xbt_heap_maxkey(actionHeap_) - now;
466 XBT_DEBUG("minimum with the HEAP %f", min);
469 XBT_DEBUG("The HEAP is empty, thus returning -1");
474 double Model::next_occuring_event_full(double /*now*/) {
479 double shareResourcesMaxMin(ActionList *runningActions, lmm_system_t sys, void (*solve) (lmm_system_t))
484 for(auto it(runningActions->begin()), itend(runningActions->end()); it != itend ; ++it) {
485 Action *action = &*it;
486 double value = lmm_variable_getvalue(action->getVariable());
488 if (action->getRemains() > 0)
489 value = action->getRemainsNoUpdate() / value;
492 if (min < 0 || value < min) {
494 XBT_DEBUG("Updating min (value) with %p: %f", action, min);
497 if ((action->getMaxDuration() >= 0) && (min<0 || action->getMaxDuration() < min)) {
498 min = action->getMaxDuration();
499 XBT_DEBUG("Updating min (duration) with %p: %f", action, min);
502 XBT_DEBUG("min value : %f", min);
507 void Model::updateActionsState(double now, double delta)
509 if (updateMechanism_ == UM_FULL)
510 updateActionsStateFull(now, delta);
511 else if (updateMechanism_ == UM_LAZY)
512 updateActionsStateLazy(now, delta);
514 xbt_die("Invalid cpu update mechanism!");
517 void Model::updateActionsStateLazy(double /*now*/, double /*delta*/)
522 void Model::updateActionsStateFull(double /*now*/, double /*delta*/)
537 Resource::Resource(Model *model, const char *name)
538 : name_(xbt_strdup(name))
542 Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint)
543 : name_(xbt_strdup(name))
545 , constraint_(constraint)
548 Resource::~Resource() {
549 xbt_free((void*)name_);
552 bool Resource::isOn() const {
555 bool Resource::isOff() const {
559 void Resource::turnOn()
564 void Resource::turnOff()
569 Model *Resource::getModel() const {
573 const char *Resource::getName() const {
577 bool Resource::operator==(const Resource &other) const {
578 return strcmp(name_, other.name_);
581 lmm_constraint_t Resource::getConstraint() const {
592 const char *surf_action_state_names[6] = {
594 "SURF_ACTION_RUNNING",
595 "SURF_ACTION_FAILED",
597 "SURF_ACTION_TO_FREE",
598 "SURF_ACTION_NOT_IN_THE_SYSTEM"
601 /* added to manage the communication action's heap */
602 void surf_action_lmm_update_index_heap(void *action, int i) {
603 static_cast<simgrid::surf::Action*>(action)->updateIndexHeap(i);
609 void Action::initialize(simgrid::surf::Model *model, double cost, bool failed,
613 start_ = surf_get_clock();
618 stateSet_ = getModel()->getFailedActionSet();
620 stateSet_ = getModel()->getRunningActionSet();
622 stateSet_->push_back(*this);
625 Action::Action(simgrid::surf::Model *model, double cost, bool failed)
627 initialize(model, cost, failed);
630 Action::Action(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var)
632 initialize(model, cost, failed, var);
639 void Action::finish() {
640 finishTime_ = surf_get_clock();
643 Action::State Action::getState()
645 if (stateSet_ == getModel()->getReadyActionSet())
646 return Action::State::ready;
647 if (stateSet_ == getModel()->getRunningActionSet())
648 return Action::State::running;
649 if (stateSet_ == getModel()->getFailedActionSet())
650 return Action::State::failed;
651 if (stateSet_ == getModel()->getDoneActionSet())
652 return Action::State::done;
653 return Action::State::not_in_the_system;
656 void Action::setState(Action::State state)
658 stateSet_->erase(stateSet_->iterator_to(*this));
660 case Action::State::ready:
661 stateSet_ = getModel()->getReadyActionSet();
663 case Action::State::running:
664 stateSet_ = getModel()->getRunningActionSet();
666 case Action::State::failed:
667 stateSet_ = getModel()->getFailedActionSet();
669 case Action::State::done:
670 stateSet_ = getModel()->getDoneActionSet();
677 stateSet_->push_back(*this);
680 double Action::getBound()
682 return (variable_) ? lmm_variable_getbound(variable_) : 0;
685 void Action::setBound(double bound)
687 XBT_IN("(%p,%g)", this, bound);
689 lmm_update_variable_bound(getModel()->getMaxminSystem(), variable_, bound);
691 if (getModel()->getUpdateMechanism() == UM_LAZY && getLastUpdate()!=surf_get_clock())
692 heapRemove(getModel()->getActionHeap());
696 double Action::getStartTime()
701 double Action::getFinishTime()
703 /* keep the function behavior, some models (cpu_ti) change the finish time before the action end */
704 return remains_ == 0 ? finishTime_ : -1;
707 void Action::setData(void* data)
712 void Action::setCategory(const char *category)
714 XBT_IN("(%p,%s)", this, category);
715 category_ = xbt_strdup(category);
723 void Action::setMaxDuration(double duration)
725 XBT_IN("(%p,%g)", this, duration);
726 maxDuration_ = duration;
727 if (getModel()->getUpdateMechanism() == UM_LAZY) // remove action from the heap
728 heapRemove(getModel()->getActionHeap());
732 void Action::gapRemove() {}
734 void Action::setPriority(double priority)
736 XBT_IN("(%p,%g)", this, priority);
737 priority_ = priority;
738 lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), priority);
740 if (getModel()->getUpdateMechanism() == UM_LAZY)
741 heapRemove(getModel()->getActionHeap());
745 void Action::cancel(){
746 setState(Action::State::failed);
747 if (getModel()->getUpdateMechanism() == UM_LAZY) {
748 if (action_lmm_hook.is_linked())
749 getModel()->getModifiedSet()->erase(getModel()->getModifiedSet()->iterator_to(*this));
750 heapRemove(getModel()->getActionHeap());
757 if (action_hook.is_linked())
758 stateSet_->erase(stateSet_->iterator_to(*this));
760 lmm_variable_free(getModel()->getMaxminSystem(), getVariable());
761 if (getModel()->getUpdateMechanism() == UM_LAZY) {
762 /* remove from heap */
763 heapRemove(getModel()->getActionHeap());
764 if (action_lmm_hook.is_linked())
765 getModel()->getModifiedSet()->erase(getModel()->getModifiedSet()->iterator_to(*this));
773 void Action::suspend()
775 XBT_IN("(%p)", this);
776 if (suspended_ != 2) {
777 lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0);
779 if (getModel()->getUpdateMechanism() == UM_LAZY)
780 heapRemove(getModel()->getActionHeap());
785 void Action::resume()
787 XBT_IN("(%p)", this);
788 if (suspended_ != 2) {
789 lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), priority_);
791 if (getModel()->getUpdateMechanism() == UM_LAZY)
792 heapRemove(getModel()->getActionHeap());
797 bool Action::isSuspended()
799 return suspended_ == 1;
801 /* insert action on heap using a given key and a hat (heap_action_type)
802 * a hat can be of three types for communications:
804 * NORMAL = this is a normal heap entry stating the date to finish transmitting
805 * LATENCY = this is a heap entry to warn us when the latency is payed
806 * MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached
808 void Action::heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat)
811 xbt_heap_push(heap, this, key);
814 void Action::heapRemove(xbt_heap_t heap)
817 if (indexHeap_ >= 0) {
818 xbt_heap_remove(heap, indexHeap_);
822 void Action::heapUpdate(xbt_heap_t heap, double key, enum heap_action_type hat)
825 if (indexHeap_ >= 0) {
826 xbt_heap_update(heap, indexHeap_, key);
828 xbt_heap_push(heap, this, key);
832 void Action::updateIndexHeap(int i) {
836 double Action::getRemains()
838 XBT_IN("(%p)", this);
839 /* update remains before return it */
840 if (getModel()->getUpdateMechanism() == UM_LAZY) /* update remains before return it */
841 updateRemainingLazy(surf_get_clock());
846 double Action::getRemainsNoUpdate()
851 //FIXME split code in the right places
852 void Action::updateRemainingLazy(double now)
856 if(getModel() == surf_network_model)
863 xbt_assert(stateSet_ == getModel()->getRunningActionSet(), "You're updating an action that is not running.");
864 xbt_assert(priority_ > 0, "You're updating an action that seems suspended.");
867 delta = now - lastUpdate_;
870 XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, remains_, lastUpdate_);
871 double_update(&remains_, lastValue_ * delta, sg_surf_precision*sg_maxmin_precision);
873 if (getModel() == surf_cpu_model_pm && TRACE_is_enabled()) {
874 simgrid::surf::Resource *cpu = static_cast<simgrid::surf::Resource*>(
875 lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)));
876 TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), lastValue_, lastUpdate_, now - lastUpdate_);
878 XBT_DEBUG("Updating action(%p): remains is now %f", this, remains_);
881 if(getModel() == surf_network_model)
883 if (maxDuration_ != NO_MAX_DURATION)
884 double_update(&maxDuration_, delta, sg_surf_precision);
886 //FIXME: duplicated code
887 if ((remains_ <= 0) &&
888 (lmm_get_variable_weight(getVariable()) > 0)) {
890 setState(Action::State::done);
891 heapRemove(getModel()->getActionHeap());
892 } else if (((maxDuration_ != NO_MAX_DURATION)
893 && (maxDuration_ <= 0))) {
895 setState(Action::State::done);
896 heapRemove(getModel()->getActionHeap());
901 lastValue_ = lmm_variable_getvalue(getVariable());