maxminSystem_ = lmm_system_new(selectiveUpdate_);
if (getUpdateMechanism() == 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_;
}
{
lmm_system_free(maxminSystem_);
maxminSystem_ = nullptr;
- xbt_heap_free(actionHeap_);
delete modifiedSet_;
surf_cpu_model_pm = nullptr;
runningActionSetThatDoesNotNeedBeingChecked_ = new ActionList();
modifiedCpu_ = new CpuTiList();
-
- actionHeap_ = xbt_heap_new(8, nullptr);
- xbt_heap_set_update_callback(actionHeap_, surf_action_lmm_update_index_heap);
}
CpuTiModel::~CpuTiModel()
surf_cpu_model_pm = nullptr;
delete runningActionSetThatDoesNotNeedBeingChecked_;
delete modifiedCpu_;
- xbt_heap_free(actionHeap_);
}
Cpu *CpuTiModel::createCpu(simgrid::s4u::Host *host, std::vector<double>* speedPerPstate, int core)
}
/* get the min next event if heap not empty */
- if (xbt_heap_size(actionHeap_) > 0)
- min_action_duration = xbt_heap_maxkey(actionHeap_) - now;
+ if (xbt_heap_size(getActionHeap()) > 0)
+ min_action_duration = xbt_heap_maxkey(getActionHeap()) - now;
XBT_DEBUG("Share resources, min next event date: %f", min_action_duration);
void CpuTiModel::updateActionsState(double now, double /*delta*/)
{
- while ((xbt_heap_size(actionHeap_) > 0) && (xbt_heap_maxkey(actionHeap_) <= now)) {
- CpuTiAction* action = static_cast<CpuTiAction*>(xbt_heap_pop(actionHeap_));
+ while ((xbt_heap_size(getActionHeap()) > 0) && (xbt_heap_maxkey(getActionHeap()) <= now)) {
+ CpuTiAction* action = static_cast<CpuTiAction*>(xbt_heap_pop(getActionHeap()));
XBT_DEBUG("Action %p: finish", action);
action->finish(Action::State::done);
/* set the remains to 0 due to precision problems when updating the remaining amount */
loopback_ = createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
if (getUpdateMechanism() == 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_;
}
void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
{
- while ((xbt_heap_size(actionHeap_) > 0)
- && (double_equals(xbt_heap_maxkey(actionHeap_), now, sg_surf_precision))) {
+ while ((xbt_heap_size(getActionHeap()) > 0) &&
+ (double_equals(xbt_heap_maxkey(getActionHeap()), now, sg_surf_precision))) {
- NetworkCm02Action *action = static_cast<NetworkCm02Action*> (xbt_heap_pop(actionHeap_));
+ NetworkCm02Action* action = static_cast<NetworkCm02Action*>(xbt_heap_pop(getActionHeap()));
XBT_DEBUG("Something happened to action %p", action);
if (TRACE_is_enabled()) {
int n = lmm_get_number_of_cnst_from_var(maxminSystem_, action->getVariable());
if (action->getHat() == LATENCY) {
XBT_DEBUG("Latency paid for action %p. Activating", action);
lmm_update_variable_weight(maxminSystem_, action->getVariable(), action->weight_);
- action->heapRemove(actionHeap_);
+ action->heapRemove(getActionHeap());
action->refreshLastUpdate();
// if I am wearing a max_duration or normal hat
XBT_DEBUG("Action %p finished", action);
action->setRemains(0);
action->finish(Action::State::done);
- action->heapRemove(actionHeap_);
+ action->heapRemove(getActionHeap());
}
}
}
if (getUpdateMechanism() == UM_LAZY) {
// add to the heap the event when the latency is payed
XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency_ + action->getLastUpdate());
- action->heapInsert(actionHeap_, action->latency_ + action->getLastUpdate(), route.empty() ? NORMAL : LATENCY);
+ action->heapInsert(getActionHeap(), action->latency_ + action->getLastUpdate(), route.empty() ? NORMAL : LATENCY);
}
} else
action->setVariable(lmm_variable_new(maxminSystem_, action, 1.0, -1.0, constraints_per_variable));
NetworkModel::~NetworkModel()
{
lmm_system_free(maxminSystem_);
- xbt_heap_free(actionHeap_);
delete modifiedSet_;
}
doneActionSet_ = new ActionList();
modifiedSet_ = nullptr;
- actionHeap_ = nullptr;
+ actionHeap_ = xbt_heap_new(8, nullptr);
+ xbt_heap_set_update_callback(actionHeap_, surf_action_lmm_update_index_heap);
updateMechanism_ = UM_UNDEFINED;
selectiveUpdate_ = 0;
}
Model::~Model(){
+ xbt_heap_free(actionHeap_);
delete readyActionSet_;
delete runningActionSet_;
delete failedActionSet_;
ActionLmmListPtr modifiedSet_;
lmm_system_t maxminSystem_ = nullptr;
bool selectiveUpdate_;
- xbt_heap_t actionHeap_;
private:
e_UM_t updateMechanism_ = UM_UNDEFINED;
ActionList* runningActionSet_; /**< Actions in state SURF_ACTION_RUNNING */
ActionList* failedActionSet_; /**< Actions in state SURF_ACTION_FAILED */
ActionList* doneActionSet_; /**< Actions in state SURF_ACTION_DONE */
+ xbt_heap_t actionHeap_;
};
}