summaryrefslogtreecommitdiffstats
path: root/src/H5Dscatgath.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2018-03-15 21:54:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2018-03-15 21:54:30 (GMT)
commit4a17aff4085ad6ee265b95730aca3f493056dec8 (patch)
tree8bfb665c6d95a2e3520fa1bb0ff54d95aff3923f /src/H5Dscatgath.c
parent853ae26333592faf69cd8c454ef92ffea8549df5 (diff)
downloadhdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.zip
hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.gz
hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.bz2
Add API context interface and use it throughout the library.
Diffstat (limited to 'src/H5Dscatgath.c')
-rw-r--r--src/H5Dscatgath.c131
1 files changed, 82 insertions, 49 deletions
diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c
index 0ae69ee..f636eb7 100644
--- a/src/H5Dscatgath.c
+++ b/src/H5Dscatgath.c
@@ -22,6 +22,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Dpkg.h" /* Dataset functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
@@ -48,8 +49,7 @@ static size_t H5D__gather_file(const H5D_io_info_t *io_info,
const H5S_t *file_space, H5S_sel_iter_t *file_iter, size_t nelmts,
void *buf);
static herr_t H5D__compound_opt_read(size_t nelmts, const H5S_t *mem_space,
- H5S_sel_iter_t *iter, const H5D_dxpl_cache_t *dxpl_cache,
- const H5D_type_info_t *type_info, void *user_buf/*out*/);
+ H5S_sel_iter_t *iter, const H5D_type_info_t *type_info, void *user_buf/*out*/);
static herr_t H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info);
@@ -103,6 +103,7 @@ H5D__scatter_file(const H5D_io_info_t *_io_info,
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 dxpl_vec_size; /* Vector length from API context's DXPL */
size_t vec_size; /* Vector length */
herr_t ret_value = SUCCEED; /* Return value */
@@ -120,9 +121,13 @@ H5D__scatter_file(const H5D_io_info_t *_io_info,
tmp_io_info.op_type = H5D_IO_OP_WRITE;
tmp_io_info.u.wbuf = _buf;
+ /* Get info from API context */
+ if(H5CX_get_vec_size(&dxpl_vec_size) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size")
+
/* Allocate the vector I/O arrays */
- if(tmp_io_info.dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
- vec_size = tmp_io_info.dxpl_cache->vec_size;
+ if(dxpl_vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = dxpl_vec_size;
else
vec_size = H5D_IO_VECTOR_SIZE;
if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
@@ -199,6 +204,7 @@ H5D__gather_file(const H5D_io_info_t *_io_info,
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 dxpl_vec_size; /* Vector length from API context's DXPL */
size_t vec_size; /* Vector length */
size_t ret_value = nelmts; /* Return value */
@@ -218,9 +224,13 @@ H5D__gather_file(const H5D_io_info_t *_io_info,
tmp_io_info.op_type = H5D_IO_OP_READ;
tmp_io_info.u.rbuf = _buf;
+ /* Get info from API context */
+ if(H5CX_get_vec_size(&dxpl_vec_size) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't retrieve I/O vector size")
+
/* Allocate the vector I/O arrays */
- if(tmp_io_info.dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
- vec_size = tmp_io_info.dxpl_cache->vec_size;
+ if(dxpl_vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = dxpl_vec_size;
else
vec_size = H5D_IO_VECTOR_SIZE;
if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
@@ -279,8 +289,7 @@ done:
*/
herr_t
H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
- H5S_sel_iter_t *iter, size_t nelmts, const H5D_dxpl_cache_t *dxpl_cache,
- void *_buf/*out*/)
+ H5S_sel_iter_t *iter, size_t nelmts, void *_buf/*out*/)
{
uint8_t *buf = (uint8_t *)_buf; /* Get local copies for address arithmetic */
const uint8_t *tscat_buf = (const uint8_t *)_tscat_buf;
@@ -290,6 +299,7 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
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 dxpl_vec_size; /* Vector length from API context's DXPL */
size_t vec_size; /* Vector length */
herr_t ret_value = SUCCEED; /* Number of elements scattered */
@@ -300,12 +310,15 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
HDassert(space);
HDassert(iter);
HDassert(nelmts > 0);
- HDassert(dxpl_cache);
HDassert(buf);
+ /* Get info from API context */
+ if(H5CX_get_vec_size(&dxpl_vec_size) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size")
+
/* Allocate the vector I/O arrays */
- if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
- vec_size = dxpl_cache->vec_size;
+ if(dxpl_vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = dxpl_vec_size;
else
vec_size = H5D_IO_VECTOR_SIZE;
if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
@@ -364,8 +377,7 @@ done:
*/
size_t
H5D__gather_mem(const void *_buf, const H5S_t *space,
- H5S_sel_iter_t *iter, size_t nelmts, const H5D_dxpl_cache_t *dxpl_cache,
- void *_tgath_buf/*out*/)
+ H5S_sel_iter_t *iter, size_t nelmts, void *_tgath_buf/*out*/)
{
const uint8_t *buf = (const uint8_t *)_buf; /* Get local copies for address arithmetic */
uint8_t *tgath_buf = (uint8_t *)_tgath_buf;
@@ -375,6 +387,7 @@ H5D__gather_mem(const void *_buf, const H5S_t *space,
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 dxpl_vec_size; /* Vector length from API context's DXPL */
size_t vec_size; /* Vector length */
size_t ret_value = nelmts; /* Number of elements gathered */
@@ -385,12 +398,15 @@ H5D__gather_mem(const void *_buf, const H5S_t *space,
HDassert(space);
HDassert(iter);
HDassert(nelmts > 0);
- HDassert(dxpl_cache);
HDassert(tgath_buf);
+ /* Get info from API context */
+ if(H5CX_get_vec_size(&dxpl_vec_size) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't retrieve I/O vector size")
+
/* Allocate the vector I/O arrays */
- if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
- vec_size = dxpl_cache->vec_size;
+ if(dxpl_vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = dxpl_vec_size;
else
vec_size = H5D_IO_VECTOR_SIZE;
if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
@@ -446,7 +462,6 @@ herr_t
H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space)
{
- 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 = NULL; /* Memory selection iteration info*/
hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */
@@ -516,12 +531,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, 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, type_info->bkg_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "mem gather failed")
} /* end if */
@@ -531,18 +546,25 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
*/
if(H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id,
smine_nelmts, (size_t)0, (size_t)0, type_info->tconv_buf,
- type_info->bkg_buf, io_info->md_dxpl_id) < 0)
+ type_info->bkg_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
/* Do the data transform after the conversion (since we're using type mem_type) */
- if(!type_info->is_xform_noop)
- if(H5Z_xform_eval(dxpl_cache->data_xform_prop, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Error performing data transform")
+ if(!type_info->is_xform_noop) {
+ H5Z_data_xform_t *data_transform; /* Data transform info */
+
+ /* Retrieve info from API context */
+ if(H5CX_get_data_transform(&data_transform) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data transform info")
+
+ if(H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "Error performing data transform")
+ } /* end if */
/*
* 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, buf/*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed")
} /* end else */
} /* end for */
@@ -582,7 +604,6 @@ herr_t
H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space)
{
- 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 = NULL; /* Memory selection iteration info*/
hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */
@@ -639,7 +660,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, type_info->tconv_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "mem gather failed")
@@ -663,16 +684,23 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
/* Do the data transform before the type conversion (since
* transforms must be done in the memory type). */
- if(!type_info->is_xform_noop)
- if(H5Z_xform_eval(dxpl_cache->data_xform_prop, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Error performing data transform")
+ if(!type_info->is_xform_noop) {
+ H5Z_data_xform_t *data_transform; /* Data transform info */
+
+ /* Retrieve info from API context */
+ if(H5CX_get_data_transform(&data_transform) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data transform info")
+
+ if(H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "Error performing data transform")
+ } /* end if */
/*
* Perform datatype conversion.
*/
if(H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id,
smine_nelmts, (size_t)0, (size_t)0, type_info->tconv_buf,
- type_info->bkg_buf, io_info->md_dxpl_id) < 0)
+ type_info->bkg_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
} /* end else */
@@ -735,8 +763,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__compound_opt_read(size_t nelmts, const H5S_t *space,
- H5S_sel_iter_t *iter, const H5D_dxpl_cache_t *dxpl_cache,
+H5D__compound_opt_read(size_t nelmts, const H5S_t *space, H5S_sel_iter_t *iter,
const H5D_type_info_t *type_info, void *user_buf/*out*/)
{
uint8_t *ubuf = (uint8_t *)user_buf; /* Cast for pointer arithmetic */
@@ -744,6 +771,7 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space,
hsize_t *off = NULL; /* Pointer to sequence offsets */
size_t *len = NULL; /* Pointer to sequence lengths */
size_t src_stride, dst_stride, copy_size;
+ size_t dxpl_vec_size; /* Vector length from API context's DXPL */
size_t vec_size; /* Vector length */
herr_t ret_value = SUCCEED; /* Return value */
@@ -753,16 +781,19 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space,
HDassert(nelmts > 0);
HDassert(space);
HDassert(iter);
- HDassert(dxpl_cache);
HDassert(type_info);
HDassert(type_info->cmpd_subset);
HDassert(H5T_SUBSET_SRC == type_info->cmpd_subset->subset ||
H5T_SUBSET_DST == type_info->cmpd_subset->subset);
HDassert(user_buf);
+ /* Get info from API context */
+ if(H5CX_get_vec_size(&dxpl_vec_size) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size")
+
/* Allocate the vector I/O arrays */
- if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
- vec_size = dxpl_cache->vec_size;
+ if(dxpl_vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = dxpl_vec_size;
else
vec_size = H5D_IO_VECTOR_SIZE;
if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
@@ -924,8 +955,7 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
size_t type_size; /* Datatype element size */
hssize_t nelmts; /* Number of remaining elements in selection */
size_t nelmts_scatter = 0; /* Number of elements to scatter to dst_buf */
- H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */
- H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -940,10 +970,10 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
if(dst_buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination buffer provided")
-
- /* Fill the DXPL cache values for later use */
- if(H5D__get_dxpl_cache(H5AC_noio_dxpl_id, &dxpl_cache) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache")
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set API context")
+api_ctx_pushed = TRUE;
/* Get datatype element size */
if(0 == (type_size = H5T_GET_SIZE(type)))
@@ -982,7 +1012,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, dst_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "scatter failed")
nelmts -= (hssize_t)nelmts_scatter;
@@ -994,6 +1024,8 @@ done:
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
if(iter)
iter = H5FL_FREE(H5S_sel_iter_t, iter);
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* H5Dscatter() */
@@ -1027,8 +1059,7 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id,
hssize_t nelmts; /* Number of remaining elements in selection */
size_t dst_buf_nelmts; /* Number of elements that can fit in dst_buf */
size_t nelmts_gathered; /* Number of elements gathered from src_buf */
- H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */
- H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -1046,10 +1077,10 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer size is 0")
if(dst_buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination buffer provided")
-
- /* Fill the DXPL cache values for later use */
- if(H5D__get_dxpl_cache(H5AC_noio_dxpl_id, &dxpl_cache) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache")
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set API context")
+api_ctx_pushed = TRUE;
/* Get datatype element size */
if(0 == (type_size = H5T_GET_SIZE(type)))
@@ -1081,7 +1112,7 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id,
/* 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), dst_buf)))
HGOTO_ERROR(H5E_IO, H5E_CANTCOPY, FAIL, "gather failed")
HDassert(nelmts_gathered == MIN(dst_buf_nelmts, (size_t)nelmts));
@@ -1099,6 +1130,8 @@ done:
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
if(iter)
iter = H5FL_FREE(H5S_sel_iter_t, iter);
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* H5Dgather() */