From bfe580c9acb43ca1ca658f9111d4cd6f5951bbdc Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Fri, 17 Nov 2023 00:21:30 +0100 Subject: [PATCH] add some new pt2pt tests from mpich --- .../smpi/mpich3-test/pt2pt/CMakeLists.txt | 5 +- .../smpi/mpich3-test/pt2pt/huge_dupcomm.c | 65 +++++++++++++ teshsuite/smpi/mpich3-test/pt2pt/huge_ssend.c | 49 ++++++++++ .../smpi/mpich3-test/pt2pt/inactivereq.c | 93 +++++++++++------- teshsuite/smpi/mpich3-test/pt2pt/large_tag.c | 75 +++++++++++++++ .../mpich3-test/pt2pt/multi_psend_derived.c | 94 +++++++++++++++++++ teshsuite/smpi/mpich3-test/pt2pt/testlist | 4 + 7 files changed, 347 insertions(+), 38 deletions(-) create mode 100644 teshsuite/smpi/mpich3-test/pt2pt/huge_dupcomm.c create mode 100644 teshsuite/smpi/mpich3-test/pt2pt/huge_ssend.c create mode 100644 teshsuite/smpi/mpich3-test/pt2pt/large_tag.c create mode 100644 teshsuite/smpi/mpich3-test/pt2pt/multi_psend_derived.c diff --git a/teshsuite/smpi/mpich3-test/pt2pt/CMakeLists.txt b/teshsuite/smpi/mpich3-test/pt2pt/CMakeLists.txt index 0a11f39160..d275f2ca0d 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/CMakeLists.txt +++ b/teshsuite/smpi/mpich3-test/pt2pt/CMakeLists.txt @@ -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_underflow inactivereq isendself isendirecv isendselfprobe issendselfcancel cancelanysrc pingping probenull + 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 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,8 @@ if(enable_smpi AND enable_testsuite_smpi_MPICH3) unset(name) endif() -foreach(file anyall bottom eagerdt huge_anysrc huge_underflow inactivereq isendself isendirecv isendselfprobe issendselfcancel pingping probenull +foreach(file anyall bottom eagerdt huge_anysrc huge_dupcomm huge_ssend huge_underflow inactivereq + 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 cancelrecv cancelanysrc dtype_send greq1 icsend large_message pscancel rcancel rqfreeb rqstatus scancel2 scancel sendself many_isend manylmt mprobe recv_any scancel_unmatch diff --git a/teshsuite/smpi/mpich3-test/pt2pt/huge_dupcomm.c b/teshsuite/smpi/mpich3-test/pt2pt/huge_dupcomm.c new file mode 100644 index 0000000000..a22c429d6e --- /dev/null +++ b/teshsuite/smpi/mpich3-test/pt2pt/huge_dupcomm.c @@ -0,0 +1,65 @@ +/* + * (C) 2018 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + * + * Portions of this code were written by Intel Corporation. + * Copyright (C) 2011-2018 Intel Corporation. Intel provides this material + * to Argonne National Laboratory subject to Software Grant and Corporate + * Contributor License Agreement dated February 8, 2012. + * + * This program checks if MPICH can correctly handle huge message sends + * over multiple different communicators simultaneously + * + */ + +#include +#include +#include + +#include "mpitest.h" + +#define COUNT (4*1024*1024) +#define NCOMMS 4 + +int main(int argc, char *argv[]) +{ + int *buff; + int size, rank; + int i; + MPI_Comm comms[NCOMMS]; + MPI_Request reqs[NCOMMS]; + + MTest_Init(&argc, &argv); + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + + if (size != 2) { + fprintf(stderr, "Launch with two processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + buff = malloc(COUNT * NCOMMS * sizeof(int)); + + for (i = 0; i < NCOMMS; i++) + MPI_Comm_dup(MPI_COMM_WORLD, &comms[i]); + + for (i = 0; i < NCOMMS; i++) { + if (rank == 0) + MPI_Isend(buff + COUNT * i, COUNT, MPI_INT, 1 /* dest */ , 0 /* tag */ , comms[i], + &reqs[i]); + else + MPI_Irecv(buff + COUNT * i, COUNT, MPI_INT, 0 /* src */ , 0 /* tag */ , comms[i], + &reqs[i]); + } + MPI_Waitall(NCOMMS, reqs, MPI_STATUSES_IGNORE); + + for (i = 0; i < NCOMMS; i++) + MPI_Comm_free(&comms[i]); + + free(buff); + + MTest_Finalize(0); + + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/pt2pt/huge_ssend.c b/teshsuite/smpi/mpich3-test/pt2pt/huge_ssend.c new file mode 100644 index 0000000000..cdd7f2c73b --- /dev/null +++ b/teshsuite/smpi/mpich3-test/pt2pt/huge_ssend.c @@ -0,0 +1,49 @@ +/* + * (C) 2018 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + * + * Portions of this code were written by Intel Corporation. + * Copyright (C) 2011-2018 Intel Corporation. Intel provides this material + * to Argonne National Laboratory subject to Software Grant and Corporate + * Contributor License Agreement dated February 8, 2012. + * + * This program checks if MPICH can correctly handle huge synchronous sends + * + */ + +#include +#include +#include + +#include "mpitest.h" + +#define COUNT (4*1024*1024) + +int main(int argc, char *argv[]) +{ + int *buff; + int size, rank; + + MTest_Init(&argc, &argv); + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + + if (size != 2) { + fprintf(stderr, "Launch with two processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + buff = malloc(COUNT * sizeof(int)); + + if (rank == 0) + MPI_Ssend(buff, COUNT, MPI_INT, 1, 0, MPI_COMM_WORLD); + else + MPI_Recv(buff, COUNT, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + + free(buff); + + MTest_Finalize(0); + + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/pt2pt/inactivereq.c b/teshsuite/smpi/mpich3-test/pt2pt/inactivereq.c index fd9e7d0e33..11084140b4 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/inactivereq.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/inactivereq.c @@ -40,13 +40,52 @@ int StatusEmpty(MPI_Status * s) return errs ? 0 : 1; } -int main(int argc, char *argv[]) +int test_recv_init(int src_rank, const char *test_name) { MPI_Request r; MPI_Status s; int errs = 0; int flag; int buf[10]; + int tag = 27; + + MPI_Recv_init(buf, 10, MPI_INT, src_rank, tag, MPI_COMM_WORLD, &r); + + flag = 0; + s.MPI_TAG = 10; + s.MPI_SOURCE = 10; + MPI_Test(&r, &flag, &s); + if (!flag) { + errs++; + printf("Flag not true after MPI_Test (%s)\n", test_name); + printf("Aborting further tests to avoid hanging in MPI_Wait\n"); + return errs; + } + if (!StatusEmpty(&s)) { + errs++; + printf("Status not empty after MPI_Test (%s)\n", test_name); + } + + s.MPI_TAG = 10; + s.MPI_SOURCE = 10; + MPI_Wait(&r, &s); + if (!StatusEmpty(&s)) { + errs++; + printf("Status not empty after MPI_Wait (%s)\n", test_name); + } + + MPI_Request_free(&r); + + return errs; +} + +int main(int argc, char *argv[]) +{ + MPI_Request r; + MPI_Status s; + int errs = 0, e; + int flag; + int buf[10]; int rbuf[10]; int tag = 27; int dest = 0; @@ -57,7 +96,9 @@ int main(int argc, char *argv[]) MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); - /* Create a persistent send request */ + if (rank == 0) + MTestPrintfMsg(1, "Create a persistent send request\n"); + MPI_Send_init(buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r); flag = 0; @@ -69,8 +110,7 @@ int main(int argc, char *argv[]) printf("Flag not true after MPI_Test (send)\n"); printf("Aborting further tests to avoid hanging in MPI_Wait\n"); MTest_Finalize(errs); - MPI_Finalize(); - return 0; + return MTestReturnValue(errs); } if (!StatusEmpty(&s)) { errs++; @@ -96,8 +136,7 @@ int main(int argc, char *argv[]) MPI_Wait(&r, &s); MPI_Waitall(size, rr, MPI_STATUSES_IGNORE); free(rr); - } - else { + } else { MPI_Start(&r); MPI_Wait(&r, &s); } @@ -111,8 +150,7 @@ int main(int argc, char *argv[]) printf("Flag not true after MPI_Test (send)\n"); printf("Aborting further tests to avoid hanging in MPI_Wait\n"); MTest_Finalize(errs); - MPI_Finalize(); - return 0; + return MTestReturnValue(errs); } if (!StatusEmpty(&s)) { errs++; @@ -131,37 +169,20 @@ int main(int argc, char *argv[]) MPI_Request_free(&r); - /* Create a persistent receive request */ - MPI_Recv_init(buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r); + if (rank == 0) + MTestPrintfMsg(1, "Create a persistent receive request\n"); - flag = 0; - s.MPI_TAG = 10; - s.MPI_SOURCE = 10; - MPI_Test(&r, &flag, &s); - if (!flag) { - errs++; - printf("Flag not true after MPI_Test (recv)\n"); - printf("Aborting further tests to avoid hanging in MPI_Wait\n"); - MTest_Finalize(errs); - MPI_Finalize(); - return 0; - } - if (!StatusEmpty(&s)) { - errs++; - printf("Status not empty after MPI_Test (recv)\n"); - } + e = test_recv_init(dest, "recv"); + errs += e; + if (e) + goto fn_exit; - s.MPI_TAG = 10; - s.MPI_SOURCE = 10; - MPI_Wait(&r, &s); - if (!StatusEmpty(&s)) { - errs++; - printf("Status not empty after MPI_Wait (recv)\n"); - } + if (rank == 0) + MTestPrintfMsg(1, "Create a persistent receive (ANY_SOURCE) request\n"); - MPI_Request_free(&r); + errs += test_recv_init(MPI_ANY_SOURCE, "recv-anysource"); + fn_exit: MTest_Finalize(errs); - MPI_Finalize(); - return 0; + return MTestReturnValue(errs); } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/large_tag.c b/teshsuite/smpi/mpich3-test/pt2pt/large_tag.c new file mode 100644 index 0000000000..10eeb1ac28 --- /dev/null +++ b/teshsuite/smpi/mpich3-test/pt2pt/large_tag.c @@ -0,0 +1,75 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2010 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ +#include +#include +#include +#include "mpitest.h" + +/* Tests send/receive with large tag values. It mimics the usage of tags in + * some MPI-based libraries (e.g., PETSc). */ + +#define ITER 5 +#define BUF_COUNT (16) + +int recvbuf[BUF_COUNT], sendbuf[BUF_COUNT]; + +int main(int argc, char *argv[]) +{ + int x, size, rank, errs = 0; + void *tag_ub_val = NULL; + int tag = 0, flag = 0; + + MTest_Init(&argc, &argv); + + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + /* perform test only with two or more processes */ + if (size < 2) + goto exit; + + /* query the upper bound of tag value */ + MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_TAG_UB, &tag_ub_val, &flag); + tag = *(int *) tag_ub_val; + if (!flag || tag < 32767) { + fprintf(stdout, "%d -- Incorrect MPI_TAG_UB, found flag=%d, tag=%d\n", rank, flag, tag); + fflush(stdout); + errs++; + goto exit; + } + + /* send/receive with large tags from the upper bound */ + for (x = 0; x < ITER; x++) { + int i; + + if (rank == 0) { + /* reset send buffer */ + for (i = 0; i < BUF_COUNT; i++) + sendbuf[i] = x * BUF_COUNT + i; + + MPI_Send(sendbuf, BUF_COUNT, MPI_INT, 1, tag, MPI_COMM_WORLD); + } else if (rank == 1) { + MPI_Recv(recvbuf, BUF_COUNT, MPI_INT, 0, tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + + /* check correctness of received data */ + for (i = 0; i < BUF_COUNT; i++) { + int expected_val = x * BUF_COUNT + i; + if (recvbuf[i] != expected_val) { + errs++; + fprintf(stdout, "%d -- Received %d at index %d with tag %d, expected %d\n", + rank, recvbuf[i], i, tag, expected_val); + fflush(stdout); + } + } + } + tag--; + } + + exit: + MTest_Finalize(errs); + + return MTestReturnValue(errs); +} diff --git a/teshsuite/smpi/mpich3-test/pt2pt/multi_psend_derived.c b/teshsuite/smpi/mpich3-test/pt2pt/multi_psend_derived.c new file mode 100644 index 0000000000..84f670e39e --- /dev/null +++ b/teshsuite/smpi/mpich3-test/pt2pt/multi_psend_derived.c @@ -0,0 +1,94 @@ +/* + * (C) 2018 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + * + * Portions of this code were written by Intel Corporation. + * Copyright (C) 2011-2018 Intel Corporation. Intel provides this material + * to Argonne National Laboratory subject to Software Grant and Corporate + * Contributor License Agreement dated February 8, 2012. + * + * This program checks if MPICH can correctly handle multiple persistent + * communication calls with a derived datatype + * + */ + +#include +#include +#include +#include "mpitest.h" + +#define ITER 16 + +int main(int argc, char *argv[]) +{ + int size, rank; + int i; + MPI_Request req; + MPI_Datatype int_dup; + int v = 1, errs = 0; + + MTest_Init(&argc, &argv); + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + + if (size != 2) { + fprintf(stderr, "Launch with two processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + if (rank == 0) + MTestPrintfMsg(1, "Test 1: Persistent send - Recv\n"); + + if (rank == 0) { + MPI_Type_dup(MPI_INT, &int_dup); + v = 42; + MPI_Send_init(&v, 1, int_dup, 1, 0, MPI_COMM_WORLD, &req); + MPI_Type_free(&int_dup); + for (i = 0; i < ITER; i++) { + MPI_Status s; + MPI_Start(&req); + MPI_Wait(&req, &s); + } + MPI_Request_free(&req); + } else { + for (i = 0; i < ITER; i++) { + v = -1; + MPI_Recv(&v, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + if (v != 42) { + errs++; + fprintf(stderr, "Psend-recv iteration %d: Expected 42 but got %d\n", i, v); + } + } + } + + if (rank == 0) + MTestPrintfMsg(1, "Test 2: Send - Persistent recv (with ANY_SOURCE)\n"); + + if (rank == 0) { + for (i = 0; i < ITER; i++) { + v = i; + MPI_Send(&v, 1, MPI_INT, 1, 0, MPI_COMM_WORLD); + } + } else { + MPI_Type_dup(MPI_INT, &int_dup); + MPI_Recv_init(&v, 1, int_dup, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &req); + MPI_Type_free(&int_dup); + for (i = 0; i < ITER; i++) { + MPI_Status s; + v = -1; + MPI_Start(&req); + MPI_Wait(&req, &s); + if (v != i) { + errs++; + fprintf(stderr, "Send-precv(anysrc) iteration %d: Expected %d but got %d\n", + i, i, v); + } + } + MPI_Request_free(&req); + } + + MTest_Finalize(errs); + MPI_Finalize(); + return MTestReturnValue(errs); +} diff --git a/teshsuite/smpi/mpich3-test/pt2pt/testlist b/teshsuite/smpi/mpich3-test/pt2pt/testlist index 6af72a266b..1e70308f97 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/testlist +++ b/teshsuite/smpi/mpich3-test/pt2pt/testlist @@ -43,11 +43,15 @@ waitany-null 1 # this should be run only on machines with large amount of memory (>=8GB) # perhaps disable in the release tarball #large_message 3 +large_tag 2 #mprobe 2 mpiversion=3.0 #big_count_status 1 mpiversion=3.0 many_isend 3 manylmt 2 +multi_psend_derived 2 huge_anysrc 2 +huge_dupcomm 2 +huge_ssend 2 huge_underflow 2 dtype_send 2 recv_any 2 -- 2.20.1