Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Beginning of the implemenation of fat tree. Parsing methods for special arguments...
[simgrid.git] / src / surf / surf_routing_cluster_fat_tree.cpp
1 #include "surf_routing_cluster_fat_tree.hpp"
2
3 #include <boost/algorithm/string/split.hpp>
4 #include <boost/algorithm/string/classification.hpp>
5
6
7 AsClusterFatTree::AsClusterFatTree() : levels(0) {}
8
9
10
11 void AsClusterFatTree::getRouteAndLatency(RoutingEdgePtr src,
12                                           RoutingEdgePtr dst,
13                                           sg_platf_route_cbarg_t into,
14                                           double *latency) {
15   // TODO
16 }
17
18 void AsClusterFatTree::create_links() {
19   if(this->levels == 0) {
20     return;
21   }
22   
23   //  for (unsigned int i = 0 ; i < this->levels)
24
25 }
26
27
28
29 void AsClusterFatTree::parse_specific_arguments(sg_platf_cluster_cbarg_t 
30                                                 cluster) {
31   std::vector<string> parameters;
32   std::vector<string> tmp;
33   boost::split(parameters, cluster->topo_parameters, boost::is_any_of(";"));
34   
35   if (parameters.size() != 4){
36     surf_parse_error("Fat trees are defined by the levels number et 3 vectors," 
37                      " see the documentation for more informations");
38     // Well, there's no doc, yet
39   }
40
41   // The first parts of topo_parameters should be the levels number
42   this->levels = std::atoi(tmp[0].c_str());
43
44   // Then, a l-sized vector standing for the childs number by level
45   boost::split(tmp, parameters[1], boost::is_any_of(","));
46   if(tmp.size() != this->levels) {
47     surf_parse_error("Fat trees are defined by the levels number et 3 vectors," 
48                      " see the documentation for more informations"); 
49   }
50   for(unsigned int i = 0 ; i < tmp.size() ; i++){
51     this->lowerLevelNodesNumber.push_back(std::atoi(tmp[i].c_str())); 
52   }
53   
54   // Then, a l-sized vector standing for the parents number by level
55    boost::split(tmp, parameters[2], boost::is_any_of(","));
56   if(tmp.size() != this->levels) {
57     surf_parse_error("Fat trees are defined by the levels number et 3 vectors," 
58                      " see the documentation for more informations"); 
59   }
60   for(unsigned int i = 0 ; i < tmp.size() ; i++){
61     this->upperLevelNodesNumber.push_back(std::atoi(tmp[i].c_str())); 
62   }
63   
64   // Finally, a l-sized vector standing for the ports number with the lower level
65   boost::split(tmp, parameters[3], boost::is_any_of(","));
66   if(tmp.size() != this->levels) {
67     surf_parse_error("Fat trees are defined by the levels number et 3 vectors," 
68                      " see the documentation for more informations"); 
69     
70   }
71   for(unsigned int i = 0 ; i < tmp.size() ; i++){
72     this->lowerLevelPortsNumber.push_back(std::atoi(tmp[i].c_str())); 
73   }
74 }
75