[mpich2-commits] r5503 - mpich2/trunk/src/mpi/datatype

goodell at mcs.anl.gov goodell at mcs.anl.gov
Tue Oct 20 15:35:37 CDT 2009


Author: goodell
Date: 2009-10-20 15:35:37 -0500 (Tue, 20 Oct 2009)
New Revision: 5503

Modified:
   mpich2/trunk/src/mpi/datatype/typeutil.c
Log:
Use proper allocation routines for predefined pair-types.

For some reason this was basically using a copy of the allocation code.
It still needs a little bit more cleanup, but it's much better now.

No reviewer.

Modified: mpich2/trunk/src/mpi/datatype/typeutil.c
===================================================================
--- mpich2/trunk/src/mpi/datatype/typeutil.c	2009-10-20 20:35:36 UTC (rev 5502)
+++ mpich2/trunk/src/mpi/datatype/typeutil.c	2009-10-20 20:35:37 UTC (rev 5503)
@@ -139,53 +139,39 @@
 int MPIR_Datatype_init(void)
 {
     int i;
-    MPIU_Handle_common *ptr;
+    MPID_Datatype *ptr;
 
     MPIU_Assert(MPID_Datatype_mem.initialized == 0);
     MPIU_Assert(MPID_DATATYPE_PREALLOC >= 5);
 
-#if 0
-    /* initialize also gets us our first pointer */
-    ptr = MPIU_Handle_direct_init(MPID_Datatype_mem.direct,
-				  MPID_Datatype_mem.direct_size,
-				  MPID_Datatype_mem.size,
-				  MPID_Datatype_mem.kind);
+    for (i=0; mpi_pairtypes[i] != (MPI_Datatype) -1; ++i) {
+        /* types based on 'long long' and 'long double', may be disabled at
+           configure time, and their values set to MPI_DATATYPE_NULL.  skip any
+           such types. */
+        if (mpi_pairtypes[i] == MPI_DATATYPE_NULL) continue;
+        /* XXX: this allocation strategy isn't right if one or more of the
+           pairtypes is MPI_DATATYPE_NULL.  in fact, the assert below will
+           fail if any type other than the las in the list is equal to
+           MPI_DATATYPE_NULL.  obviously, this should be fixed, but I need
+           to talk to Rob R. first. -- BRT */
+        /* XXX DJG it does work, but only because MPI_LONG_DOUBLE_INT is the
+         * only one that is ever optional and it comes last */
 
-    MPID_Datatype_mem.initialized = 1;
-    MPID_Datatype_mem.avail = ptr->next;
-#else
-    ptr = MPIU_Handle_obj_alloc_unsafe( &MPID_Datatype_mem );
-#endif
-    MPIU_Assert((void *) ptr == (void *) (MPID_Datatype_direct + HANDLE_INDEX(mpi_pairtypes[0])));
-    MPID_Type_create_pairtype(mpi_pairtypes[0], (MPID_Datatype *) ptr);
+        /* we use the _unsafe version because we are still in MPI_Init, before
+         * multiple threads are permitted and possibly before support for
+         * critical sections is entirely setup */
+        ptr = (MPID_Datatype *)MPIU_Handle_obj_alloc_unsafe( &MPID_Datatype_mem );
 
-    for (i=1; mpi_pairtypes[i] != (MPI_Datatype) -1; i++) {
-	/* types based on 'long long' and 'long double', may be disabled at
-	   configure time, and their values set to MPI_DATATYPE_NULL.  skip any
-	   such types. */
-	if (mpi_pairtypes[i] == MPI_DATATYPE_NULL) continue;
+        MPIU_Assert(ptr);
+        MPIU_Assert(ptr->handle == mpi_pairtypes[i]);
+        /* this is a redundant alternative to the previous statement */
+        MPIU_Assert((void *) ptr == (void *) (MPID_Datatype_direct + HANDLE_INDEX(mpi_pairtypes[i])));
 
-	/* XXX: this allocation strategy isn't right if one or more of the
-	   pairtypes is MPI_DATATYPE_NULL.  in fact, the assert below will
-	   fail if any type other than the las in the list is equal to
-	   MPI_DATATYPE_NULL.  obviously, this should be fixed, but I need
-	   to talk to Rob R. first. -- BRT */
-	ptr = MPID_Datatype_mem.avail;
-	MPID_Datatype_mem.avail = ptr->next;
-	ptr->next = 0;
-
-	MPIU_Assert(ptr);
-	MPIU_Assert((void *) ptr ==
-		    (void *) (MPID_Datatype_direct + HANDLE_INDEX(mpi_pairtypes[i])));
-
-	MPID_Type_create_pairtype(mpi_pairtypes[i], (MPID_Datatype *) ptr);
+        MPID_Type_create_pairtype(mpi_pairtypes[i], (MPID_Datatype *) ptr);
     }
 
-#if 0
-    MPIU_Handle_obj_alloc_complete(&MPID_Datatype_mem, 1);
-#endif
-    MPIR_Add_finalize(MPIR_Datatype_finalize, 0, 
-		      MPIR_FINALIZE_CALLBACK_PRIO-1);
+    MPIR_Add_finalize(MPIR_Datatype_finalize, 0,
+                      MPIR_FINALIZE_CALLBACK_PRIO-1);
 
     return MPI_SUCCESS;
 }



More information about the mpich2-commits mailing list