diff options
author | Robert E. McGrath <mcgrath@ncsa.uiuc.edu> | 2004-11-02 19:14:14 (GMT) |
---|---|---|
committer | Robert E. McGrath <mcgrath@ncsa.uiuc.edu> | 2004-11-02 19:14:14 (GMT) |
commit | 25c1e28ffd660e713f97b65e70620c7128f46f1f (patch) | |
tree | ad6abf34988df6351d4b579a7b87be6f822ca247 /tools | |
parent | 8c0c4f945db726fcddd2a40e4f617cdf6aac6be8 (diff) | |
download | hdf5-25c1e28ffd660e713f97b65e70620c7128f46f1f.zip hdf5-25c1e28ffd660e713f97b65e70620c7128f46f1f.tar.gz hdf5-25c1e28ffd660e713f97b65e70620c7128f46f1f.tar.bz2 |
[svn-r9496] Purpose:
Fix SZIP filter to dynmically detect encoder.
Description:
Solution:
See:
http://hdf.ncsa.uiuc.edu/RFC/SZIP/Szip_dynamic_12_Oct.pdf
Changes to h5repack tests, contingent on detecting SZIP encoder.
Note new program:
testh5repack_detect_szip
Checks fo rencoder, prints out "yes" or "no". Used by hrepack.sh
to detect encoder. Can also be used for windows tests. This is
only used as part of the tests.
Had to modify Makefile to build and clean this program.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5repack/Makefile.in | 12 | ||||
-rwxr-xr-x | tools/h5repack/h5repack.sh.in | 13 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_detect_szip.c | 51 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_main.c | 46 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_make.c | 30 | ||||
-rw-r--r-- | tools/lib/h5tools.h | 1 | ||||
-rw-r--r-- | tools/lib/h5tools_filters.c | 92 |
7 files changed, 226 insertions, 19 deletions
diff --git a/tools/h5repack/Makefile.in b/tools/h5repack/Makefile.in index 73601d4..4120b4d 100644 --- a/tools/h5repack/Makefile.in +++ b/tools/h5repack/Makefile.in @@ -27,9 +27,9 @@ CPPFLAGS=-I. -I$(srcdir) -I$(top_builddir)/src -I$(top_srcdir)/src \ ## Test programs and scripts. ## -TEST_PROGS=h5repacktst +TEST_PROGS=h5repacktst TEST_SCRIPTS=./h5repack.sh - +PRIV_PROGS=testh5repack_detect_szip ## These are our main targets: library and tools. ## @@ -37,7 +37,7 @@ LIBHDF5=$(top_builddir)/src/libhdf5.la LIBTOOLS=../lib/libh5tools.la PUB_PROGS=h5repack -PROGS=$(PUB_PROGS) $(TEST_PROGS) +PROGS=$(PUB_PROGS) $(TEST_PROGS) $(PRIV_PROGS) ## Source and object files for the library; do not install ## @@ -53,9 +53,10 @@ DISTCLEAN=h5repack.sh ## Source and object files for programs... ## PROG_SRC=h5repack.c h5repack_copy.c h5repack_filters.c h5repack_refs.c h5repack_list.c h5repack_main.c h5repack_opttable.c h5repack_parse.c h5repack_verify.c testh5repack_attr.c testh5repack_dset.c testh5repack_main.c testh5repack_make.c testh5repack_util.c -PROG_OBJ=$(PROG_SRC:.c=.lo) OBJS=h5repack.lo h5repack_filters.lo h5repack_copy.lo h5repack_refs.lo h5repack_list.lo h5repack_main.lo h5repack_opttable.lo h5repack_parse.lo h5repack_verify.lo TEST_OBJS=h5repack.lo h5repack_filters.lo h5repack_copy.lo h5repack_refs.lo h5repack_list.lo h5repack_opttable.lo h5repack_parse.lo h5repack_verify.lo testh5repack_attr.lo testh5repack_dset.lo testh5repack_main.lo testh5repack_make.lo testh5repack_util.lo +DETECT_OBJS=testh5repack_detect_szip.lo +PROG_OBJ=$(PROG_SRC:.c=.lo) $(DETECT_OBJS) PRIVATE_HDR= @@ -79,5 +80,8 @@ h5repack: $(OBJS) h5repacktst: $(TEST_OBJS) @$(LT_LINK_EXE) $(CFLAGS) -o $@ $(TEST_OBJS) $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS) +testh5repack_detect_szip: $(DETECT_OBJS) + @$(LT_LINK_EXE) $(CFLAGS) -o $@ $(DETECT_OBJS) $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS) + @CONCLUDE@ diff --git a/tools/h5repack/h5repack.sh.in b/tools/h5repack/h5repack.sh.in index a65cb37..a21d608 100755 --- a/tools/h5repack/h5repack.sh.in +++ b/tools/h5repack/h5repack.sh.in @@ -14,8 +14,6 @@ # # Tests for the h5repack tool -# Determine if SZIP has the encoder available -USE_FILTER_SZIP_ENCODER="@USE_FILTER_SZIP_ENCODER@" USE_FILTER_SZIP="@USE_FILTER_SZIP@" USE_FILTER_DEFLATE="@USE_FILTER_DEFLATE@" USE_FILTER_SHUFFLE="@USE_FILTER_SHUFFLE@" @@ -28,6 +26,9 @@ H5REPACK_BIN=`pwd`/$H5REPACK # The path of the tool binary H5DIFF=../h5diff/h5diff # The h5diff tool name H5DIFF_BIN=`pwd`/$H5DIFF # The path of the h5diff tool binary +H5DETECTSZIP=testh5repack_detect_szip # The tool name +H5DETECTSZIP_BIN=`pwd`/$H5DETECTSZIP # The path of the tool binary + nerrors=0 verbose=yes @@ -123,8 +124,12 @@ TOOLTEST() # See which filters are usable (and skip tests for filters we # don't have). Do this by searching H5pubconf.h to see which # filters are defined. -# A filter value of 3 means the filter can read and write, 2 -# is read-only, 1 is write-only, and 0 is not present. + +# detect whether the encoder is present. +USE_FILTER_SZIP_ENCODER="no"; +if test $USE_FILTER_SZIP = "yes"; then +USE_FILTER_SZIP_ENCODER=`$RUNSERIAL $H5DETECTSZIP_BIN` +fi # copy files (these files have no filters; test2.h5 has copied references that h5diff detects) TOOLTEST test0.h5 diff --git a/tools/h5repack/testh5repack_detect_szip.c b/tools/h5repack/testh5repack_detect_szip.c new file mode 100644 index 0000000..9e6514f --- /dev/null +++ b/tools/h5repack/testh5repack_detect_szip.c @@ -0,0 +1,51 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <stdio.h> +#include "hdf5.h" +#include "h5test.h" +#include "h5repack.h" + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: detects szip encoder, prints "yes" or "no" to stdout. + * Intended to be used in test scripts. + * + * Return: + * + * Programmer: + * + * Date: + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + + +void main(void) +{ +#ifdef H5_HAVE_FILTER_SZIP + if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { + printf("yes\n"); + exit(1); + } +#endif /* H5_HAVE_FILTER_SZIP */ + printf("no\n"); + exit(0); +} diff --git a/tools/h5repack/testh5repack_main.c b/tools/h5repack/testh5repack_main.c index caa4ac9..6729174 100644 --- a/tools/h5repack/testh5repack_main.c +++ b/tools/h5repack/testh5repack_main.c @@ -40,6 +40,9 @@ int main (void) { pack_opt_t pack_options; diff_opt_t diff_options; +#if defined (H5_HAVE_FILTER_SZIP) + int szip_can_encode = 0; +#endif memset(&diff_options, 0, sizeof (diff_opt_t)); memset(&pack_options, 0, sizeof (pack_opt_t)); @@ -229,13 +232,17 @@ int main (void) TESTING(" adding szip filter"); -#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) +#if defined (H5_HAVE_FILTER_SZIP) +if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { + szip_can_encode = 1; +} /*------------------------------------------------------------------------- * test an individual object option *------------------------------------------------------------------------- */ +if (szip_can_encode) { if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; if (h5repack_addfilter("dset2:SZIP=8,EC",&pack_options)<0) @@ -252,6 +259,9 @@ int main (void) TEST_ERROR; PASSED(); +} else { + SKIPPED(); +} #else SKIPPED(); #endif @@ -263,7 +273,8 @@ int main (void) */ TESTING(" adding szip filter to all"); -#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) +#if defined (H5_HAVE_FILTER_SZIP) +if (szip_can_encode) { if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; if (h5repack_addfilter("SZIP=8,NN",&pack_options)<0) @@ -278,6 +289,9 @@ TESTING(" adding szip filter to all"); TEST_ERROR; PASSED(); +} else { + SKIPPED(); +} #else SKIPPED(); #endif @@ -425,9 +439,11 @@ TESTING(" addding shuffle filter to all"); TEST_ERROR; #endif -#if defined (H5_SZIP_CAN_ENCODE) && defined (H5_HAVE_FILTER_SZIP) +#if defined (H5_HAVE_FILTER_SZIP) +if (szip_can_encode) { if (h5repack_addfilter("dset1:SZIP=8,NN",&pack_options)<0) TEST_ERROR; +} #endif #ifdef H5_HAVE_FILTER_DEFLATE @@ -765,7 +781,8 @@ TESTING(" addding shuffle filter to all"); TESTING(" copy of szip filter"); -#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) +#if defined (H5_HAVE_FILTER_SZIP) +if (szip_can_encode) { if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; if (h5repack(FNAME7,FNAME7OUT,&pack_options)<0) @@ -778,13 +795,17 @@ TESTING(" addding shuffle filter to all"); TEST_ERROR; PASSED(); +} else { + SKIPPED(); +} #else SKIPPED(); #endif TESTING(" removing szip filter"); -#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) +#if defined (H5_HAVE_FILTER_SZIP) +if (szip_can_encode) { if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; if (h5repack_addfilter("dset_szip:NONE",&pack_options)<0) @@ -799,6 +820,9 @@ TESTING(" addding shuffle filter to all"); TEST_ERROR; PASSED(); +} else { + SKIPPED(); +} #else SKIPPED(); #endif @@ -941,10 +965,11 @@ TESTING(" addding shuffle filter to all"); TESTING(" filter conversion from deflate to szip"); -#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) \ +#if defined (H5_HAVE_FILTER_SZIP) \ && defined (H5_HAVE_FILTER_DEFLATE) \ && defined (H5_HAVE_FILTER_FLETCHER32) && defined (H5_HAVE_FILTER_SHUFFLE) +if (szip_can_encode) { if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; if (h5repack_addfilter("dset_deflate:SZIP=8,NN",&pack_options)<0) @@ -959,16 +984,20 @@ TESTING(" addding shuffle filter to all"); TEST_ERROR; PASSED(); +} else { + SKIPPED(); +} #else SKIPPED(); #endif TESTING(" filter conversion from szip to deflate"); -#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) \ +#if defined (H5_HAVE_FILTER_SZIP) \ && defined (H5_HAVE_FILTER_DEFLATE) \ && defined (H5_HAVE_FILTER_FLETCHER32) && defined (H5_HAVE_FILTER_SHUFFLE) +if (szip_can_encode) { if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; if (h5repack_addfilter("dset_szip:GZIP=1",&pack_options)<0) @@ -983,6 +1012,9 @@ TESTING(" addding shuffle filter to all"); TEST_ERROR; PASSED(); +} else { + SKIPPED(); +} #else SKIPPED(); #endif diff --git a/tools/h5repack/testh5repack_make.c b/tools/h5repack/testh5repack_make.c index 3cf7c11..6149bd9 100644 --- a/tools/h5repack/testh5repack_make.c +++ b/tools/h5repack/testh5repack_make.c @@ -372,6 +372,9 @@ int make_szip(hid_t loc_id) hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; int buf[DIM1][DIM2]; int i, j, n; +#if defined (H5_HAVE_FILTER_SZIP) + int szip_can_encode = 0; +#endif for (i=n=0; i<DIM1; i++){ for (j=0; j<DIM2; j++){ @@ -393,12 +396,19 @@ int make_szip(hid_t loc_id) *------------------------------------------------------------------------- */ /* Make sure encoding is enabled */ -#if defined (H5_SZIP_CAN_ENCODE) && defined (H5_HAVE_FILTER_SZIP) +#if defined (H5_HAVE_FILTER_SZIP) +if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { + szip_can_encode = 1; +} +if (szip_can_encode) { /* set szip data */ if(H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block)<0) goto out; if (make_dset(loc_id,"dset_szip",sid,dcpl,buf)<0) goto out; +} else { + /* WARNING? SZIP is decoder only, can't generate test files */ +} #endif if(H5Sclose(sid)<0) @@ -629,6 +639,9 @@ int make_all(hid_t loc_id) hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; int buf[DIM1][DIM2]; int i, j, n; +#if defined (H5_HAVE_FILTER_SZIP) + int szip_can_encode = 0; +#endif for (i=n=0; i<DIM1; i++){ for (j=0; j<DIM2; j++){ @@ -657,10 +670,17 @@ int make_all(hid_t loc_id) goto out; #endif -#if defined (H5_SZIP_CAN_ENCODE) && defined (H5_HAVE_FILTER_SZIP) +#if defined (H5_HAVE_FILTER_SZIP) +if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { + szip_can_encode = 1; +} +if (szip_can_encode) { /* set szip data */ if(H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block)<0) goto out; +} else { + /* WARNING? SZIP is decoder only, can't generate test data using szip */ +} #endif #if defined (H5_HAVE_FILTER_DEFLATE) @@ -692,7 +712,8 @@ int make_all(hid_t loc_id) *------------------------------------------------------------------------- */ /* Make sure encoding is enabled */ -#if defined (H5_SZIP_CAN_ENCODE) && defined (H5_HAVE_FILTER_SZIP) +#if defined (H5_HAVE_FILTER_SZIP) +if (szip_can_encode) { /* remove the filters from the dcpl */ if (H5Premove_filter(dcpl,H5Z_FILTER_ALL)<0) goto out; @@ -701,6 +722,9 @@ int make_all(hid_t loc_id) goto out; if (make_dset(loc_id,"dset_szip",sid,dcpl,buf)<0) goto out; +} else { + /* WARNING? SZIP is decoder only, can't generate test dataset */ +} #endif /*------------------------------------------------------------------------- diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index f5731a0..93f926e 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -509,5 +509,6 @@ extern void h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid extern int h5tools_canreadf(const char* name, hid_t dcpl_id); +extern int h5tools_can_encode(H5Z_filter_t filtn); #endif /* H5TOOLS_H__ */ diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c index 368283f..3370409 100644 --- a/tools/lib/h5tools_filters.c +++ b/tools/lib/h5tools_filters.c @@ -150,5 +150,95 @@ int h5tools_canreadf(const char* name, /* object name, serves also as boolean pr } +/*------------------------------------------------------------------------- + * Function: h5tools_canwritef + * + * Purpose: check if the filter is available and can write data. + * At this time, all filters that are available can write data, + * except SZIP, which may be configured decoder-only. + * + * Return: 1, can write, 0, cannot, -1 error + * + * Programmer: + * + * Date: October 5, 2004 + * + *------------------------------------------------------------------------- + */ +int h5tools_can_encode( H5Z_filter_t filtn) +{ - + int have_deflate=0; /* assume initially we do not have filters */ + int have_szip=0; + int have_shuffle=0; + int have_fletcher=0; + herr_t status; + unsigned int filter_config_flags; + +#ifdef H5_HAVE_FILTER_DEFLATE + have_deflate=1; +#endif +#ifdef H5_HAVE_FILTER_SZIP + have_szip=1; +#endif +#ifdef H5_HAVE_FILTER_SHUFFLE + have_shuffle=1; +#endif +#ifdef H5_HAVE_FILTER_FLETCHER32 + have_fletcher=1; +#endif + + switch (filtn) + { + /* user defined filter */ + default: + return 0; + break; + case H5Z_FILTER_DEFLATE: + if (!have_deflate) + { + return 0; + } + break; + case H5Z_FILTER_SZIP: + if (!have_szip) + { + return 0; + } + status =H5Zget_filter_info(filtn, &filter_config_flags); + if ((filter_config_flags & + (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) { + /* filter present but neither encode nor decode is supported (???) */ + return -1; + } else if ((filter_config_flags & + (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == + H5Z_FILTER_CONFIG_DECODE_ENABLED) { + /* decoder only: read but not write */ + return 0; + } else if ((filter_config_flags & + (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == + H5Z_FILTER_CONFIG_ENCODE_ENABLED) { + /* encoder only: write but not read (???) */ + return -1; + } else if ((filter_config_flags & + (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == + (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) { + return 1; + } + break; + case H5Z_FILTER_SHUFFLE: + if (!have_shuffle) + { + return 0; + } + break; + case H5Z_FILTER_FLETCHER32: + if (!have_fletcher) + { + return 0; + } + break; + }/*switch*/ + + return 1; +} |