diff options
author | Robb Matzke <matzke@llnl.gov> | 1998-04-17 21:29:43 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1998-04-17 21:29:43 (GMT) |
commit | 011457075e41d587c47f89250514b3393a78d329 (patch) | |
tree | d9b12f2ffc87b12575607102d207a60cd52214b9 /test/dsets.c | |
parent | b59ab36893949af14c403ab46cbdb397f0a24f5b (diff) | |
download | hdf5-011457075e41d587c47f89250514b3393a78d329.zip hdf5-011457075e41d587c47f89250514b3393a78d329.tar.gz hdf5-011457075e41d587c47f89250514b3393a78d329.tar.bz2 |
[svn-r353] Changes since 19980414
----------------------
./html/Compression.html [NEW]
./html/Datasets.html
./html/H5.format.html
./html/H5.user.html
Documented compression. A couple of the H5P functions aren't
quite implemented yet but they're coming soon...
./src/H5Dprivate.h
./src/H5E.c
./src/H5Epublic.h
./src/H5Farray.c
./src/H5Fistore.c
./src/H5Fprivate.h
./src/H5MF.c
./src/H5MFprivate.h
./src/H5O.c
./src/H5Ocomp.c [NEW]
./src/H5Oprivate.h
./src/H5P.c
./src/H5Ppublic.h
./src/H5Sprivate.h
./src/H5Ssimp.c
./src/H5Z.c [NEW]
./src/H5Zprivate.h [NEW]
./src/H5Zpublic.h [NEW]
./src/Makefile.in
./src/hdf5.h
./test/dsets.c
./test/istore.c
Compression is now mostly working. Don't try to open a
compressed dataset though because the compression message
won't be read.
./html/Datatypes.html
./html/H5.api.html
./src/H5.c
./src/H5private.h
./src/H5D.c
./src/H5T.c
./src/H5Tconv.c
./src/H5Tpkg.h
./src/H5Tprivate.h
./src/H5Tpublic.h
Added timing support. When compiled with H5T_DEBUG defined
the library will print conversion bandwidths when the library
closes. The H5Tregister functions take a string as the first
argument so the statistics output is meaningful.
./MANIFEST
Added new files.
./configure.in
./src/H5config.h.in
Check for getrusage(). Check for compress2() in libz.a and
the zlib.h header file. Added `z' to the debug list.
./src/H5B.c
./src/H5Bprivate.h
./src/H5Gnode.c
./src/debug.c
Cleaned up some indentation and added support to print istore
B-trees. From the debugger, give the B-tree address and the
dimensionality from the layout message of the object header.
./src/h5ls.c
The oid is printed as w:x:y:z where w and x are the file ID
and y and z are the OID within the file. You can give z or
y*2^32+z as an argument to the debugger to print the object
header for the object.
./src/H5AC.c
Cleaned up statistics and made them match those reported by
H5T and H5Z.
./src/H5MM.c
./src/H5MMprivate.h
./src/H5Fistore.c
Finally got rid of a couple of long-standing const cast
warnings.
Diffstat (limited to 'test/dsets.c')
-rw-r--r-- | test/dsets.c | 145 |
1 files changed, 142 insertions, 3 deletions
diff --git a/test/dsets.c b/test/dsets.c index bf4b75f..fab1f75 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -35,6 +35,7 @@ #define DSET_CHUNKED_NAME "chunked" #define DSET_SIMPLE_IO_NAME "simple_io" #define DSET_TCONV_NAME "tconv" +#define DSET_COMPRESS_NAME "compressed" /*------------------------------------------------------------------------- @@ -89,6 +90,7 @@ test_create(hid_t file) void *client_data = NULL; printf("%-70s", "Testing create/open/close"); + fflush (stdout); /* Create the data space */ dims[0] = 256; @@ -202,6 +204,7 @@ test_simple_io(hid_t file) void *tconv_buf = NULL; printf("%-70s", "Testing simple I/O"); + fflush (stdout); /* Initialize the dataset */ for (i = n = 0; i < 100; i++) { @@ -290,7 +293,8 @@ test_tconv(hid_t file) assert (in); printf("%-70s", "Testing data type conversion"); - + fflush (stdout); + /* Initialize the dataset */ for (i = 0; i < 1000000; i++) { out[i*4+0] = 0x11; @@ -346,6 +350,132 @@ test_tconv(hid_t file) puts(" PASSED"); return 0; } + + +/*------------------------------------------------------------------------- + * Function: test_compression + * + * Purpose: Tests dataset compression. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Robb Matzke + * Wednesday, April 15, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +test_compression(hid_t file) +{ + hid_t dataset, space, xfer, dc; + herr_t status; + int points[100][200], check[100][200]; + int i, j, n; + hsize_t dims[2], chunk_size[2]; + void *tconv_buf = NULL; + + printf("%-70s", "Testing compression"); + fflush (stdout); + + /* Initialize the dataset */ + for (i = n = 0; i < 100; i++) { + for (j = 0; j < 100; j++) { + points[i][j] = n++; + } + } + + /* Create the data space */ + dims[0] = 100; + dims[1] = 200; + space = H5Screate_simple(2, dims, NULL); + assert(space>=0); + + /* Create a small conversion buffer to test strip mining */ + tconv_buf = malloc (1000); + xfer = H5Pcreate (H5P_DATASET_XFER); + assert (xfer>=0); + status = H5Pset_buffer (xfer, 1000, tconv_buf, NULL); + assert (status>=0); + + /* Use chunked storage with compression */ + dc = H5Pcreate (H5P_DATASET_CREATE); + chunk_size[0] = 2; + chunk_size[1] = 25; + H5Pset_chunk (dc, 2, chunk_size); + H5Pset_deflate (dc, 6); + + /* Create the dataset */ + dataset = H5Dcreate(file, DSET_COMPRESS_NAME, H5T_NATIVE_INT, space, dc); + assert(dataset >= 0); + + /* Write the data to the dataset */ + status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + xfer, points); + if (status<0) goto error; + + /* Read the dataset back */ + status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + xfer, check); + if (status<0) goto error; + + /* Check that the values read are the same as the values written */ + for (i = 0; i < 100; i++) { + for (j = 0; j < 200; j++) { + if (points[i][j] != check[i][j]) { + puts("*FAILED*"); + printf(" Read different values than written.\n"); + printf(" At index %d,%d\n", i, j); + goto error; + } + } + } + + /* + * Write some random data to the dataset, hopefully causing chunks to be + * reallocated as they grow. + */ + for (i=0; i<100; i++) { + for (j=0; j<100; j++) { + points[i][j] = rand (); + } + } + status = H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + xfer, points); + if (status<0) goto error; + + + /* Read the dataset back and check it */ + status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + xfer, check); + if (status<0) goto error; + + /* Check that the values read are the same as the values written */ + for (i = 0; i < 100; i++) { + for (j = 0; j < 200; j++) { + if (points[i][j] != check[i][j]) { + puts("*FAILED*"); + printf(" Read different values than written.\n"); + printf(" At index %d,%d\n", i, j); + goto error; + } + } + } + + + + + H5Dclose(dataset); + + puts(" PASSED"); + return 0; + + error: + return -1; +} /*------------------------------------------------------------------------- * Function: main @@ -366,7 +496,7 @@ test_tconv(hid_t file) int main(void) { - hid_t file; + hid_t file, grp; herr_t status; int nerrors = 0; @@ -377,9 +507,15 @@ main(void) H5Eset_auto (display_error_cb, NULL); unlink("dataset.h5"); - file = H5Fcreate("dataset.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate("dataset.h5", H5F_ACC_TRUNC|H5F_ACC_DEBUG, + H5P_DEFAULT, H5P_DEFAULT); assert(file >= 0); + /* Cause the library to emit initial messages */ + grp = H5Gcreate (file, "emit diagnostics", 0); + H5Gclose (grp); + + status = test_create(file); nerrors += status < 0 ? 1 : 0; @@ -388,6 +524,9 @@ main(void) status = test_tconv(file); nerrors += status < 0 ? 1 : 0; + + status = test_compression(file); + nerrors += status < 0 ? 1 : 0; status = H5Fclose(file); |