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

* mpi communictaion testing

parent 13ae570d
Branches
No related merge requests found
......@@ -31,22 +31,25 @@ int main(int argc, char** argv) {
restype = restype.Create_struct(3, blocklengths, displacements, datatypes);
restype.Commit();
A a;
A a[4];
if (MPI::COMM_WORLD.Get_rank() == 0) {
a.num = 1;
a.x = 2.0;
for (int i = 0; i < 4; i++) {
a.data[i] = a.x + 1 + i;
for (int j = 0; j < 4; j++) {
a[j].num = j * 10.0 + 1;
a[j].x = j * 10.0 + 2.0;
for (int i = 0; i < 4; i++) {
a[j].data[i] = j * 10.0 + a[j].x + 1 + i;
}
}
MPI::COMM_WORLD.Send(&a, 1, restype, 1, 0);
MPI::COMM_WORLD.Send(&a[0], 4, restype, 1, 0);
} else if (MPI::COMM_WORLD.Get_rank() == 1) {
MPI::COMM_WORLD.Recv(&a, 1, restype, 0, 0);
cout << a.num << " " << a.x << " ";
for (int i = 0; i < 4; i++) {
cout << a.data[i] << " ";
MPI::COMM_WORLD.Recv(&a[0], 4, restype, 0, 0);
for (int j = 0; j < 4; j++) {
cout << a[j].num << " " << a[j].x << " ";
for (int i = 0; i < 4; i++) {
cout << a[j].data[i] << " ";
}
cout << endl;
}
cout << endl;
}
MPI::Finalize();
......
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