/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "src/kernel/resource/Model.hpp"
+#include "simgrid/kernel/resource/Model.hpp"
#include "src/kernel/lmm/maxmin.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(resource);
namespace simgrid {
-namespace surf {
+namespace kernel {
+namespace resource {
-Model::Model() : maxminSystem_(nullptr)
-{
- readyActionSet_ = new ActionList();
- runningActionSet_ = new ActionList();
- failedActionSet_ = new ActionList();
- doneActionSet_ = new ActionList();
-
- modifiedSet_ = nullptr;
- updateMechanism_ = UM_UNDEFINED;
- selectiveUpdate_ = 0;
-}
+Model::Model() = default;
Model::~Model()
{
- delete readyActionSet_;
- delete runningActionSet_;
- delete failedActionSet_;
- delete doneActionSet_;
- delete modifiedSet_;
- delete maxminSystem_;
+ delete ready_action_set_;
+ delete running_action_set_;
+ delete failed_action_set_;
+ delete done_action_set_;
+ delete maxmin_system_;
}
Action* Model::actionHeapPop()
{
- Action* action = actionHeap_.top().second;
- actionHeap_.pop();
+ Action* action = action_heap_.top().second;
+ action_heap_.pop();
action->clearHeapHandle();
return action;
}
+ActionLmmListPtr Model::getModifiedSet() const
+{
+ return maxmin_system_->modified_set_;
+}
+
double Model::nextOccuringEvent(double now)
{
// FIXME: set the good function once and for all
- if (updateMechanism_ == UM_LAZY)
+ if (update_mechanism_ == UM_LAZY)
return nextOccuringEventLazy(now);
- else if (updateMechanism_ == UM_FULL)
+ else if (update_mechanism_ == UM_FULL)
return nextOccuringEventFull(now);
else
xbt_die("Invalid cpu update mechanism!");
double Model::nextOccuringEventLazy(double now)
{
- XBT_DEBUG("Before share resources, the size of modified actions set is %zu", modifiedSet_->size());
- lmm_solve(maxminSystem_);
- XBT_DEBUG("After share resources, The size of modified actions set is %zu", modifiedSet_->size());
+ XBT_DEBUG("Before share resources, the size of modified actions set is %zu", maxmin_system_->modified_set_->size());
+ lmm_solve(maxmin_system_);
+ XBT_DEBUG("After share resources, The size of modified actions set is %zu", maxmin_system_->modified_set_->size());
- while (not modifiedSet_->empty()) {
- Action* action = &(modifiedSet_->front());
- modifiedSet_->pop_front();
+ while (not maxmin_system_->modified_set_->empty()) {
+ Action* action = &(maxmin_system_->modified_set_->front());
+ maxmin_system_->modified_set_->pop_front();
bool max_dur_flag = false;
- if (action->getStateSet() != runningActionSet_)
+ if (action->getStateSet() != running_action_set_)
continue;
/* bogus priority, skip it */
action->getStartTime(), min, share, action->getMaxDuration());
if (min > -1) {
- action->heapUpdate(actionHeap_, min, max_dur_flag ? Action::Type::MAX_DURATION : Action::Type::NORMAL);
+ action->heapUpdate(action_heap_, min, max_dur_flag ? Action::Type::MAX_DURATION : Action::Type::NORMAL);
XBT_DEBUG("Insert at heap action(%p) min %f now %f", action, min, now);
} else
DIE_IMPOSSIBLE;
double Model::nextOccuringEventFull(double /*now*/)
{
- maxminSystem_->solve_fun(maxminSystem_);
+ maxmin_system_->solve_fun(maxmin_system_);
double min = -1;
void Model::updateActionsState(double now, double delta)
{
- if (updateMechanism_ == UM_FULL)
+ if (update_mechanism_ == UM_FULL)
updateActionsStateFull(now, delta);
- else if (updateMechanism_ == UM_LAZY)
+ else if (update_mechanism_ == UM_LAZY)
updateActionsStateLazy(now, delta);
else
xbt_die("Invalid cpu update mechanism!");
} // namespace surf
} // namespace simgrid
+} // namespace simgrid