From 92635ba9e9e86cef31e262c4046479dd4192705b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 27 Oct 2010 08:20:52 -0400 Subject: [PATCH] Use MPI_ANY_SOURCE when receiving sorted lists in sorting/soln/main.c. --- assignments/archive/sorting/soln/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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])); -- 2.26.2