From 25c1e28ffd660e713f97b65e70620c7128f46f1f Mon Sep 17 00:00:00 2001 From: "Robert E. McGrath" Date: Tue, 2 Nov 2004 14:14:14 -0500 Subject: [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. --- tools/h5repack/Makefile.in | 12 ++-- tools/h5repack/h5repack.sh.in | 13 +++-- tools/h5repack/testh5repack_detect_szip.c | 51 +++++++++++++++++ tools/h5repack/testh5repack_main.c | 46 +++++++++++++--- tools/h5repack/testh5repack_make.c | 30 +++++++++- tools/lib/h5tools.h | 1 + tools/lib/h5tools_filters.c | 92 ++++++++++++++++++++++++++++++- 7 files changed, 226 insertions(+), 19 deletions(-) create mode 100644 tools/h5repack/testh5repack_detect_szip.c 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 +#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