updated mpi-round-trip.cc

git-svn-id: svn://anubis/gvsu@233 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
josh 2008-11-18 00:15:09 +00:00
parent b613436557
commit c20e18d654

View File

@ -1,5 +1,5 @@
#include <iostream.h> #include <iostream>
#include <mpi.h> #include <mpi.h>
using namespace std; using namespace std;
@ -10,18 +10,18 @@ int main(int argc, char * argv[])
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
if (my_rank == MASTER) if (my_rank == 0)
{ {
int buf = 0; int buf = 0;
MPI_Recv(&buf, sizeof(buf), MPI_CHAR, MPI_Recv(&buf, sizeof(buf), MPI_CHAR,
MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD); MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
cout << "Master received " << buf << endl; cout << "Master received " << buf << endl;
} }
else else
{ {
int forty_two = 42; int forty_two = 42;
MPI_Send(&forty_two, sizeof(forty_two), MPI_CHAR, MPI_Send(&forty_two, sizeof(forty_two), MPI_CHAR,
MASTER, 42, MPI_COMM_WORLD); 0, 42, MPI_COMM_WORLD);
} }
MPI_Finalize(); MPI_Finalize();