Skip to content
Snippets Groups Projects
Commit be888bca authored by Paul Heinzlreiter's avatar Paul Heinzlreiter
Browse files

* fixed mpi struct declaration

parent 5234048c
Branches
No related merge requests found
......@@ -3,48 +3,19 @@
namespace nbody {
MpiSimulation::MpiSimulation(int& argc, char**& argv) {
MPI::Aint displacements[3];
int blocklengths[3];
MPI::Datatype types[5] = {MPI::LB, MPI::DOUBLE, MPI::DOUBLE, MPI::DOUBLE, MPI::UB};
int blocklengths[5] = {1, 3, 3, 1, 1};
MPI::Aint displacements[5];
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;
*/
displacements[0] = MPI::Get_address(&example);
displacements[1] = MPI::Get_address(&example.position[0]);
displacements[2] = MPI::Get_address(&example.acceleration[0]);
displacements[3] = MPI::Get_address(&example.mass);
displacements[4] = MPI::Get_address(&example + sizeof(Body));
this->mpiBody = this->mpiBody.Create_struct(5, blocklengths, displacements, types);
this->mpiBody.Commit();
this->mpiSize = MPI::COMM_WORLD.Get_size();
this->mpiRank = MPI::COMM_WORLD.Get_rank();
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment