Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add tests for isendrecv and isendrecv_replace
authorAugustin Degomme <adegomme@users.noreply.github.com>
Fri, 17 Nov 2023 21:33:36 +0000 (22:33 +0100)
committerAugustin Degomme <adegomme@users.noreply.github.com>
Fri, 17 Nov 2023 21:33:36 +0000 (22:33 +0100)
teshsuite/smpi/mpich3-test/pt2pt/CMakeLists.txt
teshsuite/smpi/mpich3-test/pt2pt/isendrecv.c [new file with mode: 0644]
teshsuite/smpi/mpich3-test/pt2pt/isendrecv_replace.c [new file with mode: 0644]
teshsuite/smpi/mpich3-test/pt2pt/testlist

index d275f2c..1c20021 100644 (file)
@@ -5,7 +5,7 @@ if(enable_smpi AND enable_testsuite_smpi_MPICH3)
   include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
   include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include/")
 
-  foreach(file anyall bottom eagerdt huge_anysrc huge_dupcomm huge_ssend huge_underflow inactivereq isendself isendirecv isendselfprobe issendselfcancel large_tag multi_psend_derived cancelanysrc pingping probenull
+  foreach(file anyall bottom eagerdt huge_anysrc huge_dupcomm huge_ssend huge_underflow inactivereq isendself isendrecv isendrecv_replace isendirecv isendselfprobe issendselfcancel large_tag multi_psend_derived cancelanysrc pingping probenull
           dtype_send greq1 probe-unexp rqstatus sendall sendflood sendrecv1 sendrecv2 sendrecv3 waitany-null waittestnull many_isend manylmt recv_any sendself scancel scancel2 rcancel bsend1 bsend2 bsend3 bsend4 bsend5 bsendalign bsendfrag bsendpending rqfreeb)
     # not compiled files: big_count_status mprobe
     # cancelrecv  icsend large_message pscancel     scancel_unmatch
@@ -27,7 +27,7 @@ if(enable_smpi AND enable_testsuite_smpi_MPICH3)
   unset(name)
 endif()
 
-foreach(file anyall bottom eagerdt huge_anysrc huge_dupcomm huge_ssend huge_underflow inactivereq
+foreach(file anyall bottom eagerdt huge_anysrc huge_dupcomm huge_ssend huge_underflow inactivereq isendrecv isendrecv_replace
          isendself isendirecv isendselfprobe issendselfcancel large_tag multi_psend_derived pingping probenull
           probe-unexp sendall sendflood sendrecv1 sendrecv2 sendrecv3 waitany-null waittestnull
           big_count_status bsend1 bsend2 bsend3 bsend4 bsend5 bsendalign bsendfrag bsendpending
diff --git a/teshsuite/smpi/mpich3-test/pt2pt/isendrecv.c b/teshsuite/smpi/mpich3-test/pt2pt/isendrecv.c
new file mode 100644 (file)
index 0000000..63512e6
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) by Argonne National Laboratory
+ *     See COPYRIGHT in top-level directory
+ */
+
+#include "mpi.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include "mpitest.h"
+
+/* Similar test as isendirecv.c, but use MPI_Isendrecv */
+
+int errs = 0;
+int elems = 20;
+int rank, nproc, dest;
+MPI_Comm comm;
+float *in_buf, *out_buf;
+MPI_Request *reqs;
+
+/* sendrecv may use the same or different source and destination,
+ * offset defines the offset between them */
+static void test_sendrecv(int offset)
+{
+    for (int i = 0; i < nproc; i++) {
+        for (int j = 0; j < elems; j++) {
+            in_buf[i * elems + j] = -1.0;
+            out_buf[i * elems + j] = rank * 10000.0 + i * 100.0 + j;
+        }
+    }
+
+    for (int i = 0; i < nproc; i++) {
+        int j = (i + offset) % nproc;
+        MPI_Isendrecv(&out_buf[elems * i], elems, MPI_FLOAT, i, 0,
+                      &in_buf[elems * j], elems, MPI_FLOAT, j, 0, comm, &reqs[i]);
+    }
+
+    MPI_Waitall(nproc, reqs, MPI_STATUSES_IGNORE);
+
+    for (int i = 0; i < nproc; i++) {
+        for (int j = 0; j < elems; j++) {
+            if (in_buf[i * elems + j] != i * 10000.0 + rank * 100.0 + j) {
+                errs++;
+            }
+        }
+    }
+}
+
+int main(int argc, char *argv[])
+{
+    MTest_Init(&argc, &argv);
+
+    comm = MPI_COMM_WORLD;
+    MPI_Comm_rank(comm, &rank);
+    MPI_Comm_size(comm, &nproc);
+
+    reqs = malloc(nproc * sizeof(MPI_Request));
+    in_buf = malloc(elems * nproc * sizeof(float));
+    out_buf = malloc(elems * nproc * sizeof(float));
+
+    for (int offset = 0; offset < nproc - 1; offset++) {
+        test_sendrecv(offset);
+    }
+
+    free(reqs);
+    free(in_buf);
+    free(out_buf);
+    MTest_Finalize(errs);
+    return MTestReturnValue(errs);
+}
diff --git a/teshsuite/smpi/mpich3-test/pt2pt/isendrecv_replace.c b/teshsuite/smpi/mpich3-test/pt2pt/isendrecv_replace.c
new file mode 100644 (file)
index 0000000..f0174c9
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) by Argonne National Laboratory
+ *     See COPYRIGHT in top-level directory
+ */
+
+#include "mpi.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include "mpitest.h"
+
+/* Similar test as isendirecv.c, but use MPI_Isendrecv_replace */
+
+int errs = 0;
+int elems = 20;
+int rank, nproc, dest;
+float *buf;
+MPI_Comm comm;
+MPI_Request *reqs;
+
+static void test_sendrecv(int offset)
+{
+    for (int i = 0; i < nproc; i++) {
+        for (int j = 0; j < elems; j++) {
+            buf[i * elems + j] = rank * 100.0 + j;
+        }
+    }
+
+    for (int i = 0; i < nproc; i++) {
+        int j = (i + offset) % nproc;
+        MPI_Isendrecv_replace(&buf[elems * j], elems, MPI_FLOAT, i, 0, j, 0, comm, &reqs[i]);
+    }
+
+    MPI_Waitall(nproc, reqs, MPI_STATUSES_IGNORE);
+
+    for (int i = 0; i < nproc; i++) {
+        for (int j = 0; j < elems; j++) {
+            if (buf[i * elems + j] != i * 100.0 + j) {
+                if (errs < 10) {
+                    fprintf(stderr, "buf(%d, %d) mismatch, got %f, expect %f\n", i, j,
+                            buf[i * elems + j], (float) (i * 100.0 + j));
+                }
+                errs++;
+            }
+        }
+    }
+}
+
+/* sendrecv may use the same or different source and destination,
+ * offset defines the offset between them */
+
+int main(int argc, char *argv[])
+{
+    MTest_Init(&argc, &argv);
+
+    comm = MPI_COMM_WORLD;
+    MPI_Comm_rank(comm, &rank);
+    MPI_Comm_size(comm, &nproc);
+
+    reqs = malloc(nproc * sizeof(MPI_Request));
+    buf = malloc(elems * nproc * sizeof(float));
+
+    for (int offset = 0; offset < nproc - 1; offset++) {
+        test_sendrecv(offset);
+    }
+
+    free(reqs);
+    free(buf);
+    MTest_Finalize(errs);
+    return MTestReturnValue(errs);
+}
index 1e70308..0b79f5e 100644 (file)
@@ -17,6 +17,8 @@ bsend4 1
 bsendalign 2
 bsendpending 2
 isendself 1
+isendrecv 4
+isendrecv_replace 4
 #issendselfcancel 1
 isendirecv 10
 bsendfrag 2