summaryrefslogtreecommitdiffstats
path: root/src/H5S.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-07-24 18:56:48 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-07-24 18:56:48 (GMT)
commit40df66ebd027351e48eea8b7499490c9654d3943 (patch)
tree9dd8b9170bec792e840e2b350ca48153cd45ce88 /src/H5S.c
parentc968525b29ce8cee8e842f6a7a1bbd78acc6b63f (diff)
downloadhdf5-40df66ebd027351e48eea8b7499490c9654d3943.zip
hdf5-40df66ebd027351e48eea8b7499490c9654d3943.tar.gz
hdf5-40df66ebd027351e48eea8b7499490c9654d3943.tar.bz2
[svn-r5834] Purpose:
Large code cleanup/re-write Description: This is phase 1 of the data I/O re-architecture, with the following changes: - Changed the selection drivers to not actually do any I/O, they only generate the sequences of offset/length pairs needed for the I/O (or memory access, in the case of iterating or filling a selection in a memory buffer) - Wrote more abstract I/O routines which get the sequence of offset/ length pairs for each selection and access perform the I/O or memory access. Benefits of this change include: - Removed ~3400 lines of quite redundant code, with corresponding reduction in the size of library binary. - Any selection can now directly access memory when performing I/O, if no type conversions are required, instead of just "regular" hyperslab and 'all' selections, which speeds up I/O. - Sped up I/O for hyperslab selections which have contiguous lower dimensions by "flattening" them out into lesser dimensional objects for the I/O. No file format or API changes were necessary for this change. The next phase will be to create a "selection driver" for each type of selection, allowing each type of selection to directly call certain methods that only apply to that type of selection, instead of passing through dozens of functions which have switch statements to call the appropriate method for each selection type. This will also reduce the amount of code in the library and speed things up a bit more. Phase 3 will involve generating an MPI datatype for all types of selections, instead of only "regular" hyperslab and 'all' selections. This will allow collective parallel I/O for all I/O operations which don't require type conversions. It will also open up the door for allowing collective I/O on datasets which require type conversion. Phase 4 will involve changing the access pattern to deal with chunked datasets in a more optimal way (in serial). Phase 5 will deal with accessing chunked datasets more optimally for collective parallel I/O operations. Platforms tested: FreeBSD 4.6 (sleipnir) w/ parallel & C++ and IRIX64 6.5 (modi4) w/parallel
Diffstat (limited to 'src/H5S.c')
-rw-r--r--src/H5S.c123
1 files changed, 22 insertions, 101 deletions
diff --git a/src/H5S.c b/src/H5S.c
index 0aa9b18..8d5e8b9 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -16,12 +16,12 @@
#define _H5S_IN_H5S_C
#include "H5private.h" /* Generic Functions */
-#include "H5Iprivate.h" /* ID Functions */
#include "H5Eprivate.h" /* Error handling */
+#include "H5Iprivate.h" /* ID Functions */
#include "H5FLprivate.h" /* Free Lists */
#include "H5MMprivate.h" /* Memory Management functions */
#include "H5Oprivate.h" /* object headers */
-#include "H5Spkg.h" /* Data-space functions */
+#include "H5Spkg.h" /* Dataspace functions */
/* Local static function prototypes */
@@ -31,9 +31,12 @@
static int interface_initialize_g = 0;
static herr_t H5S_init_interface(void);
-/* Tables of file and memory conversion information */
-static const H5S_fconv_t *H5S_fconv_g[H5S_SEL_N];
-static const H5S_mconv_t *H5S_mconv_g[H5S_SEL_N];
+#ifdef H5S_DEBUG
+/* Names of the selection names, for debugging */
+static const char *H5S_sel_names[]={
+ "none", "point", "hyperslab", "all"
+};
+#endif /* H5S_DEBUG */
/* The path table, variable length */
static H5S_conv_t **H5S_conv_g = NULL;
@@ -83,14 +86,6 @@ H5S_init_interface(void)
"unable to initialize interface");
}
- /* Register space conversion functions */
- if (H5S_register(H5S_SEL_POINTS, H5S_POINT_FCONV, H5S_POINT_MCONV)<0 ||
- H5S_register(H5S_SEL_ALL, H5S_ALL_FCONV, H5S_ALL_MCONV) <0 ||
- H5S_register(H5S_SEL_HYPERSLABS, H5S_HYPER_FCONV, H5S_HYPER_MCONV) <0) {
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL,
- "unable to register one or more conversion functions");
- }
-
#ifdef H5_HAVE_PARALLEL
{
/* Allow MPI buf-and-file-type optimizations? */
@@ -175,7 +170,7 @@ H5S_term_interface(void)
/* Summary */
sprintf(buf, "%s %c %s",
- path->m->name, 0==j?'>':'<', path->f->name);
+ H5S_sel_names[path->mtype], 0==j?'>':'<', H5S_sel_names[path->ftype]);
fprintf(H5DEBUG(S), " %-16s\n", buf);
/* Gather */
@@ -266,9 +261,8 @@ H5S_term_interface(void)
H5I_destroy_group(H5I_DATASPACE);
/* Clear/free conversion table */
- HDmemset(H5S_fconv_g, 0, sizeof(H5S_fconv_g));
- HDmemset(H5S_mconv_g, 0, sizeof(H5S_mconv_g));
- for (i=0; i<H5S_nconv_g; i++) H5MM_xfree(H5S_conv_g[i]);
+ for (i=0; i<H5S_nconv_g; i++)
+ H5MM_xfree(H5S_conv_g[i]);
H5S_conv_g = H5MM_xfree(H5S_conv_g);
H5S_nconv_g = H5S_aconv_g = 0;
@@ -282,46 +276,6 @@ H5S_term_interface(void)
}
-/*-------------------------------------------------------------------------
- * Function: H5S_register
- *
- * Purpose: Adds information about a data space conversion to the space
- * conversion table. A space conversion has two halves: the
- * half that copies data points between application memory and
- * the type conversion array, and the half that copies points
- * between the type conversion array and the file. Both halves
- * are required.
- *
- * Note: The conversion table will contain pointers to the file and
- * memory conversion info. The FCONV and MCONV arguments are
- * not copied.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Robb Matzke
- * Tuesday, August 11, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5S_register(H5S_sel_type cls, const H5S_fconv_t *fconv,
- const H5S_mconv_t *mconv)
-{
- FUNC_ENTER_NOAPI(H5S_register, FAIL);
-
- assert(cls>=0 && cls<H5S_SEL_N);
- assert(fconv);
- assert(mconv);
-
- H5S_fconv_g[cls] = fconv;
- H5S_mconv_g[cls] = mconv;
-
- FUNC_LEAVE(SUCCEED);
-}
-
-
/*--------------------------------------------------------------------------
NAME
H5S_create
@@ -1514,7 +1468,9 @@ H5S_conv_t *
H5S_find (const H5S_t *mem_space, const H5S_t *file_space, unsigned flags)
{
H5S_conv_t *path; /* Space conversion path */
+#ifdef H5_HAVE_PARALLEL
htri_t opt; /* Flag whether a selection is optimizable */
+#endif /* H5_HAVE_PARALLEL */
size_t i; /* Index variable */
FUNC_ENTER_NOAPI(H5S_find, NULL);
@@ -1537,8 +1493,8 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space, unsigned flags)
* If so then return a pointer to that entry.
*/
for (i=0; i<H5S_nconv_g; i++) {
- if (H5S_conv_g[i]->f->type==file_space->select.type &&
- H5S_conv_g[i]->m->type==mem_space->select.type) {
+ if (H5S_conv_g[i]->ftype==file_space->select.type &&
+ H5S_conv_g[i]->mtype==mem_space->select.type) {
#ifdef H5_HAVE_PARALLEL
/*
@@ -1555,22 +1511,8 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space, unsigned flags)
} /* end if */
else {
#endif /* H5_HAVE_PARALLEL */
- /*
- * Check if we can set direct "all" read/write functions
- */
- opt=H5S_all_opt_possible(mem_space,file_space,flags);
- if(opt==FAIL)
- HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, NULL, "invalid check for contiguous dataspace ");
-
- /* Check if we can use the optimized "all" I/O routines */
- if(opt==TRUE) {
- H5S_conv_g[i]->read = H5S_all_read;
- H5S_conv_g[i]->write = H5S_all_write;
- } /* end if */
- else {
- H5S_conv_g[i]->read = NULL;
- H5S_conv_g[i]->write = NULL;
- } /* end else */
+ H5S_conv_g[i]->read = H5S_select_read;
+ H5S_conv_g[i]->write = H5S_select_write;
#ifdef H5_HAVE_PARALLEL
} /* end else */
#endif /* H5_HAVE_PARALLEL */
@@ -1580,21 +1522,14 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space, unsigned flags)
}
/*
- * The path wasn't found. Do we have enough information to create a new
- * path?
- */
- if (NULL==H5S_fconv_g[file_space->select.type] || NULL==H5S_mconv_g[mem_space->select.type])
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, NULL, "unable to convert between data space selections");
-
- /*
- * Create a new path.
+ * The path wasn't found. Create a new path.
*/
if (NULL==(path = H5MM_calloc(sizeof(*path))))
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for data space conversion path");
/* Initialize file & memory conversion functions */
- path->f = H5S_fconv_g[file_space->select.type];
- path->m = H5S_mconv_g[mem_space->select.type];
+ path->ftype = file_space->select.type;
+ path->mtype = mem_space->select.type;
#ifdef H5_HAVE_PARALLEL
/*
@@ -1611,22 +1546,8 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space, unsigned flags)
} /* end if */
else {
#endif /* H5_HAVE_PARALLEL */
- /*
- * Check if we can set direct "all" read/write functions
- */
- opt=H5S_all_opt_possible(mem_space,file_space,flags);
- if(opt==FAIL)
- HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, NULL, "invalid check for contiguous dataspace ");
-
- /* Check if we can use the optimized "all" I/O routines */
- if(opt==TRUE) {
- path->read = H5S_all_read;
- path->write = H5S_all_write;
- } /* end if */
- else {
- path->read = NULL;
- path->write = NULL;
- } /* end else */
+ path->read = H5S_select_read;
+ path->write = H5S_select_write;
#ifdef H5_HAVE_PARALLEL
} /* end else */
#endif /* H5_HAVE_PARALLEL */