Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more protected->private fields
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 3 Nov 2017 09:50:20 +0000 (10:50 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 3 Nov 2017 09:50:20 +0000 (10:50 +0100)
src/instr/instr_paje_events.cpp
src/instr/instr_paje_events.hpp
src/surf/cpu_cas01.cpp
src/surf/cpu_ti.cpp
src/surf/network_cm02.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp

index ec50dda..067fb8b 100644 (file)
@@ -73,10 +73,10 @@ void NewEvent::print()
     return;
 
   if (timestamp_ < 1e-12)
     return;
 
   if (timestamp_ < 1e-12)
-    stream << eventType_ << " " << 0 << " " << type->getId() << " " << container->getId();
+    stream << eventType_ << " " << 0 << " ";
   else
   else
-    stream << eventType_ << " " << timestamp_ << " " << type->getId() << " " << container->getId();
-  stream << " " << val->getId();
+    stream << eventType_ << " " << timestamp_ << " ";
+  stream << getType()->getId() << " " << getContainer()->getId() << " " << val->getId();
   XBT_DEBUG("Dump %s", stream.str().c_str());
   fprintf(tracing_file, "%s\n", stream.str().c_str());
 }
   XBT_DEBUG("Dump %s", stream.str().c_str());
   fprintf(tracing_file, "%s\n", stream.str().c_str());
 }
@@ -89,11 +89,11 @@ void LinkEvent::print()
   if (instr_fmt_type != instr_fmt_paje)
     return;
   if (timestamp_ < 1e-12)
   if (instr_fmt_type != instr_fmt_paje)
     return;
   if (timestamp_ < 1e-12)
-    stream << eventType_ << " " << 0 << " " << type->getId() << " " << container->getId() << " " << value_;
+    stream << eventType_ << " " << 0 << " " << getType()->getId() << " " << getContainer()->getId();
   else
   else
-    stream << eventType_ << " " << timestamp_ << " " << type->getId() << " " << container->getId() << " " << value_;
+    stream << eventType_ << " " << timestamp_ << " " << getType()->getId() << " " << getContainer()->getId();
 
 
-  stream << " " << endpoint_->getId() << " " << key_;
+  stream << " " << value_ << " " << endpoint_->getId() << " " << key_;
 
   if (TRACE_display_sizes()) {
     stream << " " << size_;
 
   if (TRACE_display_sizes()) {
     stream << " " << size_;
@@ -111,9 +111,10 @@ void VariableEvent::print()
     return;
 
   if (timestamp_ < 1e-12)
     return;
 
   if (timestamp_ < 1e-12)
-    stream << eventType_ << " " << 0 << " " << type->getId() << " " << container->getId() << " " << value;
+    stream << eventType_ << " " << 0 << " ";
   else
   else
-    stream << eventType_ << " " << timestamp_ << " " << type->getId() << " " << container->getId() << " " << value;
+    stream << eventType_ << " " << timestamp_ << " ";
+  stream << getType()->getId() << " " << getContainer()->getId() << " " << value;
   XBT_DEBUG("Dump %s", stream.str().c_str());
   fprintf(tracing_file, "%s\n", stream.str().c_str());
 }
   XBT_DEBUG("Dump %s", stream.str().c_str());
   fprintf(tracing_file, "%s\n", stream.str().c_str());
 }
