[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
This commit is contained in:
Jonathan Kim 2011-10-14 17:44:11 -05:00
parent 3be11d46c5
commit 664c013fc7
7 changed files with 64 additions and 18 deletions

View File

@ -18,6 +18,7 @@
#include "hdf5.h"
#include "H5private.h"
#include "h5tools.h"
#include "h5tools_utils.h"
/* Name of tool */

View File

@ -15,6 +15,7 @@
#include "h5repack.h"
#include "h5tools.h"
#include "h5tools_utils.h"
/* number of members in an array */
#ifndef NELMTS

View File

@ -106,6 +106,10 @@ int main(int argc, const char **argv)
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
/* update hyperslab buffer size from H5TOOLS_BUFSIZE env if exist */
if ( h5tools_getenv_update_hyperslab_bufsize() < 0)
exit(EXIT_FAILURE);
/* initialize options */
h5repack_init(&options, 0, 0, (hsize_t)0);

View File

@ -17,6 +17,7 @@
#include "h5test.h"
#include "h5diff.h"
#include "h5tools.h"
#include "h5tools_utils.h"
#define GOERROR {H5_FAILED(); goto error;}

View File

@ -31,23 +31,6 @@
#define START_OF_DATA 0x0001
#define END_OF_DATA 0x0002
/*
* 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).
*/
#if 1
#define H5TOOLS_BUFSIZE (1024 * 1024)
#else
#define H5TOOLS_BUFSIZE (1024)
#endif
/*
* Maximum size used in a call to malloc
*/
#define H5TOOLS_MALLOCSIZE (128 * 1024 * 1024)
/* format for hsize_t */
#define HSIZE_T_FORMAT "%"H5_PRINTF_LL_WIDTH"u"

View File

@ -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);
}

View File

@ -32,6 +32,10 @@ extern "C" {
#define PRINT_DATA_MAX_SIZE 512
#define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE*4)
/* Maximum size used in a call to malloc for a dataset */
H5TOOLS_DLLVAR hsize_t H5TOOLS_MALLOCSIZE;
/* size of hyperslab buffer when a dataset is bigger than H5TOOLS_MALLOCSIZE */
H5TOOLS_DLLVAR hsize_t H5TOOLS_BUFSIZE;
H5TOOLS_DLLVAR int g_nTasks;
H5TOOLS_DLLVAR unsigned char g_Parallel;
H5TOOLS_DLLVAR char outBuff[];
@ -169,7 +173,7 @@ H5TOOLS_DLL const char *h5tools_getprogname(void);
H5TOOLS_DLL void h5tools_setprogname(const char*progname);
H5TOOLS_DLL int h5tools_getstatus(void);
H5TOOLS_DLL void h5tools_setstatus(int d_status);
H5TOOLS_DLL int h5tools_getenv_update_hyperslab_bufsize(void);
#ifdef __cplusplus
}
#endif