Parcourir la source

pdevs/mpi: add path

Eric Ramat il y a 7 ans
Parent
commit
b28640eb5b
1 fichiers modifiés avec 23 ajouts et 34 suppressions
  1. 23 34
      src/tests/mpi/cluster/main.cpp

+ 23 - 34
src/tests/mpi/cluster/main.cpp

@@ -51,14 +51,11 @@ std::vector < std::vector < std::pair <
 			      std::pair < int, int >,
 			      std::pair < int, int > > > > parents;
 
-void read_graphs()
+void read_graphs(const std::string& path)
 {
-
-  // std::cout << "READ GRAPHS" << std::endl;
-  
   for (int index = 0; index < clusters.size(); ++index) {
     std::stringstream ss;
-    ss << "../data/cluster/graphe/graphe_" << index << ".txt";
+    ss << path << "graphe/graphe_" << index << ".txt";
     std::ifstream graphFile(ss.str());
 
     graphs.push_back(std::vector < std::pair < int, int > >());
@@ -78,14 +75,11 @@ void read_graphs()
   }
 }
 
-void read_inputs()
+void read_inputs(const std::string& path)
 {
-
-  // std::cout << "READ INPUTS" << std::endl;
-  
   for (int index = 0; index < clusters.size(); ++index) {
     std::stringstream ss;
-    ss << "../data/cluster/input_edges/input_edges_" << index << ".txt";
+    ss << path << "input_edges/input_edges_" << index << ".txt";
     std::ifstream inputsFile(ss.str());
 
     inputs.push_back(std::vector < std::pair < int, int > >());
@@ -105,14 +99,11 @@ void read_inputs()
   }
 }
 
-void read_outputs()
+void read_outputs(const std::string& path)
 {
-
-  // std::cout << "READ OUTPUTS" << std::endl;
-  
   for (int index = 0; index < clusters.size(); ++index) {
     std::stringstream ss;
-    ss << "../data/cluster/output_edges/output_edges_" << index << ".txt";
+    ss << path << "output_edges/output_edges_" << index << ".txt";
     std::ifstream outputsFile(ss.str());
 
     outputs.push_back(std::vector < std::pair < int, int > >());
@@ -132,14 +123,11 @@ void read_outputs()
   }
 }
 
-void read_parents()
+void read_parents(const std::string& path)
 {
-
-  // std::cout << "READ PARENTS" << std::endl;
-  
   for (int index = 0; index < clusters.size(); ++index) {
     std::stringstream ss;
-    ss << "../data/cluster/parent_connection/parent_connection_" << index
+    ss << path << "parent_connection/parent_connection_" << index
        << ".txt";
     std::ifstream parentsFile(ss.str());
 
@@ -164,12 +152,11 @@ void read_parents()
   }
 }
 
-void read()
+void read(const std::string& path)
 {
-
-  // std::cout << "READ CLUSTERS" << std::endl;
-  
-  std::ifstream clusterFile("../data/cluster/partition.txt");
+  std::stringstream ss;
+  ss << path << "partition.txt";
+  std::ifstream clusterFile(ss.str());
 
   while (not clusterFile.eof()) {
     std::string str;
@@ -190,10 +177,10 @@ void read()
     }
   }
   clusterFile.close();
-  read_graphs();
-  read_inputs();
-  read_outputs();
-  read_parents();
+  read_graphs(path);
+  read_inputs(path);
+  read_outputs(path);
+  read_parents(path);
 }
 
 void example_simple(int argc, char *argv[])
@@ -201,8 +188,6 @@ void example_simple(int argc, char *argv[])
     environment env(argc, argv);
     communicator world;
 
-    // std::cout << "START " << world.rank() << std::endl;
-    
     if (world.rank() == 0) {
         paradevs::tests::mpi::cluster::RootGraphManagerParameters parameters;
 
@@ -252,7 +237,11 @@ void example_simple(int argc, char *argv[])
 
 int main(int argc, char *argv[])
 {
-  read();
-  example_simple(argc, argv);
-  return 0;
+  if (argc == 2) {
+    read(argv[1]);
+    example_simple(argc, argv);
+    return 0;
+  } else {
+    return -1;
+  }
 }