#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(); } }