mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-25 17:00:45 +08:00
---------------------- ./MANIFEST Added new Pablo files HDF5record_RT.h and ProcIDs.h ./acconfig.h ./configure [REGENERATED] ./configure.in ./src/H5.c ./src/H5Vprivate.h ./src/H5config.h.in [REGENERATED] ./src/H5private.h ./src/H5public.h ./test/big.c Added more configuration stuff for the Win32 environment. Removed all the #ifdef WIN32 from the source and replaced them with OS-independent stuff. Specifics follow: Check for non-Posix.1 `st_blocks' field in `struct stat' which is used by the big file test to decide if the file system supports holes. If the st_blocks field isn't present then we just skip the test. Configure checks for <io.h> <sys/resource.h> <sys/time.h> and <winsock.h> and defines HAVE_IO_H, HAVE_SYS_RESOURCE_H, HAVE_SYS_TIME_H and HAVE_WINSOCK_H when they're found. Configure checks whether both <sys/time.h> and <time.h> can be included and defines SYS_TIME_WITH_TIME if so. Otherwise include only <sys/time.h> or <time.h> even if both exist. Configure checks sizeof(__int64) and defines SIZEOF___INT64 to the result or to zero if __int64 isn't defined. The source uses `long long' in preference to `__int64'. Removed null WIN32 definition for `inline' since such a definition already exists in H5config.h Protected gettimeofday() calls in debugging code with HAVE_GETTIMEOFDAY instead of WIN32. ./src/H5F.c ./src/H5Flow.c ./src/H5Fmpio.c ./src/H5Fsec2.c ./src/H5Fstdio.h ./src/H5P.c ./src/H5Tconv.c ./src/H5private.h Removed #include of system files from library source files and consolodated them into H5private.h where they're protected by various configuration macros (most of them were duplicated there already anyway). ./test/big.c ./test/chunk.c ./test/cmpd_dset.c ./test/dsets.c ./test/dtypes.c ./test/extend.c ./test/external.c ./test/fillval.c ./test/flush1.c ./test/flush2.c ./test/iopipe.c ./test/links.c ./test/mount.c ./test/mtime.c ./test/overhead.c ./test/ragged.c ./test/shtype.c ./test/unlink.c Protected system #include's with #ifdef's from H5config.h. Undefined NDEBUG since some of the tests rely on assert() to check return values. Removed WIN32 definitions for __unused__ since this can be controlled by the definition of HAVE_ATTRIBUTE in H5config.h ./test/testhdf5.h Removed the CLEAN_CMD definition because we no longer use it. Albert's cleanup() functions replaced it. ./test/fillval.c Initialized auto hid_t variables to fix warnings in error recovery code when data flow analysis is turned on in compilers. ./test/h5tools.c Initialized an auto variable to fix a compiler warning. ./test/chunk.c ./test/ragged.c The WIN32 had some unsigned variables changed to signed because the compiler generates warnings when coercing unsigned to double(?). I changed them back to unsigned because they really are unsigned quantities. If this the change was just to shut up extraneous warnings then perhaps a compiler flag can do the same; otherwise if the compiler generates bad code then we should supply a patch file instead messing up source code with bug work-arounds. ./src/H5detect.c Protected system #include's with #ifdef's from H5config.h thereby removing a WIN32. If getpwuid() doesn't exist (HAVE_GETPWUID) then we assume that `struct passwd' doesn't exist either (we don't really need it in that case). The H5T_NATIVE_LLONG and H5T_NATIVE_ULLONG are defined in terms of `long long' or else `__int64' or else `long' depending on what's available. ./src/H5Flow.c ./src/H5Ofill.c Added __unused__ to some function arguments that aren't used when assertions are turned off. ./src/H5V.c Changed an auto variable name in some hand-inlined code to get rid of a warning about the variable shadowing a previous auto.
412 lines
9.8 KiB
C
412 lines
9.8 KiB
C
/*
|
||
* Copyright (C) 1998 NCSA
|
||
* All rights reserved.
|
||
*
|
||
* Programmer: Robb Matzke <matzke@llnl.gov>
|
||
* Thursday, March 12, 1998
|
||
*/
|
||
|
||
/* See H5private.h for how to include headers */
|
||
#undef NDEBUG
|
||
#include <H5config.h>
|
||
|
||
#ifdef STDC_HEADERS
|
||
# include <assert.h>
|
||
# include <fcntl.h>
|
||
# include <stdio.h>
|
||
# include <string.h>
|
||
# include <stdlib.h>
|
||
#endif
|
||
|
||
#ifdef HAVE_UNISTD_H
|
||
# include <sys/types.h>
|
||
# include <unistd.h>
|
||
#endif
|
||
|
||
#if defined(TIME_WITH_SYS_TIME)
|
||
# include <sys/time.h>
|
||
# include <time.h>
|
||
#elif defined(HAVE_SYS_TIME_H)
|
||
# include <sys/time.h>
|
||
#else
|
||
# include <time.h>
|
||
#endif
|
||
|
||
#ifdef HAVE_SYS_RESOURCE_H
|
||
# include <sys/resource.h>
|
||
#endif
|
||
|
||
#ifdef HAVE_WINSOCK_H
|
||
#include <Winsock.h>
|
||
#endif
|
||
|
||
#include <hdf5.h>
|
||
|
||
#define RAW_FILE_NAME "iopipe.raw"
|
||
#define HDF5_FILE_NAME "iopipe.h5"
|
||
#define HEADING "%-16s"
|
||
#define PROGRESS '='
|
||
|
||
#if 0
|
||
/* Normal testing */
|
||
#define REQUEST_SIZE_X 4579
|
||
#define REQUEST_SIZE_Y 4579
|
||
#define NREAD_REQUESTS 45
|
||
#define NWRITE_REQUESTS 45
|
||
#else
|
||
/* Speedy testing */
|
||
#define REQUEST_SIZE_X 1000
|
||
#define REQUEST_SIZE_Y 1000
|
||
#define NREAD_REQUESTS 45
|
||
#define NWRITE_REQUESTS 45
|
||
#endif
|
||
|
||
|
||
/*-------------------------------------------------------------------------
|
||
* Function: print_stats
|
||
*
|
||
* Purpose: Prints statistics
|
||
*
|
||
* Return: void
|
||
*
|
||
* Programmer: Robb Matzke
|
||
* Thursday, March 12, 1998
|
||
*
|
||
* Modifications:
|
||
*
|
||
*-------------------------------------------------------------------------
|
||
*/
|
||
static void
|
||
print_stats (const char *prefix,
|
||
struct rusage *r_start, struct rusage *r_stop,
|
||
struct timeval *t_start, struct timeval *t_stop,
|
||
size_t nbytes)
|
||
{
|
||
double e_time, bw;
|
||
#ifdef HAVE_GETRUSAGE
|
||
double u_time, s_time;
|
||
|
||
u_time = ((double)(r_stop->ru_utime.tv_sec)+
|
||
(double)(r_stop->ru_utime.tv_usec)/1000000.0) -
|
||
((double)(r_start->ru_utime.tv_sec)+
|
||
(double)(r_start->ru_utime.tv_usec)/1000000.0);
|
||
|
||
s_time = ((double)(r_stop->ru_stime.tv_sec)+
|
||
(double)(r_stop->ru_stime.tv_usec)/1000000.0) -
|
||
((double)(r_start->ru_stime.tv_sec)+
|
||
(double)(r_start->ru_stime.tv_usec)/1000000.0);
|
||
#endif
|
||
|
||
e_time = ((double)(t_stop->tv_sec)+
|
||
(double)(t_stop->tv_usec)/1000000.0) -
|
||
((double)(t_start->tv_sec)+
|
||
(double)(t_start->tv_usec)/1000000.0);
|
||
|
||
bw = (double)nbytes / e_time;
|
||
|
||
#ifdef HAVE_GETRUSAGE
|
||
printf (HEADING "%1.2fuser %1.2fsystem %1.2felapsed %1.2fMB/s\n",
|
||
prefix, u_time, s_time, e_time, bw/(1024*1024));
|
||
#else
|
||
printf (HEADING "%1.2felapsed %1.2fMB/s\n",
|
||
prefix, e_time, bw/(1024*1024));
|
||
#endif
|
||
|
||
}
|
||
|
||
|
||
/*-------------------------------------------------------------------------
|
||
* Function: synchronize
|
||
*
|
||
* Purpose:
|
||
*
|
||
* Return: void
|
||
*
|
||
* Programmer: Robb Matzke
|
||
* Thursday, March 12, 1998
|
||
*
|
||
* Modifications:
|
||
*
|
||
*-------------------------------------------------------------------------
|
||
*/
|
||
static void
|
||
synchronize (void)
|
||
{
|
||
#ifdef HAVE_SYSTEM
|
||
system ("sync");
|
||
system ("df >/dev/null");
|
||
#if 0
|
||
/*
|
||
* This works well on Linux to get rid of all cached disk buffers. The
|
||
* number should be approximately the amount of RAM in MB. Do not
|
||
* include swap space in that amount or the command will fail.
|
||
*/
|
||
system ("/sbin/swapout 128");
|
||
#endif
|
||
#endif
|
||
}
|
||
|
||
|
||
/*-------------------------------------------------------------------------
|
||
* Function: main
|
||
*
|
||
* Purpose:
|
||
*
|
||
* Return: Success:
|
||
*
|
||
* Failure:
|
||
*
|
||
* Programmer: Robb Matzke
|
||
* Thursday, March 12, 1998
|
||
*
|
||
* Modifications:
|
||
*
|
||
*-------------------------------------------------------------------------
|
||
*/
|
||
int
|
||
main (void)
|
||
{
|
||
static hsize_t size[2] = {REQUEST_SIZE_X, REQUEST_SIZE_Y};
|
||
static int nread=NREAD_REQUESTS, nwrite=NWRITE_REQUESTS;
|
||
|
||
unsigned char *the_data = NULL;
|
||
hid_t file, dset, file_space=-1;
|
||
herr_t status;
|
||
#ifdef HAVE_GETRUSAGE
|
||
struct rusage r_start, r_stop;
|
||
#else
|
||
struct timeval r_start, r_stop;
|
||
#endif
|
||
struct timeval t_start, t_stop;
|
||
int i, fd;
|
||
hssize_t n;
|
||
off_t offset;
|
||
hssize_t start[2];
|
||
hsize_t count[2];
|
||
|
||
printf ("I/O request size is %1.1fMB\n",
|
||
((double)(size[0])*(double)(size[1]))/(1024.0*1024));
|
||
|
||
|
||
/* Open the files */
|
||
file = H5Fcreate (HDF5_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
||
assert (file>=0);
|
||
fd = open (RAW_FILE_NAME, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
||
assert (fd>=0);
|
||
|
||
/* Create the dataset */
|
||
file_space = H5Screate_simple (2, size, size);
|
||
assert (file_space>=0);
|
||
dset = H5Dcreate (file, "dset", H5T_NATIVE_UCHAR, file_space, H5P_DEFAULT);
|
||
assert (dset>=0);
|
||
the_data = malloc ((size_t)(size[0]*size[1]));
|
||
/*initial fill for lazy malloc*/
|
||
memset (the_data, 0xAA, (size_t)(size[0]*size[1]));
|
||
|
||
/* Fill raw */
|
||
synchronize ();
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_start);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_start, NULL);
|
||
#endif
|
||
fprintf (stderr, HEADING, "fill raw");
|
||
for (i=0; i<nwrite; i++) {
|
||
putc (PROGRESS, stderr);
|
||
fflush (stderr);
|
||
memset (the_data, 0xAA, (size_t)(size[0]*size[1]));
|
||
}
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_stop);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_stop, NULL);
|
||
#endif
|
||
putc ('\n', stderr);
|
||
print_stats ("fill raw",
|
||
&r_start, &r_stop, &t_start, &t_stop,
|
||
(size_t)(nread*size[0]*size[1]));
|
||
|
||
|
||
/* Fill hdf5 */
|
||
synchronize ();
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_start);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_start, NULL);
|
||
#endif
|
||
fprintf (stderr, HEADING, "fill hdf5");
|
||
for (i=0; i<nread; i++) {
|
||
putc (PROGRESS, stderr);
|
||
fflush (stderr);
|
||
status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space,
|
||
H5P_DEFAULT, the_data);
|
||
assert (status>=0);
|
||
}
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_stop);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_stop, NULL);
|
||
#endif
|
||
putc ('\n', stderr);
|
||
print_stats ("fill hdf5",
|
||
&r_start, &r_stop, &t_start, &t_stop,
|
||
(size_t)(nread*size[0]*size[1]));
|
||
|
||
/* Write the raw dataset */
|
||
synchronize ();
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_start);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_start, NULL);
|
||
#endif
|
||
fprintf (stderr, HEADING, "out raw");
|
||
for (i=0; i<nwrite; i++) {
|
||
putc (PROGRESS, stderr);
|
||
fflush (stderr);
|
||
offset = lseek (fd, 0, SEEK_SET);
|
||
assert (0==offset);
|
||
n = write (fd, the_data, (size_t)(size[0]*size[1]));
|
||
assert (n>=0 && (size_t)n==size[0]*size[1]);
|
||
}
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_stop);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_stop, NULL);
|
||
#endif
|
||
putc ('\n', stderr);
|
||
print_stats ("out raw",
|
||
&r_start, &r_stop, &t_start, &t_stop,
|
||
(size_t)(nread*size[0]*size[1]));
|
||
|
||
/* Write the hdf5 dataset */
|
||
synchronize ();
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_start);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_start, NULL);
|
||
#endif
|
||
fprintf (stderr, HEADING, "out hdf5");
|
||
for (i=0; i<nwrite; i++) {
|
||
putc (PROGRESS, stderr);
|
||
fflush (stderr);
|
||
status = H5Dwrite (dset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL,
|
||
H5P_DEFAULT, the_data);
|
||
assert (status>=0);
|
||
}
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_stop);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_stop, NULL);
|
||
#endif
|
||
putc ('\n', stderr);
|
||
print_stats ("out hdf5",
|
||
&r_start, &r_stop, &t_start, &t_stop,
|
||
(size_t)(nread*size[0]*size[1]));
|
||
|
||
/* Read the raw dataset */
|
||
synchronize ();
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_start);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_start, NULL);
|
||
#endif
|
||
fprintf (stderr, HEADING, "in raw");
|
||
for (i=0; i<nread; i++) {
|
||
putc (PROGRESS, stderr);
|
||
fflush (stderr);
|
||
offset = lseek (fd, 0, SEEK_SET);
|
||
assert (0==offset);
|
||
n = read (fd, the_data, (size_t)(size[0]*size[1]));
|
||
assert (n>=0 && (size_t)n==size[0]*size[1]);
|
||
}
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_stop);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_stop, NULL);
|
||
#endif
|
||
putc ('\n', stderr);
|
||
print_stats ("in raw",
|
||
&r_start, &r_stop, &t_start, &t_stop,
|
||
(size_t)(nread*size[0]*size[1]));
|
||
|
||
|
||
/* Read the hdf5 dataset */
|
||
synchronize ();
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_start);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_start, NULL);
|
||
#endif
|
||
fprintf (stderr, HEADING, "in hdf5");
|
||
for (i=0; i<nread; i++) {
|
||
putc (PROGRESS, stderr);
|
||
fflush (stderr);
|
||
status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space,
|
||
H5P_DEFAULT, the_data);
|
||
assert (status>=0);
|
||
}
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_stop);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_stop, NULL);
|
||
#endif
|
||
putc ('\n', stderr);
|
||
print_stats ("in hdf5",
|
||
&r_start, &r_stop, &t_start, &t_stop,
|
||
(size_t)(nread*size[0]*size[1]));
|
||
|
||
/* Read hyperslab */
|
||
assert (size[0]>20 && size[1]>20);
|
||
start[0] = start[1] = 10;
|
||
count[0] = count[1] = size[0]-20;
|
||
status = H5Sselect_hyperslab (file_space, H5S_SELECT_SET, start, NULL, count, NULL);
|
||
assert (status>=0);
|
||
synchronize ();
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_start);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_start, NULL);
|
||
#endif
|
||
fprintf (stderr, HEADING, "in hdf5 partial");
|
||
for (i=0; i<nread; i++) {
|
||
putc (PROGRESS, stderr);
|
||
fflush (stderr);
|
||
status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space,
|
||
H5P_DEFAULT, the_data);
|
||
assert (status>=0);
|
||
}
|
||
#ifdef HAVE_GETRUSAGE
|
||
getrusage (RUSAGE_SELF, &r_stop);
|
||
#endif
|
||
#ifdef HAVE_GETTIMEOFDAY
|
||
gettimeofday (&t_stop, NULL);
|
||
#endif
|
||
putc ('\n', stderr);
|
||
print_stats ("in hdf5 partial",
|
||
&r_start, &r_stop, &t_start, &t_stop,
|
||
(size_t)(nread*count[0]*count[1]));
|
||
|
||
|
||
|
||
/* Close everything */
|
||
close (fd);
|
||
H5Dclose (dset);
|
||
H5Sclose (file_space);
|
||
H5Fclose (file);
|
||
|
||
return 0;
|
||
}
|