From de00c3319ae3990aae696879020aaf80060e6fc2 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Fri, 17 Nov 2023 23:29:25 +0100 Subject: [PATCH] add 2 tests for comm --- .../smpi/mpich3-test/comm/CMakeLists.txt | 8 +- teshsuite/smpi/mpich3-test/comm/cmfree2.c | 49 +++++++++ teshsuite/smpi/mpich3-test/comm/comm_info2.c | 103 ++++++++++++++++++ teshsuite/smpi/mpich3-test/comm/testlist | 2 + 4 files changed, 158 insertions(+), 4 deletions(-) create mode 100644 teshsuite/smpi/mpich3-test/comm/cmfree2.c create mode 100644 teshsuite/smpi/mpich3-test/comm/comm_info2.c diff --git a/teshsuite/smpi/mpich3-test/comm/CMakeLists.txt b/teshsuite/smpi/mpich3-test/comm/CMakeLists.txt index 86f91a2616..350a2075ab 100644 --- a/teshsuite/smpi/mpich3-test/comm/CMakeLists.txt +++ b/teshsuite/smpi/mpich3-test/comm/CMakeLists.txt @@ -5,8 +5,8 @@ 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 cmfree cmsplit2 cmsplit cmsplit_type commcreate1 comm_create_group comm_group_half comm_group_rand - comm_info ctxalloc ctxsplit dup dup_with_info commname) + foreach(file cmfree cmfree2 cmsplit2 cmsplit cmsplit_type commcreate1 comm_create_group comm_group_half comm_group_rand + comm_info comm_info2 ctxalloc ctxsplit dup dup_with_info commname) # not compiled files # comm_idup comm_idup_mul comm_idup_overlap dupic ic1 ic2 iccreate icgroup icm icsplit probe-intercomm add_executable(${file} EXCLUDE_FROM_ALL ${file}.c) @@ -20,8 +20,8 @@ if (enable_testsuite_smpi_MPICH3 AND HAVE_RAW_CONTEXTS) SET_TESTS_PROPERTIES(test-smpi-mpich3-comm-raw PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!") endif() -foreach(file cmfree cmsplit2 cmsplit cmsplit_type commcreate1 comm_create_group comm_group_half comm_group_rand - comm_info commname ctxalloc ctxsplit dup dupic dup_with_info ic1 ic2 +foreach(file cmfree cmfree2 cmsplit2 cmsplit cmsplit_type commcreate1 comm_create_group comm_group_half comm_group_rand + comm_info comm_info2 commname ctxalloc ctxsplit dup dupic dup_with_info ic1 ic2 iccreate icgroup icm icsplit probe-intercomm comm_create_group_idup comm_idup_comm comm_idup_mul comm_idup comm_idup_iallreduce comm_idup_nb comm_idup_comm2 comm_idup_isend comm_idup_overlap ) set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file}.c) diff --git a/teshsuite/smpi/mpich3-test/comm/cmfree2.c b/teshsuite/smpi/mpich3-test/comm/cmfree2.c new file mode 100644 index 0000000000..fc94efb0bd --- /dev/null +++ b/teshsuite/smpi/mpich3-test/comm/cmfree2.c @@ -0,0 +1,49 @@ +/* + * Copyright (C) by Argonne National Laboratory + * See COPYRIGHT in top-level directory + */ + +#include "mpi.h" +#include +#include "mpitest.h" + +/* +static char MTEST_Descrip[] = "Test that communicators have reference count semantics"; +*/ + +int main(int argc, char *argv[]) +{ + int errs = 0; + int rank, size; + MPI_Comm comm; + + MTest_Init(&argc, &argv); + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + if (size < 2) { + fprintf(stderr, "This test requires at least two processes."); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + MPI_Comm_dup(MPI_COMM_WORLD, &comm); + + if (rank == 0) { + MPI_Barrier(MPI_COMM_WORLD); + MPI_Ssend(NULL, 0, MPI_INT, 1, 0, comm); + MPI_Comm_free(&comm); + } else if (rank == 1) { + MPI_Request req; + /* recv an ssend after the user frees the comm */ + MPI_Irecv(NULL, 0, MPI_INT, 0, 0, comm, &req); + MPI_Comm_free(&comm); + MPI_Barrier(MPI_COMM_WORLD); + MPI_Wait(&req, MPI_STATUS_IGNORE); + } else { + MPI_Comm_free(&comm); + MPI_Barrier(MPI_COMM_WORLD); + } + + MTest_Finalize(errs); + return MTestReturnValue(errs); +} diff --git a/teshsuite/smpi/mpich3-test/comm/comm_info2.c b/teshsuite/smpi/mpich3-test/comm/comm_info2.c new file mode 100644 index 0000000000..eb4de40981 --- /dev/null +++ b/teshsuite/smpi/mpich3-test/comm/comm_info2.c @@ -0,0 +1,103 @@ +/* + * Copyright (C) by Argonne National Laboratory + * See COPYRIGHT in top-level directory + */ + +#include +#include +#include "mpitest.h" + + +/* + This program provides tests cases for the functional evaluation + of the MPI communicator info hints infrastructure. + */ + +int main(int argc, char **argv) +{ + int rank; + MPI_Info info_in, info_out; + int errs = 0; + MPI_Comm comm; + char query_key[MPI_MAX_INFO_KEY]; + char val[MPI_MAX_INFO_VAL]; + char new_key[MPI_MAX_INFO_KEY]; + MPI_Comm comm_dup2; + MPI_Comm comm_dup3; + MPI_Comm comm_dup4; + MPI_Comm comm_split1; + MPI_Info info_out2; + MPI_Info info_out3; + MPI_Info info_out5; + MPI_Info info_in3; + + + /* Read arguments: info key and value */ + snprintf(query_key, MPI_MAX_INFO_KEY, "arbitrary_key"); + snprintf(val, MPI_MAX_INFO_VAL, "arbitrary_val"); + + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + /* Goal of the test is only to make sure that MPI does not break */ + /* No expectation is made on if the hints are actually set */ + + /* Test 1: comm_dup */ + if (rank == 0) + MTestPrintfMsg(1, + "Testing MPI_Comm_dup with a source comm that has default comm infohints"); + MPI_Comm_dup(MPI_COMM_WORLD, &comm); + + /* Test 2: comm_set_info and comm_get_info */ + if (rank == 0) + MTestPrintfMsg(1, "Testing MPI_Comm_set_info and MPI_Comm_get_info"); + MPI_Info_create(&info_in); + MPI_Info_set(info_in, query_key, val); + MPI_Comm_set_info(comm, info_in); + MPI_Comm_get_info(comm, &info_out); + MPI_Info_free(&info_out); + + /* Test 3: com_dup after info is set in source comm */ + if (rank == 0) + MTestPrintfMsg(1, "Testing MPI_Comm_dup: source comm has user provided comm infohint"); + MPI_Comm_dup(comm, &comm_dup2); + MPI_Comm_get_info(comm_dup2, &info_out2); + MPI_Comm_free(&comm_dup2); + MPI_Info_free(&info_out2); + + /* Test 4: Comm_dup_with_info */ + if (rank == 0) + MTestPrintfMsg(1, "Testing MPI_Comm_dup_with_info"); + + /* Add 2 hints and create comm dup with info */ + MPI_Info_create(&info_in3); + MPI_Info_set(info_in3, query_key, val); + snprintf(new_key, MPI_MAX_INFO_KEY, "arbitrary_key_2"); + MPI_Info_set(info_in3, new_key, "arbitrary_value_2"); + MPI_Comm_dup_with_info(comm, info_in3, &comm_dup3); + MPI_Comm_get_info(comm_dup3, &info_out3); + MPI_Info_free(&info_in3); + MPI_Info_free(&info_out3); + MPI_Comm_free(&comm_dup3); + + /* Test 5: MPI_Comm_split_type */ + MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, info_in, &comm_split1); + MPI_Comm_get_info(comm_split1, &info_out5); + MPI_Info_free(&info_out5); + MPI_Comm_free(&comm_split1); + + /* Test 6: comm_dup_with_info with info=MPI_INFO_NULL */ + if (rank == 0) + MTestPrintfMsg(1, "Testing MPI_Comm_dup_with_info with MPI_INFO_NULL"); + MPI_Comm_dup_with_info(comm, MPI_INFO_NULL, &comm_dup4); + MPI_Comm_free(&comm_dup4); + + /* TODO - Test: MPI_Dist_graph_create_adjacent */ + + /* Release remaining resources */ + MPI_Info_free(&info_in); + MPI_Comm_free(&comm); + + MTest_Finalize(errs); + return MTestReturnValue(errs); +} diff --git a/teshsuite/smpi/mpich3-test/comm/testlist b/teshsuite/smpi/mpich3-test/comm/testlist index 4f2dc40600..74577b3d93 100644 --- a/teshsuite/smpi/mpich3-test/comm/testlist +++ b/teshsuite/smpi/mpich3-test/comm/testlist @@ -14,6 +14,7 @@ commname 4 ctxalloc 2 timeLimit=300 ctxsplit 4 timeLimit=300 cmfree 4 +cmfree2 2 cmsplit 4 cmsplit2 12 #probe-intercomm 2 @@ -35,3 +36,4 @@ dup_with_info 2 mpiversion=3.0 dup_with_info 4 mpiversion=3.0 dup_with_info 9 mpiversion=3.0 comm_info 6 mpiversion=3.0 +comm_info2 1 -- 2.20.1