Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 29 Feb 2016 09:42:23 +0000 (10:42 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 29 Feb 2016 09:42:23 +0000 (10:42 +0100)
12 files changed:
CMakeLists.txt
src/surf/surf_routing.cpp
src/surf/surf_routing.hpp
src/surf/surf_routing_RoutedGraph.cpp
src/surf/surf_routing_RoutedGraph.hpp
src/surf/surf_routing_dijkstra.cpp
src/surf/surf_routing_dijkstra.hpp
src/surf/surf_routing_floyd.cpp
src/surf/surf_routing_floyd.hpp
src/surf/surf_routing_full.cpp
src/surf/surf_routing_full.hpp
src/surf/surf_routing_vivaldi.hpp

index c2cd759..fd5fe39 100644 (file)
@@ -740,6 +740,8 @@ else()
     message(FATAL_ERROR "Could not figure out the stack direction. Test prog returned: ${stack}; CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}.")
   endif()
 endif()
+# If the test ran well, remove the test binary
+execute_process(COMMAND ${CMAKE_COMMAND} -E remove test_stackgrowth)
 
 ###############
 ## System checks
index 1ef547b..10e404d 100644 (file)
@@ -342,8 +342,7 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
     if (current_routing->hierarchy_ == SURF_ROUTING_NULL)
       current_routing->hierarchy_ = SURF_ROUTING_RECURSIVE;
     /* add to the sons dictionary */
-    xbt_dict_set(current_routing->sons_, AS->id,
-                 (void *) new_as, NULL);
+    xbt_dict_set(current_routing->sons_, AS->id, (void *) new_as, NULL);
     /* add to the father element list */
     netcard->setId(current_routing->addComponent(netcard));
   } else {
@@ -366,11 +365,6 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
  *
  * Once you've declared all the content of your AS, you have to close
  * it with this call. Your AS is not usable until you call this function.
- *
- * @fixme: this call is not as robust as wanted: bad things WILL happen
- * if you call it twice for the same AS, or if you forget calling it, or
- * even if you add stuff to a closed AS
- *
  */
 void routing_AS_end()
 {
@@ -379,8 +373,6 @@ void routing_AS_end()
   current_routing = current_routing->father_;
 }
 
-/* Aux Business methods */
-
 /**
  * \brief Get the AS father and the first elements of the chain
  *
@@ -391,9 +383,7 @@ void routing_AS_end()
  * father in the chain
  */
 static void elements_father(sg_netcard_t src, sg_netcard_t dst,
-                            AS_t * res_father,
-                            AS_t * res_src,
-                            AS_t * res_dst)
+    AS_t * res_father, AS_t * res_src, AS_t * res_dst)
 {
   xbt_assert(src && dst, "bad parameters for \"elements_father\" method");
 #define ROUTING_HIERARCHY_MAXDEPTH 16     /* increase if it is not enough */
@@ -727,126 +717,6 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
   free(link_down);
 }
 
