summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5diff_util.c
diff options
context:
space:
mode:
authorLeon Arber <larber@ncsa.uiuc.edu>2005-03-09 18:38:36 (GMT)
committerLeon Arber <larber@ncsa.uiuc.edu>2005-03-09 18:38:36 (GMT)
commit15e0a2331ecff452c74758ed44b456f06e528860 (patch)
tree4e3074e1355330f82cd5eb315515f280918edffc /tools/lib/h5diff_util.c
parent0be2fb3aa3ef60a741bd453ad37473a1a1ad4102 (diff)
downloadhdf5-15e0a2331ecff452c74758ed44b456f06e528860.zip
hdf5-15e0a2331ecff452c74758ed44b456f06e528860.tar.gz
hdf5-15e0a2331ecff452c74758ed44b456f06e528860.tar.bz2
[svn-r10170] Purpose:
Bug Fixes Description: Fixes for several bugs, including dumping of excess output to a temporary file, fix for printing hsize_t datatype, and the long awaited fix for intermixed output. Solution: Fix 1: Overflow file Previously, any output that a worker task made was buffered locally in memory, up to a point. Any output beyond the size of the buffer (used to be 10k) was discarded. Now, the memory buffer size has been changed to 1k and any output beyond this amount is sent a temporary file. This way, no output is lost and memory usage is kept under control. The temporary file is deleted as soon as a worker task finishes sending its contents to the manager. Fix 2: hsize_t printing Printing of the hsize_t datatype used to be handled by %Hu passed to HDfprintf. However, there is no corresponding HDvsnprintf that is able to print hsize_t types. These are now printed with the aid of H5_PRINTF_LL_WIDTH. Fix 3: Intermixed output fix Intermixed output would occur on some machines (although I haven't seen it happen for a while) due to the unpredictability of the underlying network and the speed at which various message would travel. This has been fixed by having all output send to the manager for printing. The worker tasks no longer print the output themselves upon receipt of a token, but instead send that data to the manager. Platforms tested: heping, eirene, tg-login (the only place that seems to still experience intermixed output every now and then) Misc. update:
Diffstat (limited to 'tools/lib/h5diff_util.c')
-rw-r--r--tools/lib/h5diff_util.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c
index 96d7b5e..c55028c 100644
--- a/tools/lib/h5diff_util.c
+++ b/tools/lib/h5diff_util.c
@@ -21,6 +21,7 @@ int g_nTasks = 1;
unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */
char outBuff[OUTBUFF_SIZE];
unsigned int outBuffOffset;
+FILE* overflow_file = NULL;
/*-------------------------------------------------------------------------
* Function: parallel_print
@@ -35,21 +36,46 @@ unsigned int outBuffOffset;
*/
void parallel_print(const char* format, ...)
{
+ int bytes_written;
va_list ap;
va_start(ap, format);
if(!g_Parallel)
- vprintf(format, ap);
+ vprintf(format, ap);
else
{
- if((OUTBUFF_SIZE-outBuffOffset) > 0)
- outBuffOffset += HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap);
+
+ if(overflow_file == NULL) /*no overflow has occurred yet */
+ {
+ bytes_written = HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap);
+
+ va_end(ap);
+ va_start(ap, format);
+
+ if(bytes_written >= (OUTBUFF_SIZE-outBuffOffset))
+ {
+ /* Delete the characters that were written to outBuff since they will be written to the overflow_file */
+ memset(outBuff+outBuffOffset, 0, OUTBUFF_SIZE - outBuffOffset);
+
+ overflow_file = tmpfile();
+
+ if(overflow_file == NULL)
+ printf("Warning: Could not create overflow file. Output may be truncated.\n");
+ else
+ bytes_written = HDvfprintf(overflow_file, format, ap);
+ }
+ else
+ outBuffOffset += bytes_written;
+ }
+ else
+ bytes_written = HDvfprintf(overflow_file, format, ap);
+
+
}
va_end(ap);
}
-
/*-------------------------------------------------------------------------
* Function: print_pos
*
@@ -110,7 +136,7 @@ void print_pos( int *ph,
for ( i = 0; i < rank; i++)
{
/* HDfprintf(stdout,"%Hu ", pos[i] ); */
- parallel_print("%d ",(int) pos[i]);
+ parallel_print("%"H5_PRINTF_LL_WIDTH"u ", pos[i]);
}
parallel_print("]" );
}
@@ -377,7 +403,7 @@ get_class(H5T_class_t tclass)
void print_found(hsize_t nfound)
{
if(g_Parallel)
- outBuffOffset += HDsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, "%lld differences found\n", nfound);
+ parallel_print("%"H5_PRINTF_LL_WIDTH"u differences found\n", nfound);
else
HDfprintf(stdout,"%Hu differences found\n",nfound);
}