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)
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
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)
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);
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
46 FatTreeNode *destination;
47 //FatTreeLink(FatTreeNode *source, FatTreeNode *destination, unsigned int ports = 0);
50 class AsClusterFatTree : public AsCluster {
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;
66 //description of a PGFT (TODO : better doc)
68 std::vector<int> lowerLevelNodesNumber;
69 std::vector<int> upperLevelNodesNumber;
70 std::vector<int> lowerLevelPortsNumber;
72 std::vector<FatTreeNode*> nodes;
73 std::map<std::pair<int,int>, FatTreeLink*> links;
74 std::vector<int> nodesByLevel;
76 void addLink(FatTreeNode *parent, FatTreeNode *child);
77 void getLevelPosition(const int level, int &position, int &size);