[mpich2-commits] r4010 - in mpich2/trunk/src/mpi/romio: mpi-io mpi2-other/info

robl at mcs.anl.gov robl at mcs.anl.gov
Wed Mar 11 10:54:16 CDT 2009


Author: robl
Date: 2009-03-11 10:54:16 -0500 (Wed, 11 Mar 2009)
New Revision: 4010

Added:
   mpich2/trunk/src/mpi/romio/mpi-io/mpir-mpioinit.c
Modified:
   mpich2/trunk/src/mpi/romio/mpi-io/Makefile.in
   mpich2/trunk/src/mpi/romio/mpi-io/delete.c
   mpich2/trunk/src/mpi/romio/mpi-io/mpioimpl.h
   mpich2/trunk/src/mpi/romio/mpi-io/open.c
   mpich2/trunk/src/mpi/romio/mpi-io/register_datarep.c
   mpich2/trunk/src/mpi/romio/mpi2-other/info/info_create.c
Log:
make ADIO initialization code a common routine.  Also, place ROMIO attributes
on comm_self, now that the standard explicitly states when attributes on
COMM_SELF are to be freed (early in MPI_FINALIZE).  Addresses two of the three
parts of #222 (initialization code in MPI-IO)



Modified: mpich2/trunk/src/mpi/romio/mpi-io/Makefile.in
===================================================================
--- mpich2/trunk/src/mpi/romio/mpi-io/Makefile.in	2009-03-11 09:33:14 UTC (rev 4009)
+++ mpich2/trunk/src/mpi/romio/mpi-io/Makefile.in	2009-03-11 15:54:16 UTC (rev 4010)
@@ -32,7 +32,8 @@
       wr_atalle.c write_allb.c write_alle.c \
       get_posn_sh.c iread_sh.c read_sh.c write_sh.c \
       iwrite_sh.c seek_sh.c read_ord.c read_orde.c write_ordb.c \
-      read_ordb.c write_ord.c write_orde.c mpiu_greq.c register_datarep.c
+      read_ordb.c write_ord.c write_orde.c mpiu_greq.c register_datarep.c\
+      mpir-mpioinit.c
 
 # EXTRA objects are ones that need to be included for all but MPICH2
 MPIO_OBJECTS = close.o read.o open.o write.o set_view.o \
@@ -49,7 +50,7 @@
       get_posn_sh.o iread_sh.o read_sh.o write_sh.o \
       iwrite_sh.o seek_sh.o read_ord.o read_orde.o write_ordb.o \
       read_ordb.o write_ord.o write_orde.o mpiu_greq.o mpich2_fileutil.o \
-      register_datarep.o
+      register_datarep.o mpir-mpioinit.o
 
 # MPIO_REQOBJECTS are the routines that provide the MPIO_Wait etc.
 # routines (iotest.o, iowait.o iowaitall.o iowaitany.o iotestall.o

Modified: mpich2/trunk/src/mpi/romio/mpi-io/delete.c
===================================================================
--- mpich2/trunk/src/mpi/romio/mpi-io/delete.c	2009-03-11 09:33:14 UTC (rev 4009)
+++ mpich2/trunk/src/mpi/romio/mpi-io/delete.c	2009-03-11 15:54:16 UTC (rev 4010)
@@ -23,8 +23,6 @@
 #include "mpioprof.h"
 #endif
 
