From 962dc9088023970281b691164cb95b5e37d0a8a6 Mon Sep 17 00:00:00 2001 From: Paul Heinzlreiter Date: Fri, 18 Nov 2016 09:58:56 +0100 Subject: [PATCH] * added descriptive output of current program phases being executed --- bhtree_mpi/src/mpimain.cpp | 10 ++++++++++ bhtree_mpi/src/simulation/MpiSimulation.cpp | 16 +++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/bhtree_mpi/src/mpimain.cpp b/bhtree_mpi/src/mpimain.cpp index 484813a..adffa3b 100644 --- a/bhtree_mpi/src/mpimain.cpp +++ b/bhtree_mpi/src/mpimain.cpp @@ -20,13 +20,23 @@ int main(int argc, char* argv[]) { MPI_Comm_rank(MPI_COMM_WORLD, &rank); //initialize and load particles + cout << " " << "rank " << rank << ": initialize..." << endl; + if (rank == 0) { + cout << " " << "rank 0: load particles ..." << endl; + } simulation.initialize(string(argv[1])); //initial particle and domain distribution + if (rank == 0) { + cout << " " << "rank 0: distribute particles to other processes ..." << endl; + } simulation.distributeBodies(); + cout << " " << "rank " << rank << ": distributing initial domains to other processes ..." << endl; simulation.distributeDomains(); + cout << " " << "rank " << rank << ": building initial trees ..." << endl; simulation.buildTree(); for (int i = 0; i < 3; i++) { //local tree is built and correct domains are distributed + cout << "running simulation step " << i << " ..." << endl; simulation.runStep(); } simulation.cleanup(); diff --git a/bhtree_mpi/src/simulation/MpiSimulation.cpp b/bhtree_mpi/src/simulation/MpiSimulation.cpp index c0b76db..d06e2a7 100644 --- a/bhtree_mpi/src/simulation/MpiSimulation.cpp +++ b/bhtree_mpi/src/simulation/MpiSimulation.cpp @@ -61,11 +61,13 @@ namespace nbody { this->correctState = true; this->tree = new BarnesHutTree(this->parallelRank); - //parse input data - if (!inputFile.empty()) { - this->correctState = this->readInputData(inputFile); - } else { - this->correctState = false; + if (this->parallelRank == 0) { + //parse input data + if (!inputFile.empty()) { + this->correctState = this->readInputData(inputFile); + } else { + this->correctState = false; + } } //broadcast current state and terminate if input file cannot be read MPI_Bcast(&this->correctState, 1, MPI_INT, 0, MPI_COMM_WORLD); @@ -260,12 +262,16 @@ namespace nbody { //tree is already built here //distribute local bodies needed by remote processes + cout << " " << "rank " << this->parallelRank << ": distribute local particles required for remote simulation ..." << endl; this->distributeLETs(); //force computation + cout << " " << "rank " << this->parallelRank << ": compute forces ..." << endl; this->tree->computeForces(); //advance/move particles and distribute updated domain to other processes + cout << " " << "rank " << this->parallelRank << ": move particles and redistribute simulation domains ..." << endl; this->distributeDomains(this->tree->advance()); //rebuild tree with new particle positions + cout << " " << "rank " << this->parallelRank << ": rebuild tree with new particle positions ..." << endl; this->rebuildTree(); if (!this->tree->isCorrect()) { cerr << "wrong tree" << endl; -- GitLab