diff options
Diffstat (limited to 'src/H5Dscatgath.c')
-rw-r--r-- | src/H5Dscatgath.c | 130 |
1 files changed, 73 insertions, 57 deletions
diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c index 55111f0..5856ede 100644 --- a/src/H5Dscatgath.c +++ b/src/H5Dscatgath.c @@ -5,12 +5,10 @@ * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /****************/ @@ -24,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 */ @@ -49,12 +48,8 @@ static herr_t H5D__scatter_file(const H5D_io_info_t *io_info, 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 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*/); 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); @@ -108,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 */ @@ -125,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))) @@ -204,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 */ @@ -223,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))) @@ -284,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; @@ -295,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 */ @@ -307,9 +312,13 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space, HDassert(nelmts > 0); 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))) @@ -366,10 +375,9 @@ done: * *------------------------------------------------------------------------- */ -static size_t +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; @@ -379,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 */ @@ -391,9 +400,13 @@ H5D__gather_mem(const void *_buf, const H5S_t *space, HDassert(nelmts > 0); 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))) @@ -449,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 */ @@ -519,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 */ @@ -534,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 */ @@ -585,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 */ @@ -642,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") @@ -666,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 */ @@ -738,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 */ @@ -747,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 */ @@ -756,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))) @@ -927,8 +955,6 @@ 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 */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -944,10 +970,6 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, 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") - /* Get datatype element size */ if(0 == (type_size = H5T_GET_SIZE(type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size") @@ -985,7 +1007,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; @@ -1030,8 +1052,6 @@ 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 */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1050,10 +1070,6 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, 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") - /* Get datatype element size */ if(0 == (type_size = H5T_GET_SIZE(type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size") @@ -1084,7 +1100,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)); |