Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add limiter and loopback link support in fat trees
[simgrid.git] / src / surf / surf_routing_cluster_fat_tree.hpp
index 6b8bc03..c4de13f 100644 (file)
@@ -10,8 +10,6 @@
 #define SURF_ROUTING_CLUSTER_FAT_TREE_HPP_
 
 
-AS_t model_fat_tree_cluster_create(void);
-
 /* The class AsClusterFatTree describes PGFT, as introduced by Eitan Zahavi
  * in "D-Mod-K Routing Providing Non-Blocking Traffic for Shift Permutations
  * on Real Life Fat Trees" (2010). RLFT are PGFT with some restrictions to 
@@ -25,28 +23,46 @@ AS_t model_fat_tree_cluster_create(void);
 class FatTreeNode;
 class FatTreeLink;
 
-
+/* \class FatTreeNode
+ * \brief A node in a fat tree
+ */
 class FatTreeNode {
 public:
+  /* \brief Unique ID which identifies every node
+   */
   int id;
-  unsigned int level; // The 0th level represents the leafs of the PGFT
-  unsigned int position; // Position in the level
+  /* \brief Level into the tree, with 0 being the leafs
+   */
+  unsigned int level; 
+  /* \brief Position into the level, starting from 0
+   */
+  unsigned int position; 
+  /* In order to link nodes between them, each one must be assigned a label,
+   * consisting of l integers, l being the levels number of the tree. Each label
+   * is unique in the level, and the way it is generated allows the construction
+   * of a fat tree which fits the desired topology
+   */
   std::vector<unsigned int> label;
-  /* We can see the sizes sum of the two following vectors as the device 
-   * ports number. If we use the notations used in Zahavi's paper, 
-   * children.size() = m_level and parents.size() = w_(level+1)
-   * 
+
+  /* Links to the lower level, where the position in the vector corresponds to
+   * a port number. 
    */
-  std::vector<FatTreeLink*> children;  // m, apply from lvl 0 to levels - 1 
-  std::vector<FatTreeLink*> parents; // w, apply from lvl 1 to levels
-  FatTreeNode(int id, int level=-1, int position=-1);
+  std::vector<FatTreeLink*> children;
+  /* Links to the upper level, where the position in the vector corresponds to
+   * a port number. 
+   */ 
+  std::vector<FatTreeLink*> parents;
+
+  NetworkLink* limiterLink;
+  NetworkLink* loopback;
+  FatTreeNode(sg_platf_cluster_cbarg_t cluster, int id, int level,
+              int position);
 };
 
 class FatTreeLink {
 public:
   FatTreeLink(sg_platf_cluster_cbarg_t cluster, FatTreeNode *source,
               FatTreeNode *destination);
-  //  unsigned int ports;
   /* Links are dependant of the chosen network model, but must implement 
    * NetworkLink
    */
@@ -54,7 +70,6 @@ public:
   NetworkLink *downLink;
   FatTreeNode *upNode;
   FatTreeNode *downNode;
-  
 };
 
 class AsClusterFatTree : public AsCluster {
@@ -67,29 +82,32 @@ public:
   // virtual void getRouteAndLatency(const int src, const int dst,
   //                                 std::vector<NetworkLink> *route,
   //                                 double *latency) const;
-  virtual void create_links(sg_platf_cluster_cbarg_t cluster);
+  virtual void create_links();
   void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster);
-  void addComputeNode(int id);
+  void addProcessingNode(int id);
   void generateDotFile(const string& filename = "fatTree.dot") const;
 
-protected:
+private:
+  
   //description of a PGFT (TODO : better doc)
   unsigned int levels;
   std::vector<unsigned int> lowerLevelNodesNumber; // number of children by node
   std::vector<unsigned int> upperLevelNodesNumber; // number of parents by node
   std::vector<unsigned int> lowerLevelPortsNumber; // ports between each level l and l-1
   
-  std::map<int, FatTreeNode*> nodes;
+  std::map<int, FatTreeNode*> computeNodes;
+  std::vector<FatTreeNode*> nodes;
   std::vector<FatTreeLink*> links;
   std::vector<unsigned int> nodesByLevel;
 
-  void addLink(sg_platf_cluster_cbarg_t cluster, 
-               FatTreeNode *parent, unsigned int parentPort,
+  sg_platf_cluster_cbarg_t cluster;
+
+  void addLink(FatTreeNode *parent, unsigned int parentPort,
                FatTreeNode *child, unsigned int childPort);
   int getLevelPosition(const unsigned int level);
   void generateLabels();
   void generateSwitches();
-  int connectNodeToParents(sg_platf_cluster_cbarg_t cluster, FatTreeNode *node);
+  int connectNodeToParents(FatTreeNode *node);
   bool areRelated(FatTreeNode *parent, FatTreeNode *child);
   bool isInSubTree(FatTreeNode *root, FatTreeNode *node);
 };