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

* added test program

parent bf539406
Branches
No related merge requests found
#include <mpi.h>
#include <vector>
#include "datastructures/Body.hpp"
int main(int argc, char** argv) {
using namespace nbody;
using namespace std;
/*
MPI::Datatype Btype;
MPI::Datatype type[3] = {MPI::DOUBLE, MPI::DOUBLE, MPI::DOUBLE};
int blocks[3] = {3, 3, 1};
MPI::Aint disp[3];
//Body data[16];
vector<Body> data;
MPI::Init(argc, argv);
if (MPI::COMM_WORLD.Get_rank() == 0) {
for (int i = 0; i < 16; i++) {
Body b;
data.push_back(b);
}
} else {
data.reserve(16);
}
*/
MPI::Init(argc, argv);
MPI::Datatype Btype;
MPI::Datatype type[3] = {MPI::DOUBLE, MPI::DOUBLE, MPI::DOUBLE};
int blocks[3] = {3, 3, 1};
MPI::Aint disp[3];
Body data[16];
disp[0] = MPI::Get_address(data[0].position);
disp[1] = MPI::Get_address(data[0].velocity);
disp[2] = MPI::Get_address(&data[0].mass);
Btype = Btype.Create_struct(3, blocks, disp, type);
Btype.Commit();
MPI::COMM_WORLD.Bcast(MPI::BOTTOM, 16, Btype, 0);
Btype.Free();
MPI::Finalize();
return 0;
}
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