[mpich2-commits] r5463 - mpich2/trunk/test/mpi/manual
gropp at mcs.anl.gov
gropp at mcs.anl.gov
Thu Oct 15 10:29:05 CDT 2009
Author: gropp
Date: 2009-10-15 10:29:05 -0500 (Thu, 15 Oct 2009)
New Revision: 5463
Added:
mpich2/trunk/test/mpi/manual/spawntest_child.c
mpich2/trunk/test/mpi/manual/spawntest_master.c
Modified:
mpich2/trunk/test/mpi/manual/Makefile.sm
mpich2/trunk/test/mpi/manual/README
Log:
Added a test program for use of MPI_Comm_disconnect, provided by the Parallel R group that thought they had a problem with MPI_Comm_disconnect
Modified: mpich2/trunk/test/mpi/manual/Makefile.sm
===================================================================
--- mpich2/trunk/test/mpi/manual/Makefile.sm 2009-10-14 21:46:13 UTC (rev 5462)
+++ mpich2/trunk/test/mpi/manual/Makefile.sm 2009-10-15 15:29:05 UTC (rev 5463)
@@ -1,11 +1,13 @@
INCLUDES = -I../include -I${srcdir}/../include
smvar_do_sharedlibs = 0
-singjoin_SOURCES = singjoin.c
-testconnect_SOURCES = testconnect.c
+singjoin_SOURCES = singjoin.c
+testconnect_SOURCES = testconnect.c
testconnectserial_SOURCES = testconnectserial.c tchandlers.c tcutil.c
-testconnectserial_LDADD = -lm
-dimsbalanced_SOURCES = dimsbalanced.c
+testconnectserial_LDADD = -lm
+dimsbalanced_SOURCES = dimsbalanced.c
+spawntest_master_SOURCES = spawntest_master.c
+spawntest_child_SOURCES = spawntest_child.c
testconnectserial.o: testconnectserial.c
$(C_COMPILE) -c -DMPICHLIBSTR=\"$(MPIDIR)\" $<
Modified: mpich2/trunk/test/mpi/manual/README
===================================================================
--- mpich2/trunk/test/mpi/manual/README 2009-10-14 21:46:13 UTC (rev 5462)
+++ mpich2/trunk/test/mpi/manual/README 2009-10-15 15:29:05 UTC (rev 5463)
@@ -18,5 +18,12 @@
default MPI_Dims_create when there is no underlying
network topology.
+spawntest_master, spawntest_child - A test of MPI_Comm_disconnect to ensure
+ that once processes are disconnected, one can proceed
+ through MPI_Finalize without waiting for the other to
+ also proceed through MPI_Finalize. This test is
+ designed to succeed even if either the child or master
+ waits for the other in MPI_Finalize. If MPI_Comm_disconnect
+ works correctly, the spawned children (4 by default),
+ should exit roughly 30 seconds before the master.
-
Added: mpich2/trunk/test/mpi/manual/spawntest_child.c
===================================================================
--- mpich2/trunk/test/mpi/manual/spawntest_child.c (rev 0)
+++ mpich2/trunk/test/mpi/manual/spawntest_child.c 2009-10-15 15:29:05 UTC (rev 5463)
@@ -0,0 +1,42 @@
+#include "mpi.h"
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char **argv)
+{
+ int my_rank;
+ int partner;
+ int size, i,t;
+ char greeting[100];
+ MPI_Comm parentcomm;
+ MPI_Comm allcomm;
+
+ MPI_Init(&argc, &argv);
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+
+ MPI_Comm_get_parent(&parentcomm);
+
+ if ( parentcomm == MPI_COMM_NULL )
+ {
+ fprintf(stdout, "parentcomm is null\n");
+ }
+
+ MPI_Intercomm_merge( parentcomm, 1, &allcomm);
+
+ /* Without the Free of allcomm, the children *must not exit* until the
+ master calls MPI_Finalize. */
+ MPI_Barrier( allcomm );
+ /* According to 10.5.4, case 1b in MPI2.2, the children and master are
+ still connected unless MPI_Comm_disconnect is used with allcomm.
+ MPI_Comm_free is not sufficient */
+ MPI_Comm_free( &allcomm );
+ MPI_Comm_disconnect( &parentcomm );
+
+ fprintf(stdout, "%s:%d\n", __FILE__, __LINE__ );fflush(stdout);
+ MPI_Finalize();
+
+ fprintf(stdout, "%d:child exiting.\n", my_rank );fflush(stdout);
+ return 0;
+}
Added: mpich2/trunk/test/mpi/manual/spawntest_master.c
===================================================================
--- mpich2/trunk/test/mpi/manual/spawntest_master.c (rev 0)
+++ mpich2/trunk/test/mpi/manual/spawntest_master.c 2009-10-15 15:29:05 UTC (rev 5463)
@@ -0,0 +1,51 @@
+#include "mpi.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#define NUM_SPAWNS 4
+
+int main( int argc, char *argv[] )
+{
+ int np = NUM_SPAWNS;
+ int my_rank,i, size, newsize;
+ int errcodes[NUM_SPAWNS];
+ MPI_Comm allcomm;
+ MPI_Comm intercomm;
+
+ MPI_Init( &argc, &argv );
+ MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+
+
+ MPI_Comm_spawn( "./spawntest_child", MPI_ARGV_NULL, np, MPI_INFO_NULL, 0,
+ MPI_COMM_WORLD, &intercomm, errcodes );
+
+ if ( intercomm == MPI_COMM_NULL )
+ {
+ fprintf(stdout, "intercomm is null\n");
+ }
+
+ MPI_Intercomm_merge(intercomm, 0, &allcomm);
+
+ MPI_Comm_rank(allcomm, &my_rank);
+ MPI_Comm_size(allcomm, &size);
+
+ /* Without the Free of allcomm, the children *must not exit* until the
+ master calls MPI_Finalize. */
+ MPI_Barrier( allcomm );
+ /* According to 10.5.4, case 1b in MPI2.2, the children and master are
+ still connected unless MPI_Comm_disconnect is used with allcomm.
+ MPI_Comm_free is not sufficient */
+ MPI_Comm_free( &allcomm );
+ MPI_Comm_disconnect( &intercomm );
+
+ fprintf(stdout, "%s:%d: Sleep starting; children should exit\n",
+ __FILE__, __LINE__ );fflush(stdout);
+ sleep(30);
+ fprintf(stdout,
+ "%s:%d: Sleep done; all children should have already exited\n",
+ __FILE__, __LINE__ );fflush(stdout);
+
+ MPI_Finalize();
+ return 0;
+}
More information about the mpich2-commits
mailing list