Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename some symbols around Link::isShared to make their purpose clear
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 29 Nov 2015 16:58:37 +0000 (17:58 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 29 Nov 2015 16:58:37 +0000 (17:58 +0100)
src/include/surf/maxmin.h
src/surf/fair_bottleneck.cpp
src/surf/host_ptask_L07.cpp
src/surf/host_ptask_L07.hpp
src/surf/maxmin.cpp
src/surf/maxmin_private.hpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp

index 3b102b7..18dcef5 100644 (file)
@@ -157,7 +157,7 @@ XBT_PUBLIC(void) lmm_constraint_shared(lmm_constraint_t cnst);
  * @param cnst The constraint to share
  * @return 1 if shared, 0 otherwise
  */
-XBT_PUBLIC(int) lmm_constraint_is_shared(lmm_constraint_t cnst);
+XBT_PUBLIC(int) lmm_constraint_sharing_policy(lmm_constraint_t cnst);
 
 /**
  * @brief Free a constraint
index 2affd8d..a0cd4c1 100644 (file)
@@ -102,7 +102,7 @@ void bottleneck_solve(lmm_system_t sys)
           nb++;
       }
       XBT_DEBUG("\tThere are %d variables", nb);
-      if (nb > 0 && !cnst->shared)
+      if (nb > 0 && !cnst->sharing_policy)
         nb = 1;
       if (!nb) {
         cnst->remaining = 0.0;
@@ -141,7 +141,7 @@ void bottleneck_solve(lmm_system_t sys)
         elem = (lmm_element_t)_elem;
         if (elem->variable->weight <= 0)
           break;
-        if (cnst->shared) {
+        if (cnst->sharing_policy) {
           XBT_DEBUG("\tUpdate constraint %p (%g) with variable %p by %g",
                  cnst, cnst->remaining, elem->variable,
                  elem->variable->mu);
@@ -154,7 +154,7 @@ void bottleneck_solve(lmm_system_t sys)
           cnst->usage = MIN(cnst->usage, elem->value * elem->variable->mu);
         }
       }
-      if (!cnst->shared) {
+      if (!cnst->sharing_policy) {
         XBT_DEBUG("\tUpdate constraint %p (%g) by %g",
                cnst, cnst->remaining, cnst->usage);
 
index 717e89a..ec97d10 100644 (file)
@@ -566,9 +566,9 @@ void LinkL07::updateLatency(double value, double date)
 }
 
 
-bool LinkL07::isShared()
+int LinkL07::sharingPolicy()
 {
-  return lmm_constraint_is_shared(getConstraint());
+  return lmm_constraint_sharing_policy(getConstraint());
 }
 
 /**********
index 6092bfa..86acc7d 100644 (file)
@@ -138,7 +138,7 @@ public:
   void updateState(tmgr_trace_event_t event_type, double value, double date);
   double getBandwidth();
   double getLatency();
-  bool isShared();
+  int sharingPolicy();
   void updateBandwidth(double value, double date=surf_get_clock());
   void updateLatency(double value, double date=surf_get_clock());
 
index a060d6b..57507b9 100644 (file)
@@ -157,7 +157,7 @@ lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id,
 
   cnst->bound = bound_value;
   cnst->usage = 0;
-  cnst->shared = 1;
+  cnst->sharing_policy = 1; /* FIXME: don't hardcode the value */
   insert_constraint(sys, cnst);
 
   return cnst;
@@ -165,12 +165,13 @@ lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id,
 
 void lmm_constraint_shared(lmm_constraint_t cnst)
 {
-  cnst->shared = 0;
+  cnst->sharing_policy = 0;
 }
 
-int lmm_constraint_is_shared(lmm_constraint_t cnst)
+/** Return true if the constraint is shared, and false if it's FATPIPE */
+int lmm_constraint_sharing_policy(lmm_constraint_t cnst)
 {
-  return (cnst->shared);
+  return (cnst->sharing_policy);
 }
 
 XBT_INLINE void lmm_constraint_free(lmm_system_t sys,
@@ -382,7 +383,7 @@ void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst,
       break;
 
   if (i < var->cnsts_number) {
-    if (cnst->shared)
+    if (cnst->sharing_policy)
       var->cnsts[i].value += value;
     else
       var->cnsts[i].value = MAX(var->cnsts[i].value, value);
@@ -556,7 +557,7 @@ void lmm_print(lmm_system_t sys)
     trace_buf = (char*)
         xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
     strcat(trace_buf, print_buf);
-    sprintf(print_buf, "%s(",(cnst->shared)?"":"max");
+    sprintf(print_buf, "%s(",(cnst->sharing_policy)?"":"max");
     trace_buf = (char*)
       xbt_realloc(trace_buf,
       strlen(trace_buf) + strlen(print_buf) + 1);
@@ -564,22 +565,22 @@ void lmm_print(lmm_system_t sys)
     xbt_swag_foreach(_elem, elem_list) {
       elem = (lmm_element_t)_elem;
       sprintf(print_buf, "%f.'%d'(%f) %s ", elem->value,
-              elem->variable->id_int, elem->variable->value,(cnst->shared)?"+":",");
+              elem->variable->id_int, elem->variable->value,(cnst->sharing_policy)?"+":",");
       trace_buf = (char*)
           xbt_realloc(trace_buf,
                       strlen(trace_buf) + strlen(print_buf) + 1);
       strcat(trace_buf, print_buf);
-      if(cnst->shared) 
-  sum += elem->value * elem->variable->value;
+      if(cnst->sharing_policy)
+         sum += elem->value * elem->variable->value;
       else 
-  sum = MAX(sum,elem->value * elem->variable->value);
+         sum = MAX(sum,elem->value * elem->variable->value);
     }
     sprintf(print_buf, "0) <= %f ('%d')", cnst->bound, cnst->id_int);
     trace_buf = (char*)
         xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
     strcat(trace_buf, print_buf);
 
-    if (!cnst->shared) {
+    if (!cnst->sharing_policy) {
       sprintf(print_buf, " [MAX-Constraint]");
       trace_buf = (char*)
           xbt_realloc(trace_buf,
@@ -670,7 +671,7 @@ void lmm_solve(lmm_system_t sys)
       if (elem->variable->weight <= 0)
         break;
       if ((elem->value > 0)) {
-        if (cnst->shared)
+        if (cnst->sharing_policy)
           cnst->usage += elem->value / elem->variable->weight;
         else if (cnst->usage < elem->value / elem->variable->weight)
           cnst->usage = elem->value / elem->variable->weight;
@@ -753,7 +754,7 @@ void lmm_solve(lmm_system_t sys)
       for (i = 0; i < var->cnsts_number; i++) {
         elem = &var->cnsts[i];
         cnst = elem->constraint;
-        if (cnst->shared) {
+        if (cnst->sharing_policy) {
          //Remember: shared constraints require that sum(elem->value * var->value) < cnst->bound
           double_update(&(cnst->remaining),  elem->value * var->value, cnst->bound*sg_maxmin_precision);
           double_update(&(cnst->usage), elem->value / var->weight, sg_maxmin_precision);
@@ -1028,7 +1029,7 @@ double lmm_constraint_get_usage(lmm_constraint_t cnst) {
      if (elem->variable->weight <= 0)
        break;
      if ((elem->value > 0)) {
-       if (cnst->shared)
+       if (cnst->sharing_policy)
          usage += elem->value * elem->variable->value;
        else if (usage < elem->value * elem->variable->value)
          usage = elem->value * elem->variable->value;
index 48479c8..b086827 100644 (file)
@@ -49,7 +49,7 @@ typedef struct lmm_constraint {
   double remaining;
   double usage;
   double bound;
-  int shared;
+  int sharing_policy; /* see @e_surf_link_sharing_policy_t (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX) */
   void *id;
   int id_int;
   double lambda;
index 380332f..3daac06 100644 (file)
@@ -25,7 +25,7 @@ Link * sg_link_by_name(const char* name) {
 }
 
 int sg_link_is_shared(Link *link){
-  return link->isShared();
+  return link->sharingPolicy();
 }
 double sg_link_bandwidth(Link *link){
   return link->getBandwidth();
@@ -221,9 +221,9 @@ double Link::getBandwidth()
   return p_power.peak * p_power.scale;
 }
 
-bool Link::isShared()
+int Link::sharingPolicy()
 {
-  return lmm_constraint_is_shared(getConstraint());
+  return lmm_constraint_sharing_policy(getConstraint());
 }
 
 void Link::setState(e_surf_resource_state_t state){
index bfd51b0..c89b7ff 100644 (file)
@@ -217,12 +217,8 @@ public:
   /** @brief Update the latency in seconds of current Link */
   virtual void updateLatency(double value, double date=surf_get_clock())=0;
 
-  /**
-   * @brief Check if the Link is shared
-   *
-   * @return true if the current NetwokrLink is shared, false otherwise
-   */
-  virtual bool isShared();
+  /** @brief The sharing policy is a @e_surf_link_sharing_policy_t (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX) */
+  virtual int sharingPolicy();
 
   /** @brief Check if the Link is used */
   bool isUsed();