diff --git a/bh_tree_mpi/datastructures/Body.hpp b/bh_tree_mpi/datastructures/Body.hpp index 1111804f6e73f90eccadbd41e59ab81e68f55fa5..498de36fc23803020acbcd241bb454f1255d8f5e 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 ba4b8a890577e2195f9a0d803357c17bea5e3cbb..26864e9c76a15942796155a09f941644c2d41c5d 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 d217a62a756d18f9324198a74e310e26cf45c9c6..e3ccf04709e821f2576271cdd631651cd869fd7e 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 105a4602c7212e9abe0eb9ef84d2c4fd54d2a799..0fa7e96a6a00b7bfb3817c1016597404858f5c95 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: