public:
/* Lazy update needs this Set hook to maintain a list of the tracked actions */
boost::intrusive::list_member_hook<> modified_set_hook_;
- bool isLinkedModifiedSet() const { return modified_set_hook_.is_linked(); }
+ bool is_within_modified_set() const { return modified_set_hook_.is_linked(); }
typedef boost::intrusive::list<
Action, boost::intrusive::member_hook<Action, boost::intrusive::list_member_hook<>, &Action::modified_set_hook_>>
ModifiedSet;
/** @brief Get the start time of the current action */
double get_start_time() const { return start_time_; }
/** @brief Get the finish time of the current action */
- double getFinishTime() const { return finish_time_; }
+ double get_finish_time() const { return finish_time_; }
/** @brief Get the user data associated to the current action */
void* get_data() const { return data_; }
* @param delta Amount to remove from the remaining time */
void update_remains(double delta);
+ virtual void update_remains_lazy(double now) = 0;
+
/** @brief Set the remaining time of the current action */
void set_remains(double value) { remains_ = value; }
/**@brief Add a reference to the current action (refcounting) */
void ref();
/** @brief Unref that action (and destroy it if refcount reaches 0)
- * @return true if the action was destroyed and false if someone still has references on it
- */
+ * @return true if the action was destroyed and false if someone still has references on it */
int unref();
/** @brief Cancel the current Action if running */
virtual void resume();
/** @brief Returns true if the current action is running */
- virtual bool isSuspended();
+ bool is_suspended();
/** @brief Get the maximum duration of the current action */
double get_max_duration() const { return max_duration_; }
double max_duration_ = NO_MAX_DURATION; /*< max_duration (may fluctuate until the task is completed) */
double remains_; /**< How much of that cost remains to be done in the currently running task */
double start_time_; /**< start time */
- char* category_ = nullptr; /**< tracing category for categorized resource utilization monitoring */
- double finish_time_ =
- -1; /**< finish time : this is modified during the run and fluctuates until the task is completed */
+ double finish_time_ = -1; /**< finish time (may fluctuate until the task is completed) */
+ char* category_ = nullptr; /**< tracing category for categorized resource utilization monitoring */
double cost_;
simgrid::kernel::resource::Model* model_;
void* data_ = nullptr; /**< for your convenience */
/* LMM */
- double last_update_ = 0;
- double last_value_ = 0;
- kernel::lmm::Variable* variable_ = nullptr;
- Action::Type type_ = Action::Type::NOTSET;
- boost::optional<heap_type::handle_type> heap_handle_ = boost::none;
+ double last_update_ = 0;
+ double last_value_ = 0;
+ kernel::lmm::Variable* variable_ = nullptr;
+ Action::Type type_ = Action::Type::NOTSET;
+ boost::optional<heap_type::handle_type> heap_hook_ = boost::none;
public:
- virtual void updateRemainingLazy(double now) = 0;
- void heapInsert(heap_type& heap, double key, Action::Type hat);
- void heapRemove(heap_type& heap);
- void heapUpdate(heap_type& heap, double key, Action::Type hat);
- void clearHeapHandle() { heap_handle_ = boost::none; }
- kernel::lmm::Variable* getVariable() const { return variable_; }
- void setVariable(kernel::lmm::Variable* var) { variable_ = var; }
- double getLastUpdate() const { return last_update_; }
- void refreshLastUpdate();
- double getLastValue() const { return last_value_; }
- void setLastValue(double val) { last_value_ = val; }
- Action::Type getType() const { return type_; }
+ void heapInsert(double key, Action::Type hat);
+ void heapRemove();
+ void heapUpdate(double key, Action::Type hat);
+ void clearHeapHandle() { heap_hook_ = boost::none; }
+
+ lmm::Variable* get_variable() const { return variable_; }
+ void set_variable(lmm::Variable* var) { variable_ = var; }
+
+ double get_last_update() const { return last_update_; }
+ void set_last_update();
+
+ double get_last_value() const { return last_value_; }
+ void set_last_value(double val) { last_value_ = val; }
+
+ Action::Type get_type() const { return type_; }
protected:
Action::SuspendStates suspended_ = Action::SuspendStates::not_suspended;
elem.make_active();
simgrid::kernel::resource::Action* action = static_cast<simgrid::kernel::resource::Action*>(elem.variable->id);
- if (modified_set_ && not action->isLinkedModifiedSet())
+ if (modified_set_ && not action->is_within_modified_set())
modified_set_->push_back(*action);
}
}
{
if (state_set_hook_.is_linked())
simgrid::xbt::intrusive_erase(*state_set_, *this);
- if (getVariable())
- get_model()->getMaxminSystem()->variable_free(getVariable());
+ if (get_variable())
+ get_model()->getMaxminSystem()->variable_free(get_variable());
if (get_model()->getUpdateMechanism() == UM_LAZY) {
/* remove from heap */
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
if (modified_set_hook_.is_linked())
simgrid::xbt::intrusive_erase(*get_model()->getModifiedSet(), *this);
}
if (variable_)
get_model()->getMaxminSystem()->update_variable_bound(variable_, bound);
- if (get_model()->getUpdateMechanism() == UM_LAZY && getLastUpdate() != surf_get_clock())
- heapRemove(get_model()->getActionHeap());
+ if (get_model()->getUpdateMechanism() == UM_LAZY && get_last_update() != surf_get_clock())
+ heapRemove();
XBT_OUT();
}
{
max_duration_ = duration;
if (get_model()->getUpdateMechanism() == UM_LAZY) // remove action from the heap
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
}
void Action::set_priority(double weight)
{
XBT_IN("(%p,%g)", this, weight);
sharing_priority_ = weight;
- get_model()->getMaxminSystem()->update_variable_weight(getVariable(), weight);
+ get_model()->getMaxminSystem()->update_variable_weight(get_variable(), weight);
if (get_model()->getUpdateMechanism() == UM_LAZY)
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
XBT_OUT();
}
if (get_model()->getUpdateMechanism() == UM_LAZY) {
if (modified_set_hook_.is_linked())
simgrid::xbt::intrusive_erase(*get_model()->getModifiedSet(), *this);
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
}
}
{
XBT_IN("(%p)", this);
if (suspended_ != SuspendStates::sleeping) {
- get_model()->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
+ get_model()->getMaxminSystem()->update_variable_weight(get_variable(), 0.0);
if (get_model()->getUpdateMechanism() == UM_LAZY) {
- heapRemove(get_model()->getActionHeap());
- if (get_model()->getUpdateMechanism() == UM_LAZY && state_set_ == get_model()->getRunningActionSet() &&
- sharing_priority_ > 0) {
+ heapRemove();
+ if (state_set_ == get_model()->getRunningActionSet() && sharing_priority_ > 0) {
// If we have a lazy model, we need to update the remaining value accordingly
- updateRemainingLazy(surf_get_clock());
+ update_remains_lazy(surf_get_clock());
}
}
suspended_ = SuspendStates::suspended;
{
XBT_IN("(%p)", this);
if (suspended_ != SuspendStates::sleeping) {
- get_model()->getMaxminSystem()->update_variable_weight(getVariable(), get_priority());
+ get_model()->getMaxminSystem()->update_variable_weight(get_variable(), get_priority());
suspended_ = SuspendStates::not_suspended;
if (get_model()->getUpdateMechanism() == UM_LAZY)
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
}
XBT_OUT();
}
-bool Action::isSuspended()
+bool Action::is_suspended()
{
return suspended_ == SuspendStates::suspended;
}
* 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(heap_type& heap, double key, Action::Type hat)
+void Action::heapInsert(double key, Action::Type hat)
{
type_ = hat;
- heap_handle_ = heap.emplace(std::make_pair(key, this));
+ heap_hook_ = get_model()->getActionHeap().emplace(std::make_pair(key, this));
}
-void Action::heapRemove(heap_type& heap)
+void Action::heapRemove()
{
type_ = Action::Type::NOTSET;
- if (heap_handle_) {
- heap.erase(*heap_handle_);
+ if (heap_hook_) {
+ get_model()->getActionHeap().erase(*heap_hook_);
clearHeapHandle();
}
}
-void Action::heapUpdate(heap_type& heap, double key, Action::Type hat)
+void Action::heapUpdate(double key, Action::Type hat)
{
type_ = hat;
- if (heap_handle_) {
- heap.update(*heap_handle_, std::make_pair(key, this));
+ if (heap_hook_) {
+ get_model()->getActionHeap().update(*heap_hook_, std::make_pair(key, this));
} else {
- heap_handle_ = heap.emplace(std::make_pair(key, this));
+ heap_hook_ = get_model()->getActionHeap().emplace(std::make_pair(key, this));
}
}
XBT_IN("(%p)", this);
/* update remains before return it */
if (get_model()->getUpdateMechanism() == UM_LAZY) /* update remains before return it */
- updateRemainingLazy(surf_get_clock());
+ update_remains_lazy(surf_get_clock());
XBT_OUT();
return remains_;
}
double_update(&remains_, delta, sg_maxmin_precision * sg_surf_precision);
}
-void Action::refreshLastUpdate()
+void Action::set_last_update()
{
last_update_ = surf_get_clock();
}
continue;
/* bogus priority, skip it */
- if (action->get_priority() <= 0 || action->getType() == Action::Type::LATENCY)
+ if (action->get_priority() <= 0 || action->get_type() == Action::Type::LATENCY)
continue;
- action->updateRemainingLazy(now);
+ action->update_remains_lazy(now);
double min = -1;
- double share = action->getVariable()->get_value();
+ double share = action->get_variable()->get_value();
if (share > 0) {
double time_to_completion;
max_dur_flag = true;
}
- XBT_DEBUG("Action(%p) corresponds to variable %d", action, action->getVariable()->id_int);
+ XBT_DEBUG("Action(%p) corresponds to variable %d", action, action->get_variable()->id_int);
XBT_DEBUG("Action(%p) Start %f. May finish at %f (got a share of %f). Max_duration %f", action,
action->get_start_time(), min, share, action->get_max_duration());
if (min > -1) {
- action->heapUpdate(action_heap_, min, max_dur_flag ? Action::Type::MAX_DURATION : Action::Type::NORMAL);
+ action->heapUpdate(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 min = -1;
for (Action& action : *getRunningActionSet()) {
- double value = action.getVariable()->get_value();
+ double value = action.get_variable()->get_value();
if (value > 0) {
if (action.get_remains() > 0)
value = action.get_remains_no_update() / value;
surf::Cpu* cpu = ws_vm->pimpl_cpu;
xbt_assert(cpu, "cpu-less host");
- double solved_value = ws_vm->getImpl()->action_->getVariable()->get_value(); // this is X1 in comment above, what
- // this VM got in the sharing on the PM
+ double solved_value =
+ ws_vm->getImpl()->action_->get_variable()->get_value(); // this is X1 in comment above, what
+ // this VM got in the sharing on the PM
XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->getCname(), ws_vm->getPm()->getCname());
xbt_assert(cpu->model() == surf_cpu_model_vm);
sd_global->completed_tasks->insert(task);
task->start_time = task->surf_action->get_start_time();
if (new_state == SD_DONE){
- task->finish_time = task->surf_action->getFinishTime();
+ task->finish_time = task->surf_action->get_finish_time();
#if SIMGRID_HAVE_JEDULE
jedule_log_sd_event(task);
#endif
double SD_task_get_finish_time(SD_task_t task)
{
if (task->surf_action) /* should never happen as actions are destroyed right after their completion */
- return task->surf_action->getFinishTime();
+ return task->surf_action->get_finish_time();
else
return task->finish_time;
}
while ((var = constraint()->get_variable(&elem))) {
CpuCas01Action* action = static_cast<CpuCas01Action*>(var->get_id());
- model()->getMaxminSystem()->update_variable_bound(action->getVariable(),
+ model()->getMaxminSystem()->update_variable_bound(action->get_variable(),
action->requestedCore() * speed_.scale * speed_.peak);
}
action->get_state_set()->push_back(*action);
}
- model()->getMaxminSystem()->update_variable_weight(action->getVariable(), 0.0);
+ model()->getMaxminSystem()->update_variable_weight(action->get_variable(), 0.0);
if (model()->getUpdateMechanism() == UM_LAZY) { // remove action from the heap
- action->heapRemove(model()->getActionHeap());
+ 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()->getModifiedSet()->push_front(*action);
, requestedCore_(requestedCore)
{
if (model->getUpdateMechanism() == UM_LAZY) {
- refreshLastUpdate();
- setLastValue(0.0);
+ set_last_update();
+ set_last_value(0.0);
}
- model->getMaxminSystem()->expand(constraint, getVariable(), 1.0);
+ model->getMaxminSystem()->expand(constraint, get_variable(), 1.0);
}
CpuCas01Action::CpuCas01Action(kernel::resource::Model* model, double cost, bool failed, double speed,
CpuAction* action = static_cast<CpuAction*>(actionHeapPop());
XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
if (TRACE_is_enabled()) {
- Cpu* cpu = static_cast<Cpu*>(action->getVariable()->get_constraint(0)->get_id());
- TRACE_surf_host_set_utilization(cpu->getCname(), action->get_category(), action->getVariable()->get_value(),
- action->getLastUpdate(), now - action->getLastUpdate());
+ Cpu* cpu = static_cast<Cpu*>(action->get_variable()->get_constraint(0)->get_id());
+ TRACE_surf_host_set_utilization(cpu->getCname(), action->get_category(), action->get_variable()->get_value(),
+ action->get_last_update(), now - action->get_last_update());
}
action->finish(kernel::resource::Action::State::done);
XBT_CDEBUG(surf_kernel, "Action %p finished", action);
-
- /* set the remains to 0 due to precision problems when updating the remaining amount */
- action->set_remains(0);
}
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;
for (kernel::resource::Action const& action : *getRunningActionSet()) {
- if (smaller < 0 || action.getLastUpdate() < smaller)
- smaller = action.getLastUpdate();
+ if (smaller < 0 || action.get_last_update() < smaller)
+ smaller = action.get_last_update();
}
if (smaller > 0) {
TRACE_last_timestamp_to_dump = smaller;
CpuAction& action = static_cast<CpuAction&>(*it);
++it; // increment iterator here since the following calls to action.finish() may invalidate it
if (TRACE_is_enabled()) {
- Cpu* cpu = static_cast<Cpu*>(action.getVariable()->get_constraint(0)->get_id());
- TRACE_surf_host_set_utilization(cpu->getCname(), action.get_category(), action.getVariable()->get_value(),
+ Cpu* cpu = static_cast<Cpu*>(action.get_variable()->get_constraint(0)->get_id());
+ TRACE_surf_host_set_utilization(cpu->getCname(), action.get_category(), action.get_variable()->get_value(),
now - delta, delta);
TRACE_last_timestamp_to_dump = now - delta;
}
- action.update_remains(action.getVariable()->get_value() * delta);
+ action.update_remains(action.get_variable()->get_value() * delta);
if (action.get_max_duration() != NO_MAX_DURATION)
action.update_max_duration(delta);
- if (((action.get_remains_no_update() <= 0) && (action.getVariable()->get_weight() > 0)) ||
+ if (((action.get_remains_no_update() <= 0) && (action.get_variable()->get_weight() > 0)) ||
((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
action.finish(kernel::resource::Action::State::done);
}
* Action *
**********/
-void CpuAction::updateRemainingLazy(double now)
+void CpuAction::update_remains_lazy(double now)
{
xbt_assert(get_state_set() == get_model()->getRunningActionSet(), "You're updating an action that is not running.");
xbt_assert(get_priority() > 0, "You're updating an action that seems suspended.");
- double delta = now - getLastUpdate();
+ double delta = now - get_last_update();
if (get_remains_no_update() > 0) {
XBT_CDEBUG(surf_kernel, "Updating action(%p): remains was %f, last_update was: %f", this, get_remains_no_update(),
- getLastUpdate());
- update_remains(getLastValue() * delta);
+ get_last_update());
+ update_remains(get_last_value() * delta);
if (TRACE_is_enabled()) {
- Cpu* cpu = static_cast<Cpu*>(getVariable()->get_constraint(0)->get_id());
- TRACE_surf_host_set_utilization(cpu->getCname(), get_category(), getLastValue(), getLastUpdate(),
- now - getLastUpdate());
+ Cpu* cpu = static_cast<Cpu*>(get_variable()->get_constraint(0)->get_id());
+ TRACE_surf_host_set_utilization(cpu->getCname(), get_category(), get_last_value(), get_last_update(),
+ now - get_last_update());
}
XBT_CDEBUG(surf_kernel, "Updating action(%p): remains is now %f", this, get_remains_no_update());
}
- refreshLastUpdate();
- setLastValue(getVariable()->get_value());
+ set_last_update();
+ set_last_value(get_variable()->get_value());
}
simgrid::xbt::signal<void(simgrid::surf::CpuAction*, kernel::resource::Action::State)> CpuAction::onStateChange;
/** @brief returns a list of all CPUs that this action is using */
std::list<Cpu*> CpuAction::cpus() {
std::list<Cpu*> retlist;
- int llen = getVariable()->get_number_of_constraint();
+ int llen = get_variable()->get_number_of_constraint();
for (int i = 0; i < llen; i++) {
/* Beware of composite actions: ptasks put links and cpus together */
// extra pb: we cannot dynamic_cast from void*...
kernel::resource::Resource* resource =
- static_cast<kernel::resource::Resource*>(getVariable()->get_constraint(i)->get_id());
+ static_cast<kernel::resource::Resource*>(get_variable()->get_constraint(i)->get_id());
Cpu* cpu = dynamic_cast<Cpu*>(resource);
if (cpu != nullptr)
retlist.push_back(cpu);
void set_state(simgrid::kernel::resource::Action::State state) override;
- void updateRemainingLazy(double now) override;
+ void update_remains_lazy(double now) override;
std::list<Cpu*> cpus();
void suspend() override;
CpuTiAction* action = static_cast<CpuTiAction*>(actionHeapPop());
XBT_DEBUG("Action %p: finish", action);
action->finish(kernel::resource::Action::State::done);
- /* set the remains to 0 due to precision problems when updating the remaining amount */
- action->set_remains(0);
/* update remaining amount of all actions */
action->cpu_->updateRemainingAmount(surf_get_clock());
}
action.get_state() == kernel::resource::Action::State::not_in_the_system) {
action.set_finish_time(date);
action.set_state(kernel::resource::Action::State::failed);
- action.heapRemove(model()->getActionHeap());
+ action.heapRemove();
}
}
}
action.set_finish_time(speedIntegratedTrace_->solve(now, total_area));
/* verify which event will happen before (max_duration or finish time) */
if (action.get_max_duration() > NO_MAX_DURATION &&
- action.get_start_time() + action.get_max_duration() < action.getFinishTime())
+ action.get_start_time() + action.get_max_duration() < action.get_finish_time())
min_finish = action.get_start_time() + action.get_max_duration();
else
- min_finish = action.getFinishTime();
+ min_finish = action.get_finish_time();
} else {
/* put the max duration time on heap */
if (action.get_max_duration() > NO_MAX_DURATION)
}
/* add in action heap */
if (min_finish > NO_MAX_DURATION)
- action.heapUpdate(model()->getActionHeap(), min_finish, kernel::resource::Action::Type::NOTSET);
+ action.heapUpdate(min_finish, kernel::resource::Action::Type::NOTSET);
else
- action.heapRemove(model()->getActionHeap());
+ action.heapRemove();
XBT_DEBUG("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f", getCname(),
- &action, action.get_start_time(), action.getFinishTime(), action.get_max_duration());
+ &action, action.get_start_time(), action.get_finish_time(), action.get_max_duration());
}
/* remove from modified cpu */
modified(false);
continue;
/* skip action that are finishing now */
- if (action.getFinishTime() >= 0 && action.getFinishTime() <= now)
+ if (action.get_finish_time() >= 0 && action.get_finish_time() <= now)
continue;
/* update remaining */
if (action_ti_hook.is_linked())
simgrid::xbt::intrusive_erase(cpu_->actionSet_, *this);
/* remove from heap */
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
cpu_->modified(true);
}
void CpuTiAction::cancel()
{
this->set_state(Action::State::failed);
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
cpu_->modified(true);
}
XBT_IN("(%p)", this);
if (suspended_ != Action::SuspendStates::sleeping) {
suspended_ = Action::SuspendStates::suspended;
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
cpu_->modified(true);
}
XBT_OUT();
Action::set_max_duration(duration);
if (duration >= 0)
- min_finish = (get_start_time() + get_max_duration()) < getFinishTime() ? (get_start_time() + get_max_duration())
- : getFinishTime();
+ min_finish = (get_start_time() + get_max_duration()) < get_finish_time() ? (get_start_time() + get_max_duration())
+ : get_finish_time();
else
- min_finish = getFinishTime();
+ min_finish = get_finish_time();
/* add in action heap */
- heapUpdate(get_model()->getActionHeap(), min_finish, Action::Type::NOTSET);
+ heapUpdate(min_finish, Action::Type::NOTSET);
XBT_OUT();
}
NetworkCm02Action* action = static_cast<NetworkCm02Action*>(actionHeapPop());
XBT_DEBUG("Something happened to action %p", action);
if (TRACE_is_enabled()) {
- int n = action->getVariable()->get_number_of_constraint();
+ int n = action->get_variable()->get_number_of_constraint();
for (int i = 0; i < n; i++){
- kernel::lmm::Constraint* constraint = action->getVariable()->get_constraint(i);
+ kernel::lmm::Constraint* constraint = action->get_variable()->get_constraint(i);
NetworkCm02Link* link = static_cast<NetworkCm02Link*>(constraint->get_id());
- double value = action->getVariable()->get_value() * action->getVariable()->get_constraint_weight(i);
- TRACE_surf_link_set_utilization(link->getCname(), action->get_category(), value, action->getLastUpdate(),
- now - action->getLastUpdate());
+ double value = action->get_variable()->get_value() * action->get_variable()->get_constraint_weight(i);
+ TRACE_surf_link_set_utilization(link->getCname(), action->get_category(), value, action->get_last_update(),
+ now - action->get_last_update());
}
}
// if I am wearing a latency hat
- if (action->getType() == kernel::resource::Action::Type::LATENCY) {
+ if (action->get_type() == kernel::resource::Action::Type::LATENCY) {
XBT_DEBUG("Latency paid for action %p. Activating", action);
- maxmin_system_->update_variable_weight(action->getVariable(), action->weight_);
- action->heapRemove(getActionHeap());
- action->refreshLastUpdate();
+ 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->getType() == kernel::resource::Action::Type::MAX_DURATION ||
- action->getType() == kernel::resource::Action::Type::NORMAL) {
+ // 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) {
// no need to communicate anymore
// assume that flows that reached max_duration have remaining of 0
XBT_DEBUG("Action %p finished", action);
- action->set_remains(0);
action->finish(kernel::resource::Action::State::done);
- action->heapRemove(getActionHeap());
+ action->heapRemove();
}
}
}
double_update(&deltap, action.latency_, sg_surf_precision);
action.latency_ = 0.0;
}
- if (action.latency_ <= 0.0 && not action.isSuspended())
- maxmin_system_->update_variable_weight(action.getVariable(), action.weight_);
+ if (action.latency_ <= 0.0 && not action.is_suspended())
+ maxmin_system_->update_variable_weight(action.get_variable(), action.weight_);
}
if (TRACE_is_enabled()) {
- int n = action.getVariable()->get_number_of_constraint();
+ int n = action.get_variable()->get_number_of_constraint();
for (int i = 0; i < n; i++) {
- kernel::lmm::Constraint* constraint = action.getVariable()->get_constraint(i);
+ kernel::lmm::Constraint* constraint = action.get_variable()->get_constraint(i);
NetworkCm02Link* link = static_cast<NetworkCm02Link*>(constraint->get_id());
TRACE_surf_link_set_utilization(
link->getCname(), action.get_category(),
- (action.getVariable()->get_value() * action.getVariable()->get_constraint_weight(i)),
- action.getLastUpdate(), now - action.getLastUpdate());
+ (action.get_variable()->get_value() * action.get_variable()->get_constraint_weight(i)),
+ action.get_last_update(), now - action.get_last_update());
}
}
- if (not action.getVariable()->get_number_of_constraint()) {
+ if (not action.get_variable()->get_number_of_constraint()) {
/* 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.update_remains(action.get_remains());
}
- action.update_remains(action.getVariable()->get_value() * delta);
+ action.update_remains(action.get_variable()->get_value() * delta);
if (action.get_max_duration() > NO_MAX_DURATION)
action.update_max_duration(delta);
- if (((action.get_remains() <= 0) && (action.getVariable()->get_weight() > 0)) ||
+ if (((action.get_remains() <= 0) && (action.get_variable()->get_weight() > 0)) ||
((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
action.finish(kernel::resource::Action::State::done);
}
action->latency_ = latency;
action->rate_ = rate;
if (getUpdateMechanism() == UM_LAZY) {
- action->refreshLastUpdate();
+ action->set_last_update();
}
double bandwidth_bound = -1.0;
constraints_per_variable += back_route.size();
if (action->latency_ > 0) {
- action->setVariable(maxmin_system_->variable_new(action, 0.0, -1.0, constraints_per_variable));
+ action->set_variable(maxmin_system_->variable_new(action, 0.0, -1.0, constraints_per_variable));
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(getActionHeap(), action->latency_ + action->getLastUpdate(),
- route.empty() ? kernel::resource::Action::Type::NORMAL
- : kernel::resource::Action::Type::LATENCY);
+ 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);
}
} else
- action->setVariable(maxmin_system_->variable_new(action, 1.0, -1.0, constraints_per_variable));
+ action->set_variable(maxmin_system_->variable_new(action, 1.0, -1.0, constraints_per_variable));
if (action->rate_ < 0) {
maxmin_system_->update_variable_bound(
- action->getVariable(), (action->latCurrent_ > 0) ? sg_tcp_gamma / (2.0 * action->latCurrent_) : -1.0);
+ action->get_variable(), (action->latCurrent_ > 0) ? sg_tcp_gamma / (2.0 * action->latCurrent_) : -1.0);
} else {
- maxmin_system_->update_variable_bound(action->getVariable(),
+ maxmin_system_->update_variable_bound(action->get_variable(),
(action->latCurrent_ > 0)
? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_))
: action->rate_);
}
for (auto const& link : route)
- maxmin_system_->expand(link->constraint(), action->getVariable(), 1.0);
+ maxmin_system_->expand(link->constraint(), action->get_variable(), 1.0);
if (not back_route.empty()) { // sg_network_crosstraffic was activated
XBT_DEBUG("Crosstraffic active adding backward flow using 5%%");
for (auto const& link : back_route)
- maxmin_system_->expand(link->constraint(), action->getVariable(), .05);
+ maxmin_system_->expand(link->constraint(), action->get_variable(), .05);
// Change concurrency_share here, if you want that cross-traffic is included in the SURF concurrency
// (You would also have to change simgrid::kernel::lmm::Element::get_concurrency())
while ((var = constraint()->get_variable_safe(&elem, &nextelem, &numelem))) {
NetworkCm02Action* action = static_cast<NetworkCm02Action*>(var->get_id());
action->weight_ += delta;
- if (not action->isSuspended())
- model()->getMaxminSystem()->update_variable_weight(action->getVariable(), action->weight_);
+ if (not action->is_suspended())
+ model()->getMaxminSystem()->update_variable_weight(action->get_variable(), action->weight_);
}
}
}
action->latCurrent_ += delta;
action->weight_ += delta;
if (action->rate_ < 0)
- model()->getMaxminSystem()->update_variable_bound(action->getVariable(),
+ model()->getMaxminSystem()->update_variable_bound(action->get_variable(),
sg_tcp_gamma / (2.0 * action->latCurrent_));
else {
model()->getMaxminSystem()->update_variable_bound(
- action->getVariable(), std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_)));
+ action->get_variable(), std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_)));
if (action->rate_ < sg_tcp_gamma / (2.0 * action->latCurrent_)) {
XBT_INFO("Flow is limited BYBANDWIDTH");
XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f", action->latCurrent_);
}
}
- if (not action->isSuspended())
- model()->getMaxminSystem()->update_variable_weight(action->getVariable(), action->weight_);
+ if (not action->is_suspended())
+ model()->getMaxminSystem()->update_variable_weight(action->get_variable(), action->weight_);
}
}
* Action *
**********/
-void NetworkCm02Action::updateRemainingLazy(double now)
+void NetworkCm02Action::update_remains_lazy(double now)
{
if (suspended_ != Action::SuspendStates::not_suspended)
return;
- double delta = now - getLastUpdate();
+ double delta = now - get_last_update();
double max_duration = get_max_duration();
if (get_remains_no_update() > 0) {
XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, get_remains_no_update(),
- getLastUpdate());
- update_remains(getLastValue() * delta);
+ get_last_update());
+ update_remains(get_last_value() * delta);
XBT_DEBUG("Updating action(%p): remains is now %f", this, get_remains_no_update());
}
set_max_duration(max_duration);
}
- if ((get_remains_no_update() <= 0 && (getVariable()->get_weight() > 0)) ||
+ if ((get_remains_no_update() <= 0 && (get_variable()->get_weight() > 0)) ||
((max_duration > NO_MAX_DURATION) && (max_duration <= 0))) {
finish(Action::State::done);
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
}
- refreshLastUpdate();
- setLastValue(getVariable()->get_value());
+ set_last_update();
+ set_last_value(get_variable()->get_value());
}
}
public:
NetworkCm02Action(kernel::resource::Model* model, double cost, bool failed) : NetworkAction(model, cost, failed){};
virtual ~NetworkCm02Action() = default;
- void updateRemainingLazy(double now) override;
+ void update_remains_lazy(double now) override;
};
}
}
NetworkConstantAction::~NetworkConstantAction() = default;
-void NetworkConstantAction::updateRemainingLazy(double /*now*/)
+void NetworkConstantAction::update_remains_lazy(double /*now*/)
{
THROW_IMPOSSIBLE;
}
NetworkConstantAction(NetworkConstantModel *model_, double size, double latency);
~NetworkConstantAction();
double initialLatency_;
- void updateRemainingLazy(double now) override;
+ void update_remains_lazy(double now) override;
};
}
if (not double_equals(penalized_bw, rate_before_update, sg_surf_precision)) {
XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,
(*it)->destination->id, (*it)->action, penalized_bw, (*it)->action->get_bound(), (*it)->init_rate);
- maxmin_system_->update_variable_bound((*it)->action->getVariable(), penalized_bw);
+ maxmin_system_->update_variable_bound((*it)->action->get_variable(), penalized_bw);
} else {
XBT_DEBUG("%d->%d action %p penalty not updated : bw %f, initial rate %f", root->id, (*it)->destination->id,
(*it)->action, penalized_bw, (*it)->init_rate);
std::list<LinkImpl*> NetworkAction::links()
{
std::list<LinkImpl*> retlist;
- int llen = getVariable()->get_number_of_constraint();
+ int llen = get_variable()->get_number_of_constraint();
for (int i = 0; i < llen; i++) {
/* Beware of composite actions: ptasks put links and cpus together */
// extra pb: we cannot dynamic_cast from void*...
kernel::resource::Resource* resource =
- static_cast<kernel::resource::Resource*>(getVariable()->get_constraint(i)->get_id());
+ static_cast<kernel::resource::Resource*>(get_variable()->get_constraint(i)->get_id());
LinkImpl* link = dynamic_cast<LinkImpl*>(resource);
if (link != nullptr)
retlist.push_back(link);
{
THROW_UNIMPLEMENTED;
}
-void NetworkNS3Action::updateRemainingLazy(double /*now*/)
+void NetworkNS3Action::update_remains_lazy(double /*now*/)
{
THROW_IMPOSSIBLE;
}
-/* Test whether a flow is suspended */
-bool NetworkNS3Action::isSuspended()
-{
- return false;
-}
-
}
}
public:
NetworkNS3Action(kernel::resource::Model* model, double cost, s4u::Host* src, s4u::Host* dst);
- bool isSuspended() override;
void suspend() override;
void resume() override;
std::list<LinkImpl*> links() override;
- void updateRemainingLazy(double now) override;
+ void update_remains_lazy(double now) override;
// private:
double lastSent_ = 0;
} else {
action.latency_ = 0.0;
}
- if ((action.latency_ <= 0.0) && (action.isSuspended() == 0)) {
+ if ((action.latency_ <= 0.0) && (action.is_suspended() == 0)) {
action.updateBound();
- maxmin_system_->update_variable_weight(action.getVariable(), 1.0);
+ maxmin_system_->update_variable_weight(action.get_variable(), 1.0);
}
}
XBT_DEBUG("Action (%p) : remains (%g) updated by %g.", &action, action.get_remains(),
- action.getVariable()->get_value() * delta);
- action.update_remains(action.getVariable()->get_value() * delta);
+ action.get_variable()->get_value() * delta);
+ action.update_remains(action.get_variable()->get_value() * delta);
if (action.get_max_duration() > NO_MAX_DURATION)
action.update_max_duration(delta);
* If it's not done, it may have failed.
*/
- if (((action.get_remains() <= 0) && (action.getVariable()->get_weight() > 0)) ||
+ if (((action.get_remains() <= 0) && (action.get_variable()->get_weight() > 0)) ||
((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
action.finish(kernel::resource::Action::State::done);
} else {
/* Need to check that none of the model has failed */
int i = 0;
- kernel::lmm::Constraint* cnst = action.getVariable()->get_constraint(i);
+ kernel::lmm::Constraint* cnst = action.get_variable()->get_constraint(i);
while (cnst != nullptr) {
i++;
void* constraint_id = cnst->get_id();
action.finish(kernel::resource::Action::State::failed);
break;
}
- cnst = action.getVariable()->get_constraint(i);
+ cnst = action.get_variable()->get_constraint(i);
}
}
}
XBT_DEBUG("Creating a parallel task (%p) with %d hosts and %d unique links.", this, host_nb, nb_link);
latency_ = latency;
- setVariable(model->getMaxminSystem()->variable_new(this, 1.0, (rate > 0 ? rate : -1.0), host_nb + nb_link));
+ set_variable(model->getMaxminSystem()->variable_new(this, 1.0, (rate > 0 ? rate : -1.0), host_nb + nb_link));
if (latency_ > 0)
- model->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
+ model->getMaxminSystem()->update_variable_weight(get_variable(), 0.0);
for (int i = 0; i < host_nb; i++)
- model->getMaxminSystem()->expand(host_list[i]->pimpl_cpu->constraint(), getVariable(), flops_amount[i]);
+ model->getMaxminSystem()->expand(host_list[i]->pimpl_cpu->constraint(), get_variable(), flops_amount[i]);
if(bytes_amount != nullptr) {
for (int i = 0; i < host_nb; i++) {
hostList_->at(i)->routeTo(hostList_->at(j), route, nullptr);
for (auto const& link : route)
- model->getMaxminSystem()->expand_add(link->constraint(), this->getVariable(),
+ model->getMaxminSystem()->expand_add(link->constraint(), this->get_variable(),
bytes_amount[i * host_nb + j]);
}
}
L07Action *action = static_cast<L07Action*>(execution_start(1.0));
action->set_max_duration(duration);
action->suspended_ = kernel::resource::Action::SuspendStates::sleeping;
- model()->getMaxminSystem()->update_variable_weight(action->getVariable(), 0.0);
+ model()->getMaxminSystem()->update_variable_weight(action->get_variable(), 0.0);
return action;
}
while ((var = constraint()->get_variable(&elem))) {
kernel::resource::Action* action = static_cast<kernel::resource::Action*>(var->get_id());
- model()->getMaxminSystem()->update_variable_bound(action->getVariable(), speed_.scale * speed_.peak);
+ model()->getMaxminSystem()->update_variable_bound(action->get_variable(), speed_.scale * speed_.peak);
}
Cpu::onSpeedChange();
XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
if ((latency_ <= 0.0) && (suspended_ == Action::SuspendStates::not_suspended)) {
if (rate_ < 0)
- get_model()->getMaxminSystem()->update_variable_bound(getVariable(), lat_bound);
+ get_model()->getMaxminSystem()->update_variable_bound(get_variable(), lat_bound);
else
- get_model()->getMaxminSystem()->update_variable_bound(getVariable(), std::min(rate_, lat_bound));
+ get_model()->getMaxminSystem()->update_variable_bound(get_variable(), std::min(rate_, lat_bound));
}
}
for (auto it = std::begin(*getRunningActionSet()); it != std::end(*getRunningActionSet());) {
StorageAction& action = static_cast<StorageAction&>(*it);
++it; // increment iterator here since the following calls to action.finish() may invalidate it
- action.update_remains(lrint(action.getVariable()->get_value() * delta));
+ action.update_remains(lrint(action.get_variable()->get_value() * delta));
if (action.get_max_duration() > NO_MAX_DURATION)
action.update_max_duration(delta);
- if (((action.get_remains_no_update() <= 0) && (action.getVariable()->get_weight() > 0)) ||
+ if (((action.get_remains_no_update() <= 0) && (action.get_variable()->get_weight() > 0)) ||
((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
action.finish(kernel::resource::Action::State::done);
}
XBT_IN("(%s,%g", storage->getCname(), cost);
// Must be less than the max bandwidth for all actions
- model->getMaxminSystem()->expand(storage->constraint(), getVariable(), 1.0);
+ model->getMaxminSystem()->expand(storage->constraint(), get_variable(), 1.0);
switch(type) {
case READ:
- model->getMaxminSystem()->expand(storage->constraintRead_, getVariable(), 1.0);
+ model->getMaxminSystem()->expand(storage->constraintRead_, get_variable(), 1.0);
break;
case WRITE:
- model->getMaxminSystem()->expand(storage->constraintWrite_, getVariable(), 1.0);
+ model->getMaxminSystem()->expand(storage->constraintWrite_, get_variable(), 1.0);
break;
default:
THROW_UNIMPLEMENTED;
{
XBT_IN("(%p)", this);
if (suspended_ != Action::SuspendStates::sleeping) {
- get_model()->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
+ get_model()->getMaxminSystem()->update_variable_weight(get_variable(), 0.0);
suspended_ = Action::SuspendStates::suspended;
}
XBT_OUT();
THROW_UNIMPLEMENTED;
}
-bool StorageN11Action::isSuspended()
-{
- return suspended_ == Action::SuspendStates::suspended;
-}
-
void StorageN11Action::set_max_duration(double /*duration*/)
{
THROW_UNIMPLEMENTED;
{
THROW_UNIMPLEMENTED;
}
-void StorageN11Action::updateRemainingLazy(double /*now*/)
+void StorageN11Action::update_remains_lazy(double /*now*/)
{
THROW_IMPOSSIBLE;
}
void suspend() override;
void cancel() override;
void resume() override;
- bool isSuspended() override;
void set_max_duration(double duration) override;
void set_priority(double priority) override;
- void updateRemainingLazy(double now) override;
+ void update_remains_lazy(double now) override;
};
}