[mpich-commits] r10772 - mpich2/trunk/test/mpi/errors/comm

dinan at mcs.anl.gov dinan at mcs.anl.gov
Mon Dec 17 13:53:30 CST 2012


Author: dinan
Date: 2012-12-17 13:53:30 -0600 (Mon, 17 Dec 2012)
New Revision: 10772

Added:
   mpich2/trunk/test/mpi/errors/comm/too_many_comms.c
   mpich2/trunk/test/mpi/errors/comm/too_many_comms2.c
   mpich2/trunk/test/mpi/errors/comm/too_many_comms3.c
Modified:
   mpich2/trunk/test/mpi/errors/comm/Makefile.am
   mpich2/trunk/test/mpi/errors/comm/testlist
Log:
Error tests: Handling of context ID exhaustion

These tests create a lot of communicators, in an effort to check that MPI
handles context ID exhaustion gracefully.

Reviewer: buntinas

Modified: mpich2/trunk/test/mpi/errors/comm/Makefile.am
===================================================================
--- mpich2/trunk/test/mpi/errors/comm/Makefile.am	2012-12-17 19:53:29 UTC (rev 10771)
+++ mpich2/trunk/test/mpi/errors/comm/Makefile.am	2012-12-17 19:53:30 UTC (rev 10772)
@@ -12,5 +12,5 @@
 ## for all programs that are just built from the single corresponding source
 ## file, we don't need per-target _SOURCES rules, automake will infer them
 ## correctly
-noinst_PROGRAMS = cfree ccreate1 manysplit userdup
+noinst_PROGRAMS = cfree ccreate1 manysplit userdup too_many_comms too_many_comms2 too_many_comms3
 

Modified: mpich2/trunk/test/mpi/errors/comm/testlist
===================================================================
--- mpich2/trunk/test/mpi/errors/comm/testlist	2012-12-17 19:53:29 UTC (rev 10771)
+++ mpich2/trunk/test/mpi/errors/comm/testlist	2012-12-17 19:53:30 UTC (rev 10772)
@@ -2,3 +2,6 @@
 ccreate1 8
 userdup 4
 manysplit 4
+too_many_comms 4 strict=FALSE
+too_many_comms2 4 strict=FALSE
+too_many_comms3 4 strict=FALSE

Added: mpich2/trunk/test/mpi/errors/comm/too_many_comms.c
===================================================================
--- mpich2/trunk/test/mpi/errors/comm/too_many_comms.c	                        (rev 0)
+++ mpich2/trunk/test/mpi/errors/comm/too_many_comms.c	2012-12-17 19:53:30 UTC (rev 10772)
@@ -0,0 +1,61 @@
+/* -*- mode: c; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *  (c) 2012 by argonne national laboratory.
+ *      see copyright in top-level directory.
+ */
+
+/* This test attempts to create a large number of communicators, in an effort
+ * to exceed the number of communicators that the MPI implementation can
+ * provide.  It checks that the implementation detects this error correctly
+ * handles it.
+ */
+
+/* In this version, we duplicate MPI_COMM_WORLD until we run out of context
+ * IDs. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <mpi.h>
+#include "mpitest.h"
+
+#define MAX_NCOMM 100000
+
+static const int verbose = 0;
+
+int main(int argc, char **argv) {
+    int       rank, nproc, mpi_errno;
+    int       i, ncomm;
+    int       errors = 1;
+    MPI_Comm *comm_hdls;
+
+    MPI_Init(&argc, &argv);
+
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    comm_hdls = malloc(sizeof(MPI_Comm) * MAX_NCOMM);
+
+    ncomm = 0;
+    for (i = 0; i < MAX_NCOMM; i++) {
+        /* Note: the comms we create are all dups of MPI_COMM_WORLD */
+        mpi_errno = MPI_Comm_dup(MPI_COMM_WORLD, &comm_hdls[i]);
+
+        if (mpi_errno == MPI_SUCCESS) {
+            ncomm++;
+        } else {
+            if (verbose) printf("%d: Error creating comm %d\n", rank, i);
+            errors = 0;
+            break;
+        }
+    }
+
+    for (i = 0; i < ncomm; i++)
+        MPI_Comm_free(&comm_hdls[i]);
+
+    free(comm_hdls);
+    MTest_Finalize(errors);
+    MPI_Finalize();
+
+    return 0;
+}

