diff options
author | Quincey Koziol <koziol@lbl.gov> | 2020-11-30 19:54:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-30 19:54:44 (GMT) |
commit | cadd6db431e2664e6dd3f2460639a27d21c6c8a9 (patch) | |
tree | 79bad4f1b2615f8662499a6d986e89514894acf8 /src/H5Dscatgath.c | |
parent | c256612e0950f3389249aa3a151d66ce01704d89 (diff) | |
download | hdf5-cadd6db431e2664e6dd3f2460639a27d21c6c8a9.zip hdf5-cadd6db431e2664e6dd3f2460639a27d21c6c8a9.tar.gz hdf5-cadd6db431e2664e6dd3f2460639a27d21c6c8a9.tar.bz2 |
Move API routines for VOL objects to main source file. (#133)
Diffstat (limited to 'src/H5Dscatgath.c')
-rw-r--r-- | src/H5Dscatgath.c | 196 |
1 files changed, 1 insertions, 195 deletions
diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c index ee3fce8..65bc28a 100644 --- a/src/H5Dscatgath.c +++ b/src/H5Dscatgath.c @@ -370,7 +370,7 @@ H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_tg size_t vec_size; /* Vector length */ size_t ret_value = nelmts; /* Number of elements gathered */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Check args */ HDassert(buf); @@ -899,197 +899,3 @@ H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__compound_opt_write() */ -/*------------------------------------------------------------------------- - * Function: H5Dscatter - * - * Purpose: Scatters data provided by the callback op to the - * destination buffer dst_buf, where the dimensions of - * dst_buf and the selection to be scattered to are specified - * by the dataspace dst_space_id. The type of the data to be - * scattered is specified by type_id. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * 14 Jan 2013 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, hid_t dst_space_id, void *dst_buf /*out*/) -{ - H5T_t * type; /* Datatype */ - H5S_t * dst_space; /* Dataspace */ - 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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE5("e", "DS*xiix", op, op_data, type_id, dst_space_id, dst_buf); - - /* Check args */ - if (op == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid callback function pointer") - if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (NULL == (dst_space = (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE))) - 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") - - /* Get datatype element size */ - if (0 == (type_size = H5T_GET_SIZE(type))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size") - - /* Get number of elements in dataspace */ - 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) < 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) { - /* Make callback to retrieve data */ - if (op(&src_buf, &src_buf_nbytes, op_data) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, FAIL, "callback operator returned failure") - - /* Calculate number of elements */ - nelmts_scatter = src_buf_nbytes / type_size; - - /* Check callback results */ - if (!src_buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback did not return a buffer") - if (src_buf_nbytes == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned a buffer size of 0") - if (src_buf_nbytes % type_size) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buffer size is not a multiple of datatype size") - if (nelmts_scatter > (size_t)nelmts) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned more elements than in selection") - - /* Scatter data */ - if (H5D__scatter_mem(src_buf, iter, nelmts_scatter, dst_buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "scatter failed") - - nelmts -= (hssize_t)nelmts_scatter; - } /* end while */ - -done: - /* Release selection iterator */ - 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() */ - -/*------------------------------------------------------------------------- - * Function: H5Dgather - * - * Purpose: Gathers data provided from the source buffer src_buf to - * contiguous buffer dst_buf, then calls the callback op. - * The dimensions of src_buf and the selection to be gathered - * are specified by the dataspace src_space_id. The type of - * the data to be gathered is specified by type_id. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * 16 Jan 2013 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, size_t dst_buf_size, void *dst_buf /*out*/, - H5D_gather_func_t op, void *op_data) -{ - H5T_t * type; /* Datatype */ - H5S_t * src_space; /* Dataspace */ - 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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*xizxDg*x", src_space_id, src_buf, type_id, dst_buf_size, dst_buf, op, op_data); - - /* Check args */ - if (NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if (src_buf == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source buffer provided") - if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (dst_buf_size == 0) - 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") - - /* Get datatype element size */ - if (0 == (type_size = H5T_GET_SIZE(type))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size") - - /* Get number of elements in dst_buf_size */ - dst_buf_nelmts = dst_buf_size / type_size; - if (dst_buf_nelmts == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "destination buffer is not large enough to hold one element") - - /* Get number of elements in dataspace */ - if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(src_space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") - - /* If dst_buf is not large enough to hold all the elements, make sure there - * is a callback */ - 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) < 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, 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)); - - /* Make callback to process dst_buf */ - if (op && op(dst_buf, nelmts_gathered * type_size, op_data) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, FAIL, "callback operator returned failure") - - nelmts -= (hssize_t)nelmts_gathered; - HDassert(op || (nelmts == 0)); - } /* end while */ - -done: - /* Release selection iterator */ - 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() */ |