diff options
author | Robb Matzke <matzke@llnl.gov> | 1997-10-20 23:14:35 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1997-10-20 23:14:35 (GMT) |
commit | 56ad55117a89a423a9341d2f0c3912d4ad57ec6f (patch) | |
tree | dff0bada659180ac324d81a4d97f7bfb884f0ed6 /test/istore.c | |
parent | dc4961d072249ddf39a7db7a945ea627c276d025 (diff) | |
download | hdf5-56ad55117a89a423a9341d2f0c3912d4ad57ec6f.zip hdf5-56ad55117a89a423a9341d2f0c3912d4ad57ec6f.tar.gz hdf5-56ad55117a89a423a9341d2f0c3912d4ad57ec6f.tar.bz2 |
[svn-r129] Changes since 19970916
----------------------
./config/depend.in
Fixed backslashes in sed script because the H5Gnode.c
dependency info was disappearing. You'll have to rerun
config.status to rebuild the Makefiles unless you use gnu
make.
./config/conclude.in
Also removes emacs backup files, TAGS, and svf backup files.
./config/linux
Grouped gcc flags and added provisions for debugging vs. production.
./html/H5.format.html
Updated messages 0x0008, 0x0009, and 0x000A.
./html/storage.html
Documentation describing storage schemes.
./src/Makefile.in
./test/Makefile.in
New source files.
./src/H5A.c
./src/H5Apublic.h
./src/H5C.c
Changed VOIDP to void* in a couple places.
./src/H5AC.c
./src/H5ACprivate.h
./src/H5B.c
./src/H5Bprivate.h
./src/H5G.c
./src/H5Gnode.c
./src/H5Gprivate.h
./src/H5H.c
./src/H5O.c
Removed `const' from some variables because H5G_node_found() wanted
to modify it's udata argument. Removing const there caused it
to cascade to these other locations.
./src/H5AC.c
./src/H5ACprivate.h
./src/H5B.c
./src/H5Gnode.c
./src/H5Gstab.c
./src/H5H.c
./src/H5O.c
Added an extra argument to H5AC_find_f() and H5AC_protect(). This
arg gets passed to the load() method. Also added an extra
argument to the H5AC_find() macro.
./src/H5B.c
./src/H5Bprivate.h
./src/H5Gnode.c
Extra argument passed to the sizeof_rkey() method.
./src/H5Fprivate.c
./src/H5Fistore.c (new)
Added indexed I/O operations.
./src/H5G.c
./src/H5Gnode.c
./src/H5Gprivate.h
Beginning to add H5G_open/close and related bug fixes.
./src/H5Oprivate.h
./src/H5Oistore.c (new)
Added the H5O_ISTORE messsage (0x0008) for indexed storage of
objects.
./src/H5private.h
Added extra braces around both sides of the FUNC_ENTER() and
FUNC_LEAVE() macros so FUNC_ENTER() can appear before
declarations or after executable statements the second case is
used by H5G_namei() to initialize output arguments to sane
values before FUNC_ENTER() might return failure.
int f ()
{
int decl1;
printf ("This happens before FUNC_ENTER()\n");
FUNC_ENTER (...);
int another_declaration;
./src/H5B.c
./src/H5Bprivate.h
./src/H5Gnode.c
Extra arguments for key encoding and decoding.
./src/H5E.c
./src/H5Epublic.h
./src/H5Fistore.c
./src/H5Oistore.c
./src/H5Oprivate.h
Indexed, chunked, sparse storage (not ready for general consumption
yet).
./src/H5V.c (new)
./src/H5Vprivate.h (new)
./test/hyperslab.c (new)
Vector, array, and hyperslab functions.
./src/H5B.c
./src/H5Bprivate.h
./src/H5Fistore.c
./src/H5Gnode.c
./src/H5V.c
./src/H5Vprivate.h
./test/hyperslab.c
Added functionality for indexed storage.
./src/H5F.c
Fixed problems with seek optimizing. Recommend we disable it
until we can implement it in the file/address class since all
of HDF5 must be aware of it.
./src/H5O.c
Fixed comeent speling erorr :-)
./MANIFEST
Added new files.
./config/conclude.in
Added the word `Testing' to the test cases. So if a test
program is called hyperslab then the make output will contain
the line `Testing hyperslab'.
./config/linux
The default file I/O library is Posix section 2 on my linux
machine so I can do some I/O performance testing.
./src/H5C.c
./src/H5Cprivate.h
./src/H5Cpublic.h
Added ability to set size of indexed-storage B-tree.
./src/H5D.c
./src/H5E.c
./src/H5Epublic.h
./src/H5F.c
./src/H5Fprivate.h
./src/H5G.c
./src/H5Gnode.c
./src/H5Gpkg.h
./src/H5Gprivate.h
./src/H5Gpublic.h
./src/H5Gshad.c
./src/H5Gstab.c
./test/stab.c
Changed `directory' to `group' in numerous places.
./src/H5private.h
The FILELIB constant can be set on the compile command-line.
./src/istore.c NEW
Tests for indexed storage.
Diffstat (limited to 'test/istore.c')
-rw-r--r-- | test/istore.c | 431 |
1 files changed, 431 insertions, 0 deletions
diff --git a/test/istore.c b/test/istore.c new file mode 100644 index 0000000..9f6fa1f --- /dev/null +++ b/test/istore.c @@ -0,0 +1,431 @@ +/* + * Copyright (C) 1997 NCSA + * All rights reserved. + * + * Programmer: Robb Matzke <matzke@llnl.gov> + * Wednesday, October 15, 1997 + * + * Purpose: Tests various aspects of indexed raw data storage. + */ +#include <H5private.h> +#include <H5Fprivate.h> +#include <H5Gprivate.h> +#include <H5MMprivate.h> +#include <H5Oprivate.h> +#include <H5Vprivate.h> + +#define FILENAME "istore.h5" + +#define AT() printf (" at %s:%d in %s()...\n", \ + __FILE__, __LINE__, __FUNCTION__); + + + +/*------------------------------------------------------------------------- + * Function: print_array + * + * Purpose: Prints the values in an array + * + * Return: void + * + * Programmer: Robb Matzke + * Friday, October 10, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +print_array (uint8 *array, size_t nx, size_t ny, size_t nz) +{ + int i, j, k; + + for (i=0; i<nx; i++) { + if (nz>1) { + printf ("i=%d:\n", i); + } else { + printf ("%03d:", i); + } + + for (j=0; j<ny; j++) { + if (nz>1) printf ("%03d:", j); + for (k=0; k<nz; k++) { + printf (" %3d", *array++); + } + if (nz>1) printf ("\n"); + } + printf ("\n"); + } +} + + + +/*------------------------------------------------------------------------- + * Function: new_object + * + * Purpose: Creates a new object that refers to a indexed storage of raw + * data. No raw data is stored. + * + * Return: Success: Handle to a new open object. + * + * Failure: NULL, error message printed. + * + * Programmer: Robb Matzke + * Wednesday, October 15, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static H5G_entry_t * +new_object (H5F_t *f, const char *name, size_t ndims) +{ + H5G_entry_t *handle = NULL; + H5O_istore_t istore; + intn i; + + /* Create the object symbol table entry and header */ + if (NULL==(handle=H5G_create (f, name, 64))) { + puts ("*FAILED*"); + if (!isatty (1)) { + AT (); + printf (" H5G_create (f, name=\"%s\") = NULL\n", name); + } + return NULL; + } + + /* Add the indexed-storage message */ + memset (&istore, 0, sizeof istore); + istore.ndims = ndims; + for (i=0; i<ndims; i++) istore.alignment[i] = 2; + + if (H5O_modify (f, H5O_NO_ADDR, handle, H5O_ISTORE, H5O_NEW_MESG, + &istore)<0) { + printf ("*FAILED*\n"); + if (!isatty (1)) { + AT(); + printf (" H5G_modify istore message failure\n"); + } + return NULL; + } + + return handle; +} + + +/*------------------------------------------------------------------------- + * Function: test_create + * + * Purpose: Creates a named object that refers to indexed storage of raw + * data. No raw data is stored. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, October 15, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +test_create (H5F_t *f, const char *prefix) +{ + H5G_entry_t *handle = NULL; + intn i; + char name[256]; + + printf ("%-70s", "Testing istore create"); + fflush (stdout); + + for (i=1; i<=H5O_ISTORE_NDIMS; i++) { + sprintf (name, "%s_%02d", prefix, i); + if (NULL==(handle=new_object (f, name, i))) return FAIL; + H5G_close (f, handle); + } + + puts (" PASSED"); + return SUCCEED; +} + + + +/*------------------------------------------------------------------------- + * Function: test_extend + * + * Purpose: Creates an empty object and then writes to it in such a way + * as to always extend the object's domain. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, October 15, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +test_extend (H5F_t *f, const char *prefix, + size_t nx, size_t ny, size_t nz) +{ + H5G_entry_t *handle = NULL; + int i, j, k, ndims, ctr; + uint8 *buf=NULL, *check=NULL, *whole=NULL; + char dims[64], s[256], name[256]; + size_t offset[3]; + size_t max_corner[3]; + size_t size[3]; + size_t whole_size[3]; + H5O_istore_t istore; + + if (!nz) { + if (!ny) { + ndims = 1; + ny = nz = 1; + sprintf (dims, "%d", nx); + } else { + ndims = 2; + nz = 1; + sprintf (dims, "%dx%d", nx, ny); + } + } else { + ndims = 3; + sprintf (dims, "%dx%dx%d", nx, ny, nz); + } + + + sprintf (s, "Testing istore extend: %s", dims); + printf ("%-70s", s); + fflush (stdout); + buf = H5MM_xmalloc (nx*ny*nz); + check = H5MM_xmalloc (nx*ny*nz); + whole = H5MM_xcalloc (nx*ny*nz, 1); + + /* Build the new empty object */ + sprintf (name, "%s_%s", prefix, dims); + if (NULL==(handle=new_object (f, name, ndims))) { + if (!isatty (1)) { + AT (); + printf (" Cannot create %d-d object `%s'\n", ndims, name); + } + goto error; + } + if (NULL==H5O_read (f, H5O_NO_ADDR, handle, H5O_ISTORE, 0, &istore)) { + puts ("*FAILED*"); + if (!isatty (1)) { + AT (); + printf (" Unable to read istore message\n"); + } + goto error; + } + if (ndims!=istore.ndims) { + puts ("*FAILED*"); + if (!isatty (1)) { + AT (); + printf (" Header read error: istore.ndims != %d\n", ndims); + } + goto error; + } + + whole_size[0] = nx; + whole_size[1] = ny; + whole_size[2] = nz; + max_corner[0] = 0; + max_corner[1] = 0; + max_corner[2] = 0; + + for (ctr=0; H5V_vector_lt (ndims, max_corner, whole_size); ctr++) { + + /* Size and location */ + if (0==ctr) { + offset[0] = offset[1] = offset[2] = 0; + size[0] = size[1] = size[2] = 1; + } else { + for (i=0; i<ndims; i++) { + if (ctr % ndims == i) { + offset[i] = max_corner[i]; + size[i] = 1; + if (offset[i]+size[i]>whole_size[i]) continue; + } else { + offset[i] = 0; + size[i] = max_corner[i]; + } + } + } + +#if 0 + if (0==ctr) printf ("\n"); + printf (" Insert: ctr=%d, corner=(%d", ctr, offset[0]); + if (ndims>1) printf (",%d", offset[1]); + if (ndims>2) printf (",%d", offset[2]); + printf ("), size=(%d", size[0]); + if (ndims>1) printf (",%d", size[1]); + if (ndims>2) printf (",%d", size[2]); + printf (")\n"); +#endif + + /* Fill the source array */ + memset (buf, 128+ctr, size[0]*size[1]*size[2]); + + /* Write to disk */ + if (H5F_istore_write (f, &istore, offset, size, buf)<0) { + puts ("*FAILED*"); + if (!isatty (1)) { + AT (); + printf (" Write failed: ctr=%d\n", ctr); + } + goto error; + } + + /* Read from disk */ + memset (check, 0xff, size[0]*size[1]*size[2]); + if (H5F_istore_read (f, &istore, offset, size, check)<0) { + puts ("*FAILED*"); + if (!isatty (1)) { + AT (); + printf (" Read failed: ctr=%d\n", ctr); + } + goto error; + } + if (memcmp (buf, check, size[0]*size[1]*size[2])) { + puts ("*FAILED*"); + if (!isatty (1)) { + AT (); + printf (" Read check failed: ctr=%d\n", ctr); + printf (" Wrote:\n"); + print_array (buf, size[0], size[1], size[2]); + printf (" Read:\n"); + print_array (buf, size[0], size[1], size[2]); + } + goto error; + } + + /* Write to `whole' buffer for later checking */ + H5V_hyper_copy (ndims, size, + whole_size, offset, whole, /*dst*/ + size, H5V_ZERO, buf); /*src*/ + + /* Update max corner */ + for (i=0; i<ndims; i++) { + max_corner[i] = MAX (max_corner[i], offset[i]+size[i]); + } + } + + /* Update the object header */ + H5O_modify (f, H5O_NO_ADDR, handle, H5O_ISTORE, 0, &istore); + + + /* Now read the entire array back out and check it */ + memset (buf, 0xff, nx*ny*nz); + if (H5F_istore_read (f, &istore, H5V_ZERO, whole_size, buf)<0) { + puts ("*FAILED*"); + if (!isatty (1)) { + AT (); + printf (" Read failed for whole array\n"); + } + goto error; + } + for (i=0; i<nx; i++) { + for (j=0; j<ny; j++) { + for (k=0; k<nz; k++) { + if (whole[i*ny*nz + j*nz + k] != buf[i*ny*nz + j*nz + k]) { + puts ("*FAILED*"); + if (!isatty (1)) { + AT (); + printf (" Check failed at i=%d", i); + if (ndims>1) printf (", j=%d", j); + if (ndims>2) printf (", k=%d\n", k); + printf (" Check array is:\n"); + print_array (whole, nx, ny, nz); + printf (" Value read is:\n"); + print_array (buf, nx, ny, nz); + } + goto error; + } + } + } + } + + H5G_close (f, handle); + puts (" PASSED"); + H5MM_xfree (buf); + H5MM_xfree (check); + H5MM_xfree (whole); + return SUCCEED; + + error: + H5MM_xfree (buf); + H5MM_xfree (check); + H5MM_xfree (whole); + return FAIL; +} + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests indexed storage stuff. + * + * Return: Success: exit(0) + * + * Failure: exit(non-zero) + * + * Programmer: Robb Matzke + * Wednesday, October 15, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +main (void) +{ + H5F_t *f; + herr_t status; + int nerrors = 0; + + /* Create the test file */ + if (NULL==(f=H5F_open (FILENAME, H5F_ACC_CREAT|H5F_ACC_WRITE|H5F_ACC_TRUNC, + NULL))) { + printf ("Cannot create file %s; test aborted\n", FILENAME); + exit (1); + } + + /*---------------------- + * INDEXED STORAGE TESTS + *---------------------- + */ + status = test_create (f, "test_create_1"); + nerrors += status<0 ? 1 : 0; + + status = test_extend (f, "test_extend_1", 10, 0, 0); + nerrors += status<0 ? 1 : 0; + status = test_extend (f, "test_extend_1", 10, 10, 0); + nerrors += status<0 ? 1 : 0; + status = test_extend (f, "test_extend_1", 10, 10, 10); + nerrors += status<0 ? 1 : 0; + + + + + + /* Close the test file and exit */ + H5F_close (f); + if (nerrors) { + printf ("***** %d I-STORE TEST%s FAILED! *****\n", + nerrors, 1==nerrors?"":"S"); + if (isatty (1)) { + printf ("(Redirect output to a pager or a file to see " + "debug output)\n"); + } + exit (1); + } + + printf ("All i-store tests passed.\n"); + exit (0); +} |