* Model *
*********/
-CpuModel::~CpuModel() {}
+CpuModel::~CpuModel() = default;
void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
{
- CpuAction *action;
while ((xbt_heap_size(getActionHeap()) > 0)
&& (double_equals(xbt_heap_maxkey(getActionHeap()), now, sg_surf_precision))) {
- action = static_cast<CpuAction*>(xbt_heap_pop(getActionHeap()));
+ CpuAction *action = static_cast<CpuAction*>(xbt_heap_pop(getActionHeap()));
XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
if (TRACE_is_enabled()) {
Cpu *cpu = static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)));
ActionList *actionSet = getRunningActionSet();
for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end())
; it != itend ; ++it) {
- action = static_cast<CpuAction*>(&*it);
+ CpuAction *action = static_cast<CpuAction*>(&*it);
if (smaller < 0) {
smaller = action->getLastUpdate();
continue;
TRACE_last_timestamp_to_dump = smaller;
}
}
- return;
}
void CpuModel::updateActionsStateFull(double now, double delta)
class CpuModel;
class Cpu;
class CpuAction;
-class CpuPlugin;// FIXME:DEADCODE
/** @ingroup SURF_cpu_interface
* @brief SURF cpu model interface class
XBT_PUBLIC_CLASS CpuAction : public simgrid::surf::Action {
friend XBT_PUBLIC(Cpu*) getActionCpu(CpuAction *action);
public:
- /** @brief Callbacks handler which emit the callbacks after CpuAction State changed *
- * @details Callback functions have the following signature: `void(CpuAction *action, simgrid::surf::Action::State previous)`
- */
- static simgrid::xbt::signal<void(simgrid::surf::CpuAction*, simgrid::surf::Action::State)> onStateChange;
+/** @brief Signal emitted when the action state changes (ready/running/done, etc)
+ * Signature: `void(CpuAction *action, simgrid::surf::Action::State previous)`
+ */
+static simgrid::xbt::signal<void(simgrid::surf::CpuAction*, simgrid::surf::Action::State)> onStateChange;
+/** @brief Signal emitted when the action share changes (amount of flops it gets)
+ * Signature: `void(CpuAction *action)`
+ */
+static simgrid::xbt::signal<void(simgrid::surf::CpuAction*)> onShareChange;
CpuAction(simgrid::surf::Model *model, double cost, bool failed)
- : Action(model, cost, failed) {} //FIXME:DEADCODE?
+ : Action(model, cost, failed) {}
CpuAction(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var)
: Action(model, cost, failed, var) {}
updateMechanism_ = UM_LAZY;
selectiveUpdate_ = 1;
xbt_assert((select == 1) || (xbt_cfg_is_default_value("network/maxmin-selective-update")),
- "Disabling selective update while using the lazy update mechanism is dumb!");
+ "You cannot disable selective update while using the lazy update mechanism!");
} else {
- xbt_die("Unsupported optimization (%s) for this model", optim);
+ xbt_die("Unsupported optimization (%s) for this model. Accepted: Full, Lazy.", optim);
}
if (!maxminSystem_)
routing_model_create(createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE, nullptr));
if (updateMechanism_ == UM_LAZY) {
- actionHeap_ = xbt_heap_new(8, nullptr);
- xbt_heap_set_update_callback(actionHeap_, surf_action_lmm_update_index_heap);
- modifiedSet_ = new ActionLmmList();
- maxminSystem_->keep_track = modifiedSet_;
+ actionHeap_ = xbt_heap_new(8, nullptr);
+ xbt_heap_set_update_callback(actionHeap_, surf_action_lmm_update_index_heap);
+ modifiedSet_ = new ActionLmmList();
+ maxminSystem_->keep_track = modifiedSet_;
}
}
{
while ((xbt_heap_size(actionHeap_) > 0)
&& (double_equals(xbt_heap_maxkey(actionHeap_), now, sg_surf_precision))) {
+
NetworkCm02Action *action = static_cast<NetworkCm02Action*> (xbt_heap_pop(actionHeap_));
XBT_DEBUG("Something happened to action %p", action);
if (TRACE_is_enabled()) {
for (int i = 0; i < n; i++){
lmm_constraint_t constraint = lmm_get_cnst_from_var(maxminSystem_, action->getVariable(), i);
NetworkCm02Link *link = static_cast<NetworkCm02Link*>(lmm_constraint_id(constraint));
- TRACE_surf_link_set_utilization(link->getName(),
- action->getCategory(),
- (lmm_variable_getvalue(action->getVariable())*
- lmm_get_cnst_weight_from_var(maxminSystem_,
- action->getVariable(),
- i)),
- action->getLastUpdate(),
- now - action->getLastUpdate());
+ double value = lmm_variable_getvalue(action->getVariable())*
+ lmm_get_cnst_weight_from_var(maxminSystem_, action->getVariable(), i);
+ TRACE_surf_link_set_utilization(link->getName(), action->getCategory(), value,
+ action->getLastUpdate(), now - action->getLastUpdate());
}
}
action->refreshLastUpdate();
// if I am wearing a max_duration or normal hat
- } else if (action->getHat() == MAX_DURATION ||
- action->getHat() == NORMAL) {
+ } else if (action->getHat() == MAX_DURATION || action->getHat() == NORMAL) {
// no need to communicate anymore
// assume that flows that reached max_duration have remaining of 0
XBT_DEBUG("Action %p finished", action);
void NetworkCm02Model::updateActionsStateFull(double now, double delta)
{
- NetworkCm02Action *action;
ActionList *running_actions = getRunningActionSet();
for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end())
; it != itend ; it=itNext) {
- ++itNext;
+ ++itNext;
- action = static_cast<NetworkCm02Action*> (&*it);
+ NetworkCm02Action *action = static_cast<NetworkCm02Action*> (&*it);
XBT_DEBUG("Something happened to action %p", action);
double deltap = delta;
if (action->latency_ > 0) {
void StorageN11Model::updateActionsState(double /*now*/, double delta)
{
- StorageAction *action = nullptr;
ActionList *actionSet = getRunningActionSet();
for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
; it != itend ; it=itNext) {
++itNext;
- action = static_cast<StorageAction*>(&*it);
+
+ StorageAction *action = static_cast<StorageAction*>(&*it);
if(action->m_type == WRITE){
// Update the disk usage
// Update the file size
// For each action of type write
- double current_progress =
- delta * lmm_variable_getvalue(action->getVariable());
+ double current_progress = delta * lmm_variable_getvalue(action->getVariable());
long int incr = current_progress;
XBT_DEBUG("%s:\n\t progress = %.2f, current_progress = %.2f, incr = %ld, lrint(1) = %ld, lrint(2) = %ld",
action->setState(Action::State::done);
}
}
- return;
}
/************
void StorageN11Action::cancel()
{
setState(Action::State::failed);
- return;
}
void StorageN11Action::suspend()
double Model::next_occuring_event_lazy(double now)
{
- Action *action = nullptr;
- double min = -1;
- double share;
-
- XBT_DEBUG
- ("Before share resources, the size of modified actions set is %zd",
- modifiedSet_->size());
-
+ XBT_DEBUG("Before share resources, the size of modified actions set is %zd", modifiedSet_->size());
lmm_solve(maxminSystem_);
-
- XBT_DEBUG
- ("After share resources, The size of modified actions set is %zd",
- modifiedSet_->size());
+ XBT_DEBUG("After share resources, The size of modified actions set is %zd", modifiedSet_->size());
while(!modifiedSet_->empty()) {
- action = &(modifiedSet_->front());
+ Action *action = &(modifiedSet_->front());
modifiedSet_->pop_front();
int max_dur_flag = 0;
action->updateRemainingLazy(now);
- min = -1;
- share = lmm_variable_getvalue(action->getVariable());
+ double min = -1;
+ double share = lmm_variable_getvalue(action->getVariable());
if (share > 0) {
double time_to_completion;
}
//hereafter must have already the min value for this resource model
- if (xbt_heap_size(actionHeap_) > 0)
- min = xbt_heap_maxkey(actionHeap_) - now;
- else
- min = -1;
-
- XBT_DEBUG("The minimum with the HEAP %f", min);
-
- return min;
+ if (xbt_heap_size(actionHeap_) > 0) {
+ double min = xbt_heap_maxkey(actionHeap_) - now;
+ XBT_DEBUG("minimum with the HEAP %f", min);
+ return min;
+ } else {
+ XBT_DEBUG("The HEAP is empty, thus returning -1");
+ return -1;
+ }
}
double Model::next_occuring_event_full(double /*now*/) {