Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
one more test for attr
authorAugustin Degomme <adegomme@users.noreply.github.com>
Fri, 17 Nov 2023 22:12:39 +0000 (23:12 +0100)
committerAugustin Degomme <adegomme@users.noreply.github.com>
Fri, 17 Nov 2023 22:12:39 +0000 (23:12 +0100)
teshsuite/smpi/mpich3-test/attr/CMakeLists.txt
teshsuite/smpi/mpich3-test/attr/attrdelete.c [new file with mode: 0644]
teshsuite/smpi/mpich3-test/attr/testlist
teshsuite/smpi/mpich3-test/coll/allred_float.c

index 05d6254..c8b178d 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 attr2type attrdeleteget attrend2 attrend attrerr attrerrcomm attrerrtype attrorder attrordercomm attrordertype attrt
+  foreach(file attr2type attrdelete attrdeleteget attrend2 attrend attrerr attrerrcomm attrerrtype attrorder attrordercomm attrordertype attrt
           baseattr2 baseattrcomm fkeyval fkeyvalcomm fkeyvaltype keyval_double_free) #attric
     add_executable(${file} EXCLUDE_FROM_ALL ${file}.c)
     add_dependencies(tests ${file})
@@ -18,7 +18,7 @@ if (enable_testsuite_smpi_MPICH3 AND HAVE_RAW_CONTEXTS)
   SET_TESTS_PROPERTIES(test-smpi-mpich3-attr-raw PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
 endif()
 
-foreach(file attr2type attrdeleteget attrend2 attrend attrerr attrerrcomm attrerrtype attrorder attrordercomm attrordertype attrt
+foreach(file attr2type attrdelete attrdeleteget attrend2 attrend attrerr attrerrcomm attrerrtype attrorder attrordercomm attrordertype attrt
         baseattr2 baseattrcomm fkeyval attric fkeyvalcomm fkeyvaltype keyval_double_free keyval_double_free_comm keyval_double_free_type keyval_double_free_win)
   set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file}.c)
 endforeach()
diff --git a/teshsuite/smpi/mpich3-test/attr/attrdelete.c b/teshsuite/smpi/mpich3-test/attr/attrdelete.c
new file mode 100644 (file)
index 0000000..05f03e9
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) by Argonne National Laboratory
+ *     See COPYRIGHT in top-level directory
+ */
+
+/*
+  Having attr delete function to delete another attribute.
+ */
+#include "mpi.h"
+#include "mpitest.h"
+#include <stdio.h>
+
+int key1, key2, key3;
+
+int test_communicator(MPI_Comm comm);
+
+int main(int argc, char **argv)
+{
+    int errs;
+    MTest_Init(&argc, &argv);
+    errs = test_communicator(MPI_COMM_WORLD);
+    MTest_Finalize(errs);
+    return MTestReturnValue(errs);
+}
+
+static int key2_delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state)
+{
+    MPI_Comm_delete_attr(comm, key1);
+    MPI_Comm_delete_attr(comm, key3);
+    return MPI_SUCCESS;
+}
+
+int test_communicator(MPI_Comm comm)
+{
+    int errs = 0;
+    int rank, size;
+
+    MPI_Comm_rank(comm, &rank);
+    MPI_Comm_size(comm, &size);
+
+    MPI_Comm_create_keyval(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key1, NULL);
+    MPI_Comm_create_keyval(MPI_NULL_COPY_FN, key2_delete_fn, &key2, NULL);
+    MPI_Comm_create_keyval(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key3, NULL);
+
+    MPI_Comm_set_attr(comm, key1, (void *) (MPI_Aint) rank);
+    MPI_Comm_set_attr(comm, key2, (void *) (MPI_Aint) (rank + 100));
+    MPI_Comm_set_attr(comm, key3, (void *) (MPI_Aint) (rank + 200));
+
+    MPI_Comm_delete_attr(comm, key2);
+
+    MPI_Comm_free_keyval(&key1);
+    MPI_Comm_free_keyval(&key2);
+    MPI_Comm_free_keyval(&key3);
+
+    return errs;
+}
index 56fb8c5..e8577c6 100644 (file)
@@ -13,6 +13,7 @@ attrerr 1
 #attrend2 5
 attrerrcomm 1
 attrerrtype 1
+attrdelete 1
 attrdeleteget 1
 attr2type 1
 attrorder 1
index c8d4354..6b6ebc6 100644 (file)
@@ -64,7 +64,7 @@ int main(int argc, char **argv)
 
             MPI_Allreduce(MPI_IN_PLACE, buf, N, MPI_FLOAT, MPI_SUM, MPI_COMM_WORLD);
 
-            float *check_buf;
+            float *check_buf=NULL;
             if (rank == 0) {
                 check_buf = malloc(N * size * sizeof(float));
             }