From: W. Trevor King Date: Wed, 27 Oct 2010 12:20:52 +0000 (-0400) Subject: Use MPI_ANY_SOURCE when receiving sorted lists in sorting/soln/main.c. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=92635ba9e9e86cef31e262c4046479dd4192705b;p=parallel_computing.git Use MPI_ANY_SOURCE when receiving sorted lists in sorting/soln/main.c. --- diff --git a/assignments/archive/sorting/soln/main.c b/assignments/archive/sorting/soln/main.c index be238b4..0810318 100644 --- a/assignments/archive/sorting/soln/main.c +++ b/assignments/archive/sorting/soln/main.c @@ -275,17 +275,18 @@ void master(int rank, int size, const char *file_name) } for (i = 1; i < size; i++) { -#ifdef DEBUG - fprintf(stderr, "receive sorted data chunk from node %d\n", i); -#endif /* DEBUG */ - err = MPI_Recv(arrays[i], chunk_size, MPI_DOUBLE, i, TAG_SORTED, - MPI_COMM_WORLD, &status); + err = MPI_Recv(arrays[i], chunk_size, MPI_DOUBLE, + MPI_ANY_SOURCE, TAG_SORTED, MPI_COMM_WORLD, + &status); if (err != 0) { fprintf(stderr, - "error receiving sorted block from %d\n", i); + "error receiving sorted block from %d\n", + status.MPI_SOURCE); exit(EXIT_FAILURE); } #ifdef DEBUG + fprintf(stderr, "received sorted data chunk from node %d\n", + status.MPI_SOURCE); printarray(stderr, chunk_size, arrays[i], NUM_SHOWN); fprintf(stderr, "check: sum of %d elements = %g\n", chunk_size, checkarray(chunk_size, arrays[i]));