+ if(file.is_open()) {
+ // That could also be greatly clarified with C++11
+ std::map<std::pair<int,int>,FatTreeLink*>::const_iterator iter;
+ file << "graph AsClusterFatTree {\n";
+ for (iter = this->links.begin() ; iter != this->links.end() ; iter++ ) {
+ for (unsigned int j = 0 ; j < iter->second->ports ; j++) {
+ file << iter->second->source->id
+ << " -- "
+ << iter->second->destination->id
+ << ";\n";
+ }
+ }
+ file << "}";
+ file.close();
+ }
+ else {
+ std::cerr << "Unable to open file " << filename << std::endl;
+ return;
+ }
+}
+
+FatTreeNode::FatTreeNode(int id, int level, int position) : id(id),
+ level(level),
+ position(position){}
+
+FatTreeLink::FatTreeLink(sg_platf_cluster_cbarg_t cluster, FatTreeNode *source,
+ FatTreeNode *destination,
+ unsigned int ports) : ports(ports), source(source),
+ destination(destination) {
+ s_sg_platf_link_cbarg_t linkTemplate;
+ linkTemplate.bandwidth = cluster->bw;
+ linkTemplate.latency = cluster->lat;
+ linkTemplate.state = SURF_RESOURCE_ON;
+ linkTemplate.policy = cluster->sharing_policy; // Maybe should we do sthg with that ?
+
+ for(unsigned int i = 0 ; i < ports ; i++) {
+ NetworkLink* link;
+ linkTemplate.id = bprintf("link_from_%d_to_%d_%d_UP", source->id, destination->id, i);
+ sg_platf_new_link(&linkTemplate);
+ link = (NetworkLink*) xbt_lib_get_or_null(link_lib, linkTemplate.id, SURF_LINK_LEVEL);
+ this->linksUp.push_back(link); // check link?
+ linkTemplate.id = bprintf("link_from_%d_to_%d_%d_DOWN", source->id, destination->id, i);
+ sg_platf_new_link(&linkTemplate);
+ link = (NetworkLink*) xbt_lib_get_or_null(link_lib, linkTemplate.id, SURF_LINK_LEVEL);
+ this->linksDown.push_back(link); // check link ?
+ }
+}