-// static void routing_parse_Srandom(void)
-// {
-//   double mean, std, min, max, seed;
-//   char *random_id = A_surfxml_random_id;
-//   char *random_radical = A_surfxml_random_radical;
-//   char *rd_name = NULL;
-//   char *rd_value;
-//   mean = surf_parse_get_double(A_surfxml_random_mean);
-//   std = surf_parse_get_double(A_surfxml_random_std___deviation);
-//   min = surf_parse_get_double(A_surfxml_random_min);
-//   max = surf_parse_get_double(A_surfxml_random_max);
-//   seed = surf_parse_get_double(A_surfxml_random_seed);
-
-//   double res = 0;
-//   int i = 0;
-//   random_data_t random = xbt_new0(s_random_data_t, 1);
-//   char *tmpbuf;
-
-//   xbt_dynar_t radical_elements;
-//   unsigned int iter;
-//   char *groups;
-//   int start, end;
-//   xbt_dynar_t radical_ends;
-
-//   switch (A_surfxml_random_generator) {
-//   case AU_surfxml_random_generator:
-//   case A_surfxml_random_generator_NONE:
-//     random->generator = NONE;
-//     break;
-//   case A_surfxml_random_generator_DRAND48:
-//     random->generator = DRAND48;
-//     break;
-//   case A_surfxml_random_generator_RAND:
-//     random->generator = RAND;
-//     break;
-//   case A_surfxml_random_generator_RNGSTREAM:
-//     random->generator = RNGSTREAM;
-//     break;
-//   default:
-//     surf_parse_error("Invalid random generator");
-//     break;
-//   }
-//   random->seed = seed;
-//   random->min = min;
-//   random->max = max;
-
-//   /* Check user stupidities */
-//   if (max < min)
-//     THROWF(arg_error, 0, "random->max < random->min (%f < %f)", max, min);
-//   if (mean < min)
-//     THROWF(arg_error, 0, "random->mean < random->min (%f < %f)", mean, min);
-//   if (mean > max)
-//     THROWF(arg_error, 0, "random->mean > random->max (%f > %f)", mean, max);
-
-//   /* normalize the mean and standard deviation before storing */
-//   random->mean = (mean - min) / (max - min);
-//   random->std = std / (max - min);
-
-//   if (random->mean * (1 - random->mean) < random->std * random->std)
-//     THROWF(arg_error, 0, "Invalid mean and standard deviation (%f and %f)",
-//            random->mean, random->std);
-
-//   XBT_DEBUG
-//       ("id = '%s' min = '%f' max = '%f' mean = '%f' std_deviatinon = '%f' generator = '%d' seed = '%ld' radical = '%s'",
-//        random_id, random->min, random->max, random->mean, random->std,
-//        (int)random->generator, random->seed, random_radical);
-
-//   if (!random_value)
-//     random_value = xbt_dict_new_homogeneous(free);
-
-//   if (!strcmp(random_radical, "")) {
-//     res = random_generate(random);
-//     rd_value = bprintf("%f", res);
-//     xbt_dict_set(random_value, random_id, rd_value, NULL);
-//   } else {
-//     radical_elements = xbt_str_split(random_radical, ",");
-//     xbt_dynar_foreach(radical_elements, iter, groups) {
-//       radical_ends = xbt_str_split(groups, "-");
-//       switch (xbt_dynar_length(radical_ends)) {
-//       case 1:
-//         xbt_assert(!xbt_dict_get_or_null(random_value, random_id),
-//                    "Custom Random '%s' already exists !", random_id);
-//         res = random_generate(random);
-//         tmpbuf =
-//             bprintf("%s%d", random_id,
-//                     atoi(xbt_dynar_getfirst_as(radical_ends, char *)));
-//         xbt_dict_set(random_value, tmpbuf, bprintf("%f", res), NULL);
-//         xbt_free(tmpbuf);
-//         break;
-
-//       case 2:
-//         start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
-//         end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
-//         for (i = start; i <= end; i++) {
-//           xbt_assert(!xbt_dict_get_or_null(random_value, random_id),
-//                      "Custom Random '%s' already exists !", bprintf("%s%d",
-//                                                                     random_id,
-//                                                                     i));
-//           res = random_generate(random);
-//           tmpbuf = bprintf("%s%d", random_id, i);
-//           xbt_dict_set(random_value, tmpbuf, bprintf("%f", res), NULL);
-//           xbt_free(tmpbuf);
-//         }
-//         break;
-//       default:
-//         XBT_CRITICAL("Malformed radical");
-//         break;
-//       }
-//       res = random_generate(random);
-//       rd_name = bprintf("%s_router", random_id);
-//       rd_value = bprintf("%f", res);
-//       xbt_dict_set(random_value, rd_name, rd_value, NULL);
-
-//       xbt_dynar_free(&radical_ends);
-//     }
-//     free(rd_name);
-//     xbt_dynar_free(&radical_elements);
-//   }
-// }
-
 static void check_disk_attachment()
 {
   xbt_lib_cursor_t cursor;
@@ -904,7 +774,6 @@ namespace surf {
   }
   RoutingPlatf::~RoutingPlatf()
   {
-    xbt_dynar_free(&lastRoute_);
     finalize_rec(root_);
   }
 
@@ -919,8 +788,7 @@ const char *surf_AS_get_name(simgrid::surf::As *as) {
   return as->name_;
 }
 
-static simgrid::surf::As *surf_AS_recursive_get_by_name(
-  simgrid::surf::As *current, const char * name)
+static simgrid::surf::As *surf_AS_recursive_get_by_name(simgrid::surf::As *current, const char * name)
 {
   xbt_dict_cursor_t cursor = NULL;
   char *key;
index 07afc8d..c64d677 100644 (file)
@@ -140,7 +140,7 @@ private:
 };
 
 /** @ingroup SURF_routing_interface
- * @brief Link of lenght 1, alongside with its source and destination. This is mainly usefull in the ns3 bindings
+ * @brief Link of length 1, alongside with its source and destination. This is mainly useful in the ns3 bindings
  */
 class Onelink {
 public:
@@ -160,7 +160,6 @@ public:
   ~RoutingPlatf();
   As *root_ = nullptr;
   Link *loopback_;
-  xbt_dynar_t lastRoute_ = xbt_dynar_new(sizeof(Link*),NULL);
   xbt_dynar_t getOneLinkRoutes(void);
   void getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Link*> * links, double *latency);
 };
