From 72a171242c4efb37f5207624989729b235c3cce1 Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Wed, 11 Mar 2020 12:57:43 +0000
Subject: [PATCH] Also report the tag and source of the failed receive

---
 swiftmpiproxies.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/swiftmpiproxies.c b/swiftmpiproxies.c
index 9d48671..5dcecdf 100644
--- a/swiftmpiproxies.c
+++ b/swiftmpiproxies.c
@@ -267,8 +267,8 @@ int main(int argc, char *argv[]) {
       int size = log->size;
 
       res = MPI_Isend(&size, 1, MPI_INT, log->otherrank,
-                      basetag + proxy_tag_count,
-                      MPI_COMM_WORLD, &req_send_counts[k]);
+                      basetag + proxy_tag_count, MPI_COMM_WORLD,
+                      &req_send_counts[k]);
       if (res != MPI_SUCCESS) error("Counts MPI_Isend failed.");
 
       /* Start Isend of pcells, filling the data with a pattern for checking
@@ -313,8 +313,8 @@ int main(int argc, char *argv[]) {
       datacheck_fill(1, pcells_size[pid], pcells_in[pid]);
 
       res = MPI_Irecv(pcells_in[pid], pcells_size[pid], MPI_BYTE,
-                      log->otherrank, basetag + proxy_tag_cells,
-                      MPI_COMM_WORLD, &req_pcells_in[pid]);
+                      log->otherrank, basetag + proxy_tag_cells, MPI_COMM_WORLD,
+                      &req_pcells_in[pid]);
       if (res != MPI_SUCCESS) error("Pcell MPI_Irecv failed.");
     }
     message("All proxy cell counts have arrived, pcells irecvs are launched");
@@ -338,6 +338,14 @@ int main(int argc, char *argv[]) {
       /* Check the data received is correct. */
       if (!datacheck_test(0, pcells_size[pid], pcells_in[pid])) {
         message("Received data is not correct");
+
+        /* Report the tag and source of the request. */
+        int expected_tag =
+            status.MPI_SOURCE * proxy_tag_shift + proxy_tag_cells;
+        message("sent from rank %d, with tag %d/%d and error code %d",
+                status.MPI_SOURCE, status.MPI_TAG, expected_tag,
+                status.MPI_ERROR);
+
         datacheck_fulltest(pcells_size[pid], pcells_in[pid]);
         if (datacheck_test(1, pcells_size[pid], pcells_in[pid])) {
           error("Received data is not modified on receive");
@@ -345,8 +353,7 @@ int main(int argc, char *argv[]) {
           error("Received data is corrupt");
         }
       } else {
-        if (verbose)
-          message("Received data is correct");
+        if (verbose) message("Received data is correct");
       }
       free(pcells_in[pid]);
       pcells_in[pid] = NULL;
@@ -365,14 +372,13 @@ int main(int argc, char *argv[]) {
         datacheck_fulltest(log->size, log->data);
         error("Sent data has been corrupted");
       } else {
-        if (verbose)
-          message("Sent data is correct");
+        if (verbose) message("Sent data is correct");
       }
       free(log->data);
       log->data = NULL;
     }
 
-  }/* nloop */
+  } /* nloop */
 
   /* Shutdown MPI. */
   res = MPI_Finalize();
-- 
GitLab