sleeping
};
- enum class Type { LATENCY = 100, MAX_DURATION, NORMAL, NOTSET };
+ enum class Type {
+ latency = 100, /* this is a heap entry to warn us when the latency is payed */
+ max_duration, /* this is a heap entry to warn us when the max_duration limit (timeout) is reached */
+ normal, /* this is a normal heap entry stating the date to finish transmitting */
+ unset
+ };
/**
* @brief Action constructor
double last_update_ = 0;
double last_value_ = 0;
kernel::lmm::Variable* variable_ = nullptr;
- Action::Type type_ = Action::Type::NOTSET;
+ Action::Type type_ = Action::Type::unset;
boost::optional<heap_type::handle_type> heap_hook_ = boost::none;
public:
- void heapInsert(double key, Action::Type hat);
+ void heapInsert(double key, Action::Type type);
void heapRemove();
- void heapUpdate(double key, Action::Type hat);
- void clearHeapHandle() { heap_hook_ = boost::none; }
+ void heapUpdate(double key, Action::Type type);
+ void heap_clear_handle();
lmm::Variable* get_variable() const { return variable_; }
void set_variable(lmm::Variable* var) { variable_ = var; }
/** @brief Set the maxmin system of the current Model */
void set_maxmin_system(lmm::System* system) { maxmin_system_ = system; }
- /** @brief Get the update mechanism of the current Model */
- UpdateAlgo getUpdateMechanism() const { return update_algorithm_; }
+ /** @brief Get the update algorithm of the current Model */
+ UpdateAlgo get_update_algorithm() const { return update_algorithm_; }
/** @brief Get Action heap */
- heap_type& getActionHeap() { return action_heap_; }
+ heap_type& get_action_heap() { return action_heap_; }
double actionHeapTopDate() const { return action_heap_.top().first; }
Action* actionHeapPop();
if (variable_)
get_model()->get_maxmin_system()->update_variable_bound(variable_, bound);
- if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy && get_last_update() != surf_get_clock())
+ if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy && get_last_update() != surf_get_clock())
heapRemove();
XBT_OUT();
}
void Action::set_max_duration(double duration)
{
max_duration_ = duration;
- if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy) // remove action from the heap
+ if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy) // remove action from the heap
heapRemove();
}
sharing_priority_ = weight;
get_model()->get_maxmin_system()->update_variable_weight(get_variable(), weight);
- if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy)
+ if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy)
heapRemove();
XBT_OUT();
}
void Action::cancel()
{
set_state(Action::State::failed);
- if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy) {
+ if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy) {
if (modified_set_hook_.is_linked())
simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
heapRemove();
XBT_IN("(%p)", this);
if (suspended_ != SuspendStates::sleeping) {
get_model()->get_maxmin_system()->update_variable_weight(get_variable(), 0.0);
- if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy) {
+ if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy) {
heapRemove();
if (state_set_ == get_model()->get_running_action_set() && sharing_priority_ > 0) {
// If we have a lazy model, we need to update the remaining value accordingly
if (suspended_ != SuspendStates::sleeping) {
get_model()->get_maxmin_system()->update_variable_weight(get_variable(), get_priority());
suspended_ = SuspendStates::not_suspended;
- if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy)
+ if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy)
heapRemove();
}
XBT_OUT();
{
return suspended_ == SuspendStates::suspended;
}
-/* insert action on heap using a given key and a hat (heap_action_type)
- * a hat can be of three types for communications:
- *
- * NORMAL = this is a normal heap entry stating the date to finish transmitting
- * LATENCY = this is a heap entry to warn us when the latency is payed
- * MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached
- */
-void Action::heapInsert(double key, Action::Type hat)
+/* insert action on heap using a given key and a type */
+void Action::heapInsert(double key, Action::Type type)
{
- type_ = hat;
- heap_hook_ = get_model()->getActionHeap().emplace(std::make_pair(key, this));
+ type_ = type;
+ heap_hook_ = get_model()->get_action_heap().emplace(std::make_pair(key, this));
}
void Action::heapRemove()
{
- type_ = Action::Type::NOTSET;
+ type_ = Action::Type::unset;
if (heap_hook_) {
- get_model()->getActionHeap().erase(*heap_hook_);
- clearHeapHandle();
+ get_model()->get_action_heap().erase(*heap_hook_);
+ heap_hook_ = boost::none;
}
}
+void Action::heap_clear_handle()
+{
+ heap_hook_ = boost::none;
+}
-void Action::heapUpdate(double key, Action::Type hat)
+void Action::heapUpdate(double key, Action::Type type)
{
- type_ = hat;
+ type_ = type;
if (heap_hook_) {
- get_model()->getActionHeap().update(*heap_hook_, std::make_pair(key, this));
+ get_model()->get_action_heap().update(*heap_hook_, std::make_pair(key, this));
} else {
- heap_hook_ = get_model()->getActionHeap().emplace(std::make_pair(key, this));
+ heap_hook_ = get_model()->get_action_heap().emplace(std::make_pair(key, this));
}
}
{
XBT_IN("(%p)", this);
/* update remains before return it */
- if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy) /* update remains before return it */
+ if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy) /* update remains before return it */
update_remains_lazy(surf_get_clock());
XBT_OUT();
return remains_;
{
Action* action = action_heap_.top().second;
action_heap_.pop();
- action->clearHeapHandle();
+ action->heap_clear_handle();
return action;
}
continue;
/* bogus priority, skip it */
- if (action->get_priority() <= 0 || action->get_type() == Action::Type::LATENCY)
+ if (action->get_priority() <= 0 || action->get_type() == Action::Type::latency)
continue;
action->update_remains_lazy(now);
action->get_start_time(), min, share, action->get_max_duration());
if (min > -1) {
- action->heapUpdate(min, max_duration_flag ? Action::Type::MAX_DURATION : Action::Type::NORMAL);
+ action->heapUpdate(min, max_duration_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;
}
model()->get_maxmin_system()->update_variable_weight(action->get_variable(), 0.0);
- if (model()->getUpdateMechanism() == kernel::resource::Model::UpdateAlgo::Lazy) { // remove action from the heap
+ if (model()->get_update_algorithm() == kernel::resource::Model::UpdateAlgo::Lazy) { // remove action from the heap
action->heapRemove();
// this is necessary for a variable with weight 0 since such variables are ignored in lmm and we need to set its
// max_duration correctly at the next call to share_resources
model->get_maxmin_system()->variable_new(this, 1.0 / requestedCore, requestedCore * speed, 1))
, requestedCore_(requestedCore)
{
- if (model->getUpdateMechanism() == kernel::resource::Model::UpdateAlgo::Lazy) {
+ if (model->get_update_algorithm() == kernel::resource::Model::UpdateAlgo::Lazy) {
set_last_update();
set_last_value(0.0);
}
}
/* add in action heap */
if (min_finish > NO_MAX_DURATION)
- action.heapUpdate(min_finish, kernel::resource::Action::Type::NOTSET);
+ action.heapUpdate(min_finish, kernel::resource::Action::Type::unset);
else
action.heapRemove();
min_finish = get_finish_time();
/* add in action heap */
- heapUpdate(min_finish, Action::Type::NOTSET);
+ heapUpdate(min_finish, Action::Type::unset);
XBT_OUT();
}
}
// if I am wearing a latency hat
- if (action->get_type() == kernel::resource::Action::Type::LATENCY) {
+ if (action->get_type() == kernel::resource::Action::Type::latency) {
XBT_DEBUG("Latency paid for action %p. Activating", action);
get_maxmin_system()->update_variable_weight(action->get_variable(), action->weight_);
action->heapRemove();
action->set_last_update();
// if I am wearing a max_duration or normal hat
- } else if (action->get_type() == kernel::resource::Action::Type::MAX_DURATION ||
- action->get_type() == kernel::resource::Action::Type::NORMAL) {
+ } else if (action->get_type() == kernel::resource::Action::Type::max_duration ||
+ action->get_type() == kernel::resource::Action::Type::normal) {
// no need to communicate anymore
// assume that flows that reached max_duration have remaining of 0
XBT_DEBUG("Action %p finished", action);
action->weight_ = latency;
action->latency_ = latency;
action->rate_ = rate;
- if (getUpdateMechanism() == kernel::resource::Model::UpdateAlgo::Lazy) {
+ if (get_update_algorithm() == kernel::resource::Model::UpdateAlgo::Lazy) {
action->set_last_update();
}
bandwidth_bound = (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb);
}
- action->latCurrent_ = action->latency_;
+ action->lat_current_ = action->latency_;
action->latency_ *= latencyFactor(size);
action->rate_ = bandwidthConstraint(action->rate_, bandwidth_bound, size);
if (action->latency_ > 0) {
action->set_variable(get_maxmin_system()->variable_new(action, 0.0, -1.0, constraints_per_variable));
- if (getUpdateMechanism() == kernel::resource::Model::UpdateAlgo::Lazy) {
+ if (get_update_algorithm() == kernel::resource::Model::UpdateAlgo::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->get_last_update());
action->heapInsert(action->latency_ + action->get_last_update(), route.empty()
- ? kernel::resource::Action::Type::NORMAL
- : kernel::resource::Action::Type::LATENCY);
+ ? kernel::resource::Action::Type::normal
+ : kernel::resource::Action::Type::latency);
}
} else
action->set_variable(get_maxmin_system()->variable_new(action, 1.0, -1.0, constraints_per_variable));
if (action->rate_ < 0) {
get_maxmin_system()->update_variable_bound(
- action->get_variable(), (action->latCurrent_ > 0) ? sg_tcp_gamma / (2.0 * action->latCurrent_) : -1.0);
+ action->get_variable(), (action->lat_current_ > 0) ? sg_tcp_gamma / (2.0 * action->lat_current_) : -1.0);
} else {
- get_maxmin_system()->update_variable_bound(action->get_variable(),
- (action->latCurrent_ > 0)
- ? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_))
- : action->rate_);
+ get_maxmin_system()->update_variable_bound(
+ action->get_variable(), (action->lat_current_ > 0)
+ ? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->lat_current_))
+ : action->rate_);
}
for (auto const& link : route)
while ((var = constraint()->get_variable_safe(&elem, &nextelem, &numelem))) {
NetworkCm02Action* action = static_cast<NetworkCm02Action*>(var->get_id());
- action->latCurrent_ += delta;
+ action->lat_current_ += delta;
action->weight_ += delta;
if (action->rate_ < 0)
model()->get_maxmin_system()->update_variable_bound(action->get_variable(),
- sg_tcp_gamma / (2.0 * action->latCurrent_));
+ sg_tcp_gamma / (2.0 * action->lat_current_));
else {
model()->get_maxmin_system()->update_variable_bound(
- action->get_variable(), std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_)));
+ action->get_variable(), std::min(action->rate_, sg_tcp_gamma / (2.0 * action->lat_current_)));
- if (action->rate_ < sg_tcp_gamma / (2.0 * action->latCurrent_)) {
+ if (action->rate_ < sg_tcp_gamma / (2.0 * action->lat_current_)) {
XBT_INFO("Flow is limited BYBANDWIDTH");
} else {
- XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f", action->latCurrent_);
+ XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f", action->lat_current_);
}
}
if (not action->is_suspended())
virtual std::list<LinkImpl*> links();
double latency_ = {};
- double latCurrent_ = {};
+ double lat_current_ = {};
double weight_ = {};
double rate_ = {};
};