1 /* Copyright (c) 2014. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #include "surf_routing_cluster.hpp"
9 #ifndef SURF_ROUTING_CLUSTER_FAT_TREE_HPP_
10 #define SURF_ROUTING_CLUSTER_FAT_TREE_HPP_
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)
20 /* TODO : limiter link ? Loopback?
27 * \brief A node in a fat tree
31 /* \brief Unique ID which identifies every node
34 /* \brief Level into the tree, with 0 being the leafs
37 /* \brief Position into the level, starting from 0
39 unsigned int position;
40 /* In order to link nodes between them, each one must be assigned a label,
41 * consisting of l integers, l being the levels number of the tree. Each label
42 * is unique in the level, and the way it is generated allows the construction
43 * of a fat tree which fits the desired topology
45 std::vector<unsigned int> label;
47 /* Links to the lower level, where the position in the vector corresponds to
50 std::vector<FatTreeLink*> children;
51 /* Links to the upper level, where the position in the vector corresponds to
54 std::vector<FatTreeLink*> parents;
56 NetworkLink* limiterLink;
57 NetworkLink* loopback;
58 FatTreeNode(sg_platf_cluster_cbarg_t cluster, int id, int level,
64 FatTreeLink(sg_platf_cluster_cbarg_t cluster, FatTreeNode *source,
65 FatTreeNode *destination);
66 /* Links are dependant of the chosen network model, but must implement
70 NetworkLink *downLink;
72 FatTreeNode *downNode;
75 class AsClusterFatTree : public AsCluster {
79 virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst,
80 sg_platf_route_cbarg_t into,
82 // virtual void getRouteAndLatency(const int src, const int dst,
83 // std::vector<NetworkLink> *route,
84 // double *latency) const;
85 virtual void create_links();
86 void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster);
87 void addProcessingNode(int id);
88 void generateDotFile(const string& filename = "fatTree.dot") const;
92 //description of a PGFT (TODO : better doc)
94 std::vector<unsigned int> lowerLevelNodesNumber; // number of children by node
95 std::vector<unsigned int> upperLevelNodesNumber; // number of parents by node
96 std::vector<unsigned int> lowerLevelPortsNumber; // ports between each level l and l-1
98 std::map<int, FatTreeNode*> computeNodes;
99 std::vector<FatTreeNode*> nodes;
100 std::vector<FatTreeLink*> links;
101 std::vector<unsigned int> nodesByLevel;
103 sg_platf_cluster_cbarg_t cluster;
105 void addLink(FatTreeNode *parent, unsigned int parentPort,
106 FatTreeNode *child, unsigned int childPort);
107 int getLevelPosition(const unsigned int level);
108 void generateLabels();
109 void generateSwitches();
110 int connectNodeToParents(FatTreeNode *node);
111 bool areRelated(FatTreeNode *parent, FatTreeNode *child);
112 bool isInSubTree(FatTreeNode *root, FatTreeNode *node);