|
@@ -44,7 +44,7 @@ using namespace paradevs::common;
|
|
|
using namespace boost::mpi;
|
|
|
using namespace std::chrono;
|
|
|
|
|
|
-std::vector < std::vector < int > > clusters;
|
|
|
+std::vector < std::vector < std::pair < int, int > > > clusters;
|
|
|
std::vector < std::vector < std::pair < int, int > > > graphs;
|
|
|
std::vector < std::vector < std::pair < int, int > > > inputs;
|
|
|
std::vector < std::vector < std::pair < int, int > > > outputs;
|
|
@@ -54,134 +54,145 @@ std::vector < std::vector < std::pair <
|
|
|
|
|
|
void read_graphs(const std::string& path)
|
|
|
{
|
|
|
- for (int index = 0; index < clusters.size(); ++index) {
|
|
|
- std::stringstream ss;
|
|
|
- ss << path << "graphe/graphe_" << index << ".txt";
|
|
|
- std::ifstream graphFile(ss.str());
|
|
|
-
|
|
|
- graphs.push_back(std::vector < std::pair < int, int > >());
|
|
|
- while (not graphFile.eof()) {
|
|
|
- std::string str;
|
|
|
- std::vector < std::string > strs;
|
|
|
-
|
|
|
- std::getline(graphFile, str);
|
|
|
- if (str.size() > 0) {
|
|
|
- boost::split(strs, str, boost::is_any_of(" "));
|
|
|
- graphs[graphs.size() - 1].
|
|
|
- push_back(std::make_pair(boost::lexical_cast < int >(strs[0]),
|
|
|
- boost::lexical_cast < int >(strs[1])));
|
|
|
- }
|
|
|
+ for (unsigned int index = 0; index < clusters.size(); ++index) {
|
|
|
+ std::stringstream ss;
|
|
|
+ ss << path << "graphe/graphe_" << index << ".txt";
|
|
|
+ std::ifstream graphFile(ss.str());
|
|
|
+
|
|
|
+ graphs.push_back(std::vector < std::pair < int, int > >());
|
|
|
+ while (not graphFile.eof()) {
|
|
|
+ std::string str;
|
|
|
+ std::vector < std::string > strs;
|
|
|
+
|
|
|
+ std::getline(graphFile, str);
|
|
|
+ if (str.size() > 0) {
|
|
|
+ boost::split(strs, str, boost::is_any_of(" "));
|
|
|
+ graphs[graphs.size() - 1].
|
|
|
+ push_back(std::make_pair(
|
|
|
+ boost::lexical_cast < int >(strs[0]),
|
|
|
+ boost::lexical_cast < int >(strs[1])));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ graphFile.close();
|
|
|
}
|
|
|
- graphFile.close();
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
void read_inputs(const std::string& path)
|
|
|
{
|
|
|
- for (int index = 0; index < clusters.size(); ++index) {
|
|
|
- std::stringstream ss;
|
|
|
- ss << path << "input_edges/input_edges_" << index << ".txt";
|
|
|
- std::ifstream inputsFile(ss.str());
|
|
|
-
|
|
|
- inputs.push_back(std::vector < std::pair < int, int > >());
|
|
|
- while (not inputsFile.eof()) {
|
|
|
- std::string str;
|
|
|
- std::vector < std::string > strs;
|
|
|
-
|
|
|
- std::getline(inputsFile, str);
|
|
|
- if (str.size() > 0) {
|
|
|
- boost::split(strs, str, boost::is_any_of(" "));
|
|
|
- inputs[inputs.size() - 1].
|
|
|
- push_back(std::make_pair(boost::lexical_cast < int >(strs[0]),
|
|
|
- boost::lexical_cast < int >(strs[1])));
|
|
|
- }
|
|
|
+ for (unsigned int index = 0; index < clusters.size(); ++index) {
|
|
|
+ std::stringstream ss;
|
|
|
+ ss << path << "input_edges/input_edges_" << index << ".txt";
|
|
|
+ std::ifstream inputsFile(ss.str());
|
|
|
+
|
|
|
+ inputs.push_back(std::vector < std::pair < int, int > >());
|
|
|
+ while (not inputsFile.eof()) {
|
|
|
+ std::string str;
|
|
|
+ std::vector < std::string > strs;
|
|
|
+
|
|
|
+ std::getline(inputsFile, str);
|
|
|
+ if (str.size() > 0) {
|
|
|
+ boost::split(strs, str, boost::is_any_of(" "));
|
|
|
+ inputs[inputs.size() - 1].
|
|
|
+ push_back(std::make_pair(
|
|
|
+ boost::lexical_cast < int >(strs[0]),
|
|
|
+ boost::lexical_cast < int >(strs[1])));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ inputsFile.close();
|
|
|
}
|
|
|
- inputsFile.close();
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
void read_outputs(const std::string& path)
|
|
|
{
|
|
|
- for (int index = 0; index < clusters.size(); ++index) {
|
|
|
- std::stringstream ss;
|
|
|
- ss << path << "output_edges/output_edges_" << index << ".txt";
|
|
|
- std::ifstream outputsFile(ss.str());
|
|
|
-
|
|
|
- outputs.push_back(std::vector < std::pair < int, int > >());
|
|
|
- while (not outputsFile.eof()) {
|
|
|
- std::string str;
|
|
|
- std::vector < std::string > strs;
|
|
|
-
|
|
|
- std::getline(outputsFile, str);
|
|
|
- if (str.size() > 0) {
|
|
|
- boost::split(strs, str, boost::is_any_of(" "));
|
|
|
- outputs[outputs.size() - 1].
|
|
|
- push_back(std::make_pair(boost::lexical_cast < int >(strs[0]),
|
|
|
- boost::lexical_cast < int >(strs[1])));
|
|
|
- }
|
|
|
+ for (unsigned int index = 0; index < clusters.size(); ++index) {
|
|
|
+ std::stringstream ss;
|
|
|
+ ss << path << "output_edges/output_edges_" << index << ".txt";
|
|
|
+ std::ifstream outputsFile(ss.str());
|
|
|
+
|
|
|
+ outputs.push_back(std::vector < std::pair < int, int > >());
|
|
|
+ while (not outputsFile.eof()) {
|
|
|
+ std::string str;
|
|
|
+ std::vector < std::string > strs;
|
|
|
+
|
|
|
+ std::getline(outputsFile, str);
|
|
|
+ if (str.size() > 0) {
|
|
|
+ boost::split(strs, str, boost::is_any_of(" "));
|
|
|
+ outputs[outputs.size() - 1].
|
|
|
+ push_back(std::make_pair(
|
|
|
+ boost::lexical_cast < int >(strs[0]),
|
|
|
+ boost::lexical_cast < int >(strs[1])));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ outputsFile.close();
|
|
|
}
|
|
|
- outputsFile.close();
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
void read_parents(const std::string& path)
|
|
|
{
|
|
|
- for (int index = 0; index < clusters.size(); ++index) {
|
|
|
- std::stringstream ss;
|
|
|
- ss << path << "parent_connection/parent_connection_" << index
|
|
|
- << ".txt";
|
|
|
- std::ifstream parentsFile(ss.str());
|
|
|
-
|
|
|
- parents.push_back(std::vector < std::pair < std::pair < int, int >,
|
|
|
- std::pair < int, int > > >());
|
|
|
- while (not parentsFile.eof()) {
|
|
|
- std::string str;
|
|
|
- std::vector < std::string > strs;
|
|
|
-
|
|
|
- std::getline(parentsFile, str);
|
|
|
- if (str.size() > 0) {
|
|
|
- boost::split(strs, str, boost::is_any_of(" "));
|
|
|
- parents[parents.size() - 1].
|
|
|
- push_back(std::make_pair(
|
|
|
- std::make_pair(boost::lexical_cast < int >(strs[0]),
|
|
|
- boost::lexical_cast < int >(strs[1])),
|
|
|
- std::make_pair(boost::lexical_cast < int >(strs[2]),
|
|
|
- boost::lexical_cast < int >(strs[3]))));
|
|
|
- }
|
|
|
+ for (unsigned int index = 0; index < clusters.size(); ++index) {
|
|
|
+ std::stringstream ss;
|
|
|
+ ss << path << "parent_connection/parent_connection_" << index
|
|
|
+ << ".txt";
|
|
|
+ std::ifstream parentsFile(ss.str());
|
|
|
+
|
|
|
+ parents.push_back(std::vector < std::pair < std::pair < int, int >,
|
|
|
+ std::pair < int, int > > >());
|
|
|
+ while (not parentsFile.eof()) {
|
|
|
+ std::string str;
|
|
|
+ std::vector < std::string > strs;
|
|
|
+
|
|
|
+ std::getline(parentsFile, str);
|
|
|
+ if (str.size() > 0) {
|
|
|
+ boost::split(strs, str, boost::is_any_of(" "));
|
|
|
+ parents[parents.size() - 1].
|
|
|
+ push_back(
|
|
|
+ std::make_pair(
|
|
|
+ std::make_pair(
|
|
|
+ boost::lexical_cast < int >(strs[0]),
|
|
|
+ boost::lexical_cast < int >(strs[1])),
|
|
|
+ std::make_pair(
|
|
|
+ boost::lexical_cast < int >(strs[2]),
|
|
|
+ boost::lexical_cast < int >(strs[3]))));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ parentsFile.close();
|
|
|
}
|
|
|
- parentsFile.close();
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
void read(const std::string& path)
|
|
|
{
|
|
|
- std::stringstream ss;
|
|
|
- ss << path << "partition.txt";
|
|
|
- std::ifstream clusterFile(ss.str());
|
|
|
-
|
|
|
- while (not clusterFile.eof()) {
|
|
|
- std::string str;
|
|
|
- std::vector < std::string > strs;
|
|
|
-
|
|
|
- std::getline(clusterFile, str);
|
|
|
- boost::split(strs, str, boost::is_any_of(" "));
|
|
|
-
|
|
|
- if (str.size() > 0) {
|
|
|
- clusters.push_back(std::vector < int >());
|
|
|
- for (std::vector < std::string >::const_iterator it = strs.begin();
|
|
|
- it != strs.end(); ++it) {
|
|
|
- if (it->size() > 0) {
|
|
|
- clusters[clusters.size() - 1].
|
|
|
- push_back(boost::lexical_cast < int >(*it));
|
|
|
- }
|
|
|
- }
|
|
|
+ std::stringstream ss;
|
|
|
+ ss << path << "partition.txt";
|
|
|
+ std::ifstream clusterFile(ss.str());
|
|
|
+
|
|
|
+ while (not clusterFile.eof()) {
|
|
|
+ std::string str;
|
|
|
+ std::vector < std::string > strs;
|
|
|
+
|
|
|
+ std::getline(clusterFile, str);
|
|
|
+ boost::split(strs, str, boost::is_any_of(" "));
|
|
|
+
|
|
|
+ if (str.size() > 0) {
|
|
|
+ clusters.push_back(std::vector < std::pair < int, int > >());
|
|
|
+ for (std::vector < std::string >::const_iterator it = strs.begin();
|
|
|
+ it != strs.end();) {
|
|
|
+ if (it->size() > 0) {
|
|
|
+ int index = boost::lexical_cast < int >(*it);
|
|
|
+
|
|
|
+ ++it;
|
|
|
+ clusters[clusters.size() - 1].
|
|
|
+ push_back(std::make_pair(
|
|
|
+ index, boost::lexical_cast < int >(*it)));
|
|
|
+ }
|
|
|
+ ++it;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- clusterFile.close();
|
|
|
- read_graphs(path);
|
|
|
- read_inputs(path);
|
|
|
- read_outputs(path);
|
|
|
- read_parents(path);
|
|
|
+ clusterFile.close();
|
|
|
+ read_graphs(path);
|
|
|
+ read_inputs(path);
|
|
|
+ read_outputs(path);
|
|
|
+ read_parents(path);
|
|
|
}
|
|
|
|
|
|
void example_simple(int argc, char *argv[])
|
|
@@ -223,14 +234,14 @@ void example_simple(int argc, char *argv[])
|
|
|
parameters.internals = graphs[world.rank() - 1];
|
|
|
ss << "S" << world.rank();
|
|
|
paradevs::pdevs::mpi::Coordinator <
|
|
|
- DoubleTime,
|
|
|
- paradevs::tests::mpi::cluster::SubGraphManager,
|
|
|
- paradevs::common::NoParameters,
|
|
|
- paradevs::tests::mpi::cluster::SubGraphManagerParameters >
|
|
|
- model(ss.str(), paradevs::common::NoParameters(), parameters);
|
|
|
+ DoubleTime,
|
|
|
+ paradevs::tests::mpi::cluster::SubGraphManager,
|
|
|
+ paradevs::common::NoParameters,
|
|
|
+ paradevs::tests::mpi::cluster::SubGraphManagerParameters >
|
|
|
+ model(ss.str(), paradevs::common::NoParameters(), parameters);
|
|
|
paradevs::pdevs::mpi::LogicalProcessor <
|
|
|
- DoubleTime > LP(&model, world.rank(), 0);
|
|
|
-
|
|
|
+ DoubleTime > LP(&model, world.rank(), 0);
|
|
|
+
|
|
|
model.set_logical_processor(&LP);
|
|
|
LP.loop();
|
|
|
}
|
|
@@ -238,11 +249,11 @@ void example_simple(int argc, char *argv[])
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
{
|
|
|
- if (argc == 2) {
|
|
|
- read(argv[1]);
|
|
|
- example_simple(argc, argv);
|
|
|
- return 0;
|
|
|
- } else {
|
|
|
- return -1;
|
|
|
- }
|
|
|
+ if (argc == 2) {
|
|
|
+ read(argv[1]);
|
|
|
+ example_simple(argc, argv);
|
|
|
+ return 0;
|
|
|
+ } else {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
}
|