diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-08-29 20:35:51 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-08-29 20:35:51 (GMT) |
commit | 13f357a94693c720bf101119103902c63b027706 (patch) | |
tree | a450afdd25662e4d22a952ccf5e4daed0234f2be /tools | |
parent | ca4379362b95dc8cc81152b8d994b72e7ca65eea (diff) | |
download | hdf5-13f357a94693c720bf101119103902c63b027706.zip hdf5-13f357a94693c720bf101119103902c63b027706.tar.gz hdf5-13f357a94693c720bf101119103902c63b027706.tar.bz2 |
[svn-r15558] 1) There are 2 new command line parameters for h5repack. Together they allow a call to H5Pset_alignment to be made
-t T, --threshold=T Threshold value for H5Pset_alignment
-a A, --alignment=A Alignment value for H5Pset_alignment
2) bug fix
the printing of the dataset name was not done for references (verbose mode)
tested: windows, linux
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5repack/h5repack.c | 15 | ||||
-rw-r--r-- | tools/h5repack/h5repack.h | 8 | ||||
-rwxr-xr-x | tools/h5repack/h5repack.sh.in | 5 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 50 | ||||
-rw-r--r-- | tools/h5repack/h5repack_main.c | 61 | ||||
-rw-r--r-- | tools/h5repack/h5repack_refs.c | 8 | ||||
-rw-r--r-- | tools/h5repack/h5repacktst.c | 68 |
7 files changed, 188 insertions, 27 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index 73f78f6..91ade4f 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -95,7 +95,7 @@ int h5repack_init (pack_opt_t *options, { int k, n; memset(options,0,sizeof(pack_opt_t)); - options->threshold = 1024; + options->min_comp = 1024; options->verbose = verbose; for ( n = 0; n < H5_REPACK_MAX_NFILTERS; n++) @@ -427,7 +427,18 @@ static int check_options(pack_opt_t *options) options->ublock_filename); return -1; } - + + + /*-------------------------------------------------------------------------------- + * verify alignment options; threshold is zero default but alignment not + *--------------------------------------------------------------------------------- + */ + + if ( options->alignment == 0 && options->threshold != 0 ) + { + error_msg(progname, "alignment for H5Pset_alignment missing\n"); + return -1; + } return 0; } diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index 42b9bbc..a7b3fd9 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -25,6 +25,8 @@ #define PFORMAT1 "%-7s %-7s %-7s" /* chunk info, compression info, name*/ #define MAX_NC_NAME 256 /* max length of a name */ #define MAX_VAR_DIMS 32 /* max per variable dimensions */ +#define FORMAT_OBJ " %-27s %s\n" /* obj type, name */ +#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */ /*------------------------------------------------------------------------- * data structures for command line options @@ -99,15 +101,17 @@ typedef struct { chunk_info_t chunk_g; /*global chunk INFO for the ALL case */ H5D_layout_t layout_g; /*global layout information for the ALL case */ int verbose; /*verbose mode */ - hsize_t threshold; /*minimum size to compress, in bytes */ + hsize_t min_comp; /*minimum size to compress, in bytes */ int use_native; /*use a native type in write */ int latest; /*pack file with the latest file format */ int grp_compact; /* Set the maximum number of links to store as header messages in the group */ int grp_indexed; /* Set the minimum number of links to store in the indexed format */ - int msg_size[8]; /* Minumum size of shared messages: dataspace, + int msg_size[8]; /* Minimum size of shared messages: dataspace, datatype, fill value, filter pipleline, attribute */ const char *ublock_filename; /* user block file name */ int ublock_size; /* user block size */ + hsize_t threshold; /* alignment threshold for H5Pset_alignment */ + hsize_t alignment ; /* alignment for H5Pset_alignment */ } pack_opt_t; diff --git a/tools/h5repack/h5repack.sh.in b/tools/h5repack/h5repack.sh.in index 28809eb..d5bb5c1 100755 --- a/tools/h5repack/h5repack.sh.in +++ b/tools/h5repack/h5repack.sh.in @@ -457,7 +457,7 @@ TOOLTEST $FILE1 -n # latest file format with long switches. use FILE4=h5repack_layout.h5 (no filters) -arg="$FILE4 --layout CHUNK=20x10 --filter GZIP=1 --threshold=10 --native --latest --compact=8 --indexed=6 --ssize=8[:dtype]" +arg="$FILE4 --layout CHUNK=20x10 --filter GZIP=1 --minimum=10 --native --latest --compact=8 --indexed=6 --ssize=8[:dtype]" if test $USE_FILTER_DEFLATE != "yes" ; then SKIP $arg else @@ -494,6 +494,9 @@ fi arg="$FILE1 -u ublock.bin -b 2048" TOOLTEST $arg +# add alignment +arg="$FILE1 -t 1 -a 1 " +TOOLTEST $arg if test $nerrors -eq 0 ; then diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 35bf1c9..7f43ad0 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -31,9 +31,7 @@ extern char *progname; * macros *------------------------------------------------------------------------- */ -#define FORMAT_OBJ " %-27s %s\n" /* obj type, name */ -#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */ -#define USERBLOCK_XFER_SIZE 512 /* Size of buffer/# of bytes to xfer at a time when copying userblock */ +#define USERBLOCK_XFER_SIZE 512 /* size of buffer/# of bytes to xfer at a time when copying userblock */ /*------------------------------------------------------------------------- * local functions @@ -240,6 +238,48 @@ int copy_objects(const char* fnamein, } + + /*------------------------------------------------------------------------- + * set alignment options + *------------------------------------------------------------------------- + */ + + + if ( options->alignment > 0 ) + { + /* either use the FCPL already created or create a new one */ + if (fapl != H5P_DEFAULT) + { + + if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) + { + error_msg(progname, "failed to set alignment\n"); + goto out; + } + + } + + else + { + + /* create a file access property list */ + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + { + error_msg(progname, "Could not create file access property list\n"); + goto out; + } + + if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) + { + error_msg(progname, "failed to set alignment\n"); + goto out; + } + + } + + } + + /*------------------------------------------------------------------------- * create the output file *------------------------------------------------------------------------- @@ -588,7 +628,7 @@ int do_copy_objects(hid_t fidin, dsize_in=H5Dget_storage_size(dset_in); /* check for datasets too small */ - if (nelmts*msize < options->threshold ) + if (nelmts*msize < options->min_comp ) apply_s=0; /* apply the filter */ @@ -768,7 +808,7 @@ int do_copy_objects(hid_t fidin, if ( has_filter && apply_s == 0 ) printf(" <warning: filter not applied to %s. dataset smaller than %d bytes>\n", travt->objs[i].name, - (int)options->threshold); + (int)options->min_comp); if ( has_filter && apply_f == 0 ) printf(" <warning: could not apply the filter to %s>\n", diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index c949732..f457f23 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_main.c @@ -37,14 +37,14 @@ static int has_i_o = 0; * Command-line options: The user can specify short or long-named * parameters. */ -static const char *s_opts = "hVvf:l:m:e:nLc:d:s:u:b:"; +static const char *s_opts = "hVvf:l:m:e:nLc:d:s:u:b:t:a:"; static struct long_options l_opts[] = { { "help", no_arg, 'h' }, { "version", no_arg, 'V' }, { "verbose", no_arg, 'v' }, { "filter", require_arg, 'f' }, { "layout", require_arg, 'l' }, - { "threshold", require_arg, 'm' }, + { "minimum", require_arg, 'm' }, { "file", require_arg, 'e' }, { "native", no_arg, 'n' }, { "latest", no_arg, 'L' }, @@ -53,6 +53,8 @@ static struct long_options l_opts[] = { { "ssize", require_arg, 's' }, { "ublock", require_arg, 'u' }, { "block", require_arg, 'b' }, + { "threshold", require_arg, 't' }, + { "alignment", require_arg, 'a' }, { NULL, 0, '\0' } }; @@ -87,7 +89,9 @@ static struct long_options l_opts[] = { * PVN, May 16, 2008 * added backward compatibility for -i infile -o outfile * PVN, August 20, 2008 - * add a user block to repacked file (switches -u -b) + * add a user block to repacked file (switches -u -b) + * PVN, August 28, 2008 + * add options to set alignment (H5Pset_alignment) (switches -t -a) *------------------------------------------------------------------------- */ int main(int argc, char **argv) @@ -166,10 +170,10 @@ int main(int argc, char **argv) else if (strcmp(argv[i], "-m") == 0) { - options.threshold = parse_number(argv[i+1]); - if ((int)options.threshold==-1) + options.min_comp = parse_number(argv[i+1]); + if ((int)options.min_comp<=0) { - error_msg(progname, "invalid treshold size <%s>\n",argv[i+1]); + error_msg(progname, "invalid minimum compress size <%s>\n",argv[i+1]); exit(1); } ++i; @@ -288,7 +292,6 @@ int main(int argc, char **argv) } - /* pack it */ ret=h5repack(infile,outfile,&options); @@ -327,20 +330,24 @@ static void usage(const char *prog) printf(" -c L1, --compact=L1 Maximum number of links in header messages\n"); printf(" -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); printf(" -s S[:F], --ssize=S[:F] Shared object header message minimum size\n"); - printf(" -m T, --threshold=T Do not apply the filter to datasets smaller than T\n"); - printf(" -e M, --file=M Name of file M with the -f and -l options\n"); + printf(" -m M, --minimum=M Do not apply the filter to datasets smaller than M\n"); + printf(" -e E, --file=E Name of file E with the -f and -l options\n"); printf(" -u U, --ublock=U Name of file U with user block data to be added\n"); - printf(" -b D, --block=D Size of user block to be added\n"); + printf(" -b B, --block=B Size of user block to be added\n"); + printf(" -t T, --threshold=T Threshold value for H5Pset_alignment\n"); + printf(" -a A, --alignment=A Alignment value for H5Pset_alignment\n"); printf(" -f FILT, --filter=FILT Filter type\n"); printf(" -l LAYT, --layout=LAYT Layout type\n"); printf("\n"); - printf(" T - is an integer greater than 1, size of dataset in bytes \n"); - printf(" M - is a filename.\n"); - printf(" U - is a filename.\n"); + printf(" M - is an integer greater than 1, size of dataset in bytes \n"); + printf(" E - is a filename.\n"); printf(" S - is an integer\n"); - printf(" D - is the user block size (any power of 2 equal to 512 or greater)\n"); + printf(" U - is a filename.\n"); + printf(" T - is an integer\n"); + printf(" A - is an integer greater than zero\n"); + printf(" B - is the user block size (any power of 2 equal to 512 or greater)\n"); printf(" F - is the shared object header message type, any of <dspace|dtype|fill|\n"); printf(" pline|attr>. If F is not specified, S applies to all messages\n"); @@ -464,10 +471,10 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options case 'm': - options->threshold = parse_number( opt_arg ); - if ((int)options->threshold==-1) + options->min_comp = parse_number( opt_arg ); + if ((int)options->min_comp<=0) { - error_msg(progname, "invalid treshold size <%s>\n", opt_arg ); + error_msg(progname, "invalid minimum compress size <%s>\n", opt_arg ); exit(EXIT_FAILURE); } break; @@ -550,6 +557,26 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options options->ublock_size = atoi( opt_arg ); break; + case 't': + + options->threshold = atoi( opt_arg ); + if ( options->threshold < 0 ) + { + error_msg(progname, "invalid threshold size\n", opt_arg ); + exit(EXIT_FAILURE); + } + break; + + case 'a': + + options->alignment = atoi( opt_arg ); + if ( options->alignment < 1 ) + { + error_msg(progname, "invalid alignment size\n", opt_arg ); + exit(EXIT_FAILURE); + } + break; + } /* switch */ diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c index 85af317..b0428bf 100644 --- a/tools/h5repack/h5repack_refs.c +++ b/tools/h5repack/h5repack_refs.c @@ -192,9 +192,13 @@ int do_copy_refobjs(hid_t fidin, if(H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, -1) < 0) goto error; if(options->verbose) + { + + printf(FORMAT_OBJ,"dset",travt->objs[i].name ); printf("object <%s> object reference created to <%s>\n", travt->objs[i].name, refname); + } } /*refname*/ H5Oclose(refobj_id); } /* u */ @@ -271,9 +275,13 @@ int do_copy_refobjs(hid_t fidin, if(H5Sclose(region_id) < 0) goto error; if(options->verbose) + { + + printf(FORMAT_OBJ,"dset",travt->objs[i].name ); printf("object <%s> region reference created to <%s>\n", travt->objs[i].name, refname); + } } /*refname*/ H5Oclose(refobj_id); } /* u */ diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index e7024f2..75af4f1 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -1403,6 +1403,9 @@ if (szip_can_encode) { *------------------------------------------------------------------------- */ TESTING(" file with added userblock"); + +#ifdef H5_HAVE_FILTER_DEFLATE + if(h5repack_init(&pack_options, 0) < 0) GOERROR; @@ -1420,7 +1423,72 @@ if (szip_can_encode) { GOERROR; if(h5repack_end(&pack_options) < 0) GOERROR; + + + PASSED(); +#else + SKIPPED(); +#endif + + +/*------------------------------------------------------------------------- + * test file with aligment + *------------------------------------------------------------------------- + */ + TESTING(" file with aligment"); + +#ifdef H5_HAVE_FILTER_DEFLATE + + if(h5repack_init(&pack_options, 0) < 0) + GOERROR; + + /* add the options for aligment */ + pack_options.alignment = 1; + pack_options.threshold = 1; + + if(h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) + GOERROR; + if(h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if(h5repack_verify(FNAME8OUT, &pack_options) <= 0) + GOERROR; + + + /* verify aligment */ + { + hsize_t threshold; + hsize_t alignment; + hid_t fapl; + hid_t fid; + + if (( fid = H5Fopen(FNAME8OUT, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 ) + GOERROR; + if ((fapl = H5Fget_access_plist(fid)) < 0) + GOERROR; + if ( H5Pget_alignment(fapl, &threshold, &alignment ) < 0) + GOERROR; + if ( threshold != 1 ) + GOERROR; + if ( alignment != 1 ) + GOERROR; + if ( H5Pclose(fapl) < 0) + GOERROR; + if (H5Fclose(fid) < 0) + GOERROR; + + } + + + if(h5repack_end(&pack_options) < 0) + GOERROR; + + PASSED(); +#else + SKIPPED(); +#endif + + |