activity::ActivityImpl* activity_ = nullptr;
/* LMM */
+ double factor_ = 1.0; /**< Factor for effective rate = var->get_value() * factor_ */
double last_update_ = 0;
double last_value_ = 0;
lmm::Variable* variable_ = nullptr;
double get_last_update() const { return last_update_; }
void set_last_update();
+ /**
+ * @brief Set a factor for this action
+ *
+ * Defines a multiplicative factor for the consumption of the underlying resource.
+ *
+ * @param factor Multiplicative factor for this action (e.g. 0.97)
+ */
+ void set_rate_factor(double factor) { factor_ = factor; }
+ /**
+ * @brief Get the effective consumption rate of the resource
+ *
+ * The rate is based on the sharing given by the maxmin system underneath.
+ * However, it depends on the factor defined for this action.
+ *
+ * So, the effective rate is equal to var->get_value() * factor_
+ */
+ double get_rate() const;
double get_last_value() const { return last_value_; }
void set_last_value(double val) { last_value_ = val; }
void set_suspend_state(Action::SuspendStates state) { suspended_ = state; }
auto n = static_cast<unsigned>(action.get_variable()->get_number_of_constraint());
for (unsigned i = 0; i < n; i++) {
- double value = action.get_variable()->get_value() * action.get_variable()->get_constraint_weight(i);
+ double value = action.get_rate() * action.get_variable()->get_constraint_weight(i);
/* Beware of composite actions: ptasks put links and cpus together. Extra pb: we cannot dynamic_cast from void* */
kernel::resource::Resource* resource = action.get_variable()->get_constraint(i)->get_id();
const kernel::resource::CpuImpl* cpu = dynamic_cast<kernel::resource::CpuImpl*>(resource);
return variable_ ? variable_->get_bound() : 0;
}
+double Action::get_rate() const
+{
+ return variable_ ? variable_->get_value() * factor_ : 0;
+}
+
void Action::set_bound(double bound)
{
XBT_IN("(%p,%g)", this, bound);
action->update_remains_lazy(now);
double min = -1;
- double share = action->get_variable()->get_value();
+ double share = action->get_rate();
if (share > 0) {
double time_to_completion;
double min = -1;
for (Action& action : *get_started_action_set()) {
- double value = action.get_variable()->get_value();
+ double value = action.get_rate();
if (value > 0) {
if (action.get_remains() > 0)
value = action.get_remains_no_update() / value;
double durUsage = 0;
while (const auto* var = wifi_link->get_constraint()->get_variable(&elem)) {
auto* action = static_cast<kernel::resource::NetworkWifiAction*>(var->get_id());
- XBT_DEBUG("cost: %f action value: %f link rate 1: %f link rate 2: %f", action->get_cost(),
- action->get_variable()->get_value(), wifi_link->get_host_rate(&action->get_src()),
- wifi_link->get_host_rate(&action->get_dst()));
+ XBT_DEBUG("cost: %f action value: %f link rate 1: %f link rate 2: %f", action->get_cost(), action->get_rate(),
+ wifi_link->get_host_rate(&action->get_src()), wifi_link->get_host_rate(&action->get_dst()));
- if (action->get_variable()->get_value() != 0.0) {
+ if (action->get_rate() != 0.0) {
auto it = flowTmp.find(action);
// if the flow has not been registered, initialize it: 0 bytes sent, and not updated since its creation timestamp
* If this is longer than the duration since the previous update, active duration = now - previous_update
*/
double du = // durUsage on the current flow
- (action->get_cost() - it->second.first) / action->get_variable()->get_value();
+ (action->get_cost() - it->second.first) / action->get_rate();
if(du > surf_get_clock()-it->second.second)
du = surf_get_clock()-it->second.second;
durUsage = du;
// update the amount of data already sent by the flow
- it->second.first += du*action->get_variable()->get_value();
+ it->second.first += du * action->get_rate();
it->second.second = surf_get_clock();
// important: if the transmission finished, remove it (needed for performance and multi-message flows)
const kernel::resource::CpuImpl* cpu = ws_vm->pimpl_cpu;
// solved_value below is X1 in comment above: what this VM got in the sharing on the PM
- double solved_value = ws_vm->get_vm_impl()->get_action()->get_variable()->get_value();
+ double solved_value = ws_vm->get_vm_impl()->get_action()->get_rate();
XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->get_cname(), ws_vm->get_pm()->get_cname());
kernel::lmm::System* vcpu_system = cpu->get_model()->get_maxmin_system();
auto& action = static_cast<CpuAction&>(*it);
++it; // increment iterator here since the following calls to action.finish() may invalidate it
- action.update_remains(action.get_variable()->get_value() * delta);
+ action.update_remains(action.get_rate() * delta);
action.update_max_duration(delta);
if (((action.get_remains_no_update() <= 0) && (action.get_variable()->get_penalty() > 0)) ||
}
set_last_update();
- set_last_value(get_variable()->get_value());
+ set_last_value(get_rate());
}
xbt::signal<void(CpuAction const&, Action::State)> CpuAction::on_state_change;
for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
auto& action = *it;
++it; // increment iterator here since the following calls to action.finish() may invalidate it
- action.update_remains(rint(action.get_variable()->get_value() * delta));
+ action.update_remains(rint(action.get_rate() * delta));
action.update_max_duration(delta);
if (((action.get_remains_no_update() <= 0) && (action.get_variable()->get_penalty() > 0)) ||
*/
action.update_remains(action.get_remains());
}
- action.update_remains(action.get_variable()->get_value() * delta);
+ action.update_remains(action.get_rate() * delta);
if (action.get_max_duration() != NO_MAX_DURATION)
action.update_max_duration(delta);
} else {
bw_factor = get_bandwidth_factor(size);
}
+ xbt_assert(bw_factor != 0, "Invalid param for comm %s -> %s. Bandwidth factor cannot be 0", src->get_cname(),
+ dst->get_cname());
+ action->set_rate_factor(bw_factor);
+
/* get mininum bandwidth among links in the route and multiply by correct factor
* ignore wi-fi links, they're not considered for bw_factors */
double bandwidth_bound = -1.0;
if (bandwidth_bound == -1.0 || l->get_bandwidth() < bandwidth_bound)
bandwidth_bound = l->get_bandwidth();
}
- bandwidth_bound *= bw_factor;
+ /* increase rate given by user considering the factor, since the actual rate will be
+ * modified by it */
+ rate = rate / bw_factor;
/* the bandwidth is determined by the minimum between flow and user's defined rate */
if (rate >= 0 && rate < bandwidth_bound)
bandwidth_bound = rate;
-
action->set_user_bound(bandwidth_bound);
action->lat_current_ = action->latency_;
{
bandwidth_.scale = 1.0;
bandwidth_.peak = bandwidth;
- this->set_constraint(system->constraint_new(this, sg_bandwidth_factor * bandwidth));
+ this->set_constraint(system->constraint_new(this, bandwidth));
}
void NetworkCm02Link::apply_event(kernel::profile::Event* triggered, double value)
{
bandwidth_.peak = value;
- get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(),
- sg_bandwidth_factor * (bandwidth_.peak * bandwidth_.scale));
+ get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), (bandwidth_.peak * bandwidth_.scale));
LinkImpl::on_bandwidth_change();
}
set_last_update();
- set_last_value(get_variable()->get_value());
+ set_last_value(get_rate());
}
} // namespace resource
action.set_last_update();
}
}
- XBT_DEBUG("Action (%p) : remains (%g) updated by %g.", &action, action.get_remains(),
- action.get_variable()->get_value() * delta);
- action.update_remains(action.get_variable()->get_value() * delta);
+ XBT_DEBUG("Action (%p) : remains (%g) updated by %g.", &action, action.get_remains(), action.get_rate() * delta);
+ action.update_remains(action.get_rate() * delta);
action.update_max_duration(delta);
XBT_DEBUG("Action (%p) : remains (%g).", &action, action.get_remains());