Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[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 /* TODO : limiter link ? Loopback?
21  *
22  */
23
24 class FatTreeNode {
25 public:
26   int id; // ID as given by the user, should be unique
27   int level; // The 0th level represents the leafs of the PGFT
28   int position; // Position in the level
29   
30   /* We can see the sizes sum of the two following vectors as the device 
31    * ports number. If we use the notations used in Zahavi's paper, 
32    * children.size() = m_level and parents.size() = w_(level+1)
33    * 
34    */
35   std::vector<FatTreeNode*> children;  // m, apply from lvl 0 to levels - 1 
36   std::vector<FatTreeNode*> parents; // w, apply from lvl 1 to levels
37   FatTreeNode(int id, int level=-1, int position=-1);
38 };
39
40 class FatTreeLink {
41 public:
42   FatTreeLink(sg_platf_cluster_cbarg_t cluster, FatTreeNode *source,
43               FatTreeNode *destination, unsigned int ports = 0);
44   unsigned int ports;
45   /* Links are dependant of the chosen network model, but must implement 
46    * NetworkLink
47    */
48    std::vector<NetworkLink*> linksUp; // From source to destination
49   std::vector<NetworkLink*> linksDown; // From destination to source
50   /* As it is symetric, it might as well be first / second instead
51    * of source / destination
52    */
53   FatTreeNode *source; 
54   FatTreeNode *destination;
55 };
56
57 class AsClusterFatTree : public AsCluster {
58 public:
59   AsClusterFatTree();
60   ~AsClusterFatTree();
61   virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst,
62                                   sg_platf_route_cbarg_t into,
63                                   double *latency);
64   // virtual void getRouteAndLatency(const int src, const int dst,
65   //                                 std::vector<NetworkLink> *route,
66   //                                 double *latency) const;
67   virtual void create_links(sg_platf_cluster_cbarg_t cluster);
68   void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster);
69   void addNodes(std::vector<int> const& id);
70   void generateDotFile(const string& filename = "fatTree.dot") const;
71
72 protected:
73   //description of a PGFT (TODO : better doc)
74   unsigned int levels;
75   std::vector<int> lowerLevelNodesNumber; // number of children by node
76   std::vector<int> upperLevelNodesNumber; // number of parents by node
77   std::vector<int> lowerLevelPortsNumber; // ports between each level l and l-1
78   
79   std::vector<FatTreeNode*> nodes;
80   std::map<std::pair<int,int>, FatTreeLink*> links;
81   std::vector<unsigned int> nodesByLevel;
82
83   void addLink(sg_platf_cluster_cbarg_t cluster, FatTreeNode *parent,
84                FatTreeNode *child);
85   void getLevelPosition(const unsigned int level, int *position, int *size);
86 };
87 #endif