-extern int ADIO_Init_keyval;
-
 /*@
     MPI_File_delete - Deletes a file
 
@@ -36,7 +34,7 @@
 @*/
 int MPI_File_delete(char *filename, MPI_Info info)
 {
-    int flag, error_code, file_system;
+    int error_code, file_system;
     char *tmp;
     ADIOI_Fns *fsops;
     static char myname[] = "MPI_FILE_DELETE";
@@ -52,35 +50,9 @@
     MPIU_THREAD_CS_ENTER(ALLFUNC,);
     MPIR_Nest_incr();
 
-    /* first check if ADIO has been initialized. If not, initialize it */
-    if (ADIO_Init_keyval == MPI_KEYVAL_INVALID) {
-        MPI_Initialized(&flag);
+    MPIR_MPIOInit(&error_code);
+    if (error_code != MPI_SUCCESS) goto fn_exit;
 
-	/* --BEGIN ERROR HANDLING-- */
-        if (!flag) {
-	    error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
-					      myname, __LINE__, MPI_ERR_OTHER, 
-					      "**initialized", 0);
-	    error_code = MPIO_Err_return_file(MPI_FILE_NULL, error_code);
-	    goto fn_exit;
-	}
-	/* --END ERROR HANDLING-- */
-
-        MPI_Keyval_create(MPI_NULL_COPY_FN, ADIOI_End_call, &ADIO_Init_keyval,
-                          (void *) 0);  
-
-	/* put a dummy attribute on MPI_COMM_WORLD, because we want the delete
-	   function to be called when MPI_COMM_WORLD is freed. Hopefully the
-	   MPI library frees MPI_COMM_WORLD when MPI_Finalize is called,
-	   though the standard does not mandate this. */
-
-        MPI_Attr_put(MPI_COMM_WORLD, ADIO_Init_keyval, (void *) 0);
-
-	/* initialize ADIO */
-        ADIO_Init( (int *)0, (char ***)0, &error_code);
-    }
-
-
     /* resolve file system type from file name; this is a collective call */
     ADIO_ResolveFileType(MPI_COMM_SELF, filename, &file_system, &fsops, 
 			 &error_code);

Modified: mpich2/trunk/src/mpi/romio/mpi-io/mpioimpl.h
===================================================================
--- mpich2/trunk/src/mpi/romio/mpi-io/mpioimpl.h	2009-03-11 09:33:14 UTC (rev 4009)
+++ mpich2/trunk/src/mpi/romio/mpi-io/mpioimpl.h	2009-03-11 15:54:16 UTC (rev 4010)
@@ -60,6 +60,10 @@
 
 MPI_Delete_function ADIOI_End_call;
 
+/* common initialization routine */
+void MPIR_MPIOInit(int * error_code);
+
+
 #include "mpioprof.h"
 
 #ifdef MPI_hpux

Added: mpich2/trunk/src/mpi/romio/mpi-io/mpir-mpioinit.c
===================================================================
--- mpich2/trunk/src/mpi/romio/mpi-io/mpir-mpioinit.c	                        (rev 0)
+++ mpich2/trunk/src/mpi/romio/mpi-io/mpir-mpioinit.c	2009-03-11 15:54:16 UTC (rev 4010)
@@ -0,0 +1,56 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ *  (C) 2009 UChicago/Argonne LLC
+ *      See COPYRIGHT in top-level directory.
+ */
+#include <string.h>
+#include "mpioimpl.h"
+
+#ifdef HAVE_WEAK_SYMBOLS
+/* Include mapping from MPI->PMPI */
+#define MPIO_BUILD_PROFILING
+#include "mpioprof.h"
+#endif
+
+extern int ADIO_Init_keyval;
+
+/* common code to stuff an attribute on a communicator for the purpose of
+ * cleaning up in MPI_Finalize() */
+
+void MPIR_MPIOInit(int * error_code) {
+
+    int flag;
+    char myname[] = "MPIR_MPIOInit";
+
+    /* first check if ADIO has been initialized. If not, initialize it */
+    if (ADIO_Init_keyval == MPI_KEYVAL_INVALID) {
+        MPI_Initialized(&flag);
+
+	/* --BEGIN ERROR HANDLING-- */
+        if (!flag) {
+	    *error_code = MPIO_Err_create_code(MPI_SUCCESS, 
+		    MPIR_ERR_RECOVERABLE, myname, __LINE__, 
+		    MPI_ERR_OTHER, "**initialized", 0);
+	    *error_code = MPIO_Err_return_file(MPI_FILE_NULL, *error_code);
+	    return;
+	}
+	/* --END ERROR HANDLING-- */
+
+        MPI_Keyval_create(MPI_NULL_COPY_FN, ADIOI_End_call, &ADIO_Init_keyval,
+                          (void *) 0);  
+
+	/* put a dummy attribute on MPI_COMM_SELF, because we want the delete
+	   function to be called when MPI_COMM_SELF is freed. Clarified
+	   in MPI-2 section 4.8, the standard mandates that attribugtes on
+	   MPI_COMM_SELF get cleaned up early in MPI_Finalize */
+
+        MPI_Attr_put(MPI_COMM_SELF, ADIO_Init_keyval, (void *) 0);
+
+	/* initialize ADIO */
+        ADIO_Init( (int *)0, (char ***)0, error_code);
+    }
+    *error_code = MPI_SUCCESS;
+}
+/* 
+ * vim: ts=8 sts=4 sw=4 noexpandtab 
+ */

