void set_data(void* data) { data_ = data; }
/** @brief Get the cost of the current action */
- double getCost() const { return cost_; }
+ double get_cost() const { return cost_; }
/** @brief Set the cost of the current action */
- void setCost(double cost) { cost_ = cost; }
+ void set_cost(double cost) { cost_ = cost; }
/** @brief Update the maximum duration of the current action
* @param delta Amount to remove from the MaxDuration */
- void updateMaxDuration(double delta);
+ void update_max_duration(double delta);
/** @brief Update the remaining time of the current action
* @param delta Amount to remove from the remaining time */
- void updateRemains(double delta);
+ void update_remains(double delta);
/** @brief Set the remaining time of the current action */
- void setRemains(double value) { remains_ = value; }
+ void set_remains(double value) { remains_ = value; }
+
/** @brief Get the remaining time of the current action after updating the resource */
- virtual double getRemains();
+ virtual double get_remains();
/** @brief Get the remaining time of the current action without updating the resource */
- double getRemainsNoUpdate() const { return remains_; }
+ double get_remains_no_update() const { return remains_; }
/** @brief Set the finish time of the current action */
- void setFinishTime(double value) { finish_time_ = value; }
+ void set_finish_time(double value) { finish_time_ = value; }
/**@brief Add a reference to the current action (refcounting) */
void ref();
virtual bool isSuspended();
/** @brief Get the maximum duration of the current action */
- double getMaxDuration() const { return max_duration_; }
+ double get_max_duration() const { return max_duration_; }
/** @brief Set the maximum duration of the current Action */
- virtual void setMaxDuration(double duration);
+ virtual void set_max_duration(double duration);
/** @brief Get the tracing category associated to the current action */
- char* getCategory() const { return category_; }
+ char* get_category() const { return category_; }
/** @brief Set the tracing category of the current Action */
- void setCategory(const char* category);
+ void set_category(const char* category);
/** @brief Get the priority of the current Action */
- double getPriority() const { return sharing_weight_; };
+ double get_priority() const { return sharing_priority_; };
/** @brief Set the priority of the current Action */
- virtual void setSharingWeight(double priority);
- void setSharingWeightNoUpdate(double weight) { sharing_weight_ = weight; }
+ virtual void set_priority(double priority);
+ void set_priority_no_update(double priority) { sharing_priority_ = priority; }
/** @brief Get the state set in which the action is */
- StateSet* getStateSet() const { return state_set_; };
+ StateSet* get_state_set() const { return state_set_; };
- simgrid::kernel::resource::Model* getModel() const { return model_; }
+ simgrid::kernel::resource::Model* get_model() const { return model_; }
protected:
StateSet* state_set_;
int refcount_ = 1;
private:
- double sharing_weight_ = 1.0; /**< priority (1.0 by default) */
+ double sharing_priority_ = 1.0; /**< priority (1.0 by default) */
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 */
/** @brief get the amount remaining from the communication */
double simgrid::kernel::activity::CommImpl::remains()
{
- return surfAction_->getRemains();
+ return surfAction_->get_remains();
}
/** @brief This is part of the cleanup process, probably an internal command */
-/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved. */
/* 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. */
void simgrid::kernel::activity::ExecImpl::suspend()
{
- XBT_VERB("This exec is suspended (remain: %f)", surfAction_->getRemains());
+ XBT_VERB("This exec is suspended (remain: %f)", surfAction_->get_remains());
if (surfAction_)
surfAction_->suspend();
}
void simgrid::kernel::activity::ExecImpl::resume()
{
- XBT_VERB("This exec is resumed (remain: %f)", surfAction_->getRemains());
+ XBT_VERB("This exec is resumed (remain: %f)", surfAction_->get_remains());
if (surfAction_)
surfAction_->resume();
}
"We would need to return a vector instead of a scalar. "
"Did you mean remainingRatio() instead?");
- return surfAction_ ? surfAction_->getRemains() : 0;
+ return surfAction_ ? surfAction_->get_remains() : 0;
}
double simgrid::kernel::activity::ExecImpl::remainingRatio()
{
if (host_ == nullptr) // parallel task: their remain is already between 0 and 1 (see comment in ExecImpl::remains())
- return surfAction_->getRemains();
+ return surfAction_->get_remains();
else // Actually compute the ratio for sequential tasks
- return surfAction_->getRemains() / surfAction_->getCost();
+ return surfAction_->get_remains() / surfAction_->get_cost();
}
void simgrid::kernel::activity::ExecImpl::setBound(double bound)
if (not MC_is_active() && not MC_record_replay_is_active()) {
simgrid::kernel::resource::Action* oldAction = this->surfAction_;
- simgrid::kernel::resource::Action* newAction = to->pimpl_cpu->execution_start(oldAction->getCost());
- newAction->setRemains(oldAction->getRemains());
+ simgrid::kernel::resource::Action* newAction = to->pimpl_cpu->execution_start(oldAction->get_cost());
+ newAction->set_remains(oldAction->get_remains());
newAction->set_data(this);
- newAction->setSharingWeight(oldAction->getPriority());
+ newAction->set_priority(oldAction->get_priority());
// FIXME: the user-defined bound seem to not be kept by LMM, that seem to overwrite it for the multi-core modeling.
// I hope that the user did not provide any.
for (smx_simcall_t const& simcall : simcalls) {
switch (simcall->call) {
case SIMCALL_STORAGE_WRITE:
- simcall_storage_write__set__result(simcall, surf_io->getCost());
+ simcall_storage_write__set__result(simcall, surf_io->get_cost());
break;
case SIMCALL_STORAGE_READ:
- simcall_storage_read__set__result(simcall, surf_io->getCost());
+ simcall_storage_read__set__result(simcall, surf_io->get_cost());
break;
default:
break;
: remains_(cost), start_time_(surf_get_clock()), cost_(cost), model_(model), variable_(var)
{
if (failed)
- state_set_ = getModel()->getFailedActionSet();
+ state_set_ = get_model()->getFailedActionSet();
else
- state_set_ = getModel()->getRunningActionSet();
+ state_set_ = get_model()->getRunningActionSet();
state_set_->push_back(*this);
}
{
finish_time_ = surf_get_clock();
set_state(state);
+ set_remains(0);
}
Action::State Action::get_state() const
{
XBT_IN("(%p,%g)", this, bound);
if (variable_)
- getModel()->getMaxminSystem()->update_variable_bound(variable_, bound);
+ get_model()->getMaxminSystem()->update_variable_bound(variable_, bound);
- if (getModel()->getUpdateMechanism() == UM_LAZY && getLastUpdate() != surf_get_clock())
- heapRemove(getModel()->getActionHeap());
+ if (get_model()->getUpdateMechanism() == UM_LAZY && getLastUpdate() != surf_get_clock())
+ heapRemove(get_model()->getActionHeap());
XBT_OUT();
}
-void Action::setCategory(const char* category)
+void Action::set_category(const char* category)
{
category_ = xbt_strdup(category);
}
refcount_++;
}
-void Action::setMaxDuration(double duration)
+void Action::set_max_duration(double duration)
{
max_duration_ = duration;
- if (getModel()->getUpdateMechanism() == UM_LAZY) // remove action from the heap
- heapRemove(getModel()->getActionHeap());
+ if (get_model()->getUpdateMechanism() == UM_LAZY) // remove action from the heap
+ heapRemove(get_model()->getActionHeap());
}
-void Action::setSharingWeight(double weight)
+void Action::set_priority(double weight)
{
XBT_IN("(%p,%g)", this, weight);
- sharing_weight_ = weight;
- getModel()->getMaxminSystem()->update_variable_weight(getVariable(), weight);
+ sharing_priority_ = weight;
+ get_model()->getMaxminSystem()->update_variable_weight(getVariable(), weight);
- if (getModel()->getUpdateMechanism() == UM_LAZY)
- heapRemove(getModel()->getActionHeap());
+ if (get_model()->getUpdateMechanism() == UM_LAZY)
+ heapRemove(get_model()->getActionHeap());
XBT_OUT();
}
void Action::cancel()
{
set_state(Action::State::failed);
- if (getModel()->getUpdateMechanism() == UM_LAZY) {
+ if (get_model()->getUpdateMechanism() == UM_LAZY) {
if (modified_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*getModel()->getModifiedSet(), *this);
- heapRemove(getModel()->getActionHeap());
+ simgrid::xbt::intrusive_erase(*get_model()->getModifiedSet(), *this);
+ heapRemove(get_model()->getActionHeap());
}
}
if (state_set_hook_.is_linked())
simgrid::xbt::intrusive_erase(*state_set_, *this);
if (getVariable())
- getModel()->getMaxminSystem()->variable_free(getVariable());
- if (getModel()->getUpdateMechanism() == UM_LAZY) {
+ get_model()->getMaxminSystem()->variable_free(getVariable());
+ if (get_model()->getUpdateMechanism() == UM_LAZY) {
/* remove from heap */
- heapRemove(getModel()->getActionHeap());
+ heapRemove(get_model()->getActionHeap());
if (modified_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*getModel()->getModifiedSet(), *this);
+ simgrid::xbt::intrusive_erase(*get_model()->getModifiedSet(), *this);
}
delete this;
return 1;
{
XBT_IN("(%p)", this);
if (suspended_ != SuspendStates::sleeping) {
- getModel()->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
- if (getModel()->getUpdateMechanism() == UM_LAZY) {
- heapRemove(getModel()->getActionHeap());
- if (getModel()->getUpdateMechanism() == UM_LAZY && state_set_ == getModel()->getRunningActionSet() &&
- sharing_weight_ > 0) {
+ get_model()->getMaxminSystem()->update_variable_weight(getVariable(), 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) {
// If we have a lazy model, we need to update the remaining value accordingly
updateRemainingLazy(surf_get_clock());
}
{
XBT_IN("(%p)", this);
if (suspended_ != SuspendStates::sleeping) {
- getModel()->getMaxminSystem()->update_variable_weight(getVariable(), getPriority());
+ get_model()->getMaxminSystem()->update_variable_weight(getVariable(), get_priority());
suspended_ = SuspendStates::not_suspended;
- if (getModel()->getUpdateMechanism() == UM_LAZY)
- heapRemove(getModel()->getActionHeap());
+ if (get_model()->getUpdateMechanism() == UM_LAZY)
+ heapRemove(get_model()->getActionHeap());
}
XBT_OUT();
}
}
}
-double Action::getRemains()
+double Action::get_remains()
{
XBT_IN("(%p)", this);
/* update remains before return it */
- if (getModel()->getUpdateMechanism() == UM_LAZY) /* update remains before return it */
+ if (get_model()->getUpdateMechanism() == UM_LAZY) /* update remains before return it */
updateRemainingLazy(surf_get_clock());
XBT_OUT();
return remains_;
}
-void Action::updateMaxDuration(double delta)
+void Action::update_max_duration(double delta)
{
double_update(&max_duration_, delta, sg_surf_precision);
}
-void Action::updateRemains(double delta)
+void Action::update_remains(double delta)
{
double_update(&remains_, delta, sg_maxmin_precision * sg_surf_precision);
}
maxmin_system_->modified_set_->pop_front();
bool max_dur_flag = false;
- if (action->getStateSet() != running_action_set_)
+ if (action->get_state_set() != running_action_set_)
continue;
/* bogus priority, skip it */
- if (action->getPriority() <= 0 || action->getType() == Action::Type::LATENCY)
+ if (action->get_priority() <= 0 || action->getType() == Action::Type::LATENCY)
continue;
action->updateRemainingLazy(now);
if (share > 0) {
double time_to_completion;
- if (action->getRemains() > 0) {
- time_to_completion = action->getRemainsNoUpdate() / share;
+ if (action->get_remains() > 0) {
+ time_to_completion = action->get_remains_no_update() / share;
} else {
time_to_completion = 0.0;
}
min = now + time_to_completion; // when the task will complete if nothing changes
}
- if ((action->getMaxDuration() > NO_MAX_DURATION) &&
- (min <= -1 || action->get_start_time() + action->getMaxDuration() < min)) {
+ if ((action->get_max_duration() > NO_MAX_DURATION) &&
+ (min <= -1 || action->get_start_time() + action->get_max_duration() < min)) {
// when the task will complete anyway because of the deadline if any
- min = action->get_start_time() + action->getMaxDuration();
+ min = action->get_start_time() + action->get_max_duration();
max_dur_flag = true;
}
XBT_DEBUG("Action(%p) corresponds to variable %d", action, action->getVariable()->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->getMaxDuration());
+ 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);
for (Action& action : *getRunningActionSet()) {
double value = action.getVariable()->get_value();
if (value > 0) {
- if (action.getRemains() > 0)
- value = action.getRemainsNoUpdate() / value;
+ if (action.get_remains() > 0)
+ value = action.get_remains_no_update() / value;
else
value = 0.0;
if (min < 0 || value < min) {
XBT_DEBUG("Updating min (value) with %p: %f", &action, min);
}
}
- if ((action.getMaxDuration() >= 0) && (min < 0 || action.getMaxDuration() < min)) {
- min = action.getMaxDuration();
+ if ((action.get_max_duration() >= 0) && (min < 0 || action.get_max_duration() < min)) {
+ min = action.get_max_duration();
XBT_DEBUG("Updating min (duration) with %p: %f", &action, min);
}
}
surf::CpuAction* new_cpu_action =
static_cast<surf::CpuAction*>(destination->pimpl_cpu->execution_start(0, this->coreAmount_));
- if (action_->getRemainsNoUpdate() > 0)
- XBT_CRITICAL("FIXME: need copy the state(?), %f", action_->getRemainsNoUpdate());
+ if (action_->get_remains_no_update() > 0)
+ XBT_CRITICAL("FIXME: need copy the state(?), %f", action_->get_remains_no_update());
/* keep the bound value of the cpu action of the VM. */
double old_bound = action_->get_bound();
double SD_task_get_remaining_amount(SD_task_t task)
{
if (task->surf_action)
- return task->surf_action->getRemains();
+ return task->surf_action->get_remains();
else
return (task->state == SD_DONE) ? 0 : task->amount;
}
simgrid::kernel::activity::ExecImplPtr exec =
boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(execution);
if (exec->surfAction_)
- exec->surfAction_->setSharingWeight(priority);
+ exec->surfAction_->set_priority(priority);
});
}
-/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved. */
/* 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. */
exec->surfAction_ = host->pimpl_cpu->execution_start(flops_amount);
exec->surfAction_->set_data(exec.get());
- exec->surfAction_->setSharingWeight(priority);
+ exec->surfAction_->set_priority(priority);
if (bound > 0)
static_cast<simgrid::surf::CpuAction*>(exec->surfAction_)->set_bound(bound);
simgrid::kernel::activity::ExecImplPtr exec =
boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro);
if (exec != nullptr) {
- exec->surfAction_->setCategory(category);
+ exec->surfAction_->set_category(category);
return;
}
simgrid::kernel::activity::CommImplPtr comm =
boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
if (comm != nullptr) {
- comm->surfAction_->setCategory(category);
+ comm->surfAction_->set_category(category);
}
}
XBT_DEBUG("set the weight of the dummy CPU action of VM%p on PM to %d (#tasks: %d)", ws_vm, impact, active_tasks);
if (impact > 0)
- ws_vm->getImpl()->action_->setSharingWeight(1. / impact);
+ ws_vm->getImpl()->action_->set_priority(1. / impact);
else
- ws_vm->getImpl()->action_->setSharingWeight(0.);
+ ws_vm->getImpl()->action_->set_priority(0.);
}
}
if (action->get_state() == kernel::resource::Action::State::running ||
action->get_state() == kernel::resource::Action::State::ready ||
action->get_state() == kernel::resource::Action::State::not_in_the_system) {
- action->setFinishTime(date);
+ action->set_finish_time(date);
action->set_state(kernel::resource::Action::State::failed);
}
}
CpuCas01Action* action = new CpuCas01Action(model(), 1.0, isOff(), speed_.scale * speed_.peak, constraint());
// FIXME: sleep variables should not consume 1.0 in System::expand()
- action->setMaxDuration(duration);
+ action->set_max_duration(duration);
action->suspended_ = kernel::resource::Action::SuspendStates::sleeping;
if (duration < 0) { // NO_MAX_DURATION
/* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */
- simgrid::xbt::intrusive_erase(*action->getStateSet(), *action);
+ simgrid::xbt::intrusive_erase(*action->get_state_set(), *action);
action->state_set_ = &static_cast<CpuCas01Model*>(model())->cpuRunningActionSetThatDoesNotNeedBeingChecked_;
- action->getStateSet()->push_back(*action);
+ action->get_state_set()->push_back(*action);
}
model()->getMaxminSystem()->update_variable_weight(action->getVariable(), 0.0);
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->getCategory(), action->getVariable()->get_value(),
+ TRACE_surf_host_set_utilization(cpu->getCname(), action->get_category(), action->getVariable()->get_value(),
action->getLastUpdate(), now - action->getLastUpdate());
}
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->set_remains(0);
}
if (TRACE_is_enabled()) {
//defining the last timestamp that we can safely dump to trace file
++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.getCategory(), action.getVariable()->get_value(),
+ TRACE_surf_host_set_utilization(cpu->getCname(), action.get_category(), action.getVariable()->get_value(),
now - delta, delta);
TRACE_last_timestamp_to_dump = now - delta;
}
- action.updateRemains(action.getVariable()->get_value() * delta);
+ action.update_remains(action.getVariable()->get_value() * delta);
- if (action.getMaxDuration() != NO_MAX_DURATION)
- action.updateMaxDuration(delta);
+ if (action.get_max_duration() != NO_MAX_DURATION)
+ action.update_max_duration(delta);
- if (((action.getRemainsNoUpdate() <= 0) && (action.getVariable()->get_weight() > 0)) ||
- ((action.getMaxDuration() != NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
+ if (((action.get_remains_no_update() <= 0) && (action.getVariable()->get_weight() > 0)) ||
+ ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
action.finish(kernel::resource::Action::State::done);
}
}
void CpuAction::updateRemainingLazy(double now)
{
- xbt_assert(getStateSet() == getModel()->getRunningActionSet(), "You're updating an action that is not running.");
- xbt_assert(getPriority() > 0, "You're updating an action that seems suspended.");
+ 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();
- if (getRemainsNoUpdate() > 0) {
- XBT_CDEBUG(surf_kernel, "Updating action(%p): remains was %f, last_update was: %f", this, getRemainsNoUpdate(),
+ 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());
- updateRemains(getLastValue() * delta);
+ update_remains(getLastValue() * delta);
if (TRACE_is_enabled()) {
Cpu* cpu = static_cast<Cpu*>(getVariable()->get_constraint(0)->get_id());
- TRACE_surf_host_set_utilization(cpu->getCname(), getCategory(), getLastValue(), getLastUpdate(),
+ TRACE_surf_host_set_utilization(cpu->getCname(), get_category(), getLastValue(), getLastUpdate(),
now - getLastUpdate());
}
- XBT_CDEBUG(surf_kernel, "Updating action(%p): remains is now %f", this, getRemainsNoUpdate());
+ XBT_CDEBUG(surf_kernel, "Updating action(%p): remains is now %f", this, get_remains_no_update());
}
refreshLastUpdate();
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->setRemains(0);
+ action->set_remains(0);
/* update remaining amount of all actions */
action->cpu_->updateRemainingAmount(surf_get_clock());
}
if (action.get_state() == kernel::resource::Action::State::running ||
action.get_state() == kernel::resource::Action::State::ready ||
action.get_state() == kernel::resource::Action::State::not_in_the_system) {
- action.setFinishTime(date);
+ action.set_finish_time(date);
action.set_state(kernel::resource::Action::State::failed);
action.heapRemove(model()->getActionHeap());
}
for (CpuTiAction const& action : actionSet_) {
/* action not running, skip it */
- if (action.getStateSet() != surf_cpu_model_pm->getRunningActionSet())
+ if (action.get_state_set() != surf_cpu_model_pm->getRunningActionSet())
continue;
/* bogus priority, skip it */
- if (action.getPriority() <= 0)
+ if (action.get_priority() <= 0)
continue;
/* action suspended, skip it */
if (action.suspended_ != kernel::resource::Action::SuspendStates::not_suspended)
continue;
- sum_priority += 1.0 / action.getPriority();
+ sum_priority += 1.0 / action.get_priority();
}
sumPriority_ = sum_priority;
for (CpuTiAction& action : actionSet_) {
double min_finish = -1;
/* action not running, skip it */
- if (action.getStateSet() != surf_cpu_model_pm->getRunningActionSet())
+ if (action.get_state_set() != surf_cpu_model_pm->getRunningActionSet())
continue;
/* verify if the action is really running on cpu */
- if (action.suspended_ == kernel::resource::Action::SuspendStates::not_suspended && action.getPriority() > 0) {
+ if (action.suspended_ == kernel::resource::Action::SuspendStates::not_suspended && action.get_priority() > 0) {
/* total area needed to finish the action. Used in trace integration */
- total_area = (action.getRemains()) * sum_priority * action.getPriority();
+ total_area = (action.get_remains()) * sum_priority * action.get_priority();
total_area /= speed_.peak;
- action.setFinishTime(speedIntegratedTrace_->solve(now, total_area));
+ action.set_finish_time(speedIntegratedTrace_->solve(now, total_area));
/* verify which event will happen before (max_duration or finish time) */
- if (action.getMaxDuration() > NO_MAX_DURATION &&
- action.get_start_time() + action.getMaxDuration() < action.getFinishTime())
- min_finish = action.get_start_time() + action.getMaxDuration();
+ if (action.get_max_duration() > NO_MAX_DURATION &&
+ action.get_start_time() + action.get_max_duration() < action.getFinishTime())
+ min_finish = action.get_start_time() + action.get_max_duration();
else
min_finish = action.getFinishTime();
} else {
/* put the max duration time on heap */
- if (action.getMaxDuration() > NO_MAX_DURATION)
- min_finish = action.get_start_time() + action.getMaxDuration();
+ if (action.get_max_duration() > NO_MAX_DURATION)
+ min_finish = action.get_start_time() + action.get_max_duration();
}
/* add in action heap */
if (min_finish > NO_MAX_DURATION)
action.heapRemove(model()->getActionHeap());
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.getMaxDuration());
+ &action, action.get_start_time(), action.getFinishTime(), action.get_max_duration());
}
/* remove from modified cpu */
modified(false);
XBT_DEBUG("Flops total: %f, Last update %f", area_total, lastUpdate_);
for (CpuTiAction& action : actionSet_) {
/* action not running, skip it */
- if (action.getStateSet() != model()->getRunningActionSet())
+ if (action.get_state_set() != model()->getRunningActionSet())
continue;
/* bogus priority, skip it */
- if (action.getPriority() <= 0)
+ if (action.get_priority() <= 0)
continue;
/* action suspended, skip it */
continue;
/* update remaining */
- action.updateRemains(area_total / (sumPriority_ * action.getPriority()));
- XBT_DEBUG("Update remaining action(%p) remaining %f", &action, action.getRemainsNoUpdate());
+ action.update_remains(area_total / (sumPriority_ * action.get_priority()));
+ XBT_DEBUG("Update remaining action(%p) remaining %f", &action, action.get_remains_no_update());
}
lastUpdate_ = now;
}
XBT_IN("(%s,%g)", getCname(), duration);
CpuTiAction* action = new CpuTiAction(static_cast<CpuTiModel*>(model()), 1.0, isOff(), this);
- action->setMaxDuration(duration);
+ action->set_max_duration(duration);
action->suspended_ = kernel::resource::Action::SuspendStates::sleeping;
if (duration == NO_MAX_DURATION) {
/* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */
- simgrid::xbt::intrusive_erase(*action->getStateSet(), *action);
+ simgrid::xbt::intrusive_erase(*action->get_state_set(), *action);
action->state_set_ = &static_cast<CpuTiModel*>(model())->runningActionSetThatDoesNotNeedBeingChecked_;
- action->getStateSet()->push_back(*action);
+ action->get_state_set()->push_back(*action);
}
actionSet_.push_back(*action);
refcount_--;
if (not refcount_) {
if (state_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*getStateSet(), *this);
+ simgrid::xbt::intrusive_erase(*get_state_set(), *this);
/* remove from action_set */
if (action_ti_hook.is_linked())
simgrid::xbt::intrusive_erase(cpu_->actionSet_, *this);
/* remove from heap */
- heapRemove(getModel()->getActionHeap());
+ heapRemove(get_model()->getActionHeap());
cpu_->modified(true);
delete this;
return 1;
void CpuTiAction::cancel()
{
this->set_state(Action::State::failed);
- heapRemove(getModel()->getActionHeap());
+ heapRemove(get_model()->getActionHeap());
cpu_->modified(true);
}
XBT_IN("(%p)", this);
if (suspended_ != Action::SuspendStates::sleeping) {
suspended_ = Action::SuspendStates::suspended;
- heapRemove(getModel()->getActionHeap());
+ heapRemove(get_model()->getActionHeap());
cpu_->modified(true);
}
XBT_OUT();
XBT_OUT();
}
-void CpuTiAction::setMaxDuration(double duration)
+void CpuTiAction::set_max_duration(double duration)
{
double min_finish;
XBT_IN("(%p,%g)", this, duration);
- Action::setMaxDuration(duration);
+ Action::set_max_duration(duration);
if (duration >= 0)
- min_finish = (get_start_time() + getMaxDuration()) < getFinishTime() ? (get_start_time() + getMaxDuration())
- : getFinishTime();
+ min_finish = (get_start_time() + get_max_duration()) < getFinishTime() ? (get_start_time() + get_max_duration())
+ : getFinishTime();
else
min_finish = getFinishTime();
/* add in action heap */
- heapUpdate(getModel()->getActionHeap(), min_finish, Action::Type::NOTSET);
+ heapUpdate(get_model()->getActionHeap(), min_finish, Action::Type::NOTSET);
XBT_OUT();
}
-void CpuTiAction::setSharingWeight(double priority)
+void CpuTiAction::set_priority(double priority)
{
XBT_IN("(%p,%g)", this, priority);
- setSharingWeightNoUpdate(priority);
+ set_priority_no_update(priority);
cpu_->modified(true);
XBT_OUT();
}
-double CpuTiAction::getRemains()
+double CpuTiAction::get_remains()
{
XBT_IN("(%p)", this);
cpu_->updateRemainingAmount(surf_get_clock());
XBT_OUT();
- return getRemainsNoUpdate();
+ return get_remains_no_update();
}
}
void cancel() override;
void suspend() override;
void resume() override;
- void setMaxDuration(double duration) override;
- void setSharingWeight(double priority) override;
- double getRemains() override;
+ void set_max_duration(double duration) override;
+ void set_priority(double priority) override;
+ double get_remains() override;
CpuTi *cpu_;
kernel::lmm::Constraint* constraint = action->getVariable()->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->getCategory(), value, action->getLastUpdate(),
+ TRACE_surf_link_set_utilization(link->getCname(), action->get_category(), value, action->getLastUpdate(),
now - action->getLastUpdate());
}
}
// no need to communicate anymore
// assume that flows that reached max_duration have remaining of 0
XBT_DEBUG("Action %p finished", action);
- action->setRemains(0);
+ action->set_remains(0);
action->finish(kernel::resource::Action::State::done);
action->heapRemove(getActionHeap());
}
kernel::lmm::Constraint* constraint = action.getVariable()->get_constraint(i);
NetworkCm02Link* link = static_cast<NetworkCm02Link*>(constraint->get_id());
TRACE_surf_link_set_utilization(
- link->getCname(), action.getCategory(),
+ link->getCname(), action.get_category(),
(action.getVariable()->get_value() * action.getVariable()->get_constraint_weight(i)),
action.getLastUpdate(), now - action.getLastUpdate());
}
/* 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.update_remains(action.get_remains());
}
- action.updateRemains(action.getVariable()->get_value() * delta);
+ action.update_remains(action.getVariable()->get_value() * delta);
- if (action.getMaxDuration() > NO_MAX_DURATION)
- action.updateMaxDuration(delta);
+ if (action.get_max_duration() > NO_MAX_DURATION)
+ action.update_max_duration(delta);
- if (((action.getRemains() <= 0) && (action.getVariable()->get_weight() > 0)) ||
- ((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
+ if (((action.get_remains() <= 0) && (action.getVariable()->get_weight() > 0)) ||
+ ((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
action.finish(kernel::resource::Action::State::done);
}
}
if (action->get_state() == kernel::resource::Action::State::running ||
action->get_state() == kernel::resource::Action::State::ready) {
- action->setFinishTime(now);
+ action->set_finish_time(now);
action->set_state(kernel::resource::Action::State::failed);
}
}
return;
double delta = now - getLastUpdate();
- double max_duration = getMaxDuration();
+ double max_duration = get_max_duration();
- if (getRemainsNoUpdate() > 0) {
- XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, getRemainsNoUpdate(), getLastUpdate());
- updateRemains(getLastValue() * delta);
+ 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);
- XBT_DEBUG("Updating action(%p): remains is now %f", this, getRemainsNoUpdate());
+ XBT_DEBUG("Updating action(%p): remains is now %f", this, get_remains_no_update());
}
if (max_duration > NO_MAX_DURATION) {
double_update(&max_duration, delta, sg_surf_precision);
- setMaxDuration(max_duration);
+ set_max_duration(max_duration);
}
- if ((getRemainsNoUpdate() <= 0 && (getVariable()->get_weight() > 0)) ||
+ if ((get_remains_no_update() <= 0 && (getVariable()->get_weight() > 0)) ||
((max_duration > NO_MAX_DURATION) && (max_duration <= 0))) {
finish(Action::State::done);
- heapRemove(getModel()->getActionHeap());
+ heapRemove(get_model()->getActionHeap());
}
refreshLastUpdate();
action.latency_ = 0.0;
}
}
- action.updateRemains(action.getCost() * delta / action.initialLatency_);
- if (action.getMaxDuration() != NO_MAX_DURATION)
- action.updateMaxDuration(delta);
+ action.update_remains(action.get_cost() * delta / action.initialLatency_);
+ if (action.get_max_duration() != NO_MAX_DURATION)
+ action.update_max_duration(delta);
- if ((action.getRemainsNoUpdate() <= 0) ||
- ((action.getMaxDuration() != NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
+ if ((action.get_remains_no_update() <= 0) ||
+ ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
action.finish(kernel::resource::Action::State::done);
}
}
SgFlow* sgFlow = elm.second;
NetworkNS3Action * action = sgFlow->action_;
XBT_DEBUG("Processing socket %p (action %p)",sgFlow,action);
- action->setRemains(action->getCost() - sgFlow->sentBytes_);
+ action->set_remains(action->get_cost() - sgFlow->sentBytes_);
if (TRACE_is_enabled() && action->get_state() == kernel::resource::Action::State::running) {
double data_delta_sent = sgFlow->sentBytes_ - action->lastSent_;
action->src_->routeTo(action->dst_, route, nullptr);
for (auto const& link : route)
- TRACE_surf_link_set_utilization(link->getCname(), action->getCategory(), (data_delta_sent) / delta, now - delta,
- delta);
+ TRACE_surf_link_set_utilization(link->getCname(), action->get_category(), (data_delta_sent) / delta,
+ now - delta, delta);
action->lastSent_ = sgFlow->sentBytes_;
}
maxmin_system_->update_variable_weight(action.getVariable(), 1.0);
}
}
- XBT_DEBUG("Action (%p) : remains (%g) updated by %g.", &action, action.getRemains(),
+ XBT_DEBUG("Action (%p) : remains (%g) updated by %g.", &action, action.get_remains(),
action.getVariable()->get_value() * delta);
- action.updateRemains(action.getVariable()->get_value() * delta);
+ action.update_remains(action.getVariable()->get_value() * delta);
- if (action.getMaxDuration() > NO_MAX_DURATION)
- action.updateMaxDuration(delta);
+ if (action.get_max_duration() > NO_MAX_DURATION)
+ action.update_max_duration(delta);
- XBT_DEBUG("Action (%p) : remains (%g).", &action, action.getRemains());
+ XBT_DEBUG("Action (%p) : remains (%g).", &action, action.get_remains());
/* In the next if cascade, the action can be finished either because:
* - The amount of remaining work reached 0
* If it's not done, it may have failed.
*/
- if (((action.getRemains() <= 0) && (action.getVariable()->get_weight() > 0)) ||
- ((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
+ if (((action.get_remains() <= 0) && (action.getVariable()->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 */
}
if (nb_link + nb_used_host == 0) {
- this->setCost(1.0);
- this->setRemains(0.0);
+ this->set_cost(1.0);
+ this->set_remains(0.0);
}
delete[] host_list;
}
kernel::resource::Action* CpuL07::sleep(double duration)
{
L07Action *action = static_cast<L07Action*>(execution_start(1.0));
- action->setMaxDuration(duration);
+ action->set_max_duration(duration);
action->suspended_ = kernel::resource::Action::SuspendStates::sleeping;
model()->getMaxminSystem()->update_variable_weight(action->getVariable(), 0.0);
XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
if ((latency_ <= 0.0) && (suspended_ == Action::SuspendStates::not_suspended)) {
if (rate_ < 0)
- getModel()->getMaxminSystem()->update_variable_bound(getVariable(), lat_bound);
+ get_model()->getMaxminSystem()->update_variable_bound(getVariable(), lat_bound);
else
- getModel()->getMaxminSystem()->update_variable_bound(getVariable(), std::min(rate_, lat_bound));
+ get_model()->getMaxminSystem()->update_variable_bound(getVariable(), std::min(rate_, lat_bound));
}
}
if (state_set_hook_.is_linked())
simgrid::xbt::intrusive_erase(*state_set_, *this);
if (getVariable())
- getModel()->getMaxminSystem()->variable_free(getVariable());
+ get_model()->getMaxminSystem()->variable_free(getVariable());
delete this;
return 1;
}
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.updateRemains(lrint(action.getVariable()->get_value() * delta));
+ action.update_remains(lrint(action.getVariable()->get_value() * delta));
- if (action.getMaxDuration() > NO_MAX_DURATION)
- action.updateMaxDuration(delta);
+ if (action.get_max_duration() > NO_MAX_DURATION)
+ action.update_max_duration(delta);
- if (((action.getRemainsNoUpdate() <= 0) && (action.getVariable()->get_weight() > 0)) ||
- ((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
+ if (((action.get_remains_no_update() <= 0) && (action.getVariable()->get_weight() > 0)) ||
+ ((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
action.finish(kernel::resource::Action::State::done);
}
}
if (state_set_hook_.is_linked())
simgrid::xbt::intrusive_erase(*state_set_, *this);
if (getVariable())
- getModel()->getMaxminSystem()->variable_free(getVariable());
- xbt_free(getCategory());
+ get_model()->getMaxminSystem()->variable_free(getVariable());
+ xbt_free(get_category());
delete this;
return 1;
}
{
XBT_IN("(%p)", this);
if (suspended_ != Action::SuspendStates::sleeping) {
- getModel()->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
+ get_model()->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
suspended_ = Action::SuspendStates::suspended;
}
XBT_OUT();
return suspended_ == Action::SuspendStates::suspended;
}
-void StorageN11Action::setMaxDuration(double /*duration*/)
+void StorageN11Action::set_max_duration(double /*duration*/)
{
THROW_UNIMPLEMENTED;
}
-void StorageN11Action::setSharingWeight(double /*priority*/)
+void StorageN11Action::set_priority(double /*priority*/)
{
THROW_UNIMPLEMENTED;
}
void cancel() override;
void resume() override;
bool isSuspended() override;
- void setMaxDuration(double duration) override;
- void setSharingWeight(double priority) override;
+ void set_max_duration(double duration) override;
+ void set_priority(double priority) override;
void updateRemainingLazy(double now) override;
};
/* A few basic tests for the surf library */
-/* Copyright (c) 2004-2017. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2018. The SimGrid Team. All rights reserved. */
/* 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. */