summaryrefslogtreecommitdiffstats
path: root/src/H5Dscatgath.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Dscatgath.c')
-rw-r--r--src/H5Dscatgath.c333
1 files changed, 169 insertions, 164 deletions
diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c
index 7c1abca..55111f0 100644
--- a/src/H5Dscatgath.c
+++ b/src/H5Dscatgath.c
@@ -67,10 +67,13 @@ static herr_t H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type
/* Local Variables */
/*******************/
-/* Declare a free list to manage sequences of size_t */
+/* Declare extern free list to manage the H5S_sel_iter_t struct */
+H5FL_EXTERN(H5S_sel_iter_t);
+
+/* Declare extern free list to manage sequences of size_t */
H5FL_SEQ_EXTERN(size_t);
-/* Declare a free list to manage sequences of hsize_t */
+/* Declare extern free list to manage sequences of hsize_t */
H5FL_SEQ_EXTERN(hsize_t);
@@ -97,17 +100,16 @@ H5D__scatter_file(const H5D_io_info_t *_io_info,
const void *_buf)
{
H5D_io_info_t tmp_io_info; /* Temporary I/O info object */
- hsize_t _off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */
hsize_t *off = NULL; /* Pointer to sequence offsets */
hsize_t mem_off; /* Offset in memory */
size_t mem_curr_seq; /* "Current sequence" in memory */
size_t dset_curr_seq; /* "Current sequence" in dataset */
- size_t _len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */
size_t *len = NULL; /* Array to store sequence lengths */
size_t orig_mem_len, mem_len; /* Length of sequence in memory */
- size_t nseq; /* Number of sequences generated */
- size_t nelem; /* Number of elements used in sequences */
- herr_t ret_value = SUCCEED; /* Return value */
+ size_t nseq; /* Number of sequences generated */
+ size_t nelem; /* Number of elements used in sequences */
+ size_t vec_size; /* Vector length */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -124,21 +126,19 @@ H5D__scatter_file(const H5D_io_info_t *_io_info,
tmp_io_info.u.wbuf = _buf;
/* Allocate the vector I/O arrays */
- if(tmp_io_info.dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE) {
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, tmp_io_info.dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array")
- if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, tmp_io_info.dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array")
- } /* end if */
- else {
- len = _len;
- off = _off;
- } /* end else */
+ if(tmp_io_info.dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = tmp_io_info.dxpl_cache->vec_size;
+ else
+ vec_size = H5D_IO_VECTOR_SIZE;
+ if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array")
+ if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array")
/* Loop until all elements are written */
while(nelmts > 0) {
/* Get list of sequences for selection to write */
- if(H5S_SELECT_GET_SEQ_LIST(space, H5S_GET_SEQ_LIST_SORTED, iter, tmp_io_info.dxpl_cache->vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(space, H5S_GET_SEQ_LIST_SORTED, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Reset the current sequence information */
@@ -160,9 +160,9 @@ H5D__scatter_file(const H5D_io_info_t *_io_info,
done:
/* Release resources, if allocated */
- if(len && len != _len)
+ if(len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off && off != _off)
+ if(off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
@@ -196,16 +196,15 @@ H5D__gather_file(const H5D_io_info_t *_io_info,
void *_buf/*out*/)
{
H5D_io_info_t tmp_io_info; /* Temporary I/O info object */
- hsize_t _off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */
hsize_t *off = NULL; /* Pointer to sequence offsets */
hsize_t mem_off; /* Offset in memory */
size_t mem_curr_seq; /* "Current sequence" in memory */
size_t dset_curr_seq; /* "Current sequence" in dataset */
- size_t _len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */
size_t *len = NULL; /* Pointer to sequence lengths */
size_t orig_mem_len, mem_len; /* Length of sequence in memory */
size_t nseq; /* Number of sequences generated */
size_t nelem; /* Number of elements used in sequences */
+ size_t vec_size; /* Vector length */
size_t ret_value = nelmts; /* Return value */
FUNC_ENTER_STATIC
@@ -225,21 +224,19 @@ H5D__gather_file(const H5D_io_info_t *_io_info,
tmp_io_info.u.rbuf = _buf;
/* Allocate the vector I/O arrays */
- if(tmp_io_info.dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE) {
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, tmp_io_info.dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O length vector array")
- if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, tmp_io_info.dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O offset vector array")
- } /* end if */
- else {
- len = _len;
- off = _off;
- } /* end else */
+ if(tmp_io_info.dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = tmp_io_info.dxpl_cache->vec_size;
+ else
+ vec_size = H5D_IO_VECTOR_SIZE;
+ if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O length vector array")
+ if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O offset vector array")
/* Loop until all elements are read */
while(nelmts > 0) {
/* Get list of sequences for selection to read */
- if(H5S_SELECT_GET_SEQ_LIST(space, H5S_GET_SEQ_LIST_SORTED, iter, tmp_io_info.dxpl_cache->vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(space, H5S_GET_SEQ_LIST_SORTED, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Reset the current sequence information */
@@ -261,9 +258,9 @@ H5D__gather_file(const H5D_io_info_t *_io_info,
done:
/* Release resources, if allocated */
- if(len && len != _len)
+ if(len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off && off != _off)
+ if(off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
@@ -292,15 +289,14 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
{
uint8_t *buf = (uint8_t *)_buf; /* Get local copies for address arithmetic */
const uint8_t *tscat_buf = (const uint8_t *)_tscat_buf;
- hsize_t _off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */
- hsize_t *off = NULL; /* Pointer to sequence offsets */
- size_t _len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */
- size_t *len = NULL; /* Pointer to sequence lengths */
+ hsize_t *off = NULL; /* Pointer to sequence offsets */
+ size_t *len = NULL; /* Pointer to sequence lengths */
size_t curr_len; /* Length of bytes left to process in sequence */
size_t nseq; /* Number of sequences generated */
size_t curr_seq; /* Current sequence being processed */
size_t nelem; /* Number of elements used in sequences */
- herr_t ret_value = SUCCEED; /* Number of elements scattered */
+ size_t vec_size; /* Vector length */
+ herr_t ret_value = SUCCEED; /* Number of elements scattered */
FUNC_ENTER_PACKAGE
@@ -312,21 +308,19 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
HDassert(buf);
/* Allocate the vector I/O arrays */
- if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE) {
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array")
- if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array")
- } /* end if */
- else {
- len = _len;
- off = _off;
- } /* end else */
+ if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = dxpl_cache->vec_size;
+ else
+ vec_size = H5D_IO_VECTOR_SIZE;
+ if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array")
+ if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array")
/* Loop until all elements are written */
while(nelmts > 0) {
/* Get list of sequences for selection to write */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, dxpl_cache->vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Loop, while sequences left to process */
@@ -346,9 +340,9 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
done:
/* Release resources, if allocated */
- if(len && len != _len)
+ if(len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off && off != _off)
+ if(off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
@@ -379,15 +373,14 @@ H5D__gather_mem(const void *_buf, const H5S_t *space,
{
const uint8_t *buf = (const uint8_t *)_buf; /* Get local copies for address arithmetic */
uint8_t *tgath_buf = (uint8_t *)_tgath_buf;
- hsize_t _off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */
hsize_t *off = NULL; /* Pointer to sequence offsets */
- size_t _len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */
- size_t *len = NULL; /* Pointer to sequence lengths */
+ size_t *len = NULL; /* Pointer to sequence lengths */
size_t curr_len; /* Length of bytes left to process in sequence */
size_t nseq; /* Number of sequences generated */
size_t curr_seq; /* Current sequence being processed */
size_t nelem; /* Number of elements used in sequences */
- size_t ret_value = nelmts; /* Number of elements gathered */
+ size_t vec_size; /* Vector length */
+ size_t ret_value = nelmts; /* Number of elements gathered */
FUNC_ENTER_STATIC
@@ -399,21 +392,19 @@ H5D__gather_mem(const void *_buf, const H5S_t *space,
HDassert(tgath_buf);
/* Allocate the vector I/O arrays */
- if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE) {
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O length vector array")
- if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O offset vector array")
- } /* end if */
- else {
- len = _len;
- off = _off;
- } /* end else */
+ if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = dxpl_cache->vec_size;
+ else
+ vec_size = H5D_IO_VECTOR_SIZE;
+ if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O length vector array")
+ if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O offset vector array")
/* Loop until all elements are written */
while(nelmts > 0) {
/* Get list of sequences for selection to write */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, dxpl_cache->vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Loop, while sequences left to process */
@@ -433,9 +424,9 @@ H5D__gather_mem(const void *_buf, const H5S_t *space,
done:
/* Release resources, if allocated */
- if(len && len != _len)
+ if(len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off && off != _off)
+ if(off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
@@ -460,15 +451,15 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
{
const H5D_dxpl_cache_t *dxpl_cache = io_info->dxpl_cache; /* Local pointer to dataset transfer info */
void *buf = io_info->u.rbuf; /* Local pointer to application buffer */
- H5S_sel_iter_t mem_iter; /*memory selection iteration info*/
- hbool_t mem_iter_init = FALSE; /*memory selection iteration info has been initialized */
- H5S_sel_iter_t bkg_iter; /*background iteration info*/
- hbool_t bkg_iter_init = FALSE; /*background iteration info has been initialized */
- H5S_sel_iter_t file_iter; /*file selection iteration info*/
- hbool_t file_iter_init = FALSE; /*file selection iteration info has been initialized */
- hsize_t smine_start; /*strip mine start loc */
- size_t smine_nelmts; /*elements per strip */
- herr_t ret_value = SUCCEED; /*return value */
+ H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info*/
+ hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */
+ H5S_sel_iter_t *bkg_iter = NULL; /* Background iteration info*/
+ hbool_t bkg_iter_init = FALSE; /* Background iteration info has been initialized */
+ H5S_sel_iter_t *file_iter = NULL; /* File selection iteration info*/
+ hbool_t file_iter_init = FALSE; /* File selection iteration info has been initialized */
+ hsize_t smine_start; /* Strip mine start loc */
+ size_t smine_nelmts; /* Elements per strip */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -483,14 +474,22 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
if(nelmts == 0)
HGOTO_DONE(SUCCEED)
+ /* Allocate the iterators */
+ if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory iterator")
+ if(NULL == (bkg_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate background iterator")
+ if(NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator")
+
/* Figure out the strip mine size. */
- if(H5S_select_iter_init(&file_iter, file_space, type_info->src_type_size) < 0)
+ if(H5S_select_iter_init(file_iter, file_space, type_info->src_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information")
file_iter_init = TRUE; /*file selection iteration info has been initialized */
- if(H5S_select_iter_init(&mem_iter, mem_space, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(mem_iter, mem_space, type_info->dst_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE; /*file selection iteration info has been initialized */
- if(H5S_select_iter_init(&bkg_iter, mem_space, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(bkg_iter, mem_space, type_info->dst_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information")
bkg_iter_init = TRUE; /*file selection iteration info has been initialized */
@@ -499,7 +498,7 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
size_t n; /* Elements operated on */
/* Go figure out how many elements to read from the file */
- HDassert(H5S_SELECT_ITER_NELMTS(&file_iter) == (nelmts - smine_start));
+ HDassert(H5S_SELECT_ITER_NELMTS(file_iter) == (nelmts - smine_start));
smine_nelmts = (size_t)MIN(type_info->request_nelmts, (nelmts - smine_start));
/*
@@ -511,8 +510,7 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
/*
* Gather data
*/
- n = H5D__gather_file(io_info, file_space, &file_iter, smine_nelmts,
- type_info->tconv_buf/*out*/);
+ n = H5D__gather_file(io_info, file_space, file_iter, smine_nelmts, type_info->tconv_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed")
@@ -521,14 +519,12 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
* bypass the rest of steps.
*/
if(type_info->cmpd_subset && H5T_SUBSET_FALSE != type_info->cmpd_subset->subset) {
- if(H5D__compound_opt_read(smine_nelmts, mem_space, &mem_iter, dxpl_cache,
- type_info, buf /*out*/) < 0)
+ if(H5D__compound_opt_read(smine_nelmts, mem_space, mem_iter, dxpl_cache, type_info, buf /*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "datatype conversion failed")
} /* end if */
else {
if(H5T_BKG_YES == type_info->need_bkg) {
- n = H5D__gather_mem(buf, mem_space, &bkg_iter, smine_nelmts,
- dxpl_cache, type_info->bkg_buf/*out*/);
+ n = H5D__gather_mem(buf, mem_space, bkg_iter, smine_nelmts, dxpl_cache, type_info->bkg_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "mem gather failed")
} /* end if */
@@ -549,26 +545,25 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
/*
* Scatter the data into memory.
*/
- if(H5D__scatter_mem(type_info->tconv_buf, mem_space, &mem_iter,
- smine_nelmts, dxpl_cache, buf/*out*/) < 0)
+ if(H5D__scatter_mem(type_info->tconv_buf, mem_space, mem_iter, smine_nelmts, dxpl_cache, buf/*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed")
} /* end else */
} /* end for */
done:
/* Release selection iterators */
- if(file_iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&file_iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
- if(mem_iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&mem_iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
- if(bkg_iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&bkg_iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
+ if(file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(file_iter)
+ file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter);
+ if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(mem_iter)
+ mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter);
+ if(bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(bkg_iter)
+ bkg_iter = H5FL_FREE(H5S_sel_iter_t, bkg_iter);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__scatgath_read() */
@@ -592,15 +587,15 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
{
const H5D_dxpl_cache_t *dxpl_cache = io_info->dxpl_cache; /* Local pointer to dataset transfer info */
const void *buf = io_info->u.wbuf; /* Local pointer to application buffer */
- H5S_sel_iter_t mem_iter; /*memory selection iteration info*/
- hbool_t mem_iter_init = FALSE; /*memory selection iteration info has been initialized */
- H5S_sel_iter_t bkg_iter; /*background iteration info*/
- hbool_t bkg_iter_init = FALSE; /*background iteration info has been initialized */
- H5S_sel_iter_t file_iter; /*file selection iteration info*/
- hbool_t file_iter_init = FALSE; /*file selection iteration info has been initialized */
- hsize_t smine_start; /*strip mine start loc */
- size_t smine_nelmts; /*elements per strip */
- herr_t ret_value = SUCCEED; /*return value */
+ H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info*/
+ hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */
+ H5S_sel_iter_t *bkg_iter = NULL; /* Background iteration info*/
+ hbool_t bkg_iter_init = FALSE; /* Background iteration info has been initialized */
+ H5S_sel_iter_t *file_iter = NULL; /* File selection iteration info*/
+ hbool_t file_iter_init = FALSE; /* File selection iteration info has been initialized */
+ hsize_t smine_start; /* Strip mine start loc */
+ size_t smine_nelmts; /* Elements per strip */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -615,14 +610,22 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
if(nelmts == 0)
HGOTO_DONE(SUCCEED)
+ /* Allocate the iterators */
+ if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory iterator")
+ if(NULL == (bkg_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate background iterator")
+ if(NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator")
+
/* Figure out the strip mine size. */
- if(H5S_select_iter_init(&file_iter, file_space, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(file_iter, file_space, type_info->dst_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information")
file_iter_init = TRUE; /*file selection iteration info has been initialized */
- if(H5S_select_iter_init(&mem_iter, mem_space, type_info->src_type_size) < 0)
+ if(H5S_select_iter_init(mem_iter, mem_space, type_info->src_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE; /*file selection iteration info has been initialized */
- if(H5S_select_iter_init(&bkg_iter, file_space, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(bkg_iter, file_space, type_info->dst_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information")
bkg_iter_init = TRUE; /*file selection iteration info has been initialized */
@@ -631,7 +634,7 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
size_t n; /* Elements operated on */
/* Go figure out how many elements to read from the file */
- HDassert(H5S_SELECT_ITER_NELMTS(&file_iter) == (nelmts - smine_start));
+ HDassert(H5S_SELECT_ITER_NELMTS(file_iter) == (nelmts - smine_start));
smine_nelmts = (size_t)MIN(type_info->request_nelmts, (nelmts - smine_start));
/*
@@ -639,8 +642,7 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
* buffer. Also gather data from the file into the background buffer
* if necessary.
*/
- n = H5D__gather_mem(buf, mem_space, &mem_iter, smine_nelmts,
- dxpl_cache, type_info->tconv_buf/*out*/);
+ n = H5D__gather_mem(buf, mem_space, mem_iter, smine_nelmts, dxpl_cache, type_info->tconv_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "mem gather failed")
@@ -657,8 +659,7 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
} /* end if */
else {
if(H5T_BKG_YES == type_info->need_bkg) {
- n = H5D__gather_file(io_info, file_space, &bkg_iter, smine_nelmts,
- type_info->bkg_buf/*out*/);
+ n = H5D__gather_file(io_info, file_space, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed")
} /* end if */
@@ -681,25 +682,24 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
/*
* Scatter the data out to the file.
*/
- if(H5D__scatter_file(io_info, file_space, &file_iter, smine_nelmts,
- type_info->tconv_buf) < 0)
+ if(H5D__scatter_file(io_info, file_space, file_iter, smine_nelmts, type_info->tconv_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed")
} /* end for */
done:
/* Release selection iterators */
- if(file_iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&file_iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
- if(mem_iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&mem_iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
- if(bkg_iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&bkg_iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
+ if(file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(file_iter)
+ file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter);
+ if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(mem_iter)
+ mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter);
+ if(bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(bkg_iter)
+ bkg_iter = H5FL_FREE(H5S_sel_iter_t, bkg_iter);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__scatgath_write() */
@@ -744,12 +744,11 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space,
{
uint8_t *ubuf = (uint8_t *)user_buf; /* Cast for pointer arithmetic */
uint8_t *xdbuf; /* Pointer into dataset buffer */
- hsize_t _off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */
hsize_t *off = NULL; /* Pointer to sequence offsets */
- size_t _len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */
size_t *len = NULL; /* Pointer to sequence lengths */
size_t src_stride, dst_stride, copy_size;
- herr_t ret_value = SUCCEED; /*return value */
+ size_t vec_size; /* Vector length */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -765,16 +764,14 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space,
HDassert(user_buf);
/* Allocate the vector I/O arrays */
- if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE) {
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array")
- if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array")
- } /* end if */
- else {
- len = _len;
- off = _off;
- } /* end else */
+ if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = dxpl_cache->vec_size;
+ else
+ vec_size = H5D_IO_VECTOR_SIZE;
+ if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array")
+ if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array")
/* Get source & destination strides */
src_stride = type_info->src_type_size;
@@ -791,7 +788,7 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space,
size_t elmtno; /* Element counter */
/* Get list of sequences for selection to write */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, dxpl_cache->vec_size, nelmts, &nseq, &elmtno, off, len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, vec_size, nelmts, &nseq, &elmtno, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Loop, while sequences left to process */
@@ -827,9 +824,9 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space,
done:
/* Release resources, if allocated */
- if(len && len != _len)
+ if(len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off && off != _off)
+ if(off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
@@ -923,7 +920,7 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
{
H5T_t *type; /* Datatype */
H5S_t *dst_space; /* Dataspace */
- H5S_sel_iter_t iter; /* Selection iteration info*/
+ H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/
hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */
const void *src_buf = NULL; /* Source (contiguous) data buffer */
size_t src_buf_nbytes = 0; /* Size of src_buf */
@@ -959,8 +956,12 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(dst_space)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection")
+ /* Allocate the selection iterator */
+ if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
+
/* Initialize selection iterator */
- if(H5S_select_iter_init(&iter, dst_space, type_size) < 0)
+ if(H5S_select_iter_init(iter, dst_space, type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information")
iter_init = TRUE;
@@ -984,7 +985,7 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned more elements than in selection")
/* Scatter data */
- if(H5D__scatter_mem(src_buf, dst_space, &iter, nelmts_scatter, dxpl_cache, dst_buf) < 0)
+ if(H5D__scatter_mem(src_buf, dst_space, iter, nelmts_scatter, dxpl_cache, dst_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "scatter failed")
nelmts -= (hssize_t)nelmts_scatter;
@@ -992,10 +993,10 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
done:
/* Release selection iterator */
- if(iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
+ if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(iter)
+ iter = H5FL_FREE(H5S_sel_iter_t, iter);
FUNC_LEAVE_API(ret_value)
} /* H5Dscatter() */
@@ -1023,7 +1024,7 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id,
{
H5T_t *type; /* Datatype */
H5S_t *src_space; /* Dataspace */
- H5S_sel_iter_t iter; /* Selection iteration info*/
+ H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/
hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */
size_t type_size; /* Datatype element size */
hssize_t nelmts; /* Number of remaining elements in selection */
@@ -1071,15 +1072,19 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id,
if(((size_t)nelmts > dst_buf_nelmts) && (op == NULL))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback supplied and destination buffer too small")
+ /* Allocate the selection iterator */
+ if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
+
/* Initialize selection iterator */
- if(H5S_select_iter_init(&iter, src_space, type_size) < 0)
+ if(H5S_select_iter_init(iter, src_space, type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information")
iter_init = TRUE;
/* Loop until all data has been scattered */
while(nelmts > 0) {
/* Gather data */
- if(0 == (nelmts_gathered = H5D__gather_mem(src_buf, src_space, &iter, MIN(dst_buf_nelmts, (size_t)nelmts), dxpl_cache, dst_buf)))
+ if(0 == (nelmts_gathered = H5D__gather_mem(src_buf, src_space, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dxpl_cache, dst_buf)))
HGOTO_ERROR(H5E_IO, H5E_CANTCOPY, FAIL, "gather failed")
HDassert(nelmts_gathered == MIN(dst_buf_nelmts, (size_t)nelmts));
@@ -1093,10 +1098,10 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id,
done:
/* Release selection iterator */
- if(iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
+ if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(iter)
+ iter = H5FL_FREE(H5S_sel_iter_t, iter);
FUNC_LEAVE_API(ret_value)
} /* H5Dgather() */