summaryrefslogtreecommitdiffstats
path: root/src/H5Farray.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-01-16 19:52:04 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-01-16 19:52:04 (GMT)
commit74618e3670ed6c8db4c01dd30d1d7bba70447027 (patch)
tree7cb9ab8c0802eb8a46edc885dd8d6167a3c98d24 /src/H5Farray.c
parente59138031958a1ceb6105de0e1b222f85f2ac017 (diff)
downloadhdf5-74618e3670ed6c8db4c01dd30d1d7bba70447027.zip
hdf5-74618e3670ed6c8db4c01dd30d1d7bba70447027.tar.gz
hdf5-74618e3670ed6c8db4c01dd30d1d7bba70447027.tar.bz2
[svn-r155] Changes since 19980114
---------------------- ./html/Datasets.html Removed some archaic comments about data spaces. Fixed example code. ./MANIFEST ./html/H5.format.html ./src/H5O.c ./src/H5Oprivate.h ./src/H5Ocstore.c [DELETED] ./src/H5Oistore.c [DELETED] ./src/H5Olayout.c [NEW] ./src/Makefile.in ./test/istore.c Replaced H5O_CSTORE and H5O_ISTORE messages with a more general H5O_LAYOUT message. ./src/H5D.c ./src/H5Dprivate.h ./src/H5Dpublic.h A little more work on the pipeline. Access to the file data is through the new H5F_arr_read() and H5F_arr_write() which do I/O on hyperslabs of byte arrays and don't depend on data layout. This should simplify the I/O pipeline quite a bit. I also added another argument to H5Dread() and H5Dwrite() to describe the hyerslab of the file array on which I/O is occuring. We discussed this at last week's meeting. ./src/H5Farray.c [NEW] Added functions that sit on top of H5F_block_read() and H5F_istore_read() and implement a common set of functions between all layouts. This means I/O of hyperslabs of byte-arrays in the file to arrays of bytes in memory. When operating on arrays of elements (>1byte) then we just add another dimension. That is, a 10x20 array of int32 becomes a 10x20x4 array of bytes. [This is the area I'll be working on most of next week to implement partial I/O for contiguous data and to improve performance for chunked data.] ./src/H5Fistore.c ./src/H5Fprivate.h Replaced the H5F_istore_t data type with the layout message H5O_layout_t which looks almost the same. Eventually I'd like to rename `istore' to `chunked' everywhere and use `istore' for 1-d storage where the chunks are all different sizes like in the small object heap where each object is a chunk. ./src/H5V.c Changed ISTORE to LAYOUT in one place. ./test/dsets.c Fixed for extra argument to H5Dread() and H5Dwrite().
Diffstat (limited to 'src/H5Farray.c')
-rw-r--r--src/H5Farray.c219
1 files changed, 219 insertions, 0 deletions
diff --git a/src/H5Farray.c b/src/H5Farray.c
new file mode 100644
index 0000000..88dae0b
--- /dev/null
+++ b/src/H5Farray.c
@@ -0,0 +1,219 @@
+/*
+ * Copyright (C) 1998 Spizella Software
+ * All rights reserved.
+ *
+ * Programmer: Robb Matzke <robb@arborea.spizella.com>
+ * Thursday, January 15, 1998
+ *
+ * Purpose: Provides I/O facilities for multi-dimensional arrays of bytes
+ * stored with various layout policies.
+ */
+#include <H5private.h>
+#include <H5Dprivate.h>
+#include <H5Eprivate.h>
+#include <H5Fprivate.h>
+#include <H5MFprivate.h>
+#include <H5Oprivate.h>
+
+/* Interface initialization */
+#define PABLO_MASK H5F_arr_mask
+#define INTERFACE_INIT NULL
+static intn interface_initialize_g = FALSE;
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_arr_create
+ *
+ * Purpose: Creates an array of bytes. When called to create an array of
+ * some type, the fastest varying dimension corresponds to an
+ * instance of that type. That is, a 10x20 array of int32 is
+ * really a 10x20x4 array of bytes.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Friday, January 16, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F_arr_create (H5F_t *f, struct H5O_layout_t *layout/*in,out*/)
+{
+ intn i;
+ size_t nbytes;
+
+ FUNC_ENTER (H5F_arr_create, FAIL);
+
+ /* check args */
+ assert (f);
+ assert (layout);
+ H5F_addr_undef (&(layout->addr)); /*just in case we fail*/
+
+ switch (layout->type) {
+ case H5D_CONTIGUOUS:
+ /* Reserve space in the file for the entire array */
+ for (i=0, nbytes=1; i<layout->ndims; i++) nbytes *= layout->dim[i];
+ assert (nbytes>0);
+ if (H5MF_alloc (f, H5MF_RAW, nbytes, &(layout->addr)/*out*/)<0) {
+ HRETURN_ERROR (H5E_IO, H5E_NOSPACE, FAIL,
+ "unable to reserve file space");
+ }
+ break;
+
+ case H5D_CHUNKED:
+ /* Create the root of the B-tree that describes chunked storage */
+ if (H5F_istore_create (f, layout/*out*/)<0) {
+ HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL,
+ "unable to initialize chunked storage");
+ }
+ break;
+
+ default:
+ assert ("not implemented yet" && 0);
+ HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL,
+ "unsupported storage layout");
+ break;
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_arr_read
+ *
+ * Purpose: Reads a hyperslab of a file byte array into a byte array in
+ * memory which has the same dimensions as the hyperslab.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Friday, January 16, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t offset[], const size_t size[],
+ void *buf/*out*/)
+{
+ intn i;
+ size_t nbytes;
+ size_t zero_offset[H5O_LAYOUT_NDIMS];
+
+ FUNC_ENTER (H5F_arr_read, FAIL);
+
+ /* Check args */
+ assert (f);
+ assert (layout);
+ if (!offset) {
+ HDmemset (zero_offset, 0, sizeof zero_offset);
+ offset = zero_offset;
+ }
+ assert (size);
+ assert (buf);
+
+ switch (layout->type) {
+ case H5D_CONTIGUOUS:
+ /*
+ * We currently only support complete I/O.
+ */
+ for (i=0; i<layout->ndims; i++) {
+ assert (0==offset[i]);
+ assert (size[i]==layout->dim[i]);
+ }
+ for (i=0, nbytes=1; i<layout->ndims; i++) nbytes *= layout->dim[i];
+ if (H5F_block_read (f, &(layout->addr), nbytes, buf)<0) {
+ HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, "block read failed");
+ }
+ break;
+
+ case H5D_CHUNKED:
+ if (H5F_istore_read (f, layout, offset, size, buf)<0) {
+ HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, "chunked read failed");
+ }
+ break;
+
+ default:
+ assert ("not implemented yet" && 0);
+ HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL,
+ "unsupported storage layout");
+ break;
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_arr_write
+ *
+ * Purpose: Writes an array to a hyperslab of a file byte array. The
+ * memory array and the hyperslab are the same size.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Friday, January 16, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t H5F_arr_write (H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t offset[], const size_t size[],
+ const void *buf)
+{
+ intn i;
+ size_t nbytes;
+
+ FUNC_ENTER (H5F_arr_write, FAIL);
+
+ /* Check args */
+ assert (f);
+ assert (layout);
+ assert (offset);
+ assert (size);
+ assert (buf);
+
+ switch (layout->type) {
+ case H5D_CONTIGUOUS:
+ /*
+ * We currently only support complete I/O.
+ */
+ for (i=0; i<layout->ndims; i++) {
+ assert (0==offset[i]);
+ assert (size[i]==layout->dim[i]);
+ }
+ for (i=0, nbytes=1; i<layout->ndims; i++) nbytes *= layout->dim[i];
+ if (H5F_block_write (f, &(layout->addr), nbytes, buf)<0) {
+ HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
+ }
+ break;
+
+ case H5D_CHUNKED:
+ if (H5F_istore_write (f, layout, offset, size, buf)<0) {
+ HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "chunked write failed");
+ }
+ break;
+
+ default:
+ assert ("not implemented yet" && 0);
+ HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL,
+ "unsupported storage layout");
+ break;
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+