Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename a field and slightly improve the doc
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 12 Feb 2016 20:54:56 +0000 (21:54 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 12 Feb 2016 20:55:07 +0000 (21:55 +0100)
src/surf/surf_routing.cpp
src/surf/surf_routing.hpp
src/surf/surf_routing_cluster.cpp
src/surf/surf_routing_dijkstra.cpp
src/surf/surf_routing_floyd.cpp
src/surf/surf_routing_full.cpp
src/surf/surf_routing_generic.cpp

index 237c4ed..5ad4254 100644 (file)
@@ -36,7 +36,7 @@ namespace surf {
   As::~As()
   {
     xbt_dict_free(&sons_);
-    xbt_dynar_free(&p_indexNetworkElm);
+    xbt_dynar_free(&vertices_);
     xbt_dynar_free(&upDownLinks);
     xbt_free(name_);
     if (netcard_)
@@ -45,8 +45,8 @@ namespace surf {
 
   int As::addComponent(NetCard *elm) {
     XBT_DEBUG("Load component \"%s\"", elm->getName());
-    xbt_dynar_push_as(p_indexNetworkElm, NetCard*, elm);
-    return xbt_dynar_length(p_indexNetworkElm)-1;
+    xbt_dynar_push_as(vertices_, NetCard*, elm);
+    return xbt_dynar_length(vertices_)-1;
   }
 
 }} // namespace simgrid::surf
@@ -856,7 +856,7 @@ xbt_dict_t surf_AS_get_routing_sons(simgrid::surf::As *as)
 
 xbt_dynar_t surf_AS_get_hosts(simgrid::surf::As *as)
 {
-  xbt_dynar_t elms = as->p_indexNetworkElm;
+  xbt_dynar_t elms = as->vertices_;
   int count = xbt_dynar_length(elms);
   xbt_dynar_t res =  xbt_dynar_new(sizeof(sg_host_t), NULL);
   for (int index = 0; index < count; index++) {
index 8ffb46f..f5d541f 100644 (file)
@@ -28,13 +28,14 @@ class XBT_PRIVATE Onelink;
 class RoutingPlatf;
 
 /** @ingroup SURF_routing_interface
- * @brief A network card
+ * @brief Network cards are the vertices in the graph representing the network, used to compute paths between nodes.
+ *
  * @details This represents a position in the network. One can route information between two netcards
  */
 class NetCard {
 public:
   virtual ~NetCard(){};
-  virtual int getId()=0;
+  virtual int getId()=0; // Our rank in the vertices_ array of our englobing AS.
   virtual int *getIdPtr()=0;
   virtual void setId(int id)=0;
   virtual char *getName()=0;
@@ -58,7 +59,7 @@ public:
   As *father_ = nullptr;
   xbt_dict_t sons_ = xbt_dict_new_homogeneous(NULL);
 
-  xbt_dynar_t p_indexNetworkElm = xbt_dynar_new(sizeof(char*),NULL); // TODO: What is it?
+  xbt_dynar_t vertices_ = xbt_dynar_new(sizeof(char*),NULL); // our content, as known to our graph routing algorithm (maps vertexId -> vertex)
   xbt_dict_t bypassRoutes_ = nullptr;
   e_surf_routing_hierarchy_t hierarchy_ = SURF_ROUTING_NULL;
   xbt_dynar_t upDownLinks = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
@@ -66,11 +67,18 @@ public:
 
 
   /**
-   * @brief Get the characteristics of the routing path between two points
+   * @brief Probe the routing path between two points
    *
-   * This function is used by the networking model to find the information it needs when starting a communication.
+   * The networking model uses this function when creating a communication
+   * to retrieve both the list of links that the create communication will use,
+   * and the summed latency that these links represent.
    *
-   * The things are not straightforward because the platform can be routed using several routing models.
+   * The network could recompute the latency by itself from the list, but it would
+   * require an additional link set traversal. This operation being on the critical
+   * path of SimGrid, the routing computes the latency in behalf of the network.
+   *
+   * Things are rather complex here because we have to find the path from ASes to ASes, and within each.
+   * In addition, the different ASes may use differing routing models.
    * Some ASes may be routed in full, others may have only some connection information and use a shortest path on top of that, and so on.
    * Some ASes may even not have any predefined links and use only coordinate informations to compute the latency.
    *
@@ -79,12 +87,11 @@ public:
    * 
    * @param src Initial point of the routing path
    * @param dst Final point of the routing path
-   * @param into Container into which the links should be pushed
-   * @param latency Accumulator in which the latencies should be added
+   * @param into Container into which the traversed links should be pushed
+   * @param latency Accumulator in which the latencies should be added (caller must set it to 0)
    */
-  virtual void getRouteAndLatency(
-      NetCard *src, NetCard *dst,
-      sg_platf_route_cbarg_t into, double *latency)=0;
+  virtual void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency)=0;
+  /** @brief retrieves the list of all routes of size 1 (of type src x dst x Link) */
   virtual xbt_dynar_t getOneLinkRoutes()=0;
 
   virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
index 61ced4e..d3d83f7 100644 (file)
@@ -75,7 +75,7 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb
 void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 {
   int isrc;
-  int table_size = xbt_dynar_length(p_indexNetworkElm);
+  int table_size = xbt_dynar_length(vertices_);
 
   NetCard *src;
   xbt_node_t current, previous, backboneNode = NULL, routerNode;
@@ -95,7 +95,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
   }
 
   for (isrc = 0; isrc < table_size; isrc++) {
-    src = xbt_dynar_get_as(p_indexNetworkElm, isrc, NetCard*);
+    src = xbt_dynar_get_as(vertices_, isrc, NetCard*);
 
     if (src->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) {
       previous = new_xbt_graph_node(graph, src->getName(), nodes);
index 1808d92..5211683 100644 (file)
@@ -171,12 +171,12 @@ xbt_dynar_t AsDijkstra::getOneLinkRoutes()
 
   int src,dst;
   NetCard *src_elm, *dst_elm;
-  int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
+  int table_size = (int)xbt_dynar_length(vertices_);
   for(src=0; src < table_size; src++) {
     for(dst=0; dst< table_size; dst++) {
       xbt_dynar_reset(route->link_list);
-      src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, NetCard*);
-      dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, NetCard*);
+      src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
+      dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
       this->getRouteAndLatency(src_elm, dst_elm,route, NULL);
 
       if (xbt_dynar_length(route->link_list) == 1) {
index 8500720..49022bb 100644 (file)
@@ -28,7 +28,7 @@ AsFloyd::AsFloyd(const char*name)
 AsFloyd::~AsFloyd(){
   int i, j;
   int table_size;
-  table_size = (int)xbt_dynar_length(p_indexNetworkElm);
+  table_size = (int)xbt_dynar_length(vertices_);
   if (p_linkTable == NULL) // Dealing with a parse error in the file?
     return;
   /* Delete link_table */
@@ -53,12 +53,12 @@ xbt_dynar_t AsFloyd::getOneLinkRoutes()
 
   int src,dst;
   sg_netcard_t src_elm, dst_elm;
-  int table_size = xbt_dynar_length(p_indexNetworkElm);
+  int table_size = xbt_dynar_length(vertices_);
   for(src=0; src < table_size; src++) {
     for(dst=0; dst< table_size; dst++) {
       xbt_dynar_reset(route->link_list);
-      src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, NetCard*);
-      dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, NetCard*);
+      src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
+      dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
       this->getRouteAndLatency(src_elm, dst_elm, route, NULL);
 
       if (xbt_dynar_length(route->link_list) == 1) {
@@ -82,7 +82,7 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar
 {
 
   /* set utils vars */
-  size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+  size_t table_size = xbt_dynar_length(vertices_);
 
   this->srcDstCheck(src, dst);
 
@@ -144,7 +144,7 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route)
   int as_route = 0;
 
   /* set the size of table routing */
-  int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
+  int table_size = (int)xbt_dynar_length(vertices_);
   NetCard *src_net_elm, *dst_net_elm;
 
   src_net_elm = sg_netcard_by_name_or_null(src);
@@ -265,7 +265,7 @@ void AsFloyd::Seal(){
   unsigned int i, j, a, b, c;
 
   /* set the size of table routing */
-  size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+  size_t table_size = xbt_dynar_length(vertices_);
 
   if(!p_linkTable) {
     /* Create Cost, Predecessor and Link tables */
index fc1c034..16a27d4 100644 (file)
@@ -24,7 +24,7 @@ void AsFull::Seal() {
   sg_platf_route_cbarg_t e_route;
 
   /* set utils vars */
-  int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
+  int table_size = (int)xbt_dynar_length(vertices_);
 
   /* Create table if necessary */
   if (!p_routingTable)
@@ -48,7 +48,7 @@ void AsFull::Seal() {
 
 AsFull::~AsFull(){
   if (p_routingTable) {
-    int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
+    int table_size = (int)xbt_dynar_length(vertices_);
     int i, j;
     /* Delete routing table */
     for (i = 0; i < table_size; i++)
@@ -67,7 +67,7 @@ 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(p_indexNetworkElm);
+  int table_size = xbt_dynar_length(vertices_);
 
   for(src=0; src < table_size; src++) {
     for(dst=0; dst< table_size; dst++) {
@@ -77,9 +77,9 @@ xbt_dynar_t AsFull::getOneLinkRoutes()
           void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0);
           Onelink *onelink;
           if (hierarchy_ == SURF_ROUTING_BASE) {
-          NetCard *tmp_src = xbt_dynar_get_as(p_indexNetworkElm, src, sg_netcard_t);
+          NetCard *tmp_src = xbt_dynar_get_as(vertices_, src, sg_netcard_t);
             tmp_src->setId(src);
-          NetCard *tmp_dst = xbt_dynar_get_as(p_indexNetworkElm, dst, sg_netcard_t);
+          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)
@@ -106,7 +106,7 @@ void AsFull::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg
       dst->getId());
 
   /* set utils vars */
-  size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+  size_t table_size = xbt_dynar_length(vertices_);
 
   sg_platf_route_cbarg_t e_route = NULL;
   void *link;
@@ -146,7 +146,7 @@ void AsFull::parseRoute(sg_platf_route_cbarg_t route)
   xbt_assert(src_net_elm, "Network elements %s not found", src);
   xbt_assert(dst_net_elm, "Network elements %s not found", dst);
 
-  size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+  size_t table_size = xbt_dynar_length(vertices_);
 
   xbt_assert(!xbt_dynar_is_empty(route->link_list),
       "Invalid count of links, must be greater than zero (%s,%s)",
index d332952..2e8ef80 100644 (file)
@@ -148,17 +148,17 @@ namespace surf {
 void AsGeneric::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 {
   int src, dst;
-  int table_size = xbt_dynar_length(p_indexNetworkElm);
+  int table_size = xbt_dynar_length(vertices_);
 
 
   for (src = 0; src < table_size; src++) {
     NetCard *my_src =
-        xbt_dynar_get_as(p_indexNetworkElm, src, NetCard*);
+        xbt_dynar_get_as(vertices_, src, NetCard*);
     for (dst = 0; dst < table_size; dst++) {
       if (src == dst)
         continue;
       NetCard *my_dst =
-          xbt_dynar_get_as(p_indexNetworkElm, dst, NetCard*);
+          xbt_dynar_get_as(vertices_, dst, NetCard*);
 
       sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
       route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);