Modified: mpich2/trunk/src/mpi/romio/mpi-io/open.c
===================================================================
--- mpich2/trunk/src/mpi/romio/mpi-io/open.c	2009-03-11 09:33:14 UTC (rev 4009)
+++ mpich2/trunk/src/mpi/romio/mpi-io/open.c	2009-03-11 15:54:16 UTC (rev 4010)
@@ -118,35 +118,9 @@
 */
 
 /* check if ADIO has been initialized. If not, initialize it */
-    if (ADIO_Init_keyval == MPI_KEYVAL_INVALID) {
-	MPI_Initialized(&flag);
+    MPIR_MPIOInit(&error_code);
+    if (error_code != MPI_SUCCESS) goto fn_fail;
 
-	/* --BEGIN ERROR HANDLING-- */
-	if (!flag) {
-	    error_code = MPIO_Err_create_code(MPI_SUCCESS,
-					      MPIR_ERR_RECOVERABLE,
-					      myname, __LINE__, MPI_ERR_OTHER,
-					      "**initialized", 0);
-	    goto fn_fail;
-	}
-	/* --END ERROR HANDLING-- */
-
-	MPI_Keyval_create(MPI_NULL_COPY_FN, ADIOI_End_call, &ADIO_Init_keyval,
-			  (void *) 0);  
-
-/* put a dummy attribute on MPI_COMM_WORLD, because we want the delete
-   function to be called when MPI_COMM_WORLD is freed. Hopefully the
-   MPI library frees MPI_COMM_WORLD when MPI_Finalize is called,
-   though the standard does not mandate this. */
-
-	MPI_Attr_put(MPI_COMM_WORLD, ADIO_Init_keyval, (void *) 0);
-
-/* initialize ADIO */
-
-	ADIO_Init( (int *)0, (char ***)0, &error_code);
-    }
-
-
     file_system = -1;
 
     /* resolve file system type from file name; this is a collective call */

Modified: mpich2/trunk/src/mpi/romio/mpi-io/register_datarep.c
===================================================================
--- mpich2/trunk/src/mpi/romio/mpi-io/register_datarep.c	2009-03-11 09:33:14 UTC (rev 4009)
+++ mpich2/trunk/src/mpi/romio/mpi-io/register_datarep.c	2009-03-11 15:54:16 UTC (rev 4010)
@@ -23,8 +23,6 @@
 #include "mpioprof.h"
 #endif
 
-extern int ADIO_Init_keyval;
-
 /*@
   MPI_Register_datarep - Register functions for user-defined data 
                          representations
@@ -79,34 +77,9 @@
     }
     /* --END ERROR HANDLING-- */
 