Added: mpich2/trunk/test/mpi/errors/comm/too_many_comms2.c
===================================================================
--- mpich2/trunk/test/mpi/errors/comm/too_many_comms2.c	                        (rev 0)
+++ mpich2/trunk/test/mpi/errors/comm/too_many_comms2.c	2012-12-17 19:53:30 UTC (rev 10772)
@@ -0,0 +1,78 @@
+/* -*- mode: c; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *  (c) 2012 by argonne national laboratory.
+ *      see copyright in top-level directory.
+ */
+
+/* This test attempts to create a large number of communicators, in an effort
+ * to exceed the number of communicators that the MPI implementation can
+ * provide.  It checks that the implementation detects this error correctly
+ * handles it.
+ */
+
+/* In this version, we create communicators that contain ranks {0}, {0,1}, ...,
+ * {0..P-1} from MPI_COMM_WORLD until we run out of context IDs. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <mpi.h>
+#include "mpitest.h"
+
+#define MAX_NCOMM 100000
+
+static const int verbose = 0;
+
+int main(int argc, char **argv) {
+    int       rank, nproc, mpi_errno;
+    int       i, ncomm, *ranks;
+    int       errors = 1;
+    MPI_Comm *comm_hdls;
+    MPI_Group world_group;
+
+    MPI_Init(&argc, &argv);
+
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+    MPI_Comm_group(MPI_COMM_WORLD, &world_group);
+
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    comm_hdls = malloc(sizeof(MPI_Comm) * MAX_NCOMM);
+    ranks     = malloc(sizeof(int) * nproc);
+
+    for (i = 0; i < nproc; i++)
+        ranks[i] = i;
+
+    ncomm = 0;
+    for (i = 0; i < MAX_NCOMM; i++) {
+        MPI_Group comm_group;
+
+        /* Comms include ranks: 0; 0,1; 0,1,2; ...; 0; 0,1; 0,1,2; ... */
+        MPI_Group_incl(world_group, (i+1) % (nproc+1), /* Adding 1 yields counts of 1..nproc */
+                       ranks, &comm_group);
+
+        /* Note: the comms we create are all varying subsets of MPI_COMM_WORLD */
+        mpi_errno = MPI_Comm_create(MPI_COMM_WORLD, comm_group, &comm_hdls[i]);
+
+        if (mpi_errno == MPI_SUCCESS) {
+            ncomm++;
+        } else {
+            if (verbose) printf("%d: Error creating comm %d\n", rank, i);
+            MPI_Group_free(&comm_group);
+            errors = 0;
+            break;
+        }
+
+        MPI_Group_free(&comm_group);
+    }
+
+    for (i = 0; i < ncomm; i++)
+        MPI_Comm_free(&comm_hdls[i]);
+
+    free(comm_hdls);
+    MPI_Group_free(&world_group);
+
+    MTest_Finalize(errors);
+    MPI_Finalize();
+
+    return 0;
+}

Added: mpich2/trunk/test/mpi/errors/comm/too_many_comms3.c
===================================================================
--- mpich2/trunk/test/mpi/errors/comm/too_many_comms3.c	                        (rev 0)
+++ mpich2/trunk/test/mpi/errors/comm/too_many_comms3.c	2012-12-17 19:53:30 UTC (rev 10772)
@@ -0,0 +1,79 @@
+/* -*- mode: c; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *  (c) 2012 by argonne national laboratory.
+ *      see copyright in top-level directory.
+ */
+
+/* This test attempts to create a large number of communicators, in an effort
+ * to exceed the number of communicators that the MPI implementation can
+ * provide.  It checks that the implementation detects this error correctly
+ * handles it.
+ */
+
+/* In this version, we create communicators that contain ranks {0}, {0}, ...,
+ * {P} from MPI_COMM_WORLD until we run out of context IDs.  This test
+ * fragments the context ID space, resulting in a context ID allocation that
+ * fails because there is no common free ID, even though all processes have
+ * unused context IDs. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <mpi.h>
+#include "mpitest.h"
+
+#define MAX_NCOMM 100000
+
+static const int verbose = 0;
+
+int main(int argc, char **argv) {
+    int       rank, nproc, mpi_errno;
+    int       i, ncomm, *ranks;
+    int       errors = 1;
+    MPI_Comm *comm_hdls;
+    MPI_Group world_group;
+
+    MPI_Init(&argc, &argv);
+
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+    MPI_Comm_group(MPI_COMM_WORLD, &world_group);
+
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    comm_hdls = malloc(sizeof(MPI_Comm) * MAX_NCOMM);
+    ranks     = malloc(sizeof(int) * nproc);
+
+    ncomm = 0;
+    for (i = 0; i < MAX_NCOMM; i++) {
+        int       incl = i % nproc;
+        MPI_Group comm_group;
+
+        /* Comms include ranks: 0; 1; 2; ...; 0; 1; ... */
+        MPI_Group_incl(world_group, 1, &incl, &comm_group);
+
+        /* Note: the comms we create all contain one rank from MPI_COMM_WORLD */
+        mpi_errno = MPI_Comm_create(MPI_COMM_WORLD, comm_group, &comm_hdls[i]);
+
+        if (mpi_errno == MPI_SUCCESS) {
+            if (verbose) printf("%d: Created comm %d\n", rank, i);
+            ncomm++;
+        } else {
+            if (verbose) printf("%d: Error creating comm %d\n", rank, i);
+            MPI_Group_free(&comm_group);
+            errors = 0;
+            break;
+        }
+
+        MPI_Group_free(&comm_group);
+    }
+
+    for (i = 0; i < ncomm; i++)
+        MPI_Comm_free(&comm_hdls[i]);
+
+    free(comm_hdls);
+    MPI_Group_free(&world_group);
+
+    MTest_Finalize(errors);
+    MPI_Finalize();
+
+    return 0;
+}



More information about the commits mailing list