added hw6/src directory with initial test

git-svn-id: svn://anubis/gvsu@232 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
josh 2008-11-18 00:10:08 +00:00
parent fb79f823d0
commit b613436557
2 changed files with 41 additions and 0 deletions

11
cs677/hw6/src/Makefile Normal file
View File

@ -0,0 +1,11 @@
FILE := mpi-round-trip
TARGET := $(FILE)
all: $(TARGET)
$(TARGET): $(FILE).cc
mpiCC -o $@ $<
clean:
-rm -f *.o *~ $(TARGET)

View File

@ -0,0 +1,30 @@
#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;
}