Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1c39826b4b6a377be82077d3f705ee29b5278fe9
[simgrid.git] / src / surf / surf_routing_cluster_fat_tree.hpp
1 /* Copyright (c) 2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "surf_routing_cluster.hpp"
8
9 #ifndef SURF_ROUTING_CLUSTER_FAT_TREE_HPP_
10 #define SURF_ROUTING_CLUSTER_FAT_TREE_HPP_
11
12
13 /* The class AsClusterFatTree describes PGFT, as introduced by Eitan Zahavi
14  * in "D-Mod-K Routing Providing Non-Blocking Traffic for Shift Permutations
15  * on Real Life Fat Trees" (2010). RLFT are PGFT with some restrictions to 
16  * address real world constraints, which are not currently enforced (but it 
17  * should certainly be checked for)
18  */
19
20
21 class FatTreeNode {
22 public:
23   int id; // ID as given by the user, should be unique
24   int level; // The 0th level represents the leafs of the PGFT
25   int position; // Position in the level
26   
27   /* We can see the sizes sum of the two following vectors as the device 
28    * ports number. If we use the notations used in Zahavi's paper, 
29    * children.size() = m_level and parents.size() = w_(level+1)
30    * 
31    */
32   std::vector<FatTreeNode*> children;  // m, apply from lvl 0 to levels - 1 
33   std::vector<FatTreeNode*> parents; // w, apply from lvl 1 to levels
34   FatTreeNode(int id, int level=-1, int position=-1);
35 };
36
37 class FatTreeLink {
38 public:
39   unsigned int ports;
40   std::vector<s_sg_platf_link_cbarg_t> linksUp; // From source to destination
41   std::vector<s_sg_platf_link_cbarg_t> linksDown; // From destination to source
42   /* As it is symetric, it might as well be first / second instead
43    * of source / destination
44    */
45   FatTreeNode *source; 
46   FatTreeNode *destination;
47   //FatTreeLink(FatTreeNode *source, FatTreeNode *destination, unsigned int ports = 0);
48 };
49
50 class AsClusterFatTree : public AsCluster {
51 public:
52   AsClusterFatTree();
53   ~AsClusterFatTree();
54   virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst,
55                                   sg_platf_route_cbarg_t into,
56                                   double *latency) const;
57   // virtual void getRouteAndLatency(const int src, const int dst,
58   //                                 std::vector<NetworkLink> *route,
59   //                                 double *latency) const;
60   virtual void create_links(sg_platf_cluster_cbarg_t cluster);
61   void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster);
62   void addNodes(std::vector<int> const& id);
63   void generateDotFile(const string& filename = "fatTree.dot") const;
64
65 protected:
66   //description of a PGFT (TODO : better doc)
67   unsigned int levels;
68   std::vector<int> lowerLevelNodesNumber;
69   std::vector<int> upperLevelNodesNumber;
70   std::vector<int> lowerLevelPortsNumber;
71   
72   std::vector<FatTreeNode*> nodes;
73   std::map<std::pair<int,int>, FatTreeLink*> links;
74   std::vector<int> nodesByLevel;
75
76   void addLink(FatTreeNode *parent, FatTreeNode *child);
77   void getLevelPosition(const int level, int &position, int &size);
78 };
79 #endif