gvsu/cs677/hw6/src/mpi-round-trip.cc
josh b613436557 added hw6/src directory with initial test
git-svn-id: svn://anubis/gvsu@232 45c1a28c-8058-47b2-ae61-ca45b979098e
2008-11-18 00:10:08 +00:00

31 lines
591 B
C++

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