diff options
Diffstat (limited to 'tools/perform/iopipe.c')
-rw-r--r-- | tools/perform/iopipe.c | 359 |
1 files changed, 159 insertions, 200 deletions
diff --git a/tools/perform/iopipe.c b/tools/perform/iopipe.c index b98adc4..81e1a38 100644 --- a/tools/perform/iopipe.c +++ b/tools/perform/iopipe.c @@ -25,27 +25,25 @@ #include <sys/timeb.h> #endif - #define RAW_FILE_NAME "iopipe.raw" -#define HDF5_FILE_NAME "iopipe.h5" -#define HEADING "%-16s" -#define PROGRESS '=' +#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 +#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 +#define NWRITE_REQUESTS 45 #endif - /*------------------------------------------------------------------------- * Function: print_stats * @@ -62,56 +60,41 @@ */ #ifdef H5_HAVE_GETRUSAGE 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) -#else /* H5_HAVE_GETRUSAGE */ +print_stats(const char *prefix, struct rusage *r_start, struct rusage *r_stop, struct timeval *t_start, + struct timeval *t_stop, size_t nbytes) +#else /* H5_HAVE_GETRUSAGE */ static void -print_stats (const char *prefix, - struct timeval *r_start, struct timeval *r_stop, - struct timeval *t_start, struct timeval *t_stop, - size_t nbytes) +print_stats(const char *prefix, struct timeval *r_start, struct timeval *r_stop, struct timeval *t_start, + struct timeval *t_stop, size_t nbytes) #endif /* H5_HAVE_GETRUSAGE */ { - double e_time, bw; + double e_time, bw; #ifdef H5_HAVE_GETRUSAGE - double u_time, s_time; + double u_time, s_time; - u_time = ((double)(r_stop->ru_utime.tv_sec)+ - (double)(r_stop->ru_utime.tv_usec)/(double)1000000.0F) - - ((double)(r_start->ru_utime.tv_sec)+ - (double)(r_start->ru_utime.tv_usec)/(double)1000000.0F); + u_time = ((double)(r_stop->ru_utime.tv_sec) + (double)(r_stop->ru_utime.tv_usec) / (double)1000000.0F) - + ((double)(r_start->ru_utime.tv_sec) + (double)(r_start->ru_utime.tv_usec) / (double)1000000.0F); - s_time = ((double)(r_stop->ru_stime.tv_sec)+ - (double)(r_stop->ru_stime.tv_usec)/(double)1000000.0F) - - ((double)(r_start->ru_stime.tv_sec)+ - (double)(r_start->ru_stime.tv_usec)/(double)1000000.0F); + s_time = ((double)(r_stop->ru_stime.tv_sec) + (double)(r_stop->ru_stime.tv_usec) / (double)1000000.0F) - + ((double)(r_start->ru_stime.tv_sec) + (double)(r_start->ru_stime.tv_usec) / (double)1000000.0F); #endif #ifndef H5_HAVE_SYS_TIMEB - e_time = ((double)(t_stop->tv_sec)+ - (double)(t_stop->tv_usec)/(double)1000000.0F) - - ((double)(t_start->tv_sec)+ - (double)(t_start->tv_usec)/(double)1000000.0F); + e_time = ((double)(t_stop->tv_sec) + (double)(t_stop->tv_usec) / (double)1000000.0F) - + ((double)(t_start->tv_sec) + (double)(t_start->tv_usec) / (double)1000000.0F); #else - e_time = ((double)(t_stop->tv_sec)+ - (double)(t_stop->tv_usec)/(double)1000.0F) - - ((double)(t_start->tv_sec)+ - (double)(t_start->tv_usec)/(double)1000.0F); + e_time = ((double)(t_stop->tv_sec) + (double)(t_stop->tv_usec) / (double)1000.0F) - + ((double)(t_start->tv_sec) + (double)(t_start->tv_usec) / (double)1000.0F); #endif bw = (double)nbytes / e_time; #ifdef H5_HAVE_GETRUSAGE - printf (HEADING "%1.2fuser %1.2fsystem %1.2felapsed %1.2fMB/s\n", - prefix, u_time, s_time, e_time, bw/(1024*1024)); + 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)); + printf(HEADING "%1.2felapsed %1.2fMB/s\n", prefix, e_time, bw / (1024 * 1024)); #endif - } - /*------------------------------------------------------------------------- * Function: synchronize * @@ -127,10 +110,10 @@ print_stats (const char *prefix, *------------------------------------------------------------------------- */ static void -synchronize (void) +synchronize(void) { #ifdef H5_HAVE_SYSTEM -#if defined(H5_HAVE_WIN32_API) && ! defined(__CYGWIN__) +#if defined(H5_HAVE_WIN32_API) && !defined(__CYGWIN__) _flushall(); #else int status; @@ -144,7 +127,6 @@ synchronize (void) #endif } - /*------------------------------------------------------------------------- * Function: main * @@ -162,48 +144,47 @@ synchronize (void) *------------------------------------------------------------------------- */ int -main (void) +main(void) { static hsize_t size[2] = {REQUEST_SIZE_X, REQUEST_SIZE_Y}; - static unsigned nread = NREAD_REQUESTS, nwrite = NWRITE_REQUESTS; + static unsigned nread = NREAD_REQUESTS, nwrite = NWRITE_REQUESTS; - unsigned char *the_data = NULL; - hid_t file, dset, file_space = H5I_INVALID_HID; - herr_t status; + unsigned char *the_data = NULL; + hid_t file, dset, file_space = H5I_INVALID_HID; + herr_t status; #ifdef H5_HAVE_GETRUSAGE - struct rusage r_start, r_stop; + struct rusage r_start, r_stop; #else struct timeval r_start, r_stop; #endif - struct timeval t_start, t_stop; - int fd; - unsigned u; - hssize_t n; - off_t offset; - hsize_t start[2]; - hsize_t count[2]; - + struct timeval t_start, t_stop; + int fd; + unsigned u; + hssize_t n; + off_t offset; + hsize_t start[2]; + hsize_t count[2]; #ifdef H5_HAVE_SYS_TIMEB - struct _timeb *tbstart = malloc(sizeof(struct _timeb)); - struct _timeb *tbstop = malloc(sizeof(struct _timeb)); + struct _timeb *tbstart = malloc(sizeof(struct _timeb)); + struct _timeb *tbstop = malloc(sizeof(struct _timeb)); #endif /* * The extra cast in the following statement is a bug workaround for the * Win32 version 5.0 compiler. * 1998-11-06 ptl */ - printf ("I/O request size is %1.1fMB\n", - (double)(hssize_t)(size[0]*size[1])/(double)1024.0F*(double)1024); + printf("I/O request size is %1.1fMB\n", + (double)(hssize_t)(size[0] * size[1]) / (double)1024.0F * (double)1024); /* Open the files */ - file = H5Fcreate (HDF5_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert (file>=0); - fd = HDopen (RAW_FILE_NAME, O_RDWR|O_CREAT|O_TRUNC, 0666); - HDassert (fd>=0); + file = H5Fcreate(HDF5_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(file >= 0); + fd = HDopen(RAW_FILE_NAME, O_RDWR | O_CREAT | O_TRUNC, 0666); + HDassert(fd >= 0); /* Create the dataset */ - file_space = H5Screate_simple (2, size, size); + file_space = H5Screate_simple(2, size, size); HDassert(file_space >= 0); dset = H5Dcreate2(file, "dset", H5T_NATIVE_UCHAR, file_space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); HDassert(dset >= 0); @@ -213,7 +194,7 @@ main (void) HDmemset(the_data, 0xAA, (size_t)(size[0] * size[1])); /* Fill raw */ - synchronize (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif @@ -221,14 +202,14 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif - HDfprintf (stderr, HEADING, "fill raw"); - for(u = 0; u < nwrite; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - HDmemset(the_data, 0xAA, (size_t)(size[0]*size[1])); + HDfprintf(stderr, HEADING, "fill raw"); + for (u = 0; u < nwrite; u++) { + putc(PROGRESS, stderr); + HDfflush(stderr); + HDmemset(the_data, 0xAA, (size_t)(size[0] * size[1])); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -237,21 +218,18 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif - putc ('\n', stderr); - print_stats ("fill raw", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); - + 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 (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif @@ -259,16 +237,15 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif - HDfprintf (stderr, HEADING, "fill hdf5"); - for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - HDassert (status>=0); + HDfprintf(stderr, HEADING, "fill hdf5"); + for (u = 0; u < nread; u++) { + putc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -277,20 +254,18 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif - putc ('\n', stderr); - print_stats ("fill hdf5", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + 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 (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif @@ -298,17 +273,17 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif - HDfprintf (stderr, HEADING, "out raw"); - for(u = 0; u < nwrite; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - offset = HDlseek (fd, (off_t)0, SEEK_SET); - HDassert (0==offset); - n = HDwrite (fd, the_data, (size_t)(size[0]*size[1])); - HDassert (n>=0 && (size_t)n==size[0]*size[1]); + HDfprintf(stderr, HEADING, "out raw"); + for (u = 0; u < nwrite; u++) { + putc(PROGRESS, stderr); + HDfflush(stderr); + offset = HDlseek(fd, (off_t)0, SEEK_SET); + HDassert(0 == offset); + n = HDwrite(fd, the_data, (size_t)(size[0] * size[1])); + HDassert(n >= 0 && (size_t)n == size[0] * size[1]); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -317,20 +292,18 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif - putc ('\n', stderr); - print_stats ("out raw", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + 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 (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif @@ -338,16 +311,15 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif - HDfprintf (stderr, HEADING, "out hdf5"); - for(u = 0; u < nwrite; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dwrite (dset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, - H5P_DEFAULT, the_data); - HDassert (status>=0); + HDfprintf(stderr, HEADING, "out hdf5"); + for (u = 0; u < nwrite; u++) { + putc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dwrite(dset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -356,20 +328,18 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif - putc ('\n', stderr); - print_stats ("out hdf5", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + 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 (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif @@ -377,17 +347,17 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif - HDfprintf (stderr, HEADING, "in raw"); - for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - offset = HDlseek (fd, (off_t)0, SEEK_SET); - HDassert (0==offset); - n = HDread (fd, the_data, (size_t)(size[0]*size[1])); - HDassert (n>=0 && (size_t)n==size[0]*size[1]); + HDfprintf(stderr, HEADING, "in raw"); + for (u = 0; u < nread; u++) { + putc(PROGRESS, stderr); + HDfflush(stderr); + offset = HDlseek(fd, (off_t)0, SEEK_SET); + HDassert(0 == offset); + n = HDread(fd, the_data, (size_t)(size[0] * size[1])); + HDassert(n >= 0 && (size_t)n == size[0] * size[1]); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -396,21 +366,18 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif - putc ('\n', stderr); - print_stats ("in raw", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); - + 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 (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif @@ -418,16 +385,15 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif - HDfprintf (stderr, HEADING, "in hdf5"); - for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - HDassert (status>=0); + HDfprintf(stderr, HEADING, "in hdf5"); + for (u = 0; u < nread; u++) { + putc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -436,25 +402,23 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif - putc ('\n', stderr); - print_stats ("in hdf5", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + putc('\n', stderr); + print_stats("in hdf5", &r_start, &r_stop, &t_start, &t_stop, (size_t)(nread * size[0] * size[1])); /* Read hyperslab */ - HDassert (size[0]>20 && size[1]>20); + HDassert(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); - HDassert (status>=0); - synchronize (); + count[0] = count[1] = size[0] - 20; + status = H5Sselect_hyperslab(file_space, H5S_SELECT_SET, start, NULL, count, NULL); + HDassert(status >= 0); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif @@ -462,16 +426,15 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif - HDfprintf (stderr, HEADING, "in hdf5 partial"); - for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - HDassert (status>=0); + HDfprintf(stderr, HEADING, "in hdf5 partial"); + for (u = 0; u < nread; u++) { + putc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -480,19 +443,16 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif putc('\n', stderr); - print_stats("in hdf5 partial", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*count[0]*count[1])); - - + print_stats("in hdf5 partial", &r_start, &r_stop, &t_start, &t_stop, + (size_t)(nread * count[0] * count[1])); /* Close everything */ HDclose(fd); @@ -503,4 +463,3 @@ main (void) return 0; } - |