From 96f6f8fa81bf92c5367ca3a4cc7761c445379d6e Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Castelli?= Date: Wed, 16 Apr 2014 09:47:06 +0200 Subject: [PATCH 1/1] [Fat Trees] Function generating dot files should be working, yet to be tested FatTreeLink got its members public --- src/surf/surf_routing_cluster_fat_tree.cpp | 29 +++++++++++----------- src/surf/surf_routing_cluster_fat_tree.hpp | 4 +-- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/surf/surf_routing_cluster_fat_tree.cpp b/src/surf/surf_routing_cluster_fat_tree.cpp index f852c3682b..44fa45b9f8 100644 --- a/src/surf/surf_routing_cluster_fat_tree.cpp +++ b/src/surf/surf_routing_cluster_fat_tree.cpp @@ -134,25 +134,24 @@ void AsClusterFatTree::parse_specific_arguments(sg_platf_cluster_cbarg_t void AsClusterFatTree::generateDotFile(string filename) { ofstream file; /* Maybe should we get directly a char*, as open takes strings only beginning - * with c++11... + * with C++11... */ file.open(filename.c_str(), ios::out | ios::trunc); if(file.is_open()) { - /* TODO : Iterate through a map takes 10 chars with c++11, 100 with c++98. - * All I have to do is write it down... - */ - - // file << "graph AsClusterFatTree {\n"; - // for (std::map, FatTreeLink*>::iterator link = this->links.begin() ; link != this->links.end() ; link++ ) { - // for (int j = 0 ; j < link->ports ; j++) { - // file << this->links[i]->source.id - // << " -- " this->links[i]->destination.id - // << ";\n"; - // } - // } - // file << "}"; - // file.close(); + // That could also be greatly clarified with C++11 + std::map,FatTreeLink*>::iterator iter; + file << "graph AsClusterFatTree {\n"; + for (iter = this->links.begin() ; iter != this->links.end() ; iter++ ) { + for (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; diff --git a/src/surf/surf_routing_cluster_fat_tree.hpp b/src/surf/surf_routing_cluster_fat_tree.hpp index 96ba5c97d0..1c8a865f71 100644 --- a/src/surf/surf_routing_cluster_fat_tree.hpp +++ b/src/surf/surf_routing_cluster_fat_tree.hpp @@ -34,15 +34,13 @@ public: }; class FatTreeLink { -private: +public: unsigned int ports; std::vector linksUp; // From source to destination std::vector linksDown; // From destination to source FatTreeNode source; FatTreeNode destination; -public: FatTreeLink(int source, int destination, unsigned int ports = 0); - NetworkLink getLink(int number = 0) const; }; class AsClusterFatTree : public AsCluster { -- 2.20.1