Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
tiny cleanups in the parsing of clusters
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 11 Feb 2016 09:21:25 +0000 (10:21 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 11 Feb 2016 09:21:28 +0000 (10:21 +0100)
This code has the real potential of making me insane. It drives me nuts!

src/simix/smx_global.cpp
src/surf/surf_routing.cpp
src/surf/surf_routing_cluster.hpp
src/surf/surf_routing_cluster_fat_tree.hpp
src/surf/surf_routing_cluster_torus.cpp
src/surf/surf_routing_cluster_torus.hpp
src/surf/surf_routing_generic.cpp

index 10fbceb..1fb67e2 100644 (file)
@@ -251,8 +251,7 @@ void SIMIX_global_init(int *argc, char **argv)
     signal(SIGINT, inthandler);
 
 #ifndef WIN32
-    /* Install SEGV handler */
-    install_segvhandler();
+    //install_segvhandler();
 #endif
     /* register a function to be called by SURF after the environment creation */
     sg_platf_init();
index 5e3b5ed..b196348 100644 (file)
@@ -673,32 +673,29 @@ void routing_new_cluster(sg_platf_cluster_cbarg_t cluster)
     xbt_dict_set(patterns, "suffix", xbt_strdup(cluster->suffix), NULL);
   }
 
-  /* parse the topology attribute. If we are not in a flat cluster,
-   * switch to the right mode and initialize the routing with
-   * the parameters in topo_parameters attribute
-   */
+  /* Parse the topology attributes.
+   * Nothing to do in a vanilla cluster, but that's another story for torus and flat_trees */
   s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
   AS.id = cluster->id;
 
-  if(cluster->topology == SURF_CLUSTER_TORUS){
+  switch (cluster->topology) {
+  case SURF_CLUSTER_TORUS:
     XBT_DEBUG("<AS id=\"%s\"\trouting=\"Torus_Cluster\">", cluster->id);
     AS.routing = A_surfxml_AS_routing_Cluster___torus;
-    sg_platf_new_AS_begin(&AS);
-    ((AsClusterTorus*)current_routing)->parse_specific_arguments(cluster);
-  }
-  else if (cluster->topology == SURF_CLUSTER_FAT_TREE) {
+    break;
+  case 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{
+    break;
+  default:
     XBT_DEBUG("<AS id=\"%s\"\trouting=\"Cluster\">", cluster->id);
     AS.routing = A_surfxml_AS_routing_Cluster;
-    sg_platf_new_AS_begin(&AS);
+    break;
   }
 
+  sg_platf_new_AS_begin(&AS);
+  static_cast<AsCluster*>(current_routing)->parse_specific_arguments(cluster);
+
   if(cluster->loopback_bw!=0 || cluster->loopback_lat!=0){
       ((AsCluster*)current_routing)->p_nb_links_per_node++;
       ((AsCluster*)current_routing)->p_has_loopback=1;
@@ -710,7 +707,6 @@ void routing_new_cluster(sg_platf_cluster_cbarg_t cluster)
   }
 
 
-
   current_routing->p_linkUpDownList
             = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
 
index ce935c5..c1962f0 100644 (file)
@@ -34,6 +34,7 @@ public:
   int parsePU(NetCard *elm) override; /* A host or a router, whatever */
   int parseAS(NetCard *elm) override;
   virtual void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position);
+  virtual void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) {}
 
   Link* p_backbone = nullptr;
   void *p_loopback = nullptr;
index af8e8ad..6d6adcf 100644 (file)
@@ -133,7 +133,7 @@ public:
    *
    * It will also store the cluster for future use.
    */
-  void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster);
+  void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) override;
   void addProcessingNode(int id);
   void generateDotFile(const std::string& filename = "fatTree.dot") const;
 
index e75a0c5..03bedd5 100644 (file)
@@ -32,16 +32,13 @@ AS_t model_torus_cluster_create(void)
 
 namespace simgrid {
   namespace surf {
-
-    /* Creation routing model functions */
     AsClusterTorus::AsClusterTorus():AsCluster() {
-      p_dimensions = NULL;
+    }
+    AsClusterTorus::~AsClusterTorus() {
+      xbt_dynar_free(&p_dimensions);
     }
 
-    /* Creation routing model functions */ AsClusterTorus::~AsClusterTorus() {
-      if (p_dimensions)
-        xbt_dynar_free(&p_dimensions);
-    } void AsClusterTorus::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) {
+    void AsClusterTorus::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) {
       s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
       char *link_id;
       unsigned int j = 0;
index 36aee9f..35bcb68 100644 (file)
@@ -20,12 +20,12 @@ namespace simgrid {
     class XBT_PRIVATE AsClusterTorus:public simgrid::surf::AsCluster {
     public:
       AsClusterTorus();
-      virtual ~ AsClusterTorus();
-      virtual void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position);
-      virtual void getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t into, double *latency);
-      void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster);
+      virtual ~AsClusterTorus();
+      void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) override;
+      void getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t into, double *latency) override;
+      void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) override;
       xbt_dynar_t p_dimensions = NULL;
     };
 
-}}
+  }}
 #endif
index a95b47e..6072cd8 100644 (file)
@@ -400,25 +400,19 @@ sg_platf_route_cbarg_t AsGeneric::newExtendedRoute(e_surf_routing_hierarchy_t hi
 
 As *AsGeneric::asExist(As *to_find)
 {
-  //return to_find; // FIXME: BYPASSERROR OF FOREACH WITH BREAK
   xbt_dict_cursor_t cursor = NULL;
   char *key;
-  int found = 0;
   AsGeneric *elem;
-  xbt_dict_foreach(p_routingSons, cursor, key, elem) {
-    if (to_find == elem || elem->asExist(to_find)) {
-      found = 1;
-      break;
-    }
-  }
-  if (found)
-    return to_find;
+
+  xbt_dict_foreach(p_routingSons, cursor, key, elem)
+    if (to_find == elem || elem->asExist(to_find))
+      return to_find;
+
   return NULL;
 }
 
 As *AsGeneric::autonomousSystemExist(char *element)
 {
-  //return rc; // FIXME: BYPASSERROR OF FOREACH WITH BREAK
   As *element_as, *result, *elem;
   xbt_dict_cursor_t cursor = NULL;
   char *key;