index 5c00da3..cd85779 100644 (file)
@@ -91,6 +91,36 @@ xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt
 namespace simgrid {
 namespace surf {
 
+  xbt_dynar_t AsRoutedGraph::getOneLinkRoutes()
+  {
+    xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
+    sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
+    route->link_list = new std::vector<Link*>();
+
+    int table_size = (int)xbt_dynar_length(vertices_);
+    for(int src=0; src < table_size; src++) {
+      for(int dst=0; dst< table_size; dst++) {
+        route->link_list->clear();
+        NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
+        NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
+        this->getRouteAndLatency(src_elm, dst_elm,route, NULL);
+
+        if (route->link_list->size() == 1) {
+          Link *link = route->link_list->at(0);
+          Onelink *onelink;
+          if (hierarchy_ == SURF_ROUTING_BASE)
+            onelink = new Onelink(link, src_elm, dst_elm);
+          else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
+            onelink = new Onelink(link, route->gw_src, route->gw_dst);
+          else
+            onelink = new Onelink(link, NULL, NULL);
+          xbt_dynar_push(ret, &onelink);
+        }
+      }
+    }
+    return ret;
+  }
+
 void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 {
   int src, dst;
index 9d5c7db..5a2feac 100644 (file)
@@ -21,6 +21,8 @@ public:
   AsRoutedGraph(const char*name);
   ~AsRoutedGraph();
 
+  xbt_dynar_t getOneLinkRoutes() override;
+
   virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) override;
   virtual sg_platf_route_cbarg_t newExtendedRoute(e_surf_routing_hierarchy_t hierarchy, sg_platf_route_cbarg_t routearg, int change_order);
 protected:
index fcaac99..1c5c486 100644 (file)
@@ -138,36 +138,6 @@ void AsDijkstra::newRoute(int src_id, int dst_id, sg_platf_route_cbarg_t e_route
   xbt_graph_new_edge(routeGraph_, src, dst, e_route);
 }
 
-xbt_dynar_t AsDijkstra::getOneLinkRoutes()
-{
-  xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
-  sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
-  route->link_list = new std::vector<Link*>();
-
-  int table_size = (int)xbt_dynar_length(vertices_);
-  for(int src=0; src < table_size; src++) {
-    for(int dst=0; dst< table_size; dst++) {
-      route->link_list->clear();
-      NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
-      NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
-      this->getRouteAndLatency(src_elm, dst_elm,route, NULL);
-
-      if (route->link_list->size() == 1) {
-        Link *link = route->link_list->at(0);
-        Onelink *onelink;
-        if (hierarchy_ == SURF_ROUTING_BASE)
-          onelink = new Onelink(link, src_elm, dst_elm);
-        else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
-          onelink = new Onelink(link, route->gw_src, route->gw_dst);
-        else
-          onelink = new Onelink(link, NULL, NULL);
-        xbt_dynar_push(ret, &onelink);
-      }
-    }
-  }
-  return ret;
-}
-
 void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
 {
   getRouteCheckParams(src, dst);
index ae5e000..849c682 100644 (file)
@@ -57,8 +57,6 @@ public:
      * will have a loopback attached to it.
      */
   void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat) override;
-  void getRouteAndLatency(sg_platf_route_cbarg_t route, double *lat); // FIXME: this function is dangerously not overriding because of diverging prototype
-  xbt_dynar_t getOneLinkRoutes() override;
   void addRoute(sg_platf_route_cbarg_t route) override;
 
   xbt_graph_t routeGraph_ = nullptr;     /* xbt_graph */
index c902ac3..5bfe3df 100644 (file)
@@ -39,41 +39,8 @@ AsFloyd::~AsFloyd(){
   xbt_free(costTable_);
 }
 
-/* Business methods */
-xbt_dynar_t AsFloyd::getOneLinkRoutes()
-{
-  xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
-  sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
-  route->link_list = new std::vector<Link*>();
-
-  int table_size = xbt_dynar_length(vertices_);
-  for(int src=0; src < table_size; src++) {
-    for(int dst=0; dst< table_size; dst++) {
-      route->link_list->clear();
-      NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
-      NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
-      this->getRouteAndLatency(src_elm, dst_elm, route, NULL);
-
-      if (route->link_list->size() == 1) {
-        void *link = route->link_list->at(0);
-        Onelink *onelink;
-        if (hierarchy_ == SURF_ROUTING_BASE)
-          onelink = new Onelink(link, src_elm, dst_elm);
-        else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
-          onelink = new Onelink(link, route->gw_src, route->gw_dst);
-        else
-          onelink = new Onelink(link, NULL, NULL);
-        xbt_dynar_push(ret, &onelink);
-      }
-    }
-  }
-
-  return ret;
-}
-
 void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
 {
-
   size_t table_size = xbt_dynar_length(vertices_);
 
   getRouteCheckParams(src, dst);
index 67f1f6d..e5258f8 100644 (file)
@@ -27,7 +27,6 @@ public:
   ~AsFloyd();
 
   void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
-  xbt_dynar_t getOneLinkRoutes() override;
   void addRoute(sg_platf_route_cbarg_t route) override;
   void Seal() override;
 
index 7d52469..1180fe0 100644 (file)
@@ -61,48 +61,10 @@ AsFull::~AsFull(){
   }
 }
 
-xbt_dynar_t AsFull::getOneLinkRoutes()
-{
-  xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
-
-  int src, dst;
-  int table_size = xbt_dynar_length(vertices_);
-
-  for(src=0; src < table_size; src++) {
-    for(dst=0; dst< table_size; dst++) {
-      sg_platf_route_cbarg_t route = TO_ROUTE_FULL(src,dst);
-      if (route) {
-        if (route->link_list->size() == 1) {
-          Link *link = route->link_list->at(0);
-          Onelink *onelink;
-          if (hierarchy_ == SURF_ROUTING_BASE) {
-          NetCard *tmp_src = xbt_dynar_get_as(vertices_, src, sg_netcard_t);
-            tmp_src->setId(src);
-          NetCard *tmp_dst = xbt_dynar_get_as(vertices_, dst, sg_netcard_t);
-          tmp_dst->setId(dst);
-            onelink = new Onelink(link, tmp_src, tmp_dst);
-          } else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
-            onelink = new Onelink(link, route->gw_src, route->gw_dst);
-          else
-            onelink = new Onelink(link, NULL, NULL);
-          xbt_dynar_push(ret, &onelink);
-          XBT_DEBUG("Push route from '%d' to '%d'",
-              src,
-              dst);
-        }
-      }
-    }
-  }
-  return ret;
-}
-
 void AsFull::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t res, double *lat)
 {
   XBT_DEBUG("full_get_route_and_latency from %s[%d] to %s[%d]",
-      src->name(),
-      src->id(),
-      dst->name(),
-      dst->id());
+      src->name(), src->id(), dst->name(), dst->id());
 
   /* set utils vars */
   size_t table_size = xbt_dynar_length(vertices_);
index 30dd1cb..0abbae3 100644 (file)
@@ -28,7 +28,6 @@ public:
   ~AsFull();
 
   void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
-  xbt_dynar_t getOneLinkRoutes() override;
   void addRoute(sg_platf_route_cbarg_t route) override;
 
   sg_platf_route_cbarg_t *routingTable_ = nullptr;
index 3ab9c59..3795d69 100644 (file)
@@ -28,6 +28,7 @@ public:
   AsVivaldi(const char *name);
   ~AsVivaldi() {};
 
+  xbt_dynar_t getOneLinkRoutes() override {return NULL;};
   void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
 };