Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Multiple .so support for region snapshots
[simgrid.git] / src / surf / surf_routing.cpp
index 5c6e450..48cadde 100644 (file)
@@ -8,7 +8,7 @@
 #include "surf_routing_private.hpp"
 #include "surf_routing_cluster.hpp"
 #include "surf_routing_cluster_torus.hpp"
-
+#include "surf_routing_cluster_fat_tree.hpp"
 
 #include "simgrid/platf_interface.h"    // platform creation API internal interface
 #include "simgrid/sg_config.h"
@@ -43,7 +43,6 @@ int NS3_HOST_LEVEL;             //host node for ns3
 xbt_lib_t link_lib;
 int SD_LINK_LEVEL;              //Simdag level
 int SURF_LINK_LEVEL;            //Surf level
-int NS3_LINK_LEVEL;             //link for ns3
 
 xbt_lib_t as_router_lib;
 int ROUTING_ASR_LEVEL;          //Routing level
@@ -89,7 +88,7 @@ typedef enum {
   SURF_MODEL_VIVALDI,
   SURF_MODEL_CLUSTER,
   SURF_MODEL_TORUS_CLUSTER,
-
+  SURF_MODEL_FAT_TREE_CLUSTER,
 } e_routing_types;
 
 struct s_model_type routing_models[] = {
@@ -111,8 +110,10 @@ struct s_model_type routing_models[] = {
    model_vivaldi_create, NULL},
   {"Cluster", "Cluster routing",
    model_cluster_create, NULL},
-   {"Torus_Cluster", "Torus Cluster routing",
-    model_torus_cluster_create, NULL},
+  {"Torus_Cluster", "Torus Cluster routing",
+   model_torus_cluster_create, NULL},
+  {"Fat_Tree_Cluster", "Fat Tree Cluster routing",
+   model_fat_tree_cluster_create, NULL},
   {NULL, NULL, NULL, NULL}
 };
 
@@ -356,14 +357,15 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
 
   /* search the routing model */
   switch(AS->routing){
-    case A_surfxml_AS_routing_Cluster:         model = &routing_models[SURF_MODEL_CLUSTER];break;
-    case A_surfxml_AS_routing_Cluster___torus: model = &routing_models[SURF_MODEL_TORUS_CLUSTER];break;
-    case A_surfxml_AS_routing_Dijkstra:        model = &routing_models[SURF_MODEL_DIJKSTRA];break;
-    case A_surfxml_AS_routing_DijkstraCache:   model = &routing_models[SURF_MODEL_DIJKSTRACACHE];break;
-    case A_surfxml_AS_routing_Floyd:           model = &routing_models[SURF_MODEL_FLOYD];break;
-    case A_surfxml_AS_routing_Full:            model = &routing_models[SURF_MODEL_FULL];break;
-    case A_surfxml_AS_routing_None:            model = &routing_models[SURF_MODEL_NONE];break;
-    case A_surfxml_AS_routing_Vivaldi:         model = &routing_models[SURF_MODEL_VIVALDI];break;
+    case A_surfxml_AS_routing_Cluster:               model = &routing_models[SURF_MODEL_CLUSTER];break;
+    case A_surfxml_AS_routing_Cluster___torus:       model = &routing_models[SURF_MODEL_TORUS_CLUSTER];break;
+    case A_surfxml_AS_routing_Cluster___fat___tree:  model = &routing_models[SURF_MODEL_FAT_TREE_CLUSTER];break;
+    case A_surfxml_AS_routing_Dijkstra:              model = &routing_models[SURF_MODEL_DIJKSTRA];break;
+    case A_surfxml_AS_routing_DijkstraCache:         model = &routing_models[SURF_MODEL_DIJKSTRACACHE];break;
+    case A_surfxml_AS_routing_Floyd:                 model = &routing_models[SURF_MODEL_FLOYD];break;
+    case A_surfxml_AS_routing_Full:                  model = &routing_models[SURF_MODEL_FULL];break;
+    case A_surfxml_AS_routing_None:                  model = &routing_models[SURF_MODEL_NONE];break;
+    case A_surfxml_AS_routing_Vivaldi:               model = &routing_models[SURF_MODEL_VIVALDI];break;
     default: xbt_die("Not a valid model!!!");
     break;
   }
@@ -631,7 +633,7 @@ xbt_dynar_t RoutingPlatf::getOneLinkRoutes(){
 
 xbt_dynar_t RoutingPlatf::recursiveGetOneLinkRoutes(AsPtr rc)
 {
-  xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free);
+  xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free_f);
 
   //adding my one link routes
   xbt_dynar_t onelink_mine = rc->getOneLinkRoutes();
@@ -836,7 +838,15 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
     AS.routing = A_surfxml_AS_routing_Cluster___torus;
     sg_platf_new_AS_begin(&AS);
     ((AsClusterTorusPtr)current_routing)->parse_specific_arguments(cluster);
-  }else{
+  }
+  else if (cluster->topology == SURF_CLUSTER_FAT_TREE) {
+    XBT_DEBUG("<AS id=\"%s\"\trouting=\"Fat_Tree_Cluster\">", cluster->id);
+    AS.routing = A_surfxml_AS_routing_Cluster___fat___tree;
+    sg_platf_new_AS_begin(&AS);
+    ((AsClusterFatTree*)current_routing)->parse_specific_arguments(cluster);
+  }
+
+  else{
     XBT_DEBUG("<AS id=\"%s\"\trouting=\"Cluster\">", cluster->id);
     AS.routing = A_surfxml_AS_routing_Cluster;
     sg_platf_new_AS_begin(&AS);
@@ -975,12 +985,15 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
 
 
       //call the cluster function that adds the others links
-
+      if (cluster->topology == SURF_CLUSTER_FAT_TREE) {
+        ((AsClusterFatTree*) current_routing)->addProcessingNode(i);
+      }
+      else {
       ((AsClusterPtr)current_routing)->create_links_for_node(cluster, i, rankId, rankId*
           ((AsClusterPtr)current_routing)->p_nb_links_per_node
           + ((AsClusterPtr)current_routing)->p_has_loopback
           + ((AsClusterPtr)current_routing)->p_has_limiter );
-
+      }
       xbt_free(link_id);
       xbt_free(host_id);
       rankId++;
@@ -990,6 +1003,10 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
   }
   xbt_dynar_free(&radical_elements);
 
+  // For fat trees, the links must be created once all nodes have been added
+  if(cluster->topology == SURF_CLUSTER_FAT_TREE) {
+    ((AsClusterFatTree*)current_routing)->create_links();
+  }
   // Add a router. It is magically used thanks to the way in which surf_routing_cluster is written,
   // and it's very useful to connect clusters together
   XBT_DEBUG(" ");