updated mpi-round-trip.cc
git-svn-id: svn://anubis/gvsu@233 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
b613436557
commit
c20e18d654
@ -1,5 +1,5 @@
|
||||
|
||||
#include <iostream.h>
|
||||
#include <iostream>
|
||||
#include <mpi.h>
|
||||
using namespace std;
|
||||
|
||||
@ -10,18 +10,18 @@ int main(int argc, char * argv[])
|
||||
MPI_Init(&argc, &argv);
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
|
||||
|
||||
if (my_rank == MASTER)
|
||||
if (my_rank == 0)
|
||||
{
|
||||
int buf = 0;
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
int forty_two = 42;
|
||||
MPI_Send(&forty_two, sizeof(forty_two), MPI_CHAR,
|
||||
MASTER, 42, MPI_COMM_WORLD);
|
||||
0, 42, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
MPI_Finalize();
|
||||
|
Loading…
x
Reference in New Issue
Block a user