summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools_utils.c
diff options
context:
space:
mode:
authorJonathan Kim <jkm@hdfgroup.org>2011-10-14 22:44:11 (GMT)
committerJonathan Kim <jkm@hdfgroup.org>2011-10-14 22:44:11 (GMT)
commit664c013fc76b9a440944db320e9025b4a9a62beb (patch)
tree05a4e30ae59d69fab0fd45630e71dc59b9bee2cf /tools/lib/h5tools_utils.c
parent3be11d46c5803fe65c05cd5c859989406ce25667 (diff)
downloadhdf5-664c013fc76b9a440944db320e9025b4a9a62beb.zip
hdf5-664c013fc76b9a440944db320e9025b4a9a62beb.tar.gz
hdf5-664c013fc76b9a440944db320e9025b4a9a62beb.tar.bz2
[svn-r21586] Description:
Added a funtion to reset dataset & hyperslab buffer size for h5repack from an environment variable. This is performance debugging purpose for now. Tested: jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), Windows (32-LE), cmake
Diffstat (limited to 'tools/lib/h5tools_utils.c')
-rw-r--r--tools/lib/h5tools_utils.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index ab8536f..3f89572 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -42,6 +42,18 @@ const char *opt_arg; /*flag argument (or value) */
static int h5tools_d_status = 0;
static const char *h5tools_progname = "h5tools";
+/*
+ * The output functions need a temporary buffer to hold a piece of the
+ * dataset while it's being printed. This constant sets the limit on the
+ * size of that temporary buffer in bytes. For efficiency's sake, choose the
+ * largest value suitable for your machine (for testing use a small value).
+ */
+/* Maximum size used in a call to malloc for a dataset */
+hsize_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024);
+/* size of hyperslab buffer when a dataset is bigger than H5TOOLS_MALLOCSIZE */
+hsize_t H5TOOLS_BUFSIZE = (1024 * 1024);
+
+
/* ``parallel_print'' variables */
unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */
char outBuff[OUTBUFF_SIZE];
@@ -889,3 +901,43 @@ int h5tools_getstatus(void)
{
return h5tools_d_status;
}
+
+/*-----------------------------------------------------------
+ * PURPOSE :
+ * if environment variable H5TOOLS_BUFSIZE is set,
+ * update H5TOOLS_BUFSIZE and H5TOOLS_MALLOCSIZE from the env
+ * This can be called from each tools main() as part of initial act.
+ * Note: this is more of debugging purpose for now.
+ */
+int h5tools_getenv_update_hyperslab_bufsize(void)
+{
+ const char *env_str = NULL;
+ long hyperslab_bufsize_mb;
+
+ /* check if environment variable is set for the hyperslab buffer size */
+ if (NULL != (env_str = HDgetenv ("H5TOOLS_BUFSIZE")))
+ {
+ errno = 0;
+ hyperslab_bufsize_mb = HDstrtol(env_str, (char**)NULL, 10);
+ if (errno != 0 || hyperslab_bufsize_mb <= 0)
+ {
+
+ /* TODO: later when pubilshed
+ printf("Error: Invalid environment variable \"H5TOOLS_BUFSIZE\" : %s\n", env_str);
+ */
+
+ goto error;
+ }
+
+
+ /* convert MB to byte */
+ H5TOOLS_BUFSIZE = hyperslab_bufsize_mb * 1024 * 1024;
+
+ H5TOOLS_MALLOCSIZE = MAX(H5TOOLS_BUFSIZE, H5TOOLS_MALLOCSIZE);
+ }
+
+
+ return (1);
+error:
+ return (-1);
+}