Commit a7b611d6 authored by Rob Latham's avatar Rob Latham
Browse files

[svn-r4010] 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)
parent dc27ca56
......@@ -32,7 +32,8 @@ mpi_sources = close.c read.c open.c write.c set_view.c \
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 @@ MPIO_OBJECTS = close.o read.o open.o write.o set_view.o \
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
......
......@@ -23,8 +23,6 @@
#include "mpioprof.h"
#endif
extern int ADIO_Init_keyval;
/*@
MPI_File_delete - Deletes a file
......@@ -36,7 +34,7 @@ Input Parameters:
@*/
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,34 +50,8 @@ int MPI_File_delete(char *filename, MPI_Info info)
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);
/* --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);
}
MPIR_MPIOInit(&error_code);
if (error_code != MPI_SUCCESS) goto fn_exit;
/* resolve file system type from file name; this is a collective call */
ADIO_ResolveFileType(MPI_COMM_SELF, filename, &file_system, &fsops,
......
......@@ -60,6 +60,10 @@ struct MPIR_Info {
MPI_Delete_function ADIOI_End_call;
/* common initialization routine */
void MPIR_MPIOInit(int * error_code);
#include "mpioprof.h"
#ifdef MPI_hpux
......
/* -*- 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
*/
......@@ -118,34 +118,8 @@ int MPI_File_open(MPI_Comm comm, char *filename, int amode,
*/
/* 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);
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);
}
MPIR_MPIOInit(&error_code);
if (error_code != MPI_SUCCESS) goto fn_fail;
file_system = -1;
......
......@@ -23,8 +23,6 @@
#include "mpioprof.h"
#endif
extern int ADIO_Init_keyval;
/*@
MPI_Register_datarep - Register functions for user-defined data
representations
......@@ -79,33 +77,8 @@ int MPI_Register_datarep(char *name,
}
/* --END ERROR HANDLING-- */
/* 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);
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);
}
MPIR_MPIOInit(&error_code);
if (error_code != MPI_SUCCESS) goto fn_exit;
/* --BEGIN ERROR HANDLING-- */
/* check datarep isn't already registered */
......
......@@ -23,8 +23,6 @@
#include "mpioprof.h"
#endif
extern int ADIO_Init_keyval;
/*@
MPI_Info_create - Creates a new info object
......@@ -35,33 +33,10 @@ Output Parameters:
@*/
int MPI_Info_create(MPI_Info *info)
{
int flag, error_code;
/* first check if ADIO has been initialized. If not, initialize it */
if (ADIO_Init_keyval == MPI_KEYVAL_INVALID) {
/* 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 */
int error_code;
ADIO_Init( (int *)0, (char ***)0, &error_code);
}
MPIR_MPIOInit(&error_code);
if (error_code != MPI_SUCCESS) goto fn_exit;
*info = (MPI_Info) ADIOI_Malloc(sizeof(struct MPIR_Info));
(*info)->cookie = MPIR_INFO_COOKIE;
......@@ -71,5 +46,6 @@ int MPI_Info_create(MPI_Info *info)
/* 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;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment