From 5234048c0ac16a4e720bc02d425ed85e3c11123d Mon Sep 17 00:00:00 2001 From: Paul Heinzlreiter Date: Fri, 1 Jul 2016 16:40:58 +0200 Subject: [PATCH] * debugging mpi type definition --- bh_tree_mpi/datastructures/Body.hpp | 1 + bh_tree_mpi/main.cpp | 1 - bh_tree_mpi/parallelization/MpiSimulation.cpp | 43 +++++++++++++++++++ bh_tree_mpi/parallelization/MpiSimulation.hpp | 1 + 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/bh_tree_mpi/datastructures/Body.hpp b/bh_tree_mpi/datastructures/Body.hpp index 1111804..498de36 100644 --- a/bh_tree_mpi/datastructures/Body.hpp +++ b/bh_tree_mpi/datastructures/Body.hpp @@ -9,6 +9,7 @@ namespace nbody { class Body { friend class Box; friend class Node; + friend class MpiSimulation; protected: double position[3]; double velocity[3]; diff --git a/bh_tree_mpi/main.cpp b/bh_tree_mpi/main.cpp index ba4b8a8..26864e9 100644 --- a/bh_tree_mpi/main.cpp +++ b/bh_tree_mpi/main.cpp @@ -10,7 +10,6 @@ int main(int argc, char* argv[]) { MpiSimulation simulation(argc, argv); if (argc == 2) { - vector bodies = Tree::dubinskiParse(argv[1]); cout << bodies.size() << endl; diff --git a/bh_tree_mpi/parallelization/MpiSimulation.cpp b/bh_tree_mpi/parallelization/MpiSimulation.cpp index d217a62..e3ccf04 100644 --- a/bh_tree_mpi/parallelization/MpiSimulation.cpp +++ b/bh_tree_mpi/parallelization/MpiSimulation.cpp @@ -1,13 +1,56 @@ +#include "../datastructures/Body.hpp" #include "MpiSimulation.hpp" namespace nbody { MpiSimulation::MpiSimulation(int& argc, char**& argv) { + MPI::Aint displacements[3]; + int blocklengths[3]; + Body example; + + MPI::Init(argc, argv); + displacements[0] = (MPI::Aint) ((MPI::Aint) (&example) - (MPI::Aint) (&example.position[0])); + displacements[1] = (MPI::Aint) ((MPI::Aint) (&example) - (MPI::Aint) (&example.velocity[0])); + displacements[2] = (MPI::Aint) ((MPI::Aint) (&example) - (MPI::Aint) (&example.mass)); + blocklengths[0] = 3; + blocklengths[1] = 3; + blocklengths[2] = 1; + this->mpiBody = MPI::Datatype(MPI::DOUBLE); + //this->mpiBody.Create_hindexed(3, blocklengths, displacements); + //this->mpiBody.Create_hindexed(1, &blocklengths[2], &displacements[0]); + mpiBody.Commit(); + + /* + MPI::Datatype datatypes[4] = {MPI::DOUBLE, MPI::DOUBLE, MPI::DOUBLE, MPI::UB}; + MPI::Aint displacements[4]; + int blocklengths[4] = {3, 3, 1, 1}; + MPI::Aint lb; + MPI::Aint extent; + Body example; + MPI::Init(argc, argv); + MPI::DOUBLE.Get_extent(lb, extent); + displacements[0] = (MPI::Aint) (&example.position[0] - &example.position[0]); + displacements[1] = (MPI::Aint) (&example.velocity[0] - &example.position[0]); + displacements[2] = (MPI::Aint) (&example.mass - &example.position[0]); + displacements[3] = (MPI::Aint) sizeof(Body); + mpiBody.Create_struct(4, blocklengths, displacements, datatypes); + mpiBody.Commit(); + this->mpiSize = MPI::COMM_WORLD.Get_size(); + this->mpiRank = MPI::COMM_WORLD.Get_rank(); + */ + /* + double position[3]; + double velocity[3]; + double acceleration[3]; + double mass; + bool refinement; + */ this->mpiSize = MPI::COMM_WORLD.Get_size(); this->mpiRank = MPI::COMM_WORLD.Get_rank(); } MpiSimulation::~MpiSimulation() { + this->mpiBody.Free(); MPI::Finalize(); } } diff --git a/bh_tree_mpi/parallelization/MpiSimulation.hpp b/bh_tree_mpi/parallelization/MpiSimulation.hpp index 105a460..0fa7e96 100644 --- a/bh_tree_mpi/parallelization/MpiSimulation.hpp +++ b/bh_tree_mpi/parallelization/MpiSimulation.hpp @@ -7,6 +7,7 @@ namespace nbody { class MpiSimulation : public Simulation { protected: + MPI::Datatype mpiBody; int mpiSize; int mpiRank; public: -- GitLab