@@ -125,9 +126,9 @@ void StateEvent::print()
   XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __FUNCTION__, eventType_, TRACE_precision(), timestamp_);
   if (instr_fmt_type == instr_fmt_paje) {
     if (timestamp_ < 1e-12)
   XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __FUNCTION__, eventType_, TRACE_precision(), timestamp_);
   if (instr_fmt_type == instr_fmt_paje) {
     if (timestamp_ < 1e-12)
-      stream << eventType_ << " " << 0 << " " << type->getId() << " " << container->getId();
+      stream << eventType_ << " " << 0 << " " << getType()->getId() << " " << getContainer()->getId();
     else
     else
-      stream << eventType_ << " " << timestamp_ << " " << type->getId() << " " << container->getId();
+      stream << eventType_ << " " << timestamp_ << " " << getType()->getId() << " " << getContainer()->getId();
 
     if (value != nullptr) // PAJE_PopState Event does not need to have a value
       stream << " " << value->getId();
 
     if (value != nullptr) // PAJE_PopState Event does not need to have a value
       stream << " " << value->getId();
@@ -161,12 +162,12 @@ void StateEvent::print()
     instr_extra_data extra = (instr_extra_data)extra_;
 
     // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
     instr_extra_data extra = (instr_extra_data)extra_;
 
     // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
-    if (container->getName().find("rank-") != 0)
-      stream << container->getName() << " ";
+    if (getContainer()->getName().find("rank-") != 0)
+      stream << getContainer()->getName() << " ";
     else
     else
-      stream << container->getName().erase(0, 5) << " ";
+      stream << getContainer()->getName().erase(0, 5) << " ";
 
 
-    FILE* trace_file = tracing_files.at(container);
+    FILE* trace_file = tracing_files.at(getContainer());
 
     switch (extra->type) {
       case TRACING_INIT:
 
     switch (extra->type) {
       case TRACING_INIT:
index 768ac59..6f0b3bb 100644 (file)
@@ -35,15 +35,17 @@ enum e_event_type : unsigned int {
 };
 
 class PajeEvent {
 };
 
 class PajeEvent {
-protected:
-  Container* container;
-  Type* type;
+  Container* container_;
+  Type* type_;
 
 
+protected:
+  Type* getType() { return type_; }
+  Container* getContainer() { return container_; }
 public:
   double timestamp_;
   e_event_type eventType_;
   PajeEvent(Container* container, Type* type, double timestamp, e_event_type eventType)
 public:
   double timestamp_;
   e_event_type eventType_;
   PajeEvent(Container* container, Type* type, double timestamp, e_event_type eventType)
-      : container(container), type(type), timestamp_(timestamp), eventType_(eventType){};
+      : container_(container), type_(type), timestamp_(timestamp), eventType_(eventType){};
   virtual ~PajeEvent() = default;
   virtual void print() = 0;
   void insertIntoBuffer();
   virtual ~PajeEvent() = default;
   virtual void print() = 0;
   void insertIntoBuffer();
index e269ce6..446d217 100644 (file)
@@ -41,10 +41,10 @@ CpuCas01Model::CpuCas01Model() : simgrid::surf::CpuModel()
   bool select = xbt_cfg_get_boolean("cpu/maxmin-selective-update");
 
   if (not strcmp(optim, "Full")) {
   bool select = xbt_cfg_get_boolean("cpu/maxmin-selective-update");
 
   if (not strcmp(optim, "Full")) {
-    updateMechanism_ = UM_FULL;
+    setUpdateMechanism(UM_FULL);
     selectiveUpdate_ = select;
   } else if (not strcmp(optim, "Lazy")) {
     selectiveUpdate_ = select;
   } else if (not strcmp(optim, "Lazy")) {
-    updateMechanism_ = UM_LAZY;
+    setUpdateMechanism(UM_LAZY);
     selectiveUpdate_ = true;
     xbt_assert(select || (xbt_cfg_is_default_value("cpu/maxmin-selective-update")),
                "Disabling selective update while using the lazy update mechanism is dumb!");
     selectiveUpdate_ = true;
     xbt_assert(select || (xbt_cfg_is_default_value("cpu/maxmin-selective-update")),
                "Disabling selective update while using the lazy update mechanism is dumb!");
@@ -214,7 +214,7 @@ CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double sp
     , requestedCore_(requestedCore)
 {
   if (model->getUpdateMechanism() == UM_LAZY) {
     , requestedCore_(requestedCore)
 {
   if (model->getUpdateMechanism() == UM_LAZY) {
-    indexHeap_ = -1;
+    updateIndexHeap(-1);
     refreshLastUpdate();
     setLastValue(0.0);
   }
     refreshLastUpdate();
     setLastValue(0.0);
   }
index 0149656..991cf38 100644 (file)
@@ -468,9 +468,9 @@ void CpuTi::apply_event(tmgr_trace_event_t event, double value)
          || action->getState() == Action::State::not_in_the_system) {
           action->setFinishTime(date);
           action->setState(Action::State::failed);
          || action->getState() == Action::State::not_in_the_system) {
           action->setFinishTime(date);
           action->setState(Action::State::failed);
-          if (action->indexHeap_ >= 0) {
+          if (action->getIndexHeap() >= 0) {
             CpuTiAction* heap_act = static_cast<CpuTiAction*>(
             CpuTiAction* heap_act = static_cast<CpuTiAction*>(
-                xbt_heap_remove(static_cast<CpuTiModel*>(model())->tiActionHeap_, action->indexHeap_));
+                xbt_heap_remove(static_cast<CpuTiModel*>(model())->tiActionHeap_, action->getIndexHeap()));
             if (heap_act != action)
               DIE_IMPOSSIBLE;
           }
             if (heap_act != action)
               DIE_IMPOSSIBLE;
           }
@@ -538,10 +538,10 @@ void CpuTi::updateActionsFinishTime(double now)
         min_finish = action->getStartTime() + action->getMaxDuration();
     }
     /* add in action heap */
         min_finish = action->getStartTime() + action->getMaxDuration();
     }
     /* add in action heap */
-    XBT_DEBUG("action(%p) index %d", action, action->indexHeap_);
-    if (action->indexHeap_ >= 0) {
+    XBT_DEBUG("action(%p) index %d", action, action->getIndexHeap());
+    if (action->getIndexHeap() >= 0) {
       CpuTiAction* heap_act = static_cast<CpuTiAction*>(
       CpuTiAction* heap_act = static_cast<CpuTiAction*>(
-          xbt_heap_remove(static_cast<CpuTiModel*>(model())->tiActionHeap_, action->indexHeap_));
+          xbt_heap_remove(static_cast<CpuTiModel*>(model())->tiActionHeap_, action->getIndexHeap()));
       if (heap_act != action)
         DIE_IMPOSSIBLE;
     }
       if (heap_act != action)
         DIE_IMPOSSIBLE;
     }
@@ -664,13 +664,13 @@ CpuTiAction::CpuTiAction(CpuTiModel *model_, double cost, bool failed, CpuTi *cp
  : CpuAction(model_, cost, failed)
  , cpu_(cpu)
 {
  : CpuAction(model_, cost, failed)
  , cpu_(cpu)
 {
-  indexHeap_ = -1;
+  updateIndexHeap(-1);
   cpu_->modified(true);
 }
 
 void CpuTiAction::updateIndexHeap(int i)
 {
   cpu_->modified(true);
 }
 
 void CpuTiAction::updateIndexHeap(int i)
 {
-  indexHeap_ = i;
+  Action::updateIndexHeap(i);
 }
 
 void CpuTiAction::setState(Action::State state)
 }
 
 void CpuTiAction::setState(Action::State state)
@@ -689,7 +689,7 @@ int CpuTiAction::unref()
     if (action_ti_hook.is_linked())
       cpu_->actionSet_->erase(cpu_->actionSet_->iterator_to(*this));
     /* remove from heap */
     if (action_ti_hook.is_linked())
       cpu_->actionSet_->erase(cpu_->actionSet_->iterator_to(*this));
     /* remove from heap */
-    xbt_heap_remove(static_cast<CpuTiModel*>(getModel())->tiActionHeap_, this->indexHeap_);
+    xbt_heap_remove(static_cast<CpuTiModel*>(getModel())->tiActionHeap_, getIndexHeap());
     cpu_->modified(true);
     delete this;
     return 1;
     cpu_->modified(true);
     delete this;
     return 1;
@@ -700,7 +700,7 @@ int CpuTiAction::unref()
 void CpuTiAction::cancel()
 {
   this->setState(Action::State::failed);
 void CpuTiAction::cancel()
 {
   this->setState(Action::State::failed);
-  xbt_heap_remove(getModel()->getActionHeap(), this->indexHeap_);
+  xbt_heap_remove(getModel()->getActionHeap(), getIndexHeap());
   cpu_->modified(true);
 }
 
   cpu_->modified(true);
 }
 
@@ -709,7 +709,7 @@ void CpuTiAction::suspend()
   XBT_IN("(%p)", this);
   if (suspended_ != 2) {
     suspended_ = 1;
   XBT_IN("(%p)", this);
   if (suspended_ != 2) {
     suspended_ = 1;
-    xbt_heap_remove(getModel()->getActionHeap(), indexHeap_);
+    xbt_heap_remove(getModel()->getActionHeap(), getIndexHeap());
     cpu_->modified(true);
   }
   XBT_OUT();
     cpu_->modified(true);
   }
   XBT_OUT();
@@ -740,8 +740,8 @@ void CpuTiAction::setMaxDuration(double duration)
     min_finish = getFinishTime();
 
 /* add in action heap */
     min_finish = getFinishTime();
 
 /* add in action heap */
-  if (indexHeap_ >= 0) {
-    CpuTiAction *heap_act = static_cast<CpuTiAction*>(xbt_heap_remove(getModel()->getActionHeap(), indexHeap_));
+  if (getIndexHeap() >= 0) {
+    CpuTiAction* heap_act = static_cast<CpuTiAction*>(xbt_heap_remove(getModel()->getActionHeap(), getIndexHeap()));
     if (heap_act != this)
       DIE_IMPOSSIBLE;
   }
     if (heap_act != this)
       DIE_IMPOSSIBLE;
   }
@@ -753,7 +753,7 @@ void CpuTiAction::setMaxDuration(double duration)
 void CpuTiAction::setSharingWeight(double priority)
 {
   XBT_IN("(%p,%g)", this, priority);
 void CpuTiAction::setSharingWeight(double priority)
 {
   XBT_IN("(%p,%g)", this, priority);
-  sharingWeight_ = priority;
+  setSharingWeightNoUpdate(priority);
   cpu_->modified(true);
   XBT_OUT();
 }
   cpu_->modified(true);
   XBT_OUT();
 }
index b55b754..fe1a8dc 100644 (file)
@@ -138,10 +138,10 @@ NetworkCm02Model::NetworkCm02Model()
   bool select = xbt_cfg_get_boolean("network/maxmin-selective-update");
 
   if (not strcmp(optim, "Full")) {
   bool select = xbt_cfg_get_boolean("network/maxmin-selective-update");
 
   if (not strcmp(optim, "Full")) {
-    updateMechanism_ = UM_FULL;
+    setUpdateMechanism(UM_FULL);
     selectiveUpdate_ = select;
   } else if (not strcmp(optim, "Lazy")) {
     selectiveUpdate_ = select;
   } else if (not strcmp(optim, "Lazy")) {
-    updateMechanism_ = UM_LAZY;
+    setUpdateMechanism(UM_LAZY);
     selectiveUpdate_ = true;
     xbt_assert(select || (xbt_cfg_is_default_value("network/maxmin-selective-update")),
                "You cannot disable selective update when using the lazy update mechanism");
     selectiveUpdate_ = true;
     xbt_assert(select || (xbt_cfg_is_default_value("network/maxmin-selective-update")),
                "You cannot disable selective update when using the lazy update mechanism");
@@ -152,7 +152,7 @@ NetworkCm02Model::NetworkCm02Model()
   maxminSystem_ = lmm_system_new(selectiveUpdate_);
   loopback_     = createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
 
   maxminSystem_ = lmm_system_new(selectiveUpdate_);
   loopback_     = createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
 
-  if (updateMechanism_ == UM_LAZY) {
+  if (getUpdateMechanism() == UM_LAZY) {
     actionHeap_ = xbt_heap_new(8, nullptr);
     xbt_heap_set_update_callback(actionHeap_, surf_action_lmm_update_index_heap);
     modifiedSet_ = new ActionLmmList();
     actionHeap_ = xbt_heap_new(8, nullptr);
     xbt_heap_set_update_callback(actionHeap_, surf_action_lmm_update_index_heap);
     modifiedSet_ = new ActionLmmList();
@@ -293,8 +293,8 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
   action->weight_ = latency;
   action->latency_ = latency;
   action->rate_ = rate;
   action->weight_ = latency;
   action->latency_ = latency;
   action->rate_ = rate;
-  if (updateMechanism_ == UM_LAZY) {
-    action->indexHeap_ = -1;
+  if (getUpdateMechanism() == UM_LAZY) {
+    action->updateIndexHeap(-1);
     action->refreshLastUpdate();
   }
 
     action->refreshLastUpdate();
   }
 
@@ -318,7 +318,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
 
   if (action->latency_ > 0) {
     action->setVariable(lmm_variable_new(maxminSystem_, action, 0.0, -1.0, constraints_per_variable));
 
   if (action->latency_ > 0) {
     action->setVariable(lmm_variable_new(maxminSystem_, action, 0.0, -1.0, constraints_per_variable));
-    if (updateMechanism_ == UM_LAZY) {
+    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(actionHeap_, action->latency_ + action->getLastUpdate(), route->empty() ? NORMAL : LATENCY);
       // 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(actionHeap_, action->latency_ + action->getLastUpdate(), route->empty() ? NORMAL : LATENCY);
index 837bf97..77bc7ca 100644 (file)
@@ -790,7 +790,7 @@ void Action::resume()
 {
   XBT_IN("(%p)", this);
   if (suspended_ != 2) {
 {
   XBT_IN("(%p)", this);
   if (suspended_ != 2) {
-    lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), sharingWeight_);
+    lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), getPriority());
     suspended_ = 0;
     if (getModel()->getUpdateMechanism() == UM_LAZY)
       heapRemove(getModel()->getActionHeap());
     suspended_ = 0;
     if (getModel()->getUpdateMechanism() == UM_LAZY)
       heapRemove(getModel()->getActionHeap());
index dc6ddd3..32e6ec3 100644 (file)
@@ -201,6 +201,7 @@ public:
   double getPriority() { return sharingWeight_; };
   /** @brief Set the priority of the current Action */
   virtual void setSharingWeight(double priority);
   double getPriority() { return sharingWeight_; };
   /** @brief Set the priority of the current Action */
   virtual void setSharingWeight(double priority);
+  void setSharingWeightNoUpdate(double weight) { sharingWeight_ = weight; }
 
   /** @brief Get the state set in which the action is */
   ActionList* getStateSet() {return stateSet_;};
 
   /** @brief Get the state set in which the action is */
   ActionList* getStateSet() {return stateSet_;};
@@ -211,10 +212,10 @@ public:
 
 protected:
   ActionList* stateSet_;
 
 protected:
   ActionList* stateSet_;
-  double sharingWeight_ = 1.0; /**< priority (1.0 by default) */
   int    refcount_ = 1;
 
 private:
   int    refcount_ = 1;
 
 private:
+  double sharingWeight_ = 1.0;             /**< priority (1.0 by default) */
   double maxDuration_ = 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_; /**< start time  */
   double maxDuration_ = 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_; /**< start time  */
@@ -231,6 +232,7 @@ private:
   double lastValue_          = 0;
   lmm_variable_t variable_   = nullptr;
   enum heap_action_type hat_ = NOTSET;
   double lastValue_          = 0;
   lmm_variable_t variable_   = nullptr;
   enum heap_action_type hat_ = NOTSET;
+  int indexHeap_;
 
 public:
   virtual void updateRemainingLazy(double now) { THROW_IMPOSSIBLE; };
 
 public:
   virtual void updateRemainingLazy(double now) { THROW_IMPOSSIBLE; };
@@ -246,10 +248,9 @@ public:
   void setLastValue(double val) { lastValue_ = val; }
   enum heap_action_type getHat() { return hat_; }
   bool is_linked() {return action_lmm_hook.is_linked();}
   void setLastValue(double val) { lastValue_ = val; }
   enum heap_action_type getHat() { return hat_; }
   bool is_linked() {return action_lmm_hook.is_linked();}
-
+  int getIndexHeap() { return indexHeap_; }
 protected:
   int suspended_ = 0;
 protected:
   int suspended_ = 0;
-  int indexHeap_;
 };
 
 typedef Action::ActionList ActionList;
 };
 
 typedef Action::ActionList ActionList;
@@ -295,6 +296,7 @@ public:
    * @see e_UM_t
    */
   e_UM_t getUpdateMechanism() {return updateMechanism_;}
    * @see e_UM_t
    */
   e_UM_t getUpdateMechanism() {return updateMechanism_;}
+  void setUpdateMechanism(e_UM_t mechanism) { updateMechanism_ = mechanism; }
 
   /** @brief Get Action heap */
   xbt_heap_t getActionHeap() {return actionHeap_;}
 
   /** @brief Get Action heap */
   xbt_heap_t getActionHeap() {return actionHeap_;}
@@ -329,11 +331,11 @@ public:
 protected:
   ActionLmmListPtr modifiedSet_;
   lmm_system_t maxminSystem_ = nullptr;
 protected:
   ActionLmmListPtr modifiedSet_;
   lmm_system_t maxminSystem_ = nullptr;
-  e_UM_t updateMechanism_ = UM_UNDEFINED;
   bool selectiveUpdate_;
   xbt_heap_t actionHeap_;
 
 private:
   bool selectiveUpdate_;
   xbt_heap_t actionHeap_;
 
 private:
+  e_UM_t updateMechanism_ = UM_UNDEFINED;
   ActionList* readyActionSet_; /**< Actions in state SURF_ACTION_READY */
   ActionList* runningActionSet_; /**< Actions in state SURF_ACTION_RUNNING */
   ActionList* failedActionSet_; /**< Actions in state SURF_ACTION_FAILED */
   ActionList* readyActionSet_; /**< Actions in state SURF_ACTION_READY */
   ActionList* runningActionSet_; /**< Actions in state SURF_ACTION_RUNNING */
   ActionList* failedActionSet_; /**< Actions in state SURF_ACTION_FAILED */