[mpich2-commits] r7678 - in mpich2/trunk/src/util: mem param

goodell at mcs.anl.gov goodell at mcs.anl.gov
Mon Jan 10 17:29:25 CST 2011


Author: goodell
Date: 2011-01-10 17:29:25 -0600 (Mon, 10 Jan 2011)
New Revision: 7678

Modified:
   mpich2/trunk/src/util/mem/handlemem.c
   mpich2/trunk/src/util/param/params.yml
Log:
add MPIR_PARAM_ABORT_ON_LEAKED_HANDLES to help applications detect handle leaks

This was a feature request from Quincey in order to improve the
effectiveness of the HDF5 test suite.

No reviewer.

Modified: mpich2/trunk/src/util/mem/handlemem.c
===================================================================
--- mpich2/trunk/src/util/mem/handlemem.c	2011-01-10 22:11:27 UTC (rev 7677)
+++ mpich2/trunk/src/util/mem/handlemem.c	2011-01-10 23:29:25 UTC (rev 7678)
@@ -552,6 +552,7 @@
     MPIU_Object_alloc_t *objmem = (MPIU_Object_alloc_t *)objmem_ptr;
     int i;
     MPIU_Handle_common *ptr;
+    int leaked_handles = FALSE;
     int   directSize = objmem->direct_size;
     char *direct = (char *)objmem->direct;
     char *directEnd = (char *)direct + directSize * objmem->size - 1;
@@ -608,10 +609,12 @@
 		objmem->indirect_size );
     }
     if (nDirect != directSize) {
+        leaked_handles = TRUE;
 	printf( "In direct memory block for handle type %s, %d handles are still allocated\n", MPIR_ObjectName( objmem ), directSize - nDirect );
     }
     for (i=0; i<objmem->indirect_size; i++) {
 	if (nIndirect[i] != HANDLE_BLOCK_SIZE) {
+            leaked_handles = TRUE;
 	    printf( "In indirect memory block %d for handle type %s, %d handles are still allocated\n", i, MPIR_ObjectName( objmem ), HANDLE_BLOCK_SIZE - nIndirect[i] );
 	}
     }
@@ -620,6 +623,13 @@
 	MPIU_Free( nIndirect );
     }
 
+    if (leaked_handles && MPIR_PARAM_ABORT_ON_LEAKED_HANDLES) {
+        /* comm_world has been (or should have been) destroyed by this point,
+         * pass comm=NULL */
+        MPID_Abort(NULL, MPI_ERR_OTHER, 1, "ERROR: leaked handles detected, aborting");
+        MPIU_Assert(0);
+    }
+
     return 0;
 }
 

Modified: mpich2/trunk/src/util/param/params.yml
===================================================================
--- mpich2/trunk/src/util/param/params.yml	2011-01-10 22:11:27 UTC (rev 7677)
+++ mpich2/trunk/src/util/param/params.yml	2011-01-10 23:29:25 UTC (rev 7678)
@@ -24,6 +24,8 @@
       description : intranode communication parameters
     - name        : developer
       description : useful for developers working on MPICH2 itself
+    - name        : memory
+      description : affects memory allocation and usage, including MPI object handles
     - name        : error_handling
       description : parameters that control error handling behavior (stack traces, aborts, etc)
     - name        : debugger
@@ -273,6 +275,21 @@
         If true, enables checkpointing support and returns an error if
         checkpointing library cannot be initialized.
 
+  ##############################################################
+    # memory parameters
+    - category    : memory
+      name        : ABORT_ON_LEAKED_HANDLES
+      type        : boolean
+      default     : false
+      description : >-
+        If true, MPI will call MPI_Abort at MPI_Finalize if any MPI object
+        handles have been leaked.  For example, if MPI_Comm_dup is called
+        without calling a corresponding MPI_Comm_free.  For uninteresting
+        reasons, enabling this option may prevent all known object leaks from
+        being reported.  MPICH2 must have been configure with
+        "--enable-g=handlealloc" or better in order for this functionality to
+        work.
+
 ...
 
 # Local Variables:



More information about the mpich2-commits mailing list