From 796fe1c4025f83b4060157d04d3873ca9f3fa9e7 Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Wed, 28 Jan 2004 17:48:47 -0500 Subject: [svn-r8122] Purpose: h5repack new feature Description: in the SZIP settings, when the requested pixels per block parameter does not conform to the SZIP specifications, instead of returning without applying the filter, do an attempt to set this parameter to a valid value, issuing a warning in the process Solution: Platforms tested: linux solaris AIX Misc. update: --- tools/h5repack/h5repack.c | 3 +- tools/h5repack/h5repack.h | 5 ++- tools/h5repack/h5repack_copy.c | 16 +++----- tools/h5repack/h5repack_filters.c | 83 +++++++++++++++++++++++---------------- 4 files changed, 60 insertions(+), 47 deletions(-) diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index 37ef3d1..2cbcf86 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -342,7 +342,8 @@ static int check_options(pack_opt_t *options) pack.chunk.chunk_lengths, 0, /* do not test size */ szip_options_mask, - szip_pixels_per_block)==0) + &szip_pixels_per_block, + options)==0) { /* Return: 1=can apply the filter 0=cannot apply the filter diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index 438dd45..eb71fec 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -183,7 +183,7 @@ int filter_this(const char* name, int apply_filters(hid_t dcpl_id, size_t size, /* size of datatype in bytes */ pack_opt_t *options, /* repack options */ - pack_info_t *pack); /* info about object to filter */ + pack_info_t *pack); /* info about object to filter */ int has_filter(hid_t dcpl_id, H5Z_filter_t filtnin); @@ -197,7 +197,8 @@ int check_szip(int rank, /* chunk rank */ hsize_t *dims, /* chunk dims */ size_t size, /* size of datatype in bytes */ unsigned szip_options_mask, - unsigned szip_pixels_per_block); + unsigned *szip_pixels_per_block /*IN,OUT*/, + pack_opt_t *options); /*------------------------------------------------------------------------- diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index bdde91c..f9859aa 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -244,7 +244,7 @@ int do_copy_objects(hid_t fidin, /* the information about the object to be filtered/"layouted" */ pack_info_t obj; init_packobject(&obj); - + /* get the storage size of the input dataset */ dsize_in=H5Dget_storage_size(dset_in); @@ -264,17 +264,15 @@ int do_copy_objects(hid_t fidin, /*------------------------------------------------------------------------- * apply the layout; check first if the object is to be modified. - * if the layout could not be applied, continue *------------------------------------------------------------------------- */ if (layout_this(dcpl_id,travt->objs[i].name,options,&obj)) { if (apply_layout(dcpl_id,&obj)<0) - continue; + goto error; } /*------------------------------------------------------------------------- * apply the filter; check first if the object is to be filtered. - * if the filter could not be applied, continue *------------------------------------------------------------------------- */ if (filter_this(travt->objs[i].name,options,&obj)) @@ -288,16 +286,16 @@ int do_copy_objects(hid_t fidin, for (j=0; jverbose) printf("Warning: Filter could not be applied to <%s>\n", travt->objs[i].name); - } - } + }/*rank*/ + }/*filter_this*/ }/*nelmts*/ /*------------------------------------------------------------------------- @@ -389,9 +387,7 @@ int do_copy_objects(hid_t fidin, */ case H5G_LINK: - { - H5G_stat_t statbuf; char *targbuf=NULL; diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index 6476595..0a0de02 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -158,7 +158,7 @@ int print_filters(hid_t dcpl_id) * do extra checking in the case of SZIP; delete all filters in the case * of H5Z_FILTER_NONE present in the PACK_INFO_T filter array * - * Return: 0, ok, -1 no + * Return: 0 success, -1 an error occured * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * @@ -194,12 +194,10 @@ int apply_filters(hid_t dcpl_id, { if (nfilters && H5Pdelete_filter(dcpl_id,H5Z_FILTER_NONE)<0) return -1; - - return 1; + return 0; } } - /*------------------------------------------------------------------------- * the type of filter and additional parameter * type can be one of the filters @@ -217,65 +215,67 @@ int apply_filters(hid_t dcpl_id, { default: break; - + +/*------------------------------------------------------------------------- + * H5Z_FILTER_DEFLATE 1 , deflation like gzip + *------------------------------------------------------------------------- + */ case H5Z_FILTER_DEFLATE: - aggression=obj->filter[i].cd_values[0]; - /* set up for deflated data */ if(H5Pset_chunk(dcpl_id, obj->chunk.rank, obj->chunk.chunk_lengths)<0) return -1; if(H5Pset_deflate(dcpl_id,aggression)<0) return -1; - break; - - + +/*------------------------------------------------------------------------- + * H5Z_FILTER_SZIP 4 , szip compression + *------------------------------------------------------------------------- + */ case H5Z_FILTER_SZIP: - szip_pixels_per_block=obj->filter[i].cd_values[0]; - /* check szip parameters */ if (check_szip(obj->chunk.rank, obj->chunk.chunk_lengths, size, szip_options_mask, - szip_pixels_per_block)==1) + &szip_pixels_per_block, + options)==1) { /* set up for szip data */ if(H5Pset_chunk(dcpl_id,obj->chunk.rank,obj->chunk.chunk_lengths)<0) return -1; if (H5Pset_szip(dcpl_id, szip_options_mask, szip_pixels_per_block)<0) return -1; - } else { - printf("SZIP filter cannot be applied\n"); + printf("Warning: SZIP filter cannot be applied\n"); } - break; - - + +/*------------------------------------------------------------------------- + * H5Z_FILTER_SHUFFLE 2 , shuffle the data + *------------------------------------------------------------------------- + */ case H5Z_FILTER_SHUFFLE: - if(H5Pset_chunk(dcpl_id, obj->chunk.rank, obj->chunk.chunk_lengths)<0) return -1; if (H5Pset_shuffle(dcpl_id)<0) return -1; - break; - + +/*------------------------------------------------------------------------- + * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC + *------------------------------------------------------------------------- + */ case H5Z_FILTER_FLETCHER32: - if(H5Pset_chunk(dcpl_id, obj->chunk.rank, obj->chunk.chunk_lengths)<0) return -1; if (H5Pset_fletcher32(dcpl_id)<0) return -1; - break; - - } /* switch */ }/*i*/ @@ -309,11 +309,13 @@ int apply_filters(hid_t dcpl_id, int check_szip(int rank, /* chunk rank */ hsize_t *dims, /* chunk dims */ size_t size, /* size of datatype in bytes */ - unsigned szip_options_mask, - unsigned szip_pixels_per_block) + unsigned szip_options_mask /*IN*/, + unsigned *szip_pixels_per_block /*IN,OUT*/, + pack_opt_t *options) { szip_comp_t szip; int i; + unsigned ppb=*szip_pixels_per_block; /* pixels_per_scanline = size of the fastest-changing dimension @@ -337,15 +339,28 @@ int check_szip(int rank, /* chunk rank */ pixels_per_block must be an even number, and <= pixels_per_scanline and <= MAX_PIXELS_PER_BLOCK */ - szip.pixels_per_block=szip_pixels_per_block; - if (szip.pixels_per_block > szip.pixels_per_scanline) + if (ppb > szip.pixels_per_scanline) { - printf("\n\tWarning: in SZIP setting, pixels per block <%d>, \ - cannot be greater than pixels per scanline<%d>\n", - szip.pixels_per_block, szip.pixels_per_scanline); - return 0; + /* set ppb to pixels per scanline and try to make it an even number */ + ppb=szip.pixels_per_scanline; + if (ppb%2!=0) + ppb--; + if (ppb<=1 ) + { + printf("Warning: in SZIP settings, pixels per block <%d>,\ + cannot be set with pixels per scanline <%d>\n", + ppb, szip.pixels_per_scanline); + return 0; + } + else + { + if (options->verbose) + printf("Warning: In SZIP settings, pixels per block was set to <%d>\n", ppb); + } } + szip.pixels_per_block = ppb; + *szip_pixels_per_block = ppb; szip.options_mask = szip_options_mask; szip.compression_mode = NN_MODE; @@ -373,7 +388,7 @@ int check_szip(int rank, /* chunk rank */ szip.bits_per_pixel = 64; break; default: - printf("Error: Bad numeric type of size <%d> in SZIP\n",size); + printf("Warning: Invalid numeric type of size <%d> for SZIP\n",size); return 0; } -- cgit v0.12