summaryrefslogtreecommitdiffstats
path: root/src/H5D.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-01-21 20:01:02 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-01-21 20:01:02 (GMT)
commitf5cc0548b8dacfefee4878075f568b5f124e9dc3 (patch)
tree8dc8edc28b7cde4a01e4cb650d2483aa46c2ecdd /src/H5D.c
parentb7f919cccb89f991e3ddc625bba675c2ea483b15 (diff)
downloadhdf5-f5cc0548b8dacfefee4878075f568b5f124e9dc3.zip
hdf5-f5cc0548b8dacfefee4878075f568b5f124e9dc3.tar.gz
hdf5-f5cc0548b8dacfefee4878075f568b5f124e9dc3.tar.bz2
[svn-r161] Changes since 19980121
---------------------- ./MANIFEST ./src/H5Psimp.c [NEW] ./src/Makefile.in Added H5Psimp.c and populated it with some conversion functions. Eventually the parts of H5P.c that operate on simple data spaces will be migrated to H5Psimp.c and other files will be created for other types of data spaces. ./src/H5D.c The read pipeline, H5Dread(), has been updated to handle data space conversion although the actual simple data space conversion functions don't do anything yet. But we're getting really close! ./src/H5P.c ./src/H5Pprivate.h Added H5P_find() to locate data space conversion functions. Added typedefs for structs related to data space conversion.
Diffstat (limited to 'src/H5D.c')
-rw-r--r--src/H5D.c109
1 files changed, 52 insertions, 57 deletions
diff --git a/src/H5D.c b/src/H5D.c
index dea5d3e..869e79f 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -824,14 +824,12 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
void *buf/*out*/)
{
size_t nelmts, src_size, dst_size;
- size_t offset[H5O_LAYOUT_NDIMS];
- size_t size[H5O_LAYOUT_NDIMS];
- size_t zero[H5O_LAYOUT_NDIMS];
- intn i;
herr_t ret_value = FAIL;
- uint8 *conv_buf = NULL; /*data type conv buffer */
- H5T_conv_t conv_func = NULL; /*conversion function */
+ uint8 *tconv_buf = NULL; /*data type conv buffer */
+ H5T_conv_t tconv_func = NULL; /*conversion function */
hid_t src_id = -1, dst_id = -1;/*temporary type atoms */
+ const H5P_conv_t *sconv_func = NULL; /*space conversion funcs*/
+ H5P_number_t numbering; /*element numbering info*/
FUNC_ENTER(H5D_read, FAIL);
@@ -840,13 +838,8 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
assert(mem_type);
assert(xfer_parms);
assert(buf);
-
- if ((mem_space && H5P_cmp(mem_space, dataset->space)) ||
- (file_space && H5P_cmp(file_space, dataset->space))) {
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "space conversion not supported yet");
- }
- assert (!mem_space || H5P_SIMPLE==mem_space->type);
+ if (!file_space) file_space = dataset->space;
+ if (!mem_space) mem_space = file_space;
/*
* Convert data types to atoms because the conversion functions are
@@ -859,6 +852,27 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
}
/*
+ * Locate the type conversion function, data space conversion, and set up
+ * the element numbering information.
+ */
+ if (NULL == (tconv_func = H5T_find(dataset->type, mem_type))) {
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "unable to convert between src and dest data types");
+ }
+ if (NULL==(sconv_func=H5P_find (file_space, mem_space))) {
+ HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "unable to convert between src and dest data spaces");
+ }
+ if (sconv_func->init &&
+ (sconv_func->init)(&(dataset->layout), mem_space, file_space,
+ &numbering/*out*/)<=0) {
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL,
+ "unable to initialize element numbering information");
+ } else {
+ HDmemset (&numbering, 0, sizeof numbering);
+ }
+
+ /*
* Compute the size of the request and allocate scratch buffers.
*/
#ifndef LATER
@@ -869,62 +883,43 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
nelmts = H5P_get_npoints(dataset->space);
src_size = nelmts * H5T_get_size(dataset->type);
dst_size = nelmts * H5T_get_size(mem_type);
- conv_buf = H5MM_xmalloc(MAX(src_size, dst_size));
+ tconv_buf = H5MM_xmalloc(MAX(src_size, dst_size));
#endif
/*
- * Locate the type conversion function.
- */
- if (NULL == (conv_func = H5T_find(dataset->type, mem_type))) {
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "unable to convert between src and dest data types");
- }
-
- /*
* Gather the data from disk into the data type conversion buffer.
*/
-#ifndef LATER
- /*
- * Note: We only support complete reads currently. That is, the
- * hyperslab must begin at zero in memory and on disk and the
- * size of the hyperslab must be the same as the array on disk.
- */
- for (i = 0; i < dataset->layout.ndims; i++) {
- zero[i] = 0;
- offset[i] = 0;
- }
- i = H5P_get_dims (dataset->space, size);
- assert (i+1==dataset->layout.ndims);
- size[i] = H5T_get_size (dataset->type);
-#endif
- if (H5F_arr_read(dataset->ent.file, &(dataset->layout), size, offset,
- zero, size, conv_buf) < 0) {
- HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read failed");
+ if ((sconv_func->fgath)(dataset->ent.file, &(dataset->layout),
+ H5T_get_size (dataset->type), file_space,
+ &numbering, 0, nelmts,
+ tconv_buf/*out*/)<0) {
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "gather failed");
}
/*
* Perform data type conversion.
*/
- if ((conv_func) (src_id, dst_id, nelmts, conv_buf, NULL) < 0) {
+ if ((tconv_func) (src_id, dst_id, nelmts, tconv_buf, NULL) < 0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
"data type conversion failed");
}
/*
- * Copy conversion buffer into destination.
+ * Scatter the data into memory.
*/
- HDmemcpy(buf, conv_buf, dst_size);
-
+ if ((sconv_func->mscat)(tconv_buf, H5T_get_size (mem_type), mem_space,
+ &numbering, 0, nelmts, buf/*out*/)<0) {
+ HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "scatter failed");
+ }
ret_value = SUCCEED;
+
done:
- if (src_id >= 0)
- H5A_dec_ref(src_id);
- if (dst_id >= 0)
- H5A_dec_ref(dst_id);
- conv_buf = H5MM_xfree(conv_buf);
+ if (src_id >= 0) H5A_dec_ref(src_id);
+ if (dst_id >= 0) H5A_dec_ref(dst_id);
+ tconv_buf = H5MM_xfree(tconv_buf);
FUNC_LEAVE(ret_value);
}
-
+
/*-------------------------------------------------------------------------
* Function: H5D_write
*
@@ -953,8 +948,8 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
size_t zero[H5O_LAYOUT_NDIMS];
intn i;
herr_t ret_value = FAIL;
- uint8 *conv_buf = NULL; /*data type conversion buffer */
- H5T_conv_t conv_func = NULL; /*data type conversion function */
+ uint8 *tconv_buf = NULL; /*data type conversion buffer */
+ H5T_conv_t tconv_func = NULL; /*data type conversion function */
hid_t src_id = -1, dst_id = -1; /*temporary type atoms */
FUNC_ENTER(H5D_write, FAIL);
@@ -997,13 +992,13 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
nelmts = H5P_get_npoints(dataset->space);
src_size = nelmts * H5T_get_size(mem_type);
dst_size = nelmts * H5T_get_size(dataset->type);
- conv_buf = H5MM_xmalloc(MAX(src_size, dst_size));
+ tconv_buf = H5MM_xmalloc(MAX(src_size, dst_size));
#endif
/*
* Locate the type conversion function.
*/
- if (NULL == (conv_func = H5T_find(mem_type, dataset->type))) {
+ if (NULL == (tconv_func = H5T_find(mem_type, dataset->type))) {
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
"unable to convert between src and dest data types");
}
@@ -1011,12 +1006,12 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
/*
* Gather data into the data type conversion buffer.
*/
- HDmemcpy(conv_buf, buf, src_size);
+ HDmemcpy(tconv_buf, buf, src_size);
/*
* Perform data type conversion.
*/
- if ((conv_func) (src_id, dst_id, nelmts, conv_buf, NULL) < 0) {
+ if ((tconv_func) (src_id, dst_id, nelmts, tconv_buf, NULL) < 0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
"data type conversion failed");
}
@@ -1039,7 +1034,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
size[i] = H5T_get_size (dataset->type);
#endif
if (H5F_arr_write(dataset->ent.file, &(dataset->layout), size, offset,
- zero, size, conv_buf) < 0) {
+ zero, size, tconv_buf) < 0) {
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write failed");
}
ret_value = SUCCEED;
@@ -1047,6 +1042,6 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
done:
if (src_id >= 0) H5A_dec_ref(src_id);
if (dst_id >= 0) H5A_dec_ref(dst_id);
- conv_buf = H5MM_xfree(conv_buf);
+ tconv_buf = H5MM_xfree(tconv_buf);
FUNC_LEAVE(ret_value);
}