-    /* first check if ADIO has been initialized. If not, initialize it */
-    if (ADIO_Init_keyval == MPI_KEYVAL_INVALID) {
-        MPI_Initialized(&flag);
+    MPIR_MPIOInit(&error_code);
+    if (error_code != MPI_SUCCESS) goto fn_exit;
 
-	/* --BEGIN ERROR HANDLING-- */
-        if (!flag) {
-	    error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
-					      myname, __LINE__, MPI_ERR_OTHER, 
-					      "**initialized", 0);
-	    error_code = MPIO_Err_return_file(MPI_FILE_NULL, error_code);
-	    goto fn_exit;
-	}
-	/* --END ERROR HANDLING-- */
-
-        MPI_Keyval_create(MPI_NULL_COPY_FN, ADIOI_End_call, &ADIO_Init_keyval,
-                          (void *) 0);  
-
-	/* put a dummy attribute on MPI_COMM_WORLD, because we want the delete
-	   function to be called when MPI_COMM_WORLD is freed. Hopefully the
-	   MPI library frees MPI_COMM_WORLD when MPI_Finalize is called,
-	   though the standard does not mandate this. */
-
-        MPI_Attr_put(MPI_COMM_WORLD, ADIO_Init_keyval, (void *) 0);
-
-	/* initialize ADIO */
-        ADIO_Init( (int *)0, (char ***)0, &error_code);
-    }
-
     /* --BEGIN ERROR HANDLING-- */
     /* check datarep isn't already registered */
     for (datarep = ADIOI_Datarep_head; datarep; datarep = datarep->next) {

Modified: mpich2/trunk/src/mpi/romio/mpi2-other/info/info_create.c
===================================================================
--- mpich2/trunk/src/mpi/romio/mpi2-other/info/info_create.c	2009-03-11 09:33:14 UTC (rev 4009)
+++ mpich2/trunk/src/mpi/romio/mpi2-other/info/info_create.c	2009-03-11 15:54:16 UTC (rev 4010)
@@ -23,8 +23,6 @@
 #include "mpioprof.h"
 #endif
 
-extern int ADIO_Init_keyval;
-
 /*@
     MPI_Info_create - Creates a new info object
 
@@ -35,34 +33,11 @@
 @*/
 int MPI_Info_create(MPI_Info *info)
 {
-    int flag, error_code;
+    int error_code;
 
-    /* first check if ADIO has been initialized. If not, initialize it */
-    if (ADIO_Init_keyval == MPI_KEYVAL_INVALID) {
+    MPIR_MPIOInit(&error_code);
+    if (error_code != MPI_SUCCESS) goto fn_exit;
 
-   /* check if MPI itself has been initialized. If not, flag an error.
-   Can't initialize it here, because don't know argc, argv */
-        MPI_Initialized(&flag);
-        if (!flag) {
-            FPRINTF(stderr, "Error: MPI_Init() must be called before using MPI_Info_create\n");
-            MPI_Abort(MPI_COMM_WORLD, 1);
-        }
-
-        MPI_Keyval_create(MPI_NULL_COPY_FN, ADIOI_End_call, &ADIO_Init_keyval,
-                          (void *) 0);  
-
-   /* put a dummy attribute on MPI_COMM_WORLD, because we want the delete
-   function to be called when MPI_COMM_WORLD is freed. Hopefully the
-   MPI library frees MPI_COMM_WORLD when MPI_Finalize is called,
-   though the standard does not mandate this. */
-
-        MPI_Attr_put(MPI_COMM_WORLD, ADIO_Init_keyval, (void *) 0);
-
-/* initialize ADIO */
-
-        ADIO_Init( (int *)0, (char ***)0, &error_code);
-    }
-
     *info = (MPI_Info) ADIOI_Malloc(sizeof(struct MPIR_Info));
     (*info)->cookie = MPIR_INFO_COOKIE;
     (*info)->key = 0;
@@ -71,5 +46,6 @@
     /* this is the first structure in this linked list. it is 
        always kept empty. new (key,value) pairs are added after it. */
 
+fn_exit:
     return MPI_SUCCESS;
 }



More information about the mpich2-commits mailing list