void NetworkConstantModel::updateActionsState(double /*now*/, double delta) { NetworkConstantActionPtr action = NULL; ActionListPtr actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end()) ; it != itend ; it=itNext) { ++itNext; action = static_cast<NetworkConstantActionPtr>(&*it); if (action->m_latency > 0) { if (action->m_latency > delta) { double_update(&(action->m_latency), delta, sg_surf_precision); } else { action->m_latency = 0.0; } } action->updateRemains(action->getCost() * delta / action->m_latInit); if (action->getMaxDuration() != NO_MAX_DURATION) action->updateMaxDuration(delta); if (action->getRemainsNoUpdate() <= 0) { action->finish(); action->setState(SURF_ACTION_DONE); } else if ((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0)) { action->finish(); action->setState(SURF_ACTION_DONE); } } }
double WorkstationL07Model::shareResources(double /*now*/) { WorkstationL07ActionPtr action; ActionListPtr running_actions = getRunningActionSet(); double min = this->shareResourcesMaxMin(running_actions, ptask_maxmin_system, bottleneck_solve); for(ActionList::iterator it(running_actions->begin()), itend(running_actions->end()) ; it != itend ; ++it) { action = static_cast<WorkstationL07ActionPtr>(&*it); if (action->m_latency > 0) { if (min < 0) { min = action->m_latency; XBT_DEBUG("Updating min (value) with %p (start %f): %f", action, action->getStartTime(), min); } else if (action->m_latency < min) { min = action->m_latency; XBT_DEBUG("Updating min (latency) with %p (start %f): %f", action, action->getStartTime(), min); } } } XBT_DEBUG("min value : %f", min); return min; }
void NetworkConstantModel::updateActionsState(double /*now*/, double delta) { NetworkConstantAction *action = nullptr; ActionList *actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end()) ; 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); } else { action->latency_ = 0.0; } } action->updateRemains(action->getCost() * delta / action->initialLatency_); if (action->getMaxDuration() != NO_MAX_DURATION) action->updateMaxDuration(delta); if (action->getRemainsNoUpdate() <= 0) { action->finish(); action->setState(Action::State::done); } else if ((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0)) { action->finish(); action->setState(Action::State::done); } } }
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<StorageAction*>(&*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()); long int incr = current_progress; XBT_DEBUG("%s:\n\t progress = %.2f, current_progress = %.2f, incr = %ld, lrint(1) = %ld, lrint(2) = %ld", action->p_file->name, action->progress, current_progress, incr, lrint(action->progress + current_progress), lrint(action->progress)+ incr); /* take care of rounding error accumulation */ if (lrint(action->progress + current_progress) > lrint(action->progress)+ incr) incr++; action->progress +=current_progress; action->p_storage->usedSize_ += incr; // disk usage action->p_file->current_position+= incr; // current_position // which becomes the new file size action->p_file->size = action->p_file->current_position ; sg_size_t *psize = xbt_new(sg_size_t,1); *psize = action->p_file->size; xbt_dict_t content_dict = action->p_storage->content_; xbt_dict_set(content_dict, action->p_file->name, psize, nullptr); } action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta); if (action->getMaxDuration() > NO_MAX_DURATION) action->updateMaxDuration(delta); if(action->getRemainsNoUpdate() > 0 && lmm_get_variable_weight(action->getVariable()) > 0 && action->p_storage->usedSize_ == action->p_storage->size_) { action->finish(); action->setState(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->setState(Action::State::done); } } return; }
double NetworkConstantModel::shareResources(double /*now*/) { NetworkConstantActionPtr action = NULL; double min = -1.0; ActionListPtr actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end()) ; it != itend ; ++it) { action = static_cast<NetworkConstantActionPtr>(&*it); if (action->m_latency > 0 && (min < 0 || action->m_latency < min)) min = action->m_latency; } return min; }
double NetworkConstantModel::next_occuring_event(double /*now*/) { NetworkConstantAction *action = nullptr; double min = -1.0; ActionList *actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end()) ; it != itend ; ++it) { action = static_cast<NetworkConstantAction*>(&*it); if (action->latency_ > 0 && (min < 0 || action->latency_ < min)) min = action->latency_; } return min; }
/********* * Model * *********/ 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<CpuAction*>(xbt_heap_pop(getActionHeap())); XBT_CDEBUG(surf_kernel, "Something happened to action %p", action); if (TRACE_is_enabled()) { Cpu *cpu = static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0))); TRACE_surf_host_set_utilization(cpu->getName(), action->getCategory(), lmm_variable_getvalue(action->getVariable()), action->getLastUpdate(), now - action->getLastUpdate()); } action->finish(); XBT_CDEBUG(surf_kernel, "Action %p finished", action); /* set the remains to 0 due to precision problems when updating the remaining amount */ action->setRemains(0); action->setState(SURF_ACTION_DONE); action->heapRemove(getActionHeap()); //FIXME: strange call since action was already popped } if (TRACE_is_enabled()) { //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(); for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end()) ; it != itend ; ++it) { action = static_cast<CpuAction*>(&*it); if (smaller < 0) { smaller = action->getLastUpdate(); continue; } if (action->getLastUpdate() < smaller) { smaller = action->getLastUpdate(); } } if (smaller > 0) { TRACE_last_timestamp_to_dump = smaller; } } return; }
double StorageN11Model::next_occuring_event(double /*now*/) { XBT_DEBUG("storage_share_resources"); double min_completion = shareResourcesMaxMin(getRunningActionSet(), maxminSystem_, lmm_solve); double rate; // Foreach disk for(auto storage: p_storageList) { rate = 0; // Foreach write action on disk for (auto write_action: storage->writeActions_) { rate += lmm_variable_getvalue(write_action->getVariable()); } if(rate > 0) min_completion = MIN(min_completion, (storage->size_-storage->usedSize_)/rate); } return min_completion; }
void CpuModel::updateActionsStateFull(double now, double delta) { CpuAction *action = NULL; ActionList *running_actions = getRunningActionSet(); for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end()) ; it != itend ; it=itNext) { ++itNext; action = static_cast<CpuAction*>(&*it); if (TRACE_is_enabled()) { Cpu *x = static_cast<Cpu*> (lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)) ); TRACE_surf_host_set_utilization(x->getName(), 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); if (action->getMaxDuration() != NO_MAX_DURATION) action->updateMaxDuration(delta); if ((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) { action->finish(); action->setState(SURF_ACTION_DONE); } else if ((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0)) { action->finish(); action->setState(SURF_ACTION_DONE); } } return; }
void NetworkCm02Model::updateActionsStateFull(double now, double delta) { NetworkCm02ActionPtr action; ActionListPtr running_actions = getRunningActionSet(); for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end()) ; it != itend ; it=itNext) { ++itNext; action = (NetworkCm02ActionPtr) &*it; XBT_DEBUG("Something happened to action %p", action); double deltap = delta; if (action->m_latency > 0) { if (action->m_latency > deltap) { double_update(&(action->m_latency), deltap, sg_surf_precision); deltap = 0.0; } else { double_update(&(deltap), action->m_latency, sg_surf_precision); action->m_latency = 0.0; } if (action->m_latency == 0.0 && !(action->isSuspended())) lmm_update_variable_weight(p_maxminSystem, action->getVariable(), action->m_weight); } #ifdef HAVE_TRACING if (TRACE_is_enabled()) { int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->getVariable()); int i; for (i = 0; i < n; i++){ lmm_constraint_t constraint = lmm_get_cnst_from_var(p_maxminSystem, action->getVariable(), i); NetworkCm02LinkPtr link = static_cast<NetworkCm02LinkPtr>(lmm_constraint_id(constraint)); TRACE_surf_link_set_utilization(link->getName(), action->getCategory(), (lmm_variable_getvalue(action->getVariable())* lmm_get_cnst_weight_from_var(p_maxminSystem, action->getVariable(), i)), action->getLastUpdate(), now - action->getLastUpdate()); } } #endif if (!lmm_get_number_of_cnst_from_var (p_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->getRemains() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) { action->finish(); action->setState(SURF_ACTION_DONE); action->gapRemove(); } else if (((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) { action->finish(); action->setState(SURF_ACTION_DONE); action->gapRemove(); } } return; }
double CpuCas01Model::next_occuring_event_full(double /*now*/) { return Model::shareResourcesMaxMin(getRunningActionSet(), maxminSystem_, lmm_solve); }
double CpuCas01Model::shareResourcesFull(double /*now*/) { return Model::shareResourcesMaxMin(getRunningActionSet(), p_maxminSystem, lmm_solve); }
void WorkstationL07Model::updateActionsState(double /*now*/, double delta) { double deltap = 0.0; WorkstationL07ActionPtr action; ActionListPtr actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itNext = it, itend(actionSet->end()) ; it != itend ; it=itNext) { ++itNext; action = static_cast<WorkstationL07ActionPtr>(&*it); deltap = delta; if (action->m_latency > 0) { if (action->m_latency > deltap) { double_update(&(action->m_latency), deltap, sg_surf_precision); deltap = 0.0; } else { double_update(&(deltap), action->m_latency, sg_surf_precision); action->m_latency = 0.0; } if ((action->m_latency == 0.0) && (action->isSuspended() == 0)) { action->updateBound(); lmm_update_variable_weight(ptask_maxmin_system, 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); if (action->getMaxDuration() != NO_MAX_DURATION) action->updateMaxDuration(delta); XBT_DEBUG("Action (%p) : remains (%g).", action, action->getRemains()); if ((action->getRemains() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) { action->finish(); action->setState(SURF_ACTION_DONE); } else if ((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0)) { action->finish(); action->setState(SURF_ACTION_DONE); } else { /* Need to check that none of the model has failed */ lmm_constraint_t cnst = NULL; int i = 0; void *constraint_id = NULL; while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->getVariable(), i++))) { constraint_id = lmm_constraint_id(cnst); if (static_cast<WorkstationPtr>(constraint_id)->getState() == SURF_RESOURCE_OFF) { XBT_DEBUG("Action (%p) Failed!!", action); action->finish(); action->setState(SURF_ACTION_FAILED); break; } } } } return; }