summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5C.c73
-rw-r--r--src/H5Cpublic.h4
-rw-r--r--src/H5F.c85
-rw-r--r--src/H5Fmpio.c18
-rw-r--r--src/H5Fprivate.h26
-rw-r--r--src/H5Fpublic.h5
-rw-r--r--src/H5M.c17
-rw-r--r--src/H5private.h9
-rw-r--r--src/H5public.h4
9 files changed, 207 insertions, 34 deletions
diff --git a/src/H5C.c b/src/H5C.c
index 4c4f4fe..7a20114 100644
--- a/src/H5C.c
+++ b/src/H5C.c
@@ -141,13 +141,14 @@ H5Ccreate(H5C_class_t type)
/* Allocate a new template and initialize it with default values */
switch (type) {
case H5C_FILE_CREATE:
- tmpl = H5MM_xmalloc(sizeof(H5F_create_t));
+ tmpl = H5MM_xmalloc(sizeof(H5F_create_t));
memcpy(tmpl, &H5F_create_dflt, sizeof(H5F_create_t));
break;
case H5C_FILE_ACCESS:
- HRETURN_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
- "not implemented yet");
+ tmpl = H5MM_xmalloc(sizeof(H5F_access_t));
+ memcpy(tmpl, &H5F_access_dflt, sizeof(H5F_access_t));
+ break;
case H5C_DATASET_CREATE:
tmpl = H5MM_xmalloc(sizeof(H5D_create_t));
@@ -233,6 +234,9 @@ H5Cclose(hid_t tid)
if (NULL == (tmpl = H5A_remove(tid))) {
HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "unable to remove atom");
}
+#ifdef LATER
+ /* this is for file access template too. Need to free the COMM and INFO objects too. */
+#endif
H5MM_xfree(tmpl);
FUNC_LEAVE(SUCCEED);
@@ -853,6 +857,69 @@ H5Cget_chunk(hid_t tid, int max_ndims, size_t dim[] /*out */ )
FUNC_LEAVE(tmpl->chunk_ndims);
}
+
+#ifdef HAVE_PARALLEL
+/*-------------------------------------------------------------------------
+ * Function: H5Cset_mpi
+ *
+ * Purpose: Sets the access mode for MPIO call and store the user supplied
+ * communicator and info.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Albert Cheng
+ * Feb 3, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Cset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode)
+{
+ int i;
+ H5F_access_t *tmpl = NULL;
+ MPI_Comm lcomm;
+ int mrc; /* MPI return code */
+
+ FUNC_ENTER(H5Cset_mpi, FAIL);
+
+ /* Check arguments */
+ if (H5C_FILE_ACCESS != H5Cget_class(tid) ||
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file access template");
+ }
+ switch (access_mode){
+ case H5ACC_INDEPENDENT:
+ /* fall through to next case */
+ case H5ACC_COLLECTIVE:
+ tmpl->access_mode = access_mode;
+ break;
+
+ default:
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "unknown access_mode");
+ }
+
+ /* store a duplicate copy of comm so that user may freely modify comm after this */
+ /* call. */
+#ifdef LATER
+ /* need to verify comm and info contain sensible information */
+ /* need to duplicate info too but don't know a quick way to do it now. */
+#endif
+ if ((mrc = MPI_Comm_dup(comm, &lcomm) != MPI_SUCCESS))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "failure to duplicate communicator");
+ tmpl->comm = comm;
+ tmpl->info = info;
+
+ FUNC_LEAVE(SUCCEED);
+}
+
+#endif /*HAVE_PARALLEL*/
/*--------------------------------------------------------------------------
NAME
diff --git a/src/H5Cpublic.h b/src/H5Cpublic.h
index aca09d2..b3b5348 100644
--- a/src/H5Cpublic.h
+++ b/src/H5Cpublic.h
@@ -61,6 +61,10 @@ herr_t H5Cset_layout (hid_t tid, H5D_layout_t layout);
H5D_layout_t H5Cget_layout (hid_t tid);
herr_t H5Cset_chunk (hid_t tid, int ndims, const size_t dim[]);
int H5Cget_chunk (hid_t tid, int max_ndims, size_t dim[]/*out*/);
+#ifdef HAVE_PARALLEL
+herr_t H5Cset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode);
+/* herr_t H5Cget_mpi (hid_t tid, int *ik); */ /* not defined yet */
+#endif
#ifdef __cplusplus
}
diff --git a/src/H5F.c b/src/H5F.c
index 1efc496..4b7d669 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -77,8 +77,8 @@ const H5F_create_t H5F_create_dflt = {
0, /* unused */
0, /* unused */
},
- sizeof(size_t), /* Default offset size */
- sizeof(size_t), /* Default length size */
+ 4, /* Default offset size */
+ 4, /* Default length size */
HDF5_BOOTBLOCK_VERSION, /* Current Boot-Block version # */
HDF5_SMALLOBJECT_VERSION, /* Current Small-Object heap version # */
HDF5_FREESPACE_VERSION, /* Current Free-Space info version # */
@@ -86,6 +86,18 @@ const H5F_create_t H5F_create_dflt = {
HDF5_SHAREDHEADER_VERSION, /* Current Shared-Header format version # */
};
+/*
+ * Define the default file access template.
+ */
+const H5F_access_t H5F_access_dflt =
+{
+ H5ACC_DEFAULT, /* Default file access mode */
+#ifdef HAVE_PARALLEL
+ MPI_COMM_NULL, /* Default is not using MPIO */
+ MPI_INFO_NULL, /* Default no info */
+#endif
+};
+
/* Interface initialization */
static intn interface_initialize_g = FALSE;
#define INTERFACE_INIT H5F_init_interface
@@ -557,7 +569,7 @@ H5F_dest(H5F_t *f)
*/
H5F_t *
H5F_open(const H5F_low_class_t *type, const char *name, uintn flags,
- const H5F_create_t *create_parms)
+ const H5F_create_t *create_parms, const H5F_access_t *access_parms)
{
H5F_t *f = NULL; /*return value */
H5F_t *ret_value = NULL; /*a copy of `f' */
@@ -623,7 +635,7 @@ H5F_open(const H5F_low_class_t *type, const char *name, uintn flags,
fprintf(stderr, "HDF5-DIAG: opening a split file\n");
#endif
fullname[s - name] = '\0';
- f = H5F_open(H5F_LOW_SPLIT, fullname, flags, create_parms);
+ f = H5F_open(H5F_LOW_SPLIT, fullname, flags, create_parms, access_parms);
HRETURN(f);
}
}
@@ -984,6 +996,11 @@ H5Fcreate(const char *filename, uintn flags, hid_t create_temp,
const H5F_create_t *create_parms; /* pointer to the parameters to
* use when creating the file
*/
+ const H5F_access_t *access_parms; /* pointer to the file access
+ * parameters to use when creating
+ * the file
+ */
+ const H5F_low_class_t *type; /* File type */
hid_t ret_value = FAIL;
FUNC_ENTER(H5Fcreate, FAIL);
@@ -1001,19 +1018,35 @@ H5Fcreate(const char *filename, uintn flags, hid_t create_temp,
} else if (NULL == (create_parms = H5A_object(create_temp))) {
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't unatomize template");
}
-#ifdef LATER
if (access_temp <= 0) {
access_parms = &H5F_access_dflt;
} else if (NULL == (access_parms = H5A_object(access_temp))) {
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /*can't unatomize template */
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't unatomize template");
}
+ /* figure out what kind of file I/O to use. */
+ /* Currently, MPIO is the only alternative than default I/O */
+ switch (access_parms->access_mode){
+ case H5ACC_DEFAULT:
+ type = H5F_LOW_DFLT;
+ break;
+#ifdef HAVE_PARALLEL
+ case H5ACC_INDEPENDENT:
+ type = H5F_LOW_MPIO;
+ break;
+ case H5ACC_COLLECTIVE:
+ /* not implemented yet */
+ /* type = H5F_LOW_MPIO; */
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid file access mode");
#endif
-
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid file access mode");
+ }
+
/*
* Create a new file or truncate an existing file.
*/
- if (NULL == (new_file = H5F_open(H5F_LOW_DFLT, filename, flags,
- create_parms))) {
+ if (NULL == (new_file = H5F_open(type, filename, flags,
+ create_parms, access_parms))) {
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "can't create file");
}
/* Get an atom for the file */
@@ -1076,6 +1109,11 @@ hid_t
H5Fopen(const char *filename, uintn flags, hid_t access_temp)
{
H5F_t *new_file = NULL; /* file struct for new file */
+ const H5F_access_t *access_parms; /* pointer to the file access
+ * parameters to use when creating
+ * the file
+ */
+ const H5F_low_class_t *type; /* File type */
hid_t ret_value = FAIL;
FUNC_ENTER(H5Fopen, FAIL);
@@ -1085,15 +1123,32 @@ H5Fopen(const char *filename, uintn flags, hid_t access_temp)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid file name");
flags = flags & H5ACC_WRITE ? H5F_ACC_WRITE : 0;
-#ifdef LATER
- if (access_temp <= 0)
- access_temp = H5CPget_default_atom(H5_TEMPLATE);
- if (NULL == (f_access_parms = H5A_object(access_temp)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /*can't unatomize template */
+ if (access_temp <= 0) {
+ access_parms = &H5F_access_dflt;
+ } else if (NULL == (access_parms = H5A_object(access_temp))) {
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't unatomize template");
+ }
+ /* figure out what kind of file I/O to use. */
+ /* Currently, MPIO is the only alternative than default I/O */
+ switch (access_parms->access_mode){
+ case H5ACC_DEFAULT:
+ type = H5F_LOW_DFLT;
+ break;
+#ifdef HAVE_PARALLEL
+ case H5ACC_INDEPENDENT:
+ type = H5F_LOW_MPIO;
+ break;
+ case H5ACC_COLLECTIVE:
+ /* not implemented yet */
+ /* type = H5F_LOW_MPIO; */
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid file access mode");
#endif
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid file access mode");
+ }
/* Open the file */
- if (NULL == (new_file = H5F_open(H5F_LOW_DFLT, filename, flags, NULL))) {
+ if (NULL == (new_file = H5F_open(type, filename, flags, NULL, access_parms))) {
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "cant open file");
}
/* Get an atom for the file */
diff --git a/src/H5Fmpio.c b/src/H5Fmpio.c
index 6db6bc8..b9f2238 100644
--- a/src/H5Fmpio.c
+++ b/src/H5Fmpio.c
@@ -127,7 +127,7 @@ ino_t mpio_inode_num = 0; /* fake "inode" number */
*-------------------------------------------------------------------------
*/
static hbool_t
-H5F_mpio_access(char *name, int mode, H5F_search_t *key /*out */ )
+H5F_mpio_access(const char *name, int mode, H5F_search_t *key /*out */ )
{
hbool_t ret_val = FALSE;
MPI_File fh;
@@ -150,24 +150,25 @@ H5F_mpio_access(char *name, int mode, H5F_search_t *key /*out */ )
break;
case W_OK: mpi_mode = MPI_MODE_WRONLY;
break;
- default: HRETURN_ERROR(H5E_IO, H5E_ARGS, FAIL,
+ default: HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"invalid mode parameter");
}
- mpierr = MPI_File_open( MPI_COMM_SELF, name, mpi_mode, MPI_INFO_NULL, &fh );
+ /* (char*) name is okay since MPI_File_open will not change it. */
+ mpierr = MPI_File_open( MPI_COMM_SELF, (char*) name, mpi_mode, MPI_INFO_NULL, &fh );
if (mpierr == MPI_SUCCESS) {
mpierr = MPI_File_close( &fh );
if (mpierr != MPI_SUCCESS)
- HRETURN_ERROR(H5E_IO, H5E_ARGS, FAIL, "MPI_File_open failed");
+ HRETURN_ERROR(H5E_IO, H5E_CLOSEERROR, FAIL, "MPI_File_close failed");
ret_val = TRUE;
} else if (mode == F_OK) {
/* to see if it exists, this time try to open for write */
- mpierr = MPI_File_open( MPI_COMM_SELF, name, MPI_MODE_WRONLY,
+ mpierr = MPI_File_open( MPI_COMM_SELF, (char*)name, MPI_MODE_WRONLY,
MPI_INFO_NULL, &fh );
if (mpierr == MPI_SUCCESS) {
mpierr = MPI_File_close( &fh );
if (mpierr != MPI_SUCCESS)
- HRETURN_ERROR(H5E_IO, H5E_INTERNAL, FAIL, "MPI_File_close failed");
+ HRETURN_ERROR(H5E_IO, H5E_CLOSEERROR, FAIL, "MPI_File_close failed");
ret_val = TRUE;
}
}
@@ -214,7 +215,7 @@ H5F_mpio_access(char *name, int mode, H5F_search_t *key /*out */ )
*-------------------------------------------------------------------------
*/
static H5F_low_t *
-H5F_mpio_open(char *name, uintn flags, H5F_search_t *key /*out */ )
+H5F_mpio_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
{
H5F_low_t *lf = NULL;
MPI_File fh;
@@ -234,7 +235,7 @@ H5F_mpio_open(char *name, uintn flags, H5F_search_t *key /*out */ )
if (flags&H5F_ACC_CREAT) mpi_amode |= MPI_MODE_CREATE;
if (flags&H5F_ACC_EXCL) mpi_amode |= MPI_MODE_EXCL;
- mpierr = MPI_File_open(MPI_COMM_WORLD, name, mpi_amode, MPI_INFO_NULL, &fh);
+ mpierr = MPI_File_open(MPI_COMM_WORLD, (char*)name, mpi_amode, MPI_INFO_NULL, &fh);
if (mpierr != MPI_SUCCESS) {
MPI_Error_string( mpierr, mpierrmsg, &msglen );
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, mpierrmsg );
@@ -391,6 +392,7 @@ H5F_mpio_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, mpierrmsg );
}
+#define MPI_KLUGE0202
#ifdef MPI_KLUGE0202
/* KLUGE rky 980202 MPI_Get_count incorrectly returns negative count;
fake a complete read */
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 76ca1f6..3f71055 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -22,7 +22,7 @@
/* This is a near top-level header! Try not to include much! */
#include <H5private.h>
-#ifdef PHDF5
+#ifdef HAVE_PARALLEL
#ifndef MPI_SUCCESS
#include <mpi.h>
#include <mpio.h>
@@ -231,6 +231,17 @@ typedef struct H5F_create_t {
} H5F_create_t;
/*
+ * File-access template.
+ */
+typedef struct H5F_access_t {
+ uintn access_mode; /* file access mode */
+#ifdef HAVE_PARALLEL
+ MPI_Comm comm; /* communicator for file access */
+ MPI_Info info; /* optional info for MPI-IO */
+#endif /*HAVE_PARALLEL*/
+} H5F_access_t;
+
+/*
* These things make a file unique.
*/
typedef struct H5F_search_t {
@@ -304,7 +315,7 @@ typedef struct H5F_low_t {
size_t alloc; /* Current size of MEM buffer */
} core;
-#ifdef PHDF5
+#ifdef HAVE_PARALLEL
/* MPI-IO */
struct {
MPI_File f; /* MPI-IO file handle */
@@ -323,10 +334,8 @@ extern const H5F_low_class_t H5F_LOW_STDIO[]; /* Posix stdio */
extern const H5F_low_class_t H5F_LOW_CORE[]; /* In-core temp file */
extern const H5F_low_class_t H5F_LOW_FAM[]; /* File family */
extern const H5F_low_class_t H5F_LOW_SPLIT[]; /* Split meta/raw data */
-#ifdef PHDF5
+#ifdef HAVE_PARALLEL
extern const H5F_low_class_t H5F_LOW_MPIO[]; /* MPI-IO */
-# undef H5F_LOW_DFLT
-# define H5F_LOW_DFLT H5F_LOW_MPIO /* The default type */
#endif
/*
@@ -346,8 +355,8 @@ typedef struct H5F_file_t {
haddr_t hdf5_eof; /* Relative addr of end of all hdf5 data*/
struct H5AC_t *cache; /* The object cache */
H5F_create_t create_parms; /* File-creation template */
-#ifdef LATER
- file_access_temp_t file_access_parms; /* File-access template */
+#ifdef HAVE_PARALLEL
+ H5F_access_t access_parms; /* File-access template */
#endif
struct H5G_entry_t *root_ent; /* Root symbol table entry */
} H5F_file_t;
@@ -414,11 +423,12 @@ struct H5O_layout_t; /*forward decl for prototype arguments */
/* library variables */
extern const H5F_create_t H5F_create_dflt;
+extern const H5F_access_t H5F_access_dflt;
/* Private functions, not part of the publicly documented API */
void H5F_encode_length_unusual(const H5F_t *f, uint8 **p, uint8 *l);
H5F_t *H5F_open(const H5F_low_class_t *type, const char *name, uintn flags,
- const H5F_create_t *create_parms);
+ const H5F_create_t *create_parms, const H5F_access_t *access_parms);
herr_t H5F_close(H5F_t *f);
herr_t H5F_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
intn fwidth);
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index 885277d..538b07b 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -24,6 +24,11 @@
#define H5ACC_DEFAULT 0x0000/*use in H5Fopen & H5Fcreate to open a file with default access*/
#define H5ACC_WRITE 0x0001/*use in H5Fopen to open a file with write access*/
#define H5ACC_OVERWRITE 0x0002/*use in H5Fcreate truncate an existing file*/
+#ifdef HAVE_PARALLEL
+#define H5ACC_INDEPENDENT 0x0010/*use in H5Cset_mpi for MPI independent access*/
+#define H5ACC_COLLECTIVE 0x0011/*use in H5Cset_mpi for MPI collective access*/
+#endif
+
#ifdef __cplusplus
extern "C" {
diff --git a/src/H5M.c b/src/H5M.c
index 5466a1e..a9dc02b 100644
--- a/src/H5M.c
+++ b/src/H5M.c
@@ -76,6 +76,23 @@ static meta_func_t meta_func_arr[] =
NULL, /* File-Creation Template GetFile */
H5Cclose /* File-Creation Template Release */
},
+ { /* Template object meta-functions (defined in H5C.c) */
+ H5_TEMPLATE_1, /* File-Access Template Type ID */
+ NULL, /* File-Access Template Create */
+ NULL, /* File-Access Template Access */
+ H5Ccopy, /* File-Access Template Copy */
+ NULL, /* File-Access Template FindName */
+ NULL, /* File-Access Template NameLen */
+ NULL, /* File-Access Template GetName */
+ NULL, /* File-Access Template SetName */
+ NULL, /* File-Access Template Search */
+ NULL, /* File-Access Template Index */
+ NULL, /* File-Access Template Flush */
+ NULL, /* File-Access Template Delete */
+ NULL, /* File-Access Template GetParent */
+ NULL, /* File-Access Template GetFile */
+ H5Cclose /* File-Access Template Release */
+ },
{ /* Datatype object meta-functions (defined in H5T.c) */
H5_DATATYPE, /* Datatype Type ID */
NULL, /* Datatype Create */
diff --git a/src/H5private.h b/src/H5private.h
index 995b53d..a2d5d49 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -46,6 +46,15 @@
# include <unistd.h>
#endif
+#ifdef HAVE_PARALLEL
+/*
+ * MPIO headers
+ */
+# include <mpi.h>
+# include <mpio.h>
+#endif
+
+
/*
* Pablo support files.
*/
diff --git a/src/H5public.h b/src/H5public.h
index 7436cc2..9d7eee8 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -18,6 +18,10 @@
#include <H5config.h> /*from configure */
#include <sys/types.h>
+#ifdef HAVE_PARALLEL
+#include <mpi.h>
+#include <mpio.h>
+#endif
/*
* Data types