hdf5/test/chunk.c

522 lines
14 KiB
C
Raw Normal View History

/*
* Copyright (C) 1998 NCSA
* All rights reserved.
*
* Programmer: Robb Matzke <robb@arborea.spizella.com>
* Thursday, May 14, 1998
*
* Purpose: Checks the effect of various I/O request sizes and raw data
* cache sizes. Performance depends on the amount of data read
* from disk and we use a filter to get that number.
*/
[svn-r859] Changes since 19981030 ---------------------- ./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.
1998-11-03 01:58:28 +08:00
/* See H5private.h for how to include headers */
#undef NDEBUG
#include <hdf5.h>
[svn-r859] Changes since 19981030 ---------------------- ./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.
1998-11-03 01:58:28 +08:00
#ifdef H5_STDC_HEADERS
[svn-r859] Changes since 19981030 ---------------------- ./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.
1998-11-03 01:58:28 +08:00
# include <assert.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
#endif
#ifndef HAVE_ATTRIBUTE
# undef __attribute__
# define __attribute__(X) /*void*/
[svn-r1184] Changes since 19990402 ---------------------- ./config/commence.in ./config/conclude.in ./test/Makefile.in ./tools/Makefile.in Fixed so private libraries are not installed publicly. The installation directories `bin', `include', and `lib' are created mode 755. ./src/H5.c ./src/H5A.c ./src/H5F.c ./src/H5Fcore.c ./src/H5Fistore.c ./src/H5Flow.c ./src/H5Fmpio.c ./src/H5Fsec2.c ./src/H5Fstdio.c ./src/H5G.c ./src/H5Gent.c ./src/H5Gnode.c ./src/H5HG.c ./src/H5HL.c ./src/H5O.c ./src/H5Oattr.c ./src/H5Ocomp.c ./src/H5Ocont.c ./src/H5Odtype.c ./src/H5Oefl.c ./src/H5Ofill.c ./src/H5Olayout.c ./src/H5Omtime.c ./src/H5Oname.c ./src/H5Osdspace.c ./src/H5Oshared.c ./src/H5Ostab.c ./src/H5R.c ./src/H5Sall.c ./src/H5Shyper.c ./src/H5Smpio.c ./src/H5Snone.c ./src/H5Spoint.c ./src/H5T.c ./src/H5Tconv.c ./src/H5Vprivate.h ./src/H5Z.c ./src/H5detect.c ./src/H5private.h ./test/chunk.c ./test/dsets.c ./test/dtypes.c ./test/h5test.c ./test/overhead.c ./test/ragged.c ./test/tattr.c ./tools/h5dump.c ./tools/h5findshd.c ./tools/h5ls.c Changed `__unused__' to `UNUSED' to fix a conflict with GNU header files. ./src/H5Tpkg.h ./test/h5test.h Removed __unused__ from forward function declarations. ./src/H5P.c Removed a comment about restrictions for the type conversion temporary buffers. Thanks to Quincey, the comment no longer applied. ./src/H5T.c Relaxed the H5Tpack() a little so it would pack compound data structures that had non-transient atomic members. ./tools/h5ls.c Added a `-g' (or `--group') flag that causes information to be printed about the specified group instead of the group's contents. (sort of like Unix's `ls -d'). The `-g' can be used in combination with `-r' to print information about the group and its contents.
1999-04-16 03:57:50 +08:00
# define UNUSED /*void*/
#else
[svn-r1184] Changes since 19990402 ---------------------- ./config/commence.in ./config/conclude.in ./test/Makefile.in ./tools/Makefile.in Fixed so private libraries are not installed publicly. The installation directories `bin', `include', and `lib' are created mode 755. ./src/H5.c ./src/H5A.c ./src/H5F.c ./src/H5Fcore.c ./src/H5Fistore.c ./src/H5Flow.c ./src/H5Fmpio.c ./src/H5Fsec2.c ./src/H5Fstdio.c ./src/H5G.c ./src/H5Gent.c ./src/H5Gnode.c ./src/H5HG.c ./src/H5HL.c ./src/H5O.c ./src/H5Oattr.c ./src/H5Ocomp.c ./src/H5Ocont.c ./src/H5Odtype.c ./src/H5Oefl.c ./src/H5Ofill.c ./src/H5Olayout.c ./src/H5Omtime.c ./src/H5Oname.c ./src/H5Osdspace.c ./src/H5Oshared.c ./src/H5Ostab.c ./src/H5R.c ./src/H5Sall.c ./src/H5Shyper.c ./src/H5Smpio.c ./src/H5Snone.c ./src/H5Spoint.c ./src/H5T.c ./src/H5Tconv.c ./src/H5Vprivate.h ./src/H5Z.c ./src/H5detect.c ./src/H5private.h ./test/chunk.c ./test/dsets.c ./test/dtypes.c ./test/h5test.c ./test/overhead.c ./test/ragged.c ./test/tattr.c ./tools/h5dump.c ./tools/h5findshd.c ./tools/h5ls.c Changed `__unused__' to `UNUSED' to fix a conflict with GNU header files. ./src/H5Tpkg.h ./test/h5test.h Removed __unused__ from forward function declarations. ./src/H5P.c Removed a comment about restrictions for the type conversion temporary buffers. Thanks to Quincey, the comment no longer applied. ./src/H5T.c Relaxed the H5Tpack() a little so it would pack compound data structures that had non-transient atomic members. ./tools/h5ls.c Added a `-g' (or `--group') flag that causes information to be printed about the specified group instead of the group's contents. (sort of like Unix's `ls -d'). The `-g' can be used in combination with `-r' to print information about the group and its contents.
1999-04-16 03:57:50 +08:00
# define UNUSED __attribute__((unused))
#endif
#define FILE_NAME "chunk.h5"
#define LINESPOINTS "lines"
#define CH_SIZE 100 /*squared in terms of bytes */
#define DS_SIZE 20 /*squared in terms of chunks */
#define FILTER_COUNTER 305
#define READ 0
#define WRITE 1
#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define SQUARE(X) ((X)*(X))
/* The row-major test */
#define RM_CACHE_STRT 25
#define RM_CACHE_END 25
#define RM_CACHE_DELT 5
#define RM_START 0.50
#define RM_END 5.00
#define RM_DELTA 0.50
#define RM_W0 0.0
#define RM_NRDCC 521
/* Diagonal test */
#define DIAG_CACHE_STRT 25
#define DIAG_CACHE_END 25
#define DIAG_CACHE_DELT 5
#define DIAG_START 0.50
#define DIAG_END 5.00
#define DIAG_DELTA 0.50
/* #define DIAG_W0 0.65 */
/* #define DIAG_NRDCC 521 */
static size_t nio_g;
static hid_t fapl_g = -1;
/*-------------------------------------------------------------------------
* Function: counter
*
* Purpose: Count number of bytes but don't do anything.
*
* Return: Success: src_nbytes-1
*
* Failure: never fails
*
* Programmer: Robb Matzke
* Thursday, May 14, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static size_t
[svn-r1184] Changes since 19990402 ---------------------- ./config/commence.in ./config/conclude.in ./test/Makefile.in ./tools/Makefile.in Fixed so private libraries are not installed publicly. The installation directories `bin', `include', and `lib' are created mode 755. ./src/H5.c ./src/H5A.c ./src/H5F.c ./src/H5Fcore.c ./src/H5Fistore.c ./src/H5Flow.c ./src/H5Fmpio.c ./src/H5Fsec2.c ./src/H5Fstdio.c ./src/H5G.c ./src/H5Gent.c ./src/H5Gnode.c ./src/H5HG.c ./src/H5HL.c ./src/H5O.c ./src/H5Oattr.c ./src/H5Ocomp.c ./src/H5Ocont.c ./src/H5Odtype.c ./src/H5Oefl.c ./src/H5Ofill.c ./src/H5Olayout.c ./src/H5Omtime.c ./src/H5Oname.c ./src/H5Osdspace.c ./src/H5Oshared.c ./src/H5Ostab.c ./src/H5R.c ./src/H5Sall.c ./src/H5Shyper.c ./src/H5Smpio.c ./src/H5Snone.c ./src/H5Spoint.c ./src/H5T.c ./src/H5Tconv.c ./src/H5Vprivate.h ./src/H5Z.c ./src/H5detect.c ./src/H5private.h ./test/chunk.c ./test/dsets.c ./test/dtypes.c ./test/h5test.c ./test/overhead.c ./test/ragged.c ./test/tattr.c ./tools/h5dump.c ./tools/h5findshd.c ./tools/h5ls.c Changed `__unused__' to `UNUSED' to fix a conflict with GNU header files. ./src/H5Tpkg.h ./test/h5test.h Removed __unused__ from forward function declarations. ./src/H5P.c Removed a comment about restrictions for the type conversion temporary buffers. Thanks to Quincey, the comment no longer applied. ./src/H5T.c Relaxed the H5Tpack() a little so it would pack compound data structures that had non-transient atomic members. ./tools/h5ls.c Added a `-g' (or `--group') flag that causes information to be printed about the specified group instead of the group's contents. (sort of like Unix's `ls -d'). The `-g' can be used in combination with `-r' to print information about the group and its contents.
1999-04-16 03:57:50 +08:00
counter (unsigned UNUSED flags, size_t UNUSED cd_nelmts,
const unsigned UNUSED *cd_values, size_t nbytes,
size_t UNUSED *buf_size, void UNUSED **buf)
{
nio_g += nbytes;
return nbytes;
}
/*-------------------------------------------------------------------------
* Function: create_dataset
*
* Purpose: Creates a square dataset with square chunks, registers a
* stupid compress/uncompress pair for counting I/O, and
* initializes the dataset. The chunk size is in bytes, the
* dataset size is in terms of chunks.
*
* Return: void
*
* Programmer: Robb Matzke
* Thursday, May 14, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
create_dataset (void)
{
hid_t file, space, dcpl, dset;
hsize_t size[2];
signed char *buf;
/* The file */
file = H5Fcreate (FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_g);
/* The data space */
size[0] = size[1] = DS_SIZE * CH_SIZE;
space = H5Screate_simple (2, size, size);
/* The storage layout and compression */
dcpl = H5Pcreate (H5P_DATASET_CREATE);
size[0] = size[1] = CH_SIZE;
H5Pset_chunk (dcpl, 2, size);
H5Zregister (FILTER_COUNTER, "counter", counter);
H5Pset_filter (dcpl, FILTER_COUNTER, 0, 0, NULL);
/* The dataset */
dset = H5Dcreate (file, "dset", H5T_NATIVE_SCHAR, space, dcpl);
assert (dset>=0);
/* The data */
buf = calloc (1, SQUARE (DS_SIZE*CH_SIZE));
H5Dwrite (dset, H5T_NATIVE_SCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
free (buf);
/* Close */
H5Dclose (dset);
H5Sclose (space);
H5Pclose (dcpl);
H5Fclose (file);
}
/*-------------------------------------------------------------------------
* Function: test_rowmaj
*
* Purpose: Reads the entire dataset using the specified size-squared
* I/O requests in row major order.
*
* Return: Efficiency: data requested divided by data actually read.
*
* Programmer: Robb Matzke
* Thursday, May 14, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static double
test_rowmaj (int op, hsize_t cache_size, hsize_t io_size)
{
hid_t file, dset, mem_space, file_space;
signed char *buf = calloc (1, SQUARE(io_size));
hsize_t i, j, hs_size[2];
hssize_t hs_offset[2];
int mdc_nelmts, rdcc_nelmts;
double w0;
H5Pget_cache (fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0);
#ifdef RM_W0
w0 = RM_W0;
#endif
#ifdef RM_NRDCC
rdcc_nelmts = RM_NRDCC;
#endif
H5Pset_cache (fapl_g, mdc_nelmts, rdcc_nelmts,
cache_size*SQUARE (CH_SIZE), w0);
file = H5Fopen (FILE_NAME, H5F_ACC_RDWR, fapl_g);
dset = H5Dopen (file, "dset");
file_space = H5Dget_space (dset);
nio_g = 0;
for (i=0; i<CH_SIZE*DS_SIZE; i+=io_size) {
#if 0
fprintf (stderr, "%5d\b\b\b\b\b", (int)i);
fflush (stderr);
#endif
for (j=0; j<CH_SIZE*DS_SIZE; j+=io_size) {
hs_offset[0] = i;
hs_size[0] = MIN (io_size, CH_SIZE*DS_SIZE-i);
hs_offset[1] = j;
hs_size[1] = MIN (io_size, CH_SIZE*DS_SIZE-j);
mem_space = H5Screate_simple (2, hs_size, hs_size);
H5Sselect_hyperslab (file_space, H5S_SELECT_SET, hs_offset,
NULL, hs_size, NULL);
if (READ==op) {
H5Dread (dset, H5T_NATIVE_SCHAR, mem_space, file_space,
H5P_DEFAULT, buf);
} else {
H5Dwrite (dset, H5T_NATIVE_SCHAR, mem_space, file_space,
H5P_DEFAULT, buf);
}
H5Sclose (mem_space);
}
}
free (buf);
H5Sclose (file_space);
H5Dclose (dset);
H5Fclose (file);
return (double)SQUARE(CH_SIZE*DS_SIZE)/(double)nio_g;
}
/*-------------------------------------------------------------------------
* Function: test_diag
*
* Purpose: Reads windows diagonally across the dataset. Each window is
* offset from the previous window by OFFSET in the x and y
* directions. The reading ends after the (k,k) value is read
* where k is the maximum index in the dataset.
*
* Return: Efficiency.
*
* Programmer: Robb Matzke
* Friday, May 15, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static double
test_diag (int op, hsize_t cache_size, hsize_t io_size, hsize_t offset)
{
hid_t file, dset, mem_space, file_space;
hsize_t i, hs_size[2];
[svn-r859] Changes since 19981030 ---------------------- ./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.
1998-11-03 01:58:28 +08:00
hsize_t nio = 0;
hssize_t hs_offset[2];
signed char *buf = calloc (1, SQUARE (io_size));
int mdc_nelmts, rdcc_nelmts;
double w0;
H5Pget_cache (fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0);
#ifdef DIAG_W0
w0 = DIAG_W0;
#endif
#ifdef DIAG_NRDCC
rdcc_nelmts = DIAG_NRDCC;
#endif
H5Pset_cache (fapl_g, mdc_nelmts, rdcc_nelmts,
cache_size*SQUARE (CH_SIZE), w0);
file = H5Fopen (FILE_NAME, H5F_ACC_RDWR, fapl_g);
dset = H5Dopen (file, "dset");
file_space = H5Dget_space (dset);
nio_g = 0;
for (i=0, hs_size[0]=io_size; hs_size[0]==io_size; i+=offset) {
hs_offset[0] = hs_offset[1] = i;
hs_size[0] = hs_size[1] = MIN (io_size, CH_SIZE*DS_SIZE-i);
mem_space = H5Screate_simple (2, hs_size, hs_size);
H5Sselect_hyperslab (file_space, H5S_SELECT_SET, hs_offset, NULL,
hs_size, NULL);
if (READ==op) {
H5Dread (dset, H5T_NATIVE_SCHAR, mem_space, file_space,
H5P_DEFAULT, buf);
} else {
H5Dwrite (dset, H5T_NATIVE_SCHAR, mem_space, file_space,
H5P_DEFAULT, buf);
}
H5Sclose (mem_space);
nio += hs_size[0]*hs_size[1];
if (i>0) nio -= SQUARE (io_size-offset);
}
free (buf);
H5Sclose (file_space);
H5Dclose (dset);
H5Fclose (file);
/*
* The extra cast in the following statement is a bug workaround for the
* Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
[svn-r936] Changes since 19981119 ---------------------- ./src/H5.c ./src/H5A.c ./src/H5AC.c ./src/H5B.c ./src/H5D.c ./src/H5E.c ./src/H5F.c ./src/H5Farray.c ./src/H5Fcore.c ./src/H5Ffamily.c ./src/H5Fistore.c ./src/H5Flow.c ./src/H5Fmpio.c ./src/H5Fsec2.c ./src/H5Fsplit.c ./src/H5Fstdio.c ./src/H5G.c ./src/H5Gent.c ./src/H5Gnode.c ./src/H5Gstab.c ./src/H5HG.c ./src/H5HL.c ./src/H5I.c ./src/H5Iprivate.h ./src/H5MF.c ./src/H5MM.c ./src/H5O.c ./src/H5Oattr.c ./src/H5Ocomp.c ./src/H5Ocont.c ./src/H5Odtype.c ./src/H5Oefl.c ./src/H5Ofill.c ./src/H5Olayout.c ./src/H5Omtime.c ./src/H5Oname.c ./src/H5Osdspace.c ./src/H5Oshared.c ./src/H5Ostab.c ./src/H5P.c ./src/H5R.c ./src/H5RA.c ./src/H5S.c ./src/H5Sall.c ./src/H5Shyper.c ./src/H5Smpio.c ./src/H5Snone.c ./src/H5Spoint.c ./src/H5Sselect.c ./src/H5T.c ./src/H5TB.c ./src/H5Tbit.c ./src/H5Tconv.c ./src/H5V.c ./src/H5Z.c ./src/H5detect.c ./src/H5private.h Most of these changes are because the `interface_initialize_g' variable change from hbool_t to int. It's a one line change. Changed the way the library is closed so we have more control over the order the interfaces are shut down. Instead of registering an atexit() function for every interface in some haphazard order we just register one: H5_term_library() which then calls the H5*_term_interface() functions in a well-defined order. If the library is closed and then reopened repeatedly by calling H5close() and H5open() in a loop we only add one copy of the library termination functions with atexit(). Termination is a two-step process in order to help detect programming errors that would cause an infinite loop caused by the termination of one interface waking up some other previously terminated interface. The first step terminates the interface and *marks it as unusable*. After all interfaces are terminated then we mark them all as usable again. The FUNC_ENTER() macro has been modified to return failure or to dump core (depending on whether NDEBUG is defined) if we try to call an interface while it's shutting down. ./src/H5.c The H5dont_atexit() function returns failure if it's called more than once or if it's called too late. However, the error stack is not automatically printed on failure because the library might not be initialized yet ./test/chunk.c ./test/flush1.c ./test/flush2.c ./test/iopipe.c ./test/overhead.c ./test/ragged.c Changed the extra cast for Win32 so we do floating point division again -- it was just confusion about precedence and associativity of casting and the C coercion rules. Removed extra carriage returns inserted by broken operating system. ./src/H5Ffamily.c Fixed an bug where H5F_fam_write() lowered the EOF marker for one of the family members causing H5F_fam_read() to read zeros. ./test/h5test.h [NEW] ./test/h5test.c [NEW] ./test/Makefile.in ./test/bittests.c ./test/cmpd_dset.c ./test/dsets.c ./test/dtypes.c ./test/extend.c ./test/external.c Support library for test files. This isn't done yet but Katie's contractions are ~10 minutes apart so I figured I better back this stuff up just in case I'm not here next week... Eventually all test files will understand HDF5_DRIVER to name the low level file driver and parameters so we can easily test various drivers. They will also understand HDF5_PREFIX to prepend to the beginning of file names which is necessary for testing ROMIO with various drivers. Also, the cleanup function will know how to use the file name prefix and will understand different file driver naming schemes like file families. I'm not sure they'll understand the `gsf:' type prefixes yet. Note, the external test is completely commented out because I'm in the middle of modifying it. It will still compile and run but it doesn't test anything at the moment.
1998-11-21 11:36:51 +08:00
return (double)(hssize_t)nio/(hssize_t)nio_g;
}
/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: See file prologue.
*
* Return: Success:
*
* Failure:
*
* Programmer: Robb Matzke
* Thursday, May 14, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
main (void)
{
hsize_t io_size;
double effic, io_percent;
FILE *f, *d;
int cache_size;
double w0;
/*
* Create a global file access property list.
*/
fapl_g = H5Pcreate (H5P_FILE_ACCESS);
H5Pget_cache (fapl_g, NULL, NULL, NULL, &w0);
/* Create the file */
create_dataset ();
f = fopen ("x-gnuplot", "w");
printf("Test %8s %8s %8s\n", "CacheSz", "ChunkSz", "Effic");
printf("--------- -------- -------- --------\n");
#if 1
/*
* Test row-major reading of the dataset with various sizes of request
* windows.
*/
if (RM_CACHE_STRT==RM_CACHE_END) {
fprintf (f, "set yrange [0:1.2]\n");
fprintf (f, "set ytics 0, 0.1, 1\n");
fprintf (f, "set xlabel \"%s\"\n",
"Request size as a fraction of chunk size");
fprintf (f, "set ylabel \"Efficiency\"\n");
fprintf (f, "set title \"Cache %d chunks, w0=%g, "
"Size=(total=%d, chunk=%d)\"\n",
RM_CACHE_STRT, w0, DS_SIZE*CH_SIZE, CH_SIZE);
} else {
fprintf (f, "set autoscale\n");
fprintf (f, "set hidden3d\n");
}
fprintf (f, "set terminal postscript\nset output \"x-rowmaj-rd.ps\"\n");
fprintf (f, "%s \"x-rowmaj-rd.dat\" title \"RowMaj-Read\" with %s\n",
RM_CACHE_STRT==RM_CACHE_END?"plot":"splot",
LINESPOINTS);
fprintf (f, "set terminal x11\nreplot\n");
d = fopen ("x-rowmaj-rd.dat", "w");
for (cache_size=RM_CACHE_STRT;
cache_size<=RM_CACHE_END;
cache_size+=RM_CACHE_DELT) {
for (io_percent=RM_START; io_percent<=RM_END; io_percent+=RM_DELTA) {
io_size = MAX (1, (int)(CH_SIZE*io_percent));
printf ("Rowmaj-rd %8d %8.2f", cache_size, io_percent);
fflush (stdout);
effic = test_rowmaj (READ, cache_size, io_size);
printf (" %8.2f\n", effic);
if (RM_CACHE_STRT==RM_CACHE_END) {
fprintf (d, "%g %g\n", io_percent, effic);
} else {
fprintf (d, "%g\n", effic);
}
}
fprintf (d, "\n");
}
fclose (d);
fprintf (f, "pause -1\n");
#endif
#if 1
/*
* Test row-major writing of the dataset with various sizes of request
* windows.
*/
if (RM_CACHE_STRT==RM_CACHE_END) {
fprintf (f, "set yrange [0:1.2]\n");
fprintf (f, "set ytics 0, 0.1, 1\n");
fprintf (f, "set xlabel \"%s\"\n",
"Request size as a fraction of chunk size");
fprintf (f, "set ylabel \"Efficiency\"\n");
fprintf (f, "set title \"Cache %d chunks,w0=%g, "
"Size=(total=%d, chunk=%d)\"\n",
RM_CACHE_STRT, w0, DS_SIZE*CH_SIZE, CH_SIZE);
} else {
fprintf (f, "set autoscale\n");
fprintf (f, "set hidden3d\n");
}
fprintf (f, "set terminal postscript\nset output \"x-rowmaj-wr.ps\"\n");
fprintf (f, "%s \"x-rowmaj-wr.dat\" title \"RowMaj-Write\" with %s\n",
RM_CACHE_STRT==RM_CACHE_END?"plot":"splot",
LINESPOINTS);
fprintf (f, "set terminal x11\nreplot\n");
d = fopen ("x-rowmaj-wr.dat", "w");
for (cache_size=RM_CACHE_STRT;
cache_size<=RM_CACHE_END;
cache_size+=RM_CACHE_DELT) {
for (io_percent=RM_START; io_percent<=RM_END; io_percent+=RM_DELTA) {
io_size = MAX (1, (int)(CH_SIZE*io_percent));
printf ("Rowmaj-wr %8d %8.2f", cache_size, io_percent);
fflush (stdout);
effic = test_rowmaj (WRITE, cache_size, io_size);
printf (" %8.2f\n", effic);
if (RM_CACHE_STRT==RM_CACHE_END) {
fprintf (d, "%g %g\n", io_percent, effic);
} else {
fprintf (d, "%g\n", effic);
}
}
fprintf (d, "\n");
}
fclose (d);
fprintf (f, "pause -1\n");
#endif
#if 1
/*
* Test diagonal read
*/
if (DIAG_CACHE_STRT==DIAG_CACHE_END) {
fprintf (f, "set yrange [0:1.2]\n");
fprintf (f, "set ytics 0, 0.1, 1\n");
fprintf (f, "set xlabel \"%s\"\n",
"Request size as a fraction of chunk size");
fprintf (f, "set ylabel \"Efficiency\"\n");
fprintf (f, "set title \"Cache %d chunks,w0=%g, "
"Size=(total=%d, chunk=%d)\"\n",
DIAG_CACHE_STRT, w0, DS_SIZE*CH_SIZE, CH_SIZE);
} else {
fprintf (f, "set autoscale\n");
fprintf (f, "set hidden3d\n");
}
fprintf (f, "set terminal postscript\nset output \"x-diag-rd.ps\"\n");
fprintf (f, "%s \"x-diag-rd.dat\" title \"Diag-Read\" with %s\n",
DIAG_CACHE_STRT==DIAG_CACHE_END?"plot":"splot", LINESPOINTS);
fprintf (f, "set terminal x11\nreplot\n");
d = fopen ("x-diag-rd.dat", "w");
for (cache_size=DIAG_CACHE_STRT;
cache_size<=DIAG_CACHE_END;
cache_size+=DIAG_CACHE_DELT) {
for (io_percent=DIAG_START;
io_percent<=DIAG_END;
io_percent+=DIAG_DELTA) {
io_size = MAX (1, (int)(CH_SIZE*io_percent));
printf ("Diag-rd %8d %8.2f", cache_size, io_percent);
fflush (stdout);
effic = test_diag (READ, cache_size, io_size, MAX (1, io_size/2));
printf (" %8.2f\n", effic);
if (DIAG_CACHE_STRT==DIAG_CACHE_END) {
fprintf (d, "%g %g\n", io_percent, effic);
} else {
fprintf (d, "%g\n", effic);
}
}
fprintf (d, "\n");
}
fclose (d);
fprintf (f, "pause -1\n");
#endif
#if 1
/*
* Test diagonal write
*/
if (DIAG_CACHE_STRT==DIAG_CACHE_END) {
fprintf (f, "set yrange [0:1.2]\n");
fprintf (f, "set ytics 0, 0.1, 1\n");
fprintf (f, "set xlabel \"%s\"\n",
"Request size as a fraction of chunk size");
fprintf (f, "set ylabel \"Efficiency\"\n");
fprintf (f, "set title \"Cache %d chunks, w0=%g, "
"Size=(total=%d, chunk=%d)\"\n",
DIAG_CACHE_STRT, w0, DS_SIZE*CH_SIZE, CH_SIZE);
} else {
fprintf (f, "set autoscale\n");
fprintf (f, "set hidden3d\n");
}
fprintf (f, "set terminal postscript\nset output \"x-diag-wr.ps\"\n");
fprintf (f, "%s \"x-diag-wr.dat\" title \"Diag-Write\" with %s\n",
DIAG_CACHE_STRT==DIAG_CACHE_END?"plot":"splot", LINESPOINTS);
fprintf (f, "set terminal x11\nreplot\n");
d = fopen ("x-diag-wr.dat", "w");
for (cache_size=DIAG_CACHE_STRT;
cache_size<=DIAG_CACHE_END;
cache_size+=DIAG_CACHE_DELT) {
for (io_percent=DIAG_START;
io_percent<=DIAG_END;
io_percent+=DIAG_DELTA) {
io_size = MAX (1, (int)(CH_SIZE*io_percent));
printf ("Diag-wr %8d %8.2f", cache_size, io_percent);
fflush (stdout);
effic = test_diag (WRITE, cache_size, io_size, MAX (1, io_size/2));
printf (" %8.2f\n", effic);
if (DIAG_CACHE_STRT==DIAG_CACHE_END) {
fprintf (d, "%g %g\n", io_percent, effic);
} else {
fprintf (d, "%g\n", effic);
}
}
fprintf (d, "\n");
}
fclose (d);
fprintf (f, "pause -1\n");
#endif
H5Pclose (fapl_g);
fclose (f);
return 0;
}