summaryrefslogtreecommitdiffstats
path: root/src/H5S.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-04-01 18:52:02 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-04-01 18:52:02 (GMT)
commitebbabfd3efea4b8b15a406f24686005fd2ad9312 (patch)
treed445d915e4f23210e4a4b3a8881981dc49dc2c25 /src/H5S.c
parenta2ea33e6b97429f7b3f143c355ee7d8566930b2a (diff)
downloadhdf5-ebbabfd3efea4b8b15a406f24686005fd2ad9312.zip
hdf5-ebbabfd3efea4b8b15a406f24686005fd2ad9312.tar.gz
hdf5-ebbabfd3efea4b8b15a406f24686005fd2ad9312.tar.bz2
[svn-r5126] Purpose:
Bug Fix (sorta) Description: "small" contiguous hyperslabs were not being detected correctly by H5S_hyper_select_contigous() leading to poorer performance than possible. Solution: Corrected check for small hyperslabs. Also cleaned up the H5S_find() code. Platforms tested: FreeBSD 4.5 (sleipnir)
Diffstat (limited to 'src/H5S.c')
-rw-r--r--src/H5S.c48
1 files changed, 18 insertions, 30 deletions
diff --git a/src/H5S.c b/src/H5S.c
index 877de5d..0b6632c 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -1496,9 +1496,9 @@ H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims,
H5S_conv_t *
H5S_find (const H5S_t *mem_space, const H5S_t *file_space)
{
- size_t i;
- htri_t c1,c2;
- H5S_conv_t *path;
+ H5S_conv_t *path; /* Space conversion path */
+ htri_t c1,c2; /* Flags whether a selection is contiguous */
+ size_t i; /* Index variable */
FUNC_ENTER (H5S_find, NULL);
@@ -1512,11 +1512,8 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space)
* We can't do conversion if the source and destination select a
* different number of data points.
*/
- if (H5S_get_select_npoints(mem_space) !=
- H5S_get_select_npoints (file_space)) {
- HRETURN_ERROR (H5E_DATASPACE, H5E_BADRANGE, NULL,
- "memory and file data spaces are different sizes");
- }
+ if (H5S_get_select_npoints(mem_space) != H5S_get_select_npoints (file_space))
+ HRETURN_ERROR (H5E_DATASPACE, H5E_BADRANGE, NULL, "memory and file data spaces are different sizes");
/*
* Is this path already present in the data space conversion path table?
@@ -1524,15 +1521,14 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space)
*/
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) {
+ H5S_conv_g[i]->m->type==mem_space->select.type) {
/*
* Initialize direct read/write functions
*/
c1=H5S_select_contiguous(file_space);
c2=H5S_select_contiguous(mem_space);
if(c1==FAIL || c2==FAIL)
- HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, NULL,
- "invalid check for contiguous dataspace ");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, NULL, "invalid check for contiguous dataspace ");
if (c1==TRUE && c2==TRUE) {
H5S_conv_g[i]->read = H5S_all_read;
@@ -1551,20 +1547,16 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space)
* 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");
- }
+ 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.
*/
- if (NULL==(path = H5MM_calloc(sizeof(*path)))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for data space conversion "
- "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];
@@ -1574,13 +1566,12 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space)
c1=H5S_select_contiguous(file_space);
c2=H5S_select_contiguous(mem_space);
if(c1==FAIL || c2==FAIL)
- HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, NULL,
- "invalid check for contiguous dataspace ");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, NULL, "invalid check for contiguous dataspace ");
if (c1==TRUE && c2==TRUE) {
path->read = H5S_all_read;
path->write = H5S_all_write;
- }
+ } /* end if */
/*
* Add the new path to the table.
@@ -1589,14 +1580,11 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space)
size_t n = MAX(10, 2*H5S_aconv_g);
H5S_conv_t **p = H5MM_realloc(H5S_conv_g, n*sizeof(H5S_conv_g[0]));
- if (NULL==p) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for data space conversion "
- "path table");
- }
+ if (NULL==p)
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for data space conversion path table");
H5S_aconv_g = n;
H5S_conv_g = p;
- }
+ } /* end if */
H5S_conv_g[H5S_nconv_g++] = path;
FUNC_LEAVE(path);