summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2008-08-28 19:47:26 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2008-08-28 19:47:26 (GMT)
commitf384b17625179b29475b2ec836c949fe3b9d5e44 (patch)
tree2adc53784220241216b8ef41697c9e984889575d /tools
parenta4c82ed0491ce7e28079cdde9745b8ddfa9d60bc (diff)
downloadhdf5-f384b17625179b29475b2ec836c949fe3b9d5e44.zip
hdf5-f384b17625179b29475b2ec836c949fe3b9d5e44.tar.gz
hdf5-f384b17625179b29475b2ec836c949fe3b9d5e44.tar.bz2
[svn-r15551] 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.c20
-rw-r--r--tools/h5repack/h5repack.h6
-rwxr-xr-xtools/h5repack/h5repack.sh.in4
-rw-r--r--tools/h5repack/h5repack_copy.c48
-rw-r--r--tools/h5repack/h5repack_main.c61
-rw-r--r--tools/h5repack/h5repack_refs.c8
-rw-r--r--tools/h5repack/h5repacktst.c68
7 files changed, 192 insertions, 23 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c
index 73f78f6..75684fc 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,25 @@ static int check_options(pack_opt_t *options)
options->ublock_filename);
return -1;
}
+
+
+ /*--------------------------------------------------------------------------------
+ * verify alignment options; both threshold and alignment sizes must be present
+ *---------------------------------------------------------------------------------
+ */
+#if 0
+ if ( options->alignment != 0 && options->threshold == 0 )
+ {
+ error_msg(progname, "threshold for H5Pset_alignment missing\n");
+ return -1;
+ }
+ if ( options->alignment == 0 && options->threshold != 0 )
+ {
+ error_msg(progname, "alignment for H5Pset_alignment missing\n");
+ return -1;
+ }
+#endif
return 0;
}
diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h
index e67bb97..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,7 +101,7 @@ 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 */
@@ -108,6 +110,8 @@ typedef struct {
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 fdd93da..c4afde9 100755
--- a/tools/h5repack/h5repack.sh.in
+++ b/tools/h5repack/h5repack.sh.in
@@ -494,6 +494,10 @@ 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
echo "All $H5REPACK tests passed."
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index e9ddbe0..7f43ad0 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -31,8 +31,6 @@ 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 */
/*-------------------------------------------------------------------------
@@ -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
+
+