From: Martin Quinson Date: Sun, 2 Oct 2016 11:31:51 +0000 (+0200) Subject: preparatory cleanups in model share computations X-Git-Tag: v3_14~381 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/446069ad8e6d4580649af853f64ebbd259737bbe preparatory cleanups in model share computations --- diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index ed4f8dd4a3..a90e142e33 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -30,14 +30,13 @@ simgrid::xbt::signal cpuActionSt * Model * *********/ -CpuModel::~CpuModel() {} +CpuModel::~CpuModel() = default; void CpuModel::updateActionsStateLazy(double now, double /*delta*/) { - CpuAction *action; while ((xbt_heap_size(getActionHeap()) > 0) && (double_equals(xbt_heap_maxkey(getActionHeap()), now, sg_surf_precision))) { - action = static_cast(xbt_heap_pop(getActionHeap())); + CpuAction *action = static_cast(xbt_heap_pop(getActionHeap())); XBT_CDEBUG(surf_kernel, "Something happened to action %p", action); if (TRACE_is_enabled()) { Cpu *cpu = static_cast(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0))); @@ -62,7 +61,7 @@ void CpuModel::updateActionsStateLazy(double now, double /*delta*/) ActionList *actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end()) ; it != itend ; ++it) { - action = static_cast(&*it); + CpuAction *action = static_cast(&*it); if (smaller < 0) { smaller = action->getLastUpdate(); continue; @@ -75,7 +74,6 @@ void CpuModel::updateActionsStateLazy(double now, double /*delta*/) TRACE_last_timestamp_to_dump = smaller; } } - return; } void CpuModel::updateActionsStateFull(double now, double delta) diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 9ddf06aa77..5823a71414 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -30,7 +30,6 @@ namespace surf { class CpuModel; class Cpu; class CpuAction; -class CpuPlugin;// FIXME:DEADCODE /** @ingroup SURF_cpu_interface * @brief SURF cpu model interface class @@ -154,13 +153,17 @@ public: XBT_PUBLIC_CLASS CpuAction : public simgrid::surf::Action { friend XBT_PUBLIC(Cpu*) getActionCpu(CpuAction *action); public: - /** @brief Callbacks handler which emit the callbacks after CpuAction State changed * - * @details Callback functions have the following signature: `void(CpuAction *action, simgrid::surf::Action::State previous)` - */ - static simgrid::xbt::signal onStateChange; +/** @brief Signal emitted when the action state changes (ready/running/done, etc) + * Signature: `void(CpuAction *action, simgrid::surf::Action::State previous)` + */ +static simgrid::xbt::signal onStateChange; +/** @brief Signal emitted when the action share changes (amount of flops it gets) + * Signature: `void(CpuAction *action)` + */ +static simgrid::xbt::signal onShareChange; CpuAction(simgrid::surf::Model *model, double cost, bool failed) - : Action(model, cost, failed) {} //FIXME:DEADCODE? + : Action(model, cost, failed) {} CpuAction(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var) : Action(model, cost, failed, var) {} diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index ad17bf6fb7..799a17c19c 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -148,9 +148,9 @@ NetworkCm02Model::NetworkCm02Model() updateMechanism_ = UM_LAZY; selectiveUpdate_ = 1; xbt_assert((select == 1) || (xbt_cfg_is_default_value("network/maxmin-selective-update")), - "Disabling selective update while using the lazy update mechanism is dumb!"); + "You cannot disable selective update while using the lazy update mechanism!"); } else { - xbt_die("Unsupported optimization (%s) for this model", optim); + xbt_die("Unsupported optimization (%s) for this model. Accepted: Full, Lazy.", optim); } if (!maxminSystem_) @@ -159,10 +159,10 @@ NetworkCm02Model::NetworkCm02Model() routing_model_create(createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE, nullptr)); if (updateMechanism_ == UM_LAZY) { - actionHeap_ = xbt_heap_new(8, nullptr); - xbt_heap_set_update_callback(actionHeap_, surf_action_lmm_update_index_heap); - modifiedSet_ = new ActionLmmList(); - maxminSystem_->keep_track = modifiedSet_; + actionHeap_ = xbt_heap_new(8, nullptr); + xbt_heap_set_update_callback(actionHeap_, surf_action_lmm_update_index_heap); + modifiedSet_ = new ActionLmmList(); + maxminSystem_->keep_track = modifiedSet_; } } @@ -178,6 +178,7 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) { while ((xbt_heap_size(actionHeap_) > 0) && (double_equals(xbt_heap_maxkey(actionHeap_), now, sg_surf_precision))) { + NetworkCm02Action *action = static_cast (xbt_heap_pop(actionHeap_)); XBT_DEBUG("Something happened to action %p", action); if (TRACE_is_enabled()) { @@ -186,14 +187,10 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) for (int i = 0; i < n; i++){ lmm_constraint_t constraint = lmm_get_cnst_from_var(maxminSystem_, action->getVariable(), i); NetworkCm02Link *link = static_cast(lmm_constraint_id(constraint)); - TRACE_surf_link_set_utilization(link->getName(), - action->getCategory(), - (lmm_variable_getvalue(action->getVariable())* - lmm_get_cnst_weight_from_var(maxminSystem_, - action->getVariable(), - i)), - action->getLastUpdate(), - now - action->getLastUpdate()); + double value = lmm_variable_getvalue(action->getVariable())* + lmm_get_cnst_weight_from_var(maxminSystem_, action->getVariable(), i); + TRACE_surf_link_set_utilization(link->getName(), action->getCategory(), value, + action->getLastUpdate(), now - action->getLastUpdate()); } } @@ -205,8 +202,7 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) action->refreshLastUpdate(); // if I am wearing a max_duration or normal hat - } else if (action->getHat() == MAX_DURATION || - action->getHat() == NORMAL) { + } else if (action->getHat() == MAX_DURATION || action->getHat() == NORMAL) { // no need to communicate anymore // assume that flows that reached max_duration have remaining of 0 XBT_DEBUG("Action %p finished", action); @@ -224,14 +220,13 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) void NetworkCm02Model::updateActionsStateFull(double now, double delta) { - NetworkCm02Action *action; ActionList *running_actions = getRunningActionSet(); for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end()) ; it != itend ; it=itNext) { - ++itNext; + ++itNext; - action = static_cast (&*it); + NetworkCm02Action *action = static_cast (&*it); XBT_DEBUG("Something happened to action %p", action); double deltap = delta; if (action->latency_ > 0) { diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 21fbb424d6..bec7c64110 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -133,20 +133,19 @@ double StorageN11Model::next_occuring_event(double /*now*/) void StorageN11Model::updateActionsState(double /*now*/, double delta) { - StorageAction *action = nullptr; ActionList *actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end()) ; it != itend ; it=itNext) { ++itNext; - action = static_cast(&*it); + + StorageAction *action = static_cast(&*it); if(action->m_type == WRITE){ // Update the disk usage // Update the file size // For each action of type write - double current_progress = - delta * lmm_variable_getvalue(action->getVariable()); + double current_progress = delta * lmm_variable_getvalue(action->getVariable()); long int incr = current_progress; XBT_DEBUG("%s:\n\t progress = %.2f, current_progress = %.2f, incr = %ld, lrint(1) = %ld, lrint(2) = %ld", @@ -187,7 +186,6 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta) action->setState(Action::State::done); } } - return; } /************ @@ -334,7 +332,6 @@ int StorageN11Action::unref() void StorageN11Action::cancel() { setState(Action::State::failed); - return; } void StorageN11Action::suspend() diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 194b467879..31cf110b31 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -406,22 +406,12 @@ double Model::next_occuring_event(double now) double Model::next_occuring_event_lazy(double now) { - Action *action = nullptr; - double min = -1; - double share; - - XBT_DEBUG - ("Before share resources, the size of modified actions set is %zd", - modifiedSet_->size()); - + XBT_DEBUG("Before share resources, the size of modified actions set is %zd", modifiedSet_->size()); lmm_solve(maxminSystem_); - - XBT_DEBUG - ("After share resources, The size of modified actions set is %zd", - modifiedSet_->size()); + XBT_DEBUG("After share resources, The size of modified actions set is %zd", modifiedSet_->size()); while(!modifiedSet_->empty()) { - action = &(modifiedSet_->front()); + Action *action = &(modifiedSet_->front()); modifiedSet_->pop_front(); int max_dur_flag = 0; @@ -434,8 +424,8 @@ double Model::next_occuring_event_lazy(double now) action->updateRemainingLazy(now); - min = -1; - share = lmm_variable_getvalue(action->getVariable()); + double min = -1; + double share = lmm_variable_getvalue(action->getVariable()); if (share > 0) { double time_to_completion; @@ -471,14 +461,14 @@ double Model::next_occuring_event_lazy(double now) } //hereafter must have already the min value for this resource model - if (xbt_heap_size(actionHeap_) > 0) - min = xbt_heap_maxkey(actionHeap_) - now; - else - min = -1; - - XBT_DEBUG("The minimum with the HEAP %f", min); - - return min; + if (xbt_heap_size(actionHeap_) > 0) { + double min = xbt_heap_maxkey(actionHeap_) - now; + XBT_DEBUG("minimum with the HEAP %f", min); + return min; + } else { + XBT_DEBUG("The HEAP is empty, thus returning -1"); + return -1; + } } double Model::next_occuring_event_full(double /*now*/) {