diff options
Diffstat (limited to 'tools/test/perform')
-rw-r--r-- | tools/test/perform/chunk.c | 578 | ||||
-rw-r--r-- | tools/test/perform/chunk_cache.c | 313 | ||||
-rw-r--r-- | tools/test/perform/direct_write_perf.c | 430 | ||||
-rw-r--r-- | tools/test/perform/iopipe.c | 188 | ||||
-rw-r--r-- | tools/test/perform/overhead.c | 306 | ||||
-rw-r--r-- | tools/test/perform/perf.c | 391 | ||||
-rw-r--r-- | tools/test/perform/perf_meta.c | 618 | ||||
-rw-r--r-- | tools/test/perform/pio_engine.c | 3628 | ||||
-rw-r--r-- | tools/test/perform/pio_perf.c | 1079 | ||||
-rw-r--r-- | tools/test/perform/pio_perf.h | 86 | ||||
-rw-r--r-- | tools/test/perform/pio_standalone.c | 114 | ||||
-rw-r--r-- | tools/test/perform/pio_standalone.h | 676 | ||||
-rw-r--r-- | tools/test/perform/sio_engine.c | 1166 | ||||
-rw-r--r-- | tools/test/perform/sio_perf.c | 1038 | ||||
-rw-r--r-- | tools/test/perform/sio_perf.h | 74 | ||||
-rw-r--r-- | tools/test/perform/sio_standalone.c | 63 | ||||
-rw-r--r-- | tools/test/perform/sio_standalone.h | 696 | ||||
-rw-r--r-- | tools/test/perform/zip_perf.c | 342 |
18 files changed, 5887 insertions, 5899 deletions
diff --git a/tools/test/perform/chunk.c b/tools/test/perform/chunk.c index bd16e1d..9f99ce9 100644 --- a/tools/test/perform/chunk.c +++ b/tools/test/perform/chunk.c @@ -25,73 +25,70 @@ #include "hdf5.h" #ifdef H5_STDC_HEADERS -# include <assert.h> -# include <stdio.h> -# include <stdlib.h> -# include <string.h> +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #endif /* Solaris Studio defines attribute, but for the attributes we need */ #if !defined(H5_HAVE_ATTRIBUTE) || defined __cplusplus || defined(__SUNPRO_C) -# undef __attribute__ -# define __attribute__(X) /*void*/ -# define H5_ATTR_UNUSED /*void*/ +#undef __attribute__ +#define __attribute__(X) /*void*/ +#define H5_ATTR_UNUSED /*void*/ #else -# define H5_ATTR_UNUSED __attribute__((unused)) +#define H5_ATTR_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)) +#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 (double)0.50F -#define RM_END (double)5.00F -#define RM_DELTA (double)0.50F -#define RM_W0 0.0F -#define RM_NRDCC 521 +#define RM_CACHE_STRT 25 +#define RM_CACHE_END 25 +#define RM_CACHE_DELT 5 +#define RM_START (double)0.50F +#define RM_END (double)5.00F +#define RM_DELTA (double)0.50F +#define RM_W0 0.0F +#define RM_NRDCC 521 /* Diagonal test */ -#define DIAG_CACHE_STRT 25 -#define DIAG_CACHE_END 25 -#define DIAG_CACHE_DELT 5 -#define DIAG_START (double)0.50F -#define DIAG_END (double)5.00F -#define DIAG_DELTA (double)0.50F +#define DIAG_CACHE_STRT 25 +#define DIAG_CACHE_END 25 +#define DIAG_CACHE_DELT 5 +#define DIAG_START (double)0.50F +#define DIAG_END (double)5.00F +#define DIAG_DELTA (double)0.50F /* #define DIAG_W0 0.65F */ /* #define DIAG_NRDCC 521 */ -static size_t nio_g; -static hid_t fapl_g = H5I_INVALID_HID; +static size_t nio_g; +static hid_t fapl_g = H5I_INVALID_HID; /* Local function prototypes */ -static size_t -counter (unsigned H5_ATTR_UNUSED flags, size_t cd_nelmts, - const unsigned *cd_values, size_t nbytes, - size_t *buf_size, void **buf); +static size_t counter(unsigned H5_ATTR_UNUSED flags, size_t cd_nelmts, const unsigned *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_COUNTER[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - FILTER_COUNTER, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "counter", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - counter, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER_COUNTER, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "counter", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + counter, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: counter * @@ -109,15 +106,14 @@ const H5Z_class2_t H5Z_COUNTER[1] = {{ *------------------------------------------------------------------------- */ static size_t -counter (unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) +counter(unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, + const unsigned H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, + void H5_ATTR_UNUSED **buf) { nio_g += nbytes; return nbytes; } - /*------------------------------------------------------------------------- * Function: create_dataset * @@ -136,21 +132,21 @@ counter (unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, *------------------------------------------------------------------------- */ static void -create_dataset (void) +create_dataset(void) { - hid_t file, space, dcpl, dset; - hsize_t size[2]; - signed char *buf; + 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); + 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); + space = H5Screate_simple(2, size, size); /* The storage layout and compression */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); size[0] = size[1] = CH_SIZE; H5Pset_chunk(dcpl, 2, size); H5Zregister(H5Z_COUNTER); @@ -158,10 +154,10 @@ create_dataset (void) /* The dataset */ dset = H5Dcreate2(file, "dset", H5T_NATIVE_SCHAR, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - assert(dset>=0); + assert(dset >= 0); /* The data */ - buf = (signed char *)calloc(1, SQUARE (DS_SIZE*CH_SIZE)); + buf = (signed char *)calloc(1, SQUARE(DS_SIZE * CH_SIZE)); H5Dwrite(dset, H5T_NATIVE_SCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); free(buf); @@ -172,7 +168,6 @@ create_dataset (void) H5Fclose(file); } - /*------------------------------------------------------------------------- * Function: test_rowmaj * @@ -189,64 +184,60 @@ create_dataset (void) *------------------------------------------------------------------------- */ static double -test_rowmaj (int op, size_t cache_size, size_t io_size) +test_rowmaj(int op, size_t cache_size, size_t io_size) { - hid_t file, dset, mem_space, file_space; - signed char *buf = (signed char *)calloc (1, (size_t)(SQUARE(io_size))); - hsize_t i, j, hs_size[2]; - hsize_t hs_offset[2]; - int mdc_nelmts; - size_t rdcc_nelmts; - double w0; - - H5Pget_cache (fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0); + hid_t file, dset, mem_space, file_space; + signed char *buf = (signed char *)calloc(1, (size_t)(SQUARE(io_size))); + hsize_t i, j, hs_size[2]; + hsize_t hs_offset[2]; + int mdc_nelmts; + size_t 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 = H5Dopen2(file, "dset", H5P_DEFAULT); + H5Pset_cache(fapl_g, mdc_nelmts, rdcc_nelmts, cache_size * SQUARE(CH_SIZE), w0); + file = H5Fopen(FILE_NAME, H5F_ACC_RDWR, fapl_g); + dset = H5Dopen2(file, "dset", H5P_DEFAULT); file_space = H5Dget_space(dset); - nio_g = 0; + nio_g = 0; - for (i=0; i<CH_SIZE*DS_SIZE; i+=io_size) { + 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); - } + 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); + free(buf); + H5Sclose(file_space); + H5Dclose(dset); + H5Fclose(file); - return (double)SQUARE(CH_SIZE*DS_SIZE)/(double)nio_g; + return (double)SQUARE(CH_SIZE * DS_SIZE) / (double)nio_g; } - /*------------------------------------------------------------------------- * Function: test_diag * @@ -265,63 +256,60 @@ test_rowmaj (int op, size_t cache_size, size_t io_size) *------------------------------------------------------------------------- */ static double -test_diag (int op, size_t cache_size, size_t io_size, size_t offset) +test_diag(int op, size_t cache_size, size_t io_size, size_t offset) { - hid_t file, dset, mem_space, file_space; - hsize_t i, hs_size[2]; - hsize_t nio = 0; - hsize_t hs_offset[2]; - signed char *buf = (signed char *)calloc(1, (size_t)(SQUARE (io_size))); - int mdc_nelmts; - size_t rdcc_nelmts; - double w0; - - H5Pget_cache (fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0); + hid_t file, dset, mem_space, file_space; + hsize_t i, hs_size[2]; + hsize_t nio = 0; + hsize_t hs_offset[2]; + signed char *buf = (signed char *)calloc(1, (size_t)(SQUARE(io_size))); + int mdc_nelmts; + size_t 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 = H5Dopen2(file, "dset", H5P_DEFAULT); + H5Pset_cache(fapl_g, mdc_nelmts, rdcc_nelmts, cache_size * SQUARE(CH_SIZE), w0); + file = H5Fopen(FILE_NAME, H5F_ACC_RDWR, fapl_g); + dset = H5Dopen2(file, "dset", H5P_DEFAULT); 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); + 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); + 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 */ - return (double)nio/(double)nio_g; + return (double)nio / (double)nio_g; } - /*------------------------------------------------------------------------- * Function: main * @@ -339,25 +327,25 @@ test_diag (int op, size_t cache_size, size_t io_size, size_t offset) *------------------------------------------------------------------------- */ int -main (void) +main(void) { - size_t io_size; - double effic, io_percent; - FILE *f, *d; - size_t cache_size; - double w0; + size_t io_size; + double effic, io_percent; + FILE * f, *d; + size_t 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); + fapl_g = H5Pcreate(H5P_FILE_ACCESS); + H5Pget_cache(fapl_g, NULL, NULL, NULL, &w0); /* Create the file */ - create_dataset (); - f = fopen ("x-gnuplot", "w"); + create_dataset(); + f = fopen("x-gnuplot", "w"); - printf("Test %8s %8s %8s\n", "CacheSz", "ChunkSz", "Effic"); + printf("Test %8s %8s %8s\n", "CacheSz", "ChunkSz", "Effic"); printf("--------- -------- -------- --------\n"); #if 1 @@ -365,45 +353,44 @@ main (void) * 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"); + 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, (size_t)(CH_SIZE*io_percent)); - printf ("Rowmaj-rd %8d %8.2f", (int)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"); + 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, (size_t)(CH_SIZE * io_percent)); + printf("Rowmaj-rd %8d %8.2f", (int)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"); + fclose(d); + fprintf(f, "pause -1\n"); #endif #if 1 @@ -411,138 +398,133 @@ main (void) * 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"); + 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, (size_t)(CH_SIZE*io_percent)); - printf ("Rowmaj-wr %8d %8.2f", (int)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"); + 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, (size_t)(CH_SIZE * io_percent)); + printf("Rowmaj-wr %8d %8.2f", (int)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"); + 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"); + 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, (size_t)(CH_SIZE*io_percent)); - printf ("Diag-rd %8d %8.2f", (int)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"); + 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, (size_t)(CH_SIZE * io_percent)); + printf("Diag-rd %8d %8.2f", (int)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"); + 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"); + 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); } - 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, (size_t)(CH_SIZE*io_percent)); - printf ("Diag-wr %8d %8.2f", (int)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"); + else { + fprintf(f, "set autoscale\n"); + fprintf(f, "set hidden3d\n"); } - fclose (d); - fprintf (f, "pause -1\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, (size_t)(CH_SIZE * io_percent)); + printf("Diag-wr %8d %8.2f", (int)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); + H5Pclose(fapl_g); + fclose(f); return 0; } - diff --git a/tools/test/perform/chunk_cache.c b/tools/test/perform/chunk_cache.c index d8af390..3a6a209 100644 --- a/tools/test/perform/chunk_cache.c +++ b/tools/test/perform/chunk_cache.c @@ -21,28 +21,28 @@ #include "H5private.h" #include "h5test.h" -#define FILENAME "chunk_cache_perf.h5" +#define FILENAME "chunk_cache_perf.h5" -#define RANK 2 +#define RANK 2 #define DSET1_NAME "partial_chunks" -#define DSET1_DIM1 9 * 1000 -#define DSET1_DIM2 9 -#define CHUNK1_DIM1 2 * 1000 -#define CHUNK1_DIM2 2 +#define DSET1_DIM1 9 * 1000 +#define DSET1_DIM2 9 +#define CHUNK1_DIM1 2 * 1000 +#define CHUNK1_DIM2 2 #define DSET2_NAME "hash_value" -#define DSET2_DIM1 300 -#define DSET2_DIM2 600 -#define CHUNK2_DIM1 100 -#define CHUNK2_DIM2 100 +#define DSET2_DIM1 300 +#define DSET2_DIM2 600 +#define CHUNK2_DIM1 100 +#define CHUNK2_DIM2 100 -#define RDCC_NSLOTS 5 -#define RDCC_NBYTES 1024 * 1024 * 10 -#define RDCC_W0 0.75F +#define RDCC_NSLOTS 5 +#define RDCC_NBYTES 1024 * 1024 * 10 +#define RDCC_W0 0.75F -#define FILTER_COUNTER 306 -static size_t nbytes_global; +#define FILTER_COUNTER 306 +static size_t nbytes_global; typedef struct test_time_t { long tv_sec; @@ -50,20 +50,18 @@ typedef struct test_time_t { } test_time_t; /* Local function prototypes for the dummy filter */ -static size_t -counter (unsigned flags, size_t cd_nelmts, - const unsigned *cd_values, size_t nbytes, - size_t *buf_size, void **buf); +static size_t counter(unsigned flags, size_t cd_nelmts, const unsigned *cd_values, size_t nbytes, + size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_COUNTER[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - FILTER_COUNTER, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "counter", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - counter, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER_COUNTER, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "counter", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + counter, /* The actual filter function */ }}; /*------------------------------------------------------------------------- @@ -71,9 +69,9 @@ const H5Z_class2_t H5Z_COUNTER[1] = {{ * track of the data of chunks being read from file into memory. */ static size_t -counter (unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) +counter(unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, + const unsigned H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, + void H5_ATTR_UNUSED **buf) { nbytes_global += nbytes; return nbytes; @@ -81,10 +79,10 @@ counter (unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, /*---------------------------------------------------------------------------*/ static void -cleanup (void) +cleanup(void) { - if (!getenv ("HDF5_NOCLEANUP")) { - remove (FILENAME); + if (!getenv("HDF5_NOCLEANUP")) { + remove(FILENAME); } } @@ -93,58 +91,59 @@ cleanup (void) * dataset dimension: 9000 x 9 * chunk dimension: 2000 x 2 */ -static int create_dset1(hid_t file) +static int +create_dset1(hid_t file) { - hid_t dataspace = H5I_INVALID_HID, dataset = H5I_INVALID_HID; - hid_t dcpl = H5I_INVALID_HID; - hsize_t dims[RANK] = {DSET1_DIM1, DSET1_DIM2}; - hsize_t chunk_dims[RANK] = {CHUNK1_DIM1, CHUNK1_DIM2}; - int **data; /* data for writing */ + hid_t dataspace = H5I_INVALID_HID, dataset = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + hsize_t dims[RANK] = {DSET1_DIM1, DSET1_DIM2}; + hsize_t chunk_dims[RANK] = {CHUNK1_DIM1, CHUNK1_DIM2}; + int ** data; /* data for writing */ /* Create the data space. */ - if((dataspace = H5Screate_simple (RANK, dims, NULL)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; /* Modify dataset creation properties, i.e. enable chunking */ - if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; /* Set the dummy filter simply for counting the number of bytes being read into the memory */ - if(H5Zregister(H5Z_COUNTER) < 0) + if (H5Zregister(H5Z_COUNTER) < 0) goto error; - if(H5Pset_filter(dcpl, FILTER_COUNTER, 0, 0, NULL) < 0) + if (H5Pset_filter(dcpl, FILTER_COUNTER, 0, 0, NULL) < 0) goto error; /* Create a new dataset within the file using chunk creation properties. */ - if((dataset = H5Dcreate2 (file, DSET1_NAME, H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET1_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) goto error; /* Create & fill array */ - H5TEST_ALLOCATE_2D_ARRAY(data, int, DSET1_DIM1, DSET1_DIM2); + H5TEST_ALLOCATE_2D_ARRAY(data, int, DSET1_DIM1, DSET1_DIM2); H5TEST_FILL_2D_ARRAY(data, int, DSET1_DIM1, DSET1_DIM2); - /* Write data to dataset */ - if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; /* Close resources */ - H5Dclose (dataset); - H5Pclose (dcpl); - H5Sclose (dataspace); + H5Dclose(dataset); + H5Pclose(dcpl); + H5Sclose(dataspace); return 0; error: - H5E_BEGIN_TRY { - H5Dclose (dataset); - H5Pclose (dcpl); - H5Sclose (dataspace); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Dclose(dataset); + H5Pclose(dcpl); + H5Sclose(dataspace); + } + H5E_END_TRY; return 1; } @@ -154,41 +153,42 @@ error: * dataset dimensions: 300 x 600 * chunk dimensions: 100 x 100 */ -static int create_dset2(hid_t file) +static int +create_dset2(hid_t file) { - hid_t dataspace = H5I_INVALID_HID, dataset = H5I_INVALID_HID; - hid_t dcpl = H5I_INVALID_HID; - hsize_t dims[RANK] = {DSET2_DIM1, DSET2_DIM2}; - hsize_t chunk_dims[RANK] = {CHUNK2_DIM1, CHUNK2_DIM2}; - int **data; /* data for writing */ + hid_t dataspace = H5I_INVALID_HID, dataset = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + hsize_t dims[RANK] = {DSET2_DIM1, DSET2_DIM2}; + hsize_t chunk_dims[RANK] = {CHUNK2_DIM1, CHUNK2_DIM2}; + int ** data; /* data for writing */ /* Create the data space. */ - if((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; /* Modify dataset creation properties, i.e. enable chunking */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; /* Set the dummy filter simply for counting the number of bytes being read into the memory */ - if(H5Zregister(H5Z_COUNTER) < 0) + if (H5Zregister(H5Z_COUNTER) < 0) goto error; - if(H5Pset_filter(dcpl, FILTER_COUNTER, 0, 0, NULL) < 0) + if (H5Pset_filter(dcpl, FILTER_COUNTER, 0, 0, NULL) < 0) goto error; /* Create a new dataset within the file using chunk creation properties. */ - if((dataset = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) goto error; /* Create & fill array */ - H5TEST_ALLOCATE_2D_ARRAY(data, int, DSET2_DIM1, DSET2_DIM2); + H5TEST_ALLOCATE_2D_ARRAY(data, int, DSET2_DIM1, DSET2_DIM2); H5TEST_FILL_2D_ARRAY(data, int, DSET2_DIM1, DSET2_DIM2); /* Write data to dataset */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; /* Close resources */ @@ -199,11 +199,13 @@ static int create_dset2(hid_t file) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Pclose(dcpl); H5Sclose(dataspace); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } @@ -212,31 +214,32 @@ error: * Check the performance of the chunk cache when partial chunks exist * along the dataset dimensions. */ -static int check_partial_chunks_perf(hid_t file) +static int +check_partial_chunks_perf(hid_t file) { - hid_t dataset = H5I_INVALID_HID; - hid_t filespace = H5I_INVALID_HID; - hid_t memspace = H5I_INVALID_HID; - hid_t dapl = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t filespace = H5I_INVALID_HID; + hid_t memspace = H5I_INVALID_HID; + hid_t dapl = H5I_INVALID_HID; - int rdata[DSET1_DIM2]; /* data for reading */ - int i; + int rdata[DSET1_DIM2]; /* data for reading */ + int i; - hsize_t row_rank = 1; - hsize_t row_dim[1] = {DSET1_DIM2}; - hsize_t start[RANK] = {0, 0}; - hsize_t count[RANK] = {1, DSET1_DIM2}; - double start_t, end_t; + hsize_t row_rank = 1; + hsize_t row_dim[1] = {DSET1_DIM2}; + hsize_t start[RANK] = {0, 0}; + hsize_t count[RANK] = {1, DSET1_DIM2}; + double start_t, end_t; - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) goto error; - if(H5Pset_chunk_cache (dapl, RDCC_NSLOTS, RDCC_NBYTES, RDCC_W0) < 0) + if (H5Pset_chunk_cache(dapl, RDCC_NSLOTS, RDCC_NBYTES, RDCC_W0) < 0) goto error; - dataset = H5Dopen2 (file, DSET1_NAME, dapl); + dataset = H5Dopen2(file, DSET1_NAME, dapl); H5_CHECK_OVERFLOW(row_rank, hsize_t, int); - memspace = H5Screate_simple((int)row_rank, row_dim, NULL); + memspace = H5Screate_simple((int)row_rank, row_dim, NULL); filespace = H5Dget_space(dataset); nbytes_global = 0; @@ -244,37 +247,40 @@ static int check_partial_chunks_perf(hid_t file) start_t = H5_get_time(); /* Read the data row by row */ - for(i = 0; i < DSET1_DIM1; i++) { + for (i = 0; i < DSET1_DIM1; i++) { start[0] = (hsize_t)i; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, - start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) goto error; - if(H5Dread (dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, rdata) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, rdata) < 0) goto error; } end_t = H5_get_time(); - if((end_t - start_t) > (double)0.0f) - printf("1. Partial chunks: total read time is %lf; number of bytes being read from file is %zu\n", (end_t -start_t), nbytes_global); + if ((end_t - start_t) > (double)0.0f) + printf("1. Partial chunks: total read time is %lf; number of bytes being read from file is %zu\n", + (end_t - start_t), nbytes_global); else - printf("1. Partial chunks: no total read time because timer is not available; number of bytes being read from file is %zu\n", nbytes_global); + printf("1. Partial chunks: no total read time because timer is not available; number of bytes being " + "read from file is %zu\n", + nbytes_global); - H5Dclose (dataset); - H5Sclose (filespace); - H5Sclose (memspace); - H5Pclose (dapl); + H5Dclose(dataset); + H5Sclose(filespace); + H5Sclose(memspace); + H5Pclose(dapl); return 0; error: - H5E_BEGIN_TRY { - H5Dclose (dataset); - H5Sclose (filespace); - H5Sclose (memspace); - H5Pclose (dapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Dclose(dataset); + H5Sclose(filespace); + H5Sclose(memspace); + H5Pclose(dapl); + } + H5E_END_TRY; return 1; } @@ -283,34 +289,35 @@ error: * is smaller than the number of chunks along the fastest-growing * dimension of the dataset. */ -static int check_hash_value_perf(hid_t file) +static int +check_hash_value_perf(hid_t file) { - hid_t dataset = H5I_INVALID_HID; - hid_t filespace = H5I_INVALID_HID; - hid_t memspace = H5I_INVALID_HID; - hid_t dapl = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t filespace = H5I_INVALID_HID; + hid_t memspace = H5I_INVALID_HID; + hid_t dapl = H5I_INVALID_HID; - int rdata[DSET2_DIM1]; /* data for reading */ - int i; + int rdata[DSET2_DIM1]; /* data for reading */ + int i; - hsize_t column_rank = 1; - hsize_t column_dim[1] = {DSET2_DIM1}; - hsize_t start[RANK] = {0, 0}; - hsize_t count[RANK] = {DSET2_DIM1, 1}; - double start_t, end_t; + hsize_t column_rank = 1; + hsize_t column_dim[1] = {DSET2_DIM1}; + hsize_t start[RANK] = {0, 0}; + hsize_t count[RANK] = {DSET2_DIM1, 1}; + double start_t, end_t; - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) goto error; - if(H5Pset_chunk_cache (dapl, RDCC_NSLOTS, RDCC_NBYTES, RDCC_W0) < 0) + if (H5Pset_chunk_cache(dapl, RDCC_NSLOTS, RDCC_NBYTES, RDCC_W0) < 0) goto error; - if((dataset = H5Dopen2 (file, DSET2_NAME, dapl)) < 0) + if ((dataset = H5Dopen2(file, DSET2_NAME, dapl)) < 0) goto error; H5_CHECK_OVERFLOW(column_rank, hsize_t, int); - if((memspace = H5Screate_simple((int)column_rank, column_dim, NULL)) < 0) + if ((memspace = H5Screate_simple((int)column_rank, column_dim, NULL)) < 0) goto error; - if((filespace = H5Dget_space(dataset)) < 0) + if ((filespace = H5Dget_space(dataset)) < 0) goto error; nbytes_global = 0; @@ -318,37 +325,40 @@ static int check_hash_value_perf(hid_t file) start_t = H5_get_time(); /* Read the data column by column */ - for(i = 0; i < DSET2_DIM2; i++) { + for (i = 0; i < DSET2_DIM2; i++) { start[1] = (hsize_t)i; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, - start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) goto error; - if(H5Dread (dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, rdata) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, rdata) < 0) goto error; } end_t = H5_get_time(); - if((end_t - start_t) > (double)0.0f) - printf("2. Hash value: total read time is %lf; number of bytes being read from file is %zu\n", (end_t -start_t), nbytes_global); + if ((end_t - start_t) > (double)0.0f) + printf("2. Hash value: total read time is %lf; number of bytes being read from file is %zu\n", + (end_t - start_t), nbytes_global); else - printf("2. Hash value: no total read time because timer is not available; number of bytes being read from file is %zu\n", nbytes_global); + printf("2. Hash value: no total read time because timer is not available; number of bytes being read " + "from file is %zu\n", + nbytes_global); - H5Dclose (dataset); - H5Sclose (filespace); - H5Sclose (memspace); - H5Pclose (dapl); + H5Dclose(dataset); + H5Sclose(filespace); + H5Sclose(memspace); + H5Pclose(dapl); return 0; error: - H5E_BEGIN_TRY { - H5Dclose (dataset); - H5Sclose (filespace); - H5Sclose (memspace); - H5Pclose (dapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Dclose(dataset); + H5Sclose(filespace); + H5Sclose(memspace); + H5Pclose(dapl); + } + H5E_END_TRY; return 1; } @@ -359,32 +369,33 @@ error: * in the fastest-growing dimension. *-------------------------------------------------------------------------------------*/ int -main (void) +main(void) { - hid_t file; /* handles */ - int nerrors = 0; + hid_t file; /* handles */ + int nerrors = 0; /* Create a new file. If file exists its contents will be overwritten. */ - if((file = H5Fcreate (FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; nerrors += create_dset1(file); nerrors += create_dset2(file); - if(H5Fclose (file) < 0) + if (H5Fclose(file) < 0) goto error; /* Re-open the file for testing performance. */ - if((file = H5Fopen (FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((file = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto error; nerrors += check_partial_chunks_perf(file); nerrors += check_hash_value_perf(file); - if(H5Fclose (file) < 0) + if (H5Fclose(file) < 0) goto error; - if (nerrors>0) goto error; + if (nerrors > 0) + goto error; cleanup(); return 0; diff --git a/tools/test/perform/direct_write_perf.c b/tools/test/perform/direct_write_perf.c index 20b7237..f4ec7f8 100644 --- a/tools/test/perform/direct_write_perf.c +++ b/tools/test/perform/direct_write_perf.c @@ -26,213 +26,226 @@ #include <math.h> #ifdef H5_STDC_HEADERS -# include <errno.h> -# include <fcntl.h> -# include <stdio.h> -# include <stdlib.h> +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> #endif #ifdef H5_HAVE_UNISTD_H -# include <sys/types.h> -# include <unistd.h> +#include <sys/types.h> +#include <unistd.h> #endif #ifdef H5_HAVE_SYS_STAT_H -# include <sys/stat.h> +#include <sys/stat.h> #endif #if defined(H5_TIME_WITH_SYS_TIME) -# include <sys/time.h> -# include <time.h> +#include <sys/time.h> +#include <time.h> #elif defined(H5_HAVE_SYS_TIME_H) -# include <sys/time.h> +#include <sys/time.h> #else -# include <time.h> +#include <time.h> #endif -const char *FILENAME[] = { - "direct_write", - "unix.raw", - NULL -}; +const char *FILENAME[] = {"direct_write", "unix.raw", NULL}; /* * Print the current location on the standard output stream. */ #define FUNC __func__ -#define AT() printf (" at %s:%d in %s()...\n", \ - __FILE__, __LINE__, FUNC); -#define H5_FAILED() {puts("*FAILED*");fflush(stdout);} -#define TEST_ERROR {H5_FAILED(); AT(); goto error;} -#define TESTING(WHAT) {printf("Testing %-62s",WHAT); fflush(stdout);} -#define PASSED() {puts(" PASSED");fflush(stdout);} - -#define DIRECT_UNCOMPRESSED_DSET "direct_uncompressed_dset" -#define DIRECT_COMPRESSED_DSET "direct_compressed_dset" -#define REG_COMPRESSED_DSET "reg_compressed_dset" -#define REG_NO_COMPRESS_DSET "reg_no_compress_dset" -#define RANK 3 -#define NX 100 -#define NY 1000 -#define NZ 250 -#define CHUNK_NX 1 -#define CHUNK_NY 1000 -#define CHUNK_NZ 250 - -#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s))*1.001)+12) -char filename[1024]; +#define AT() printf(" at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); +#define H5_FAILED() \ + { \ + puts("*FAILED*"); \ + fflush(stdout); \ + } +#define TEST_ERROR \ + { \ + H5_FAILED(); \ + AT(); \ + goto error; \ + } +#define TESTING(WHAT) \ + { \ + printf("Testing %-62s", WHAT); \ + fflush(stdout); \ + } +#define PASSED() \ + { \ + puts(" PASSED"); \ + fflush(stdout); \ + } + +#define DIRECT_UNCOMPRESSED_DSET "direct_uncompressed_dset" +#define DIRECT_COMPRESSED_DSET "direct_compressed_dset" +#define REG_COMPRESSED_DSET "reg_compressed_dset" +#define REG_NO_COMPRESS_DSET "reg_no_compress_dset" +#define RANK 3 +#define NX 100 +#define NY 1000 +#define NZ 250 +#define CHUNK_NX 1 +#define CHUNK_NY 1000 +#define CHUNK_NZ 250 + +#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s)) * 1.001) + 12) +char filename[1024]; unsigned int *outbuf[NX]; -size_t data_size[NX]; -double total_size = 0.0; +size_t data_size[NX]; +double total_size = 0.0; unsigned int *direct_buf[NX]; -double MB = 1048576.0; +double MB = 1048576.0; /*-------------------------------------------------- * Function to report IO rate *-------------------------------------------------- */ -void reportTime(struct timeval start, double mbytes) +void +reportTime(struct timeval start, double mbytes) { - struct timeval timeval_stop,timeval_diff; + struct timeval timeval_stop, timeval_diff; /*end timing*/ - gettimeofday(&timeval_stop,NULL); + gettimeofday(&timeval_stop, NULL); /* Calculate the elapsed gettimeofday time */ - timeval_diff.tv_usec=timeval_stop.tv_usec-start.tv_usec; - timeval_diff.tv_sec=timeval_stop.tv_sec-start.tv_sec; + timeval_diff.tv_usec = timeval_stop.tv_usec - start.tv_usec; + timeval_diff.tv_sec = timeval_stop.tv_sec - start.tv_sec; - if(timeval_diff.tv_usec<0) { - timeval_diff.tv_usec+=1000000; + if (timeval_diff.tv_usec < 0) { + timeval_diff.tv_usec += 1000000; timeval_diff.tv_sec--; } /* end if */ -/*printf("mbytes=%lf, sec=%lf, usec=%lf\n", mbytes, (double)timeval_diff.tv_sec, (double)timeval_diff.tv_usec);*/ - printf("MBytes/second: %lf\n", (double)mbytes/((double)timeval_diff.tv_sec+((double)timeval_diff.tv_usec/(double)1000000.0))); + /*printf("mbytes=%lf, sec=%lf, usec=%lf\n", mbytes, (double)timeval_diff.tv_sec, + * (double)timeval_diff.tv_usec);*/ + printf("MBytes/second: %lf\n", (double)mbytes / ((double)timeval_diff.tv_sec + + ((double)timeval_diff.tv_usec / (double)1000000.0))); } /*-------------------------------------------------- * Create file, datasets, and initialize data *-------------------------------------------------- */ -int create_file(hid_t fapl_id) +int +create_file(hid_t fapl_id) { - hid_t file; /* handles */ - hid_t fapl; - hid_t cparms; - hid_t dataspace, dataset; - hsize_t dims[RANK] = {NX, NY, NZ}; - hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ}; - unsigned int aggression = 9; /* Compression aggression setting */ - int ret; - int i, j, n; + hid_t file; /* handles */ + hid_t fapl; + hid_t cparms; + hid_t dataspace, dataset; + hsize_t dims[RANK] = {NX, NY, NZ}; + hsize_t chunk_dims[RANK] = {CHUNK_NX, CHUNK_NY, CHUNK_NZ}; + unsigned int aggression = 9; /* Compression aggression setting */ + int ret; + int i, j, n; int flag; int unix_file; unsigned int *p; - size_t buf_size = CHUNK_NY*CHUNK_NZ*sizeof(unsigned int); + size_t buf_size = CHUNK_NY * CHUNK_NZ * sizeof(unsigned int); const Bytef *z_src; - Bytef *z_dst; /*destination buffer */ - uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); - uLong z_src_nbytes = (uLong)buf_size; + Bytef * z_dst; /*destination buffer */ + uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); + uLong z_src_nbytes = (uLong)buf_size; TESTING("Create a file and dataset"); /* * Create the data space with unlimited dimensions. */ - if((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR; /* * Create a new file. If file exists its contents will be overwritten. */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR; /* * Modify dataset creation properties, i.e. enable chunking and compression */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; - if(H5Pset_chunk( cparms, RANK, chunk_dims) < 0) + if (H5Pset_chunk(cparms, RANK, chunk_dims) < 0) TEST_ERROR; /* * Create a new dataset within the file using cparms * creation properties. */ - if((dataset = H5Dcreate2(file, DIRECT_UNCOMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DIRECT_UNCOMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, + H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; - if((dataset = H5Dcreate2(file, REG_NO_COMPRESS_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, REG_NO_COMPRESS_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, + H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; /* Set compression */ - if(H5Pset_deflate( cparms, aggression) < 0) + if (H5Pset_deflate(cparms, aggression) < 0) TEST_ERROR; - if((dataset = H5Dcreate2(file, DIRECT_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DIRECT_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, + H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; - - if((dataset = H5Dcreate2(file, REG_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, REG_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, + H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR; - if(H5Sclose(dataspace) < 0) + if (H5Sclose(dataspace) < 0) TEST_ERROR; - if(H5Pclose(cparms) < 0) + if (H5Pclose(cparms) < 0) TEST_ERROR; /* create a unix file*/ - flag = O_CREAT|O_TRUNC|O_WRONLY; + flag = O_CREAT | O_TRUNC | O_WRONLY; - if ((unix_file=open(FILENAME[1],flag,S_IRWXU))== -1) + if ((unix_file = open(FILENAME[1], flag, S_IRWXU)) == -1) TEST_ERROR; - if (close(unix_file) < 0) - { + if (close(unix_file) < 0) { printf(" unable to close the file\n"); TEST_ERROR; } - /* Initialize data for chunks */ - for(i = 0; i < NX; i++) { - p = direct_buf[i] = (unsigned int*)malloc(CHUNK_NY*CHUNK_NZ*sizeof(unsigned int)); + for (i = 0; i < NX; i++) { + p = direct_buf[i] = (unsigned int *)malloc(CHUNK_NY * CHUNK_NZ * sizeof(unsigned int)); - for(j=0; j < CHUNK_NY*CHUNK_NZ; j++, p++) + for (j = 0; j < CHUNK_NY * CHUNK_NZ; j++, p++) *p = rand() % 65000; - z_src = (const Bytef*)direct_buf[i]; + z_src = (const Bytef *)direct_buf[i]; z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); /* Allocate output (compressed) buffer */ - outbuf[i] = (unsigned int*)malloc((size_t)z_dst_nbytes); - z_dst = (Bytef *)outbuf[i]; + outbuf[i] = (unsigned int *)malloc((size_t)z_dst_nbytes); + z_dst = (Bytef *)outbuf[i]; /* Perform compression from the source to the destination buffer */ ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression); @@ -241,28 +254,31 @@ int create_file(hid_t fapl_id) total_size += data_size[i]; /* Check for various zlib errors */ - if(Z_BUF_ERROR == ret) { + if (Z_BUF_ERROR == ret) { fprintf(stderr, "overflow"); TEST_ERROR; - } else if(Z_MEM_ERROR == ret) { - fprintf(stderr, "deflate memory error"); + } + else if (Z_MEM_ERROR == ret) { + fprintf(stderr, "deflate memory error"); TEST_ERROR; - } else if(Z_OK != ret) { - fprintf(stderr, "other deflate error"); + } + else if (Z_OK != ret) { + fprintf(stderr, "other deflate error"); TEST_ERROR; } } - PASSED(); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Sclose(dataspace); H5Pclose(cparms); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } @@ -274,37 +290,37 @@ error: int test_direct_write_uncompressed_data(hid_t fapl_id) { - hid_t file; /* handles */ - hid_t dataspace, dataset; - hid_t dxpl; - herr_t status; - int i; + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t dxpl; + herr_t status; + int i; - unsigned filter_mask = 0; - hsize_t offset[RANK] = {0, 0, 0}; + unsigned filter_mask = 0; + hsize_t offset[RANK] = {0, 0, 0}; struct timeval timeval_start; TESTING("H5Dwrite_chunk for uncompressed data"); - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; /* Start the timer */ - gettimeofday(&timeval_start,NULL); + gettimeofday(&timeval_start, NULL); /* Reopen the file and dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; - if((dataset = H5Dopen2(file, DIRECT_UNCOMPRESSED_DSET, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DIRECT_UNCOMPRESSED_DSET, H5P_DEFAULT)) < 0) TEST_ERROR; - /* Write the compressed chunk data repeatedly to cover all the chunks in the * dataset, using the direct writing function. */ - for(i=0; i<NX; i++) { - status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, CHUNK_NY*CHUNK_NZ*sizeof(unsigned int), direct_buf[i]); + for (i = 0; i < NX; i++) { + status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, + CHUNK_NY * CHUNK_NZ * sizeof(unsigned int), direct_buf[i]); (offset[0])++; } @@ -316,21 +332,22 @@ test_direct_write_uncompressed_data(hid_t fapl_id) H5Fclose(file); /* Report the performance */ - reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB)); + reportTime(timeval_start, (double)(NX * NY * NZ * sizeof(unsigned int) / MB)); PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Pclose(dxpl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } - /*-------------------------------------------------- * Benchmark the performance of the new function * with precompressed data. @@ -339,36 +356,35 @@ error: int test_direct_write_compressed_data(hid_t fapl_id) { - hid_t file; /* handles */ - hid_t dataspace, dataset; - hid_t dxpl; - herr_t status; - int i; + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t dxpl; + herr_t status; + int i; - unsigned filter_mask = 0; - hsize_t offset[RANK] = {0, 0, 0}; + unsigned filter_mask = 0; + hsize_t offset[RANK] = {0, 0, 0}; struct timeval timeval_start; TESTING("H5DOwrite_chunk for pre-compressed data"); - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; /* Start the timer */ - gettimeofday(&timeval_start,NULL); + gettimeofday(&timeval_start, NULL); /* Reopen the file and dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; - if((dataset = H5Dopen2(file, DIRECT_COMPRESSED_DSET, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DIRECT_COMPRESSED_DSET, H5P_DEFAULT)) < 0) TEST_ERROR; - /* Write the compressed chunk data repeatedly to cover all the chunks in the * dataset, using the direct writing function. */ - for(i=0; i<NX; i++) { + for (i = 0; i < NX; i++) { status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, data_size[i], outbuf[i]); (offset[0])++; } @@ -381,17 +397,19 @@ test_direct_write_compressed_data(hid_t fapl_id) H5Fclose(file); /* Report the performance */ - reportTime(timeval_start, (double)(total_size/MB)); + reportTime(timeval_start, (double)(total_size / MB)); PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Pclose(dxpl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } @@ -403,13 +421,13 @@ error: int test_compressed_write(hid_t fapl_id) { - hid_t file; /* handles */ - hid_t dataspace, dataset; - hid_t mem_space; - hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ}; - hid_t dxpl; - herr_t status; - int i; + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t mem_space; + hsize_t chunk_dims[RANK] = {CHUNK_NX, CHUNK_NY, CHUNK_NZ}; + hid_t dxpl; + herr_t status; + int i; hsize_t start[RANK]; /* Start of hyperslab */ hsize_t stride[RANK]; /* Stride of hyperslab */ @@ -420,40 +438,42 @@ test_compressed_write(hid_t fapl_id) TESTING("H5Dwrite with compression enabled"); - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; - if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) + if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) TEST_ERROR; /* Start the timer */ - gettimeofday(&timeval_start,NULL); + gettimeofday(&timeval_start, NULL); /* Reopen the file and dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; - if((dataset = H5Dopen2(file, REG_COMPRESSED_DSET, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, REG_COMPRESSED_DSET, H5P_DEFAULT)) < 0) TEST_ERROR; - if((dataspace = H5Dget_space(dataset)) < 0) + if ((dataspace = H5Dget_space(dataset)) < 0) TEST_ERROR; - start[0] = start[1] = start[2] = 0; + start[0] = start[1] = start[2] = 0; stride[0] = stride[1] = stride[2] = 1; - count[0] = count[1] = count[2] = 1; - block[0] = CHUNK_NX; block[1] = CHUNK_NY; block[2] = CHUNK_NZ; + count[0] = count[1] = count[2] = 1; + block[0] = CHUNK_NX; + block[1] = CHUNK_NY; + block[2] = CHUNK_NZ; - for(i=0; i<NX; i++) { + for (i = 0; i < NX; i++) { /* * Select hyperslab for one chunk in the file */ - if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) + if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) TEST_ERROR; (start[0])++; - if((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, - H5P_DEFAULT, direct_buf[i])) < 0) + if ((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, direct_buf[i])) < + 0) TEST_ERROR; } @@ -467,19 +487,21 @@ test_compressed_write(hid_t fapl_id) H5Fclose(file); /* Report the performance */ - reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB)); + reportTime(timeval_start, (double)(NX * NY * NZ * sizeof(unsigned int) / MB)); PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Sclose(dataspace); H5Sclose(mem_space); H5Pclose(dxpl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } @@ -491,13 +513,13 @@ error: int test_no_compress_write(hid_t fapl_id) { - hid_t file; /* handles */ - hid_t dataspace, dataset; - hid_t mem_space; - hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ}; - hid_t dxpl; - herr_t status; - int i; + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t mem_space; + hsize_t chunk_dims[RANK] = {CHUNK_NX, CHUNK_NY, CHUNK_NZ}; + hid_t dxpl; + herr_t status; + int i; hsize_t start[RANK]; /* Start of hyperslab */ hsize_t stride[RANK]; /* Stride of hyperslab */ @@ -508,40 +530,42 @@ test_no_compress_write(hid_t fapl_id) TESTING("H5Dwrite without compression"); - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; - if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) + if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) TEST_ERROR; /* Start the timer */ - gettimeofday(&timeval_start,NULL); + gettimeofday(&timeval_start, NULL); /* Reopen the file and dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; - if((dataset = H5Dopen2(file, REG_NO_COMPRESS_DSET, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, REG_NO_COMPRESS_DSET, H5P_DEFAULT)) < 0) TEST_ERROR; - if((dataspace = H5Dget_space(dataset)) < 0) + if ((dataspace = H5Dget_space(dataset)) < 0) TEST_ERROR; - start[0] = start[1] = start[2] = 0; + start[0] = start[1] = start[2] = 0; stride[0] = stride[1] = stride[2] = 1; - count[0] = count[1] = count[2] = 1; - block[0] = CHUNK_NX; block[1] = CHUNK_NY; block[2] = CHUNK_NZ; + count[0] = count[1] = count[2] = 1; + block[0] = CHUNK_NX; + block[1] = CHUNK_NY; + block[2] = CHUNK_NZ; - for(i=0; i<NX; i++) { + for (i = 0; i < NX; i++) { /* * Select hyperslab for one chunk in the file */ - if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) + if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) TEST_ERROR; (start[0])++; - if((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, - H5P_DEFAULT, direct_buf[i])) < 0) + if ((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, direct_buf[i])) < + 0) TEST_ERROR; } @@ -555,19 +579,21 @@ test_no_compress_write(hid_t fapl_id) H5Fclose(file); /* Report the performance */ - reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB)); + reportTime(timeval_start, (double)(NX * NY * NZ * sizeof(unsigned int) / MB)); PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Sclose(dataspace); H5Sclose(mem_space); H5Pclose(dxpl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } @@ -579,9 +605,9 @@ error: int test_unix_write(void) { - int file, flag; - ssize_t op_size; - int i; + int file, flag; + ssize_t op_size; + int i; struct timeval timeval_start; TESTING("Write compressed data to a Unix file"); @@ -590,35 +616,32 @@ test_unix_write(void) flag = O_WRONLY; /* Start the timer */ - gettimeofday(&timeval_start,NULL); + gettimeofday(&timeval_start, NULL); - if ((file=open(FILENAME[1],flag))== -1) + if ((file = open(FILENAME[1], flag)) == -1) TEST_ERROR; /* Write the compressed chunk data repeatedly to cover all the chunks in the * dataset, using the direct writing function. */ - for(i=0; i<NX; i++) { - op_size = write(file, outbuf[i],data_size[i]); - if (op_size < 0) - { + for (i = 0; i < NX; i++) { + op_size = write(file, outbuf[i], data_size[i]); + if (op_size < 0) { printf(" Error in writing data to file because %s \n", strerror(errno)); TEST_ERROR; } - else if (op_size == 0) - { + else if (op_size == 0) { printf(" unable to write sufficent data to file because %s \n", strerror(errno)); TEST_ERROR; } } - if (close(file) < 0) - { + if (close(file) < 0) { printf(" unable to close the file\n"); TEST_ERROR; } /* Report the performance */ - reportTime(timeval_start, (double)(total_size/MB)); + reportTime(timeval_start, (double)(total_size / MB)); PASSED(); return 0; @@ -632,10 +655,10 @@ error: *-------------------------------------------------- */ int -main (void) +main(void) { - hid_t fapl = H5P_DEFAULT; - int i; + hid_t fapl = H5P_DEFAULT; + int i; sprintf(filename, "%s.h5", FILENAME[0]); @@ -646,7 +669,7 @@ main (void) test_compressed_write(fapl); test_unix_write(); - for(i=0; i<NX; i++) { + for (i = 0; i < NX; i++) { free(outbuf[i]); free(direct_buf[i]); } @@ -665,7 +688,7 @@ main(void) #endif /* WIN32 / MINGW32 */ -#else /* !H5_HAVE_FILTER_DEFLATE */ +#else /* !H5_HAVE_FILTER_DEFLATE */ /* * Function: main @@ -680,5 +703,4 @@ main(void) return EXIT_SUCCESS; } -#endif /* !H5_HAVE_FILTER_DEFLATE */ - +#endif /* !H5_HAVE_FILTER_DEFLATE */ diff --git a/tools/test/perform/iopipe.c b/tools/test/perform/iopipe.c index bb74a1b..8fc4058 100644 --- a/tools/test/perform/iopipe.c +++ b/tools/test/perform/iopipe.c @@ -21,27 +21,25 @@ #include "H5private.h" - #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 * @@ -57,39 +55,31 @@ static void print_stats(const char *prefix, #ifdef H5_HAVE_GETRUSAGE - struct rusage *r_start, struct rusage *r_stop, + struct rusage *r_start, struct rusage *r_stop, #endif /* H5_HAVE_GETRUSAGE */ - double t_start, double t_stop, - size_t nbytes) + double t_start, double t_stop, size_t nbytes) { - double e_time; - char bw[16]; + double e_time; + char bw[16]; #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 e_time = t_stop - t_start; H5_bandwidth(bw, (double)nbytes, e_time); #ifdef H5_HAVE_GETRUSAGE - HDprintf(HEADING "%1.2fuser %1.2fsystem %1.2felapsed %s\n", - prefix, u_time, s_time, e_time, bw); + HDprintf(HEADING "%1.2fuser %1.2fsystem %1.2felapsed %s\n", prefix, u_time, s_time, e_time, bw); #else - HDprintf(HEADING "%1.2felapsed %s\n", - prefix, e_time, bw); + HDprintf(HEADING "%1.2felapsed %s\n", prefix, e_time, bw); #endif } - /*------------------------------------------------------------------------- * Function: synchronize * @@ -106,7 +96,7 @@ static 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 H5_ATTR_NDEBUG_UNUSED status; @@ -120,7 +110,6 @@ synchronize(void) #endif } - /*------------------------------------------------------------------------- * Function: main * @@ -139,22 +128,21 @@ int main(void) { hsize_t size[2] = {REQUEST_SIZE_X, REQUEST_SIZE_Y}; - unsigned nread = NREAD_REQUESTS, nwrite = NWRITE_REQUESTS; + unsigned nread = NREAD_REQUESTS, nwrite = NWRITE_REQUESTS; - unsigned char *the_data = NULL; - hid_t file, dset, file_space = H5I_INVALID_HID; + unsigned char *the_data = NULL; + hid_t file, dset, file_space = H5I_INVALID_HID; #ifdef H5_HAVE_GETRUSAGE - struct rusage r_start, r_stop; + struct rusage r_start, r_stop; #endif - double t_start, t_stop; - int fd; - unsigned u; - herr_t H5_ATTR_NDEBUG_UNUSED status; - hssize_t H5_ATTR_NDEBUG_UNUSED n; - off_t H5_ATTR_NDEBUG_UNUSED offset; - hsize_t start[2]; - hsize_t count[2]; - + double t_start, t_stop; + int fd; + unsigned u; + herr_t H5_ATTR_NDEBUG_UNUSED status; + hssize_t H5_ATTR_NDEBUG_UNUSED n; + off_t H5_ATTR_NDEBUG_UNUSED offset; + hsize_t start[2]; + hsize_t count[2]; /* * The extra cast in the following statement is a bug workaround for the @@ -162,12 +150,12 @@ main(void) * 1998-11-06 ptl */ HDprintf("I/O request size is %1.1fMB\n", - (double)(hssize_t)(size[0] * size[1]) / (double)1024.0F * (double)1024); + (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); + fd = HDopen(RAW_FILE_NAME, O_RDWR | O_CREAT | O_TRUNC, 0666); HDassert(fd >= 0); /* Create the dataset */ @@ -180,7 +168,6 @@ main(void) /* initial fill for lazy malloc */ HDmemset(the_data, 0xAA, (size_t)(size[0] * size[1])); - /* Fill raw */ synchronize(); #ifdef H5_HAVE_GETRUSAGE @@ -188,10 +175,10 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "fill raw"); - for(u = 0; u < nwrite; u++) { - HDputc(PROGRESS, stderr); - HDfflush(stderr); - HDmemset(the_data, 0xAA, (size_t)(size[0] * size[1])); + for (u = 0; u < nwrite; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + HDmemset(the_data, 0xAA, (size_t)(size[0] * size[1])); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -200,10 +187,9 @@ main(void) HDputc('\n', stderr); print_stats("fill raw", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); - + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Fill hdf5 */ synchronize(); @@ -212,12 +198,11 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "fill hdf5"); - for(u = 0; u < nread; u++) { - HDputc(PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - HDassert(status >= 0); + for (u = 0; u < nread; u++) { + HDputc(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); @@ -226,9 +211,9 @@ main(void) HDputc('\n', stderr); print_stats("fill hdf5", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Write the raw dataset */ synchronize(); @@ -237,13 +222,13 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "out raw"); - for(u = 0; u < nwrite; u++) { - HDputc(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])); + for (u = 0; u < nwrite; u++) { + HDputc(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); @@ -252,9 +237,9 @@ main(void) HDputc('\n', stderr); print_stats("out raw", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Write the hdf5 dataset */ synchronize(); @@ -263,12 +248,11 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "out hdf5"); - for(u = 0; u < nwrite; u++) { - HDputc(PROGRESS, stderr); - HDfflush(stderr); - status = H5Dwrite(dset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, - H5P_DEFAULT, the_data); - HDassert(status >= 0); + for (u = 0; u < nwrite; u++) { + HDputc(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); @@ -277,9 +261,9 @@ main(void) HDputc('\n', stderr); print_stats("out hdf5", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Read the raw dataset */ synchronize(); @@ -288,13 +272,13 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "in raw"); - for(u = 0; u < nread; u++) { - HDputc(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])); + for (u = 0; u < nread; u++) { + HDputc(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); @@ -303,10 +287,9 @@ main(void) HDputc('\n', stderr); print_stats("in raw", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); - + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Read the hdf5 dataset */ synchronize(); @@ -315,12 +298,11 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "in hdf5"); - for(u = 0; u < nread; u++) { - HDputc(PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - HDassert(status >= 0); + for (u = 0; u < nread; u++) { + HDputc(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); @@ -329,15 +311,15 @@ main(void) HDputc('\n', stderr); print_stats("in hdf5", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Read hyperslab */ 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); + status = H5Sselect_hyperslab(file_space, H5S_SELECT_SET, start, NULL, count, NULL); HDassert(status >= 0); synchronize(); #ifdef H5_HAVE_GETRUSAGE @@ -345,12 +327,11 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "in hdf5 partial"); - for(u = 0; u < nread; u++) { - HDputc(PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - HDassert(status >= 0); + for (u = 0; u < nread; u++) { + HDputc(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); @@ -359,9 +340,9 @@ main(void) HDputc('\n', stderr); print_stats("in hdf5 partial", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Close everything */ HDclose(fd); @@ -374,4 +355,3 @@ main(void) return 0; } - diff --git a/tools/test/perform/overhead.c b/tools/test/perform/overhead.c index bb3aff5..a08c367 100644 --- a/tools/test/perform/overhead.c +++ b/tools/test/perform/overhead.c @@ -24,49 +24,41 @@ #include "H5private.h" #ifdef H5_STDC_HEADERS -# include <ctype.h> -# include <fcntl.h> -# include <stdlib.h> -# include <sys/stat.h> -# include <string.h> +#include <ctype.h> +#include <fcntl.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <string.h> #endif #ifdef H5_HAVE_IO_H -# include <io.h> +#include <io.h> #endif #ifdef H5_HAVE_UNISTD_H -# include <sys/types.h> -# include <unistd.h> +#include <sys/types.h> +#include <unistd.h> #endif /* Solaris Studio defines attribute, but for the attributes we need */ #if !defined(H5_HAVE_ATTRIBUTE) || defined __cplusplus || defined(__SUNPRO_C) -# undef __attribute__ -# define __attribute__(X) /*void*/ -# define H5_ATTR_UNUSED /*void*/ +#undef __attribute__ +#define __attribute__(X) /*void*/ +#define H5_ATTR_UNUSED /*void*/ #else -# define H5_ATTR_UNUSED __attribute__((unused)) +#define H5_ATTR_UNUSED __attribute__((unused)) #endif -#define FILE_NAME_1 "overhead.h5" +#define FILE_NAME_1 "overhead.h5" #ifndef FALSE -#define FALSE 0 +#define FALSE 0 #endif /* FALSE */ #ifndef TRUE -#define TRUE 1 +#define TRUE 1 #endif /* TRUE */ -typedef enum fill_t { - FILL_ALL, - FILL_FORWARD, - FILL_REVERSE, - FILL_INWARD, - FILL_OUTWARD, - FILL_RANDOM -} fill_t; +typedef enum fill_t { FILL_ALL, FILL_FORWARD, FILL_REVERSE, FILL_INWARD, FILL_OUTWARD, FILL_RANDOM } fill_t; - /*------------------------------------------------------------------------- * Function: usage * @@ -84,8 +76,7 @@ typedef enum fill_t { static void usage(const char *prog) { - HDfprintf(stderr, "usage: %s [STYLE|cache] [LEFT [MIDDLE [RIGHT]]]\n", - prog); + HDfprintf(stderr, "usage: %s [STYLE|cache] [LEFT [MIDDLE [RIGHT]]]\n", prog); HDfprintf(stderr, "\ STYLE is the order that the dataset is filled and should be one of:\n\ forward -- Fill the dataset from lowest address to highest\n\ @@ -117,7 +108,6 @@ usage(const char *prog) exit(1); } - /*------------------------------------------------------------------------- * Function: cleanup * @@ -133,14 +123,13 @@ usage(const char *prog) *------------------------------------------------------------------------- */ static void -cleanup (void) +cleanup(void) { - if (!getenv ("HDF5_NOCLEANUP")) { - remove (FILE_NAME_1); + if (!getenv("HDF5_NOCLEANUP")) { + remove(FILE_NAME_1); } } - /*------------------------------------------------------------------------- * Function: display_error_cb * @@ -158,15 +147,14 @@ cleanup (void) *------------------------------------------------------------------------- */ static herr_t -display_error_cb (hid_t estack, void H5_ATTR_UNUSED *client_data) +display_error_cb(hid_t estack, void H5_ATTR_UNUSED *client_data) { - puts ("*FAILED*"); + puts("*FAILED*"); H5Eprint2(estack, stdout); return 0; } - /*------------------------------------------------------------------------- * Function: test * @@ -184,92 +172,103 @@ display_error_cb (hid_t estack, void H5_ATTR_UNUSED *client_data) *------------------------------------------------------------------------- */ static int -test(fill_t fill_style, const double splits[], - hbool_t verbose, hbool_t use_rdcc) +test(fill_t fill_style, const double splits[], hbool_t verbose, hbool_t use_rdcc) { - hid_t file = (-1), fapl = (-1), dcpl = (-1), xfer = (-1), mspace = (-1), fspace = (-1), dset = (-1); - hsize_t ch_size[1] = {1}; /*chunk size */ - hsize_t cur_size[1] = {1000}; /*current dataset size */ - hsize_t max_size[1] = {H5S_UNLIMITED}; /*maximum dataset size */ - hsize_t hs_start[1]; /*hyperslab start offset*/ - hsize_t hs_count[1] = {1}; /*hyperslab nelmts */ - int fd = (-1); /*h5 file direct */ - int *had = NULL; /*for random filling */ - const char *sname=NULL; /*fill style nam */ - int mdc_nelmts; /*num meta objs to cache*/ - hsize_t i, k; - int j; - h5_stat_t sb; + hid_t file = (-1), fapl = (-1), dcpl = (-1), xfer = (-1), mspace = (-1), fspace = (-1), dset = (-1); + hsize_t ch_size[1] = {1}; /*chunk size */ + hsize_t cur_size[1] = {1000}; /*current dataset size */ + hsize_t max_size[1] = {H5S_UNLIMITED}; /*maximum dataset size */ + hsize_t hs_start[1]; /*hyperslab start offset*/ + hsize_t hs_count[1] = {1}; /*hyperslab nelmts */ + int fd = (-1); /*h5 file direct */ + int * had = NULL; /*for random filling */ + const char *sname = NULL; /*fill style nam */ + int mdc_nelmts; /*num meta objs to cache*/ + hsize_t i, k; + int j; + h5_stat_t sb; - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - if(!use_rdcc) { - if(H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL) < 0) goto error; - if(H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0F) < 0) goto error; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if (!use_rdcc) { + if (H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL) < 0) + goto error; + if (H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0F) < 0) + goto error; } - if((file = H5Fcreate(FILE_NAME_1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 1, ch_size) < 0) goto error; - if((xfer = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; - if(H5Pset_btree_ratios(xfer, splits[0], splits[1], splits[2]) < 0) goto error; - if((fspace = H5Screate_simple(1, cur_size, max_size)) < 0) goto error; - if((mspace = H5Screate_simple(1, ch_size, ch_size)) < 0) goto error; - if((dset = H5Dcreate2(file, "chunked", H5T_NATIVE_INT, - fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if ((fd=HDopen(FILE_NAME_1, O_RDONLY, 0666)) < 0) goto error; + if ((file = H5Fcreate(FILE_NAME_1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dcpl, 1, ch_size) < 0) + goto error; + if ((xfer = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if (H5Pset_btree_ratios(xfer, splits[0], splits[1], splits[2]) < 0) + goto error; + if ((fspace = H5Screate_simple(1, cur_size, max_size)) < 0) + goto error; + if ((mspace = H5Screate_simple(1, ch_size, ch_size)) < 0) + goto error; + if ((dset = H5Dcreate2(file, "chunked", H5T_NATIVE_INT, fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if ((fd = HDopen(FILE_NAME_1, O_RDONLY, 0666)) < 0) + goto error; - if(FILL_RANDOM==fill_style) + if (FILL_RANDOM == fill_style) had = (int *)calloc((size_t)cur_size[0], sizeof(int)); - for (i=1; i<=cur_size[0]; i++) { + for (i = 1; i <= cur_size[0]; i++) { /* Decide which chunk to write to */ switch (fill_style) { - case FILL_FORWARD: - hs_start[0] = i-1; - break; - case FILL_REVERSE: - hs_start[0] = cur_size[0]-i; - break; - case FILL_INWARD: - hs_start[0] = i%2 ? i/2 : cur_size[0]-i/2; - break; - case FILL_OUTWARD: - k = (cur_size[0] - i) + 1; - hs_start[0] = k % 2 ? (k / 2) : (hsize_t)((hssize_t)cur_size[0] - (hssize_t)(k / 2)); - break; - case FILL_RANDOM: - for (j=HDrand()%(int)cur_size[0]; had[j]; j=(j+1)%(int)cur_size[0]) - /*void*/; - hs_start[0] = (hsize_t)j; - had[j] = 1; - break; - case FILL_ALL: - abort(); - default: - /* unknown request */ - HDfprintf(stderr, "Unknown fill style\n"); - goto error; - break; + case FILL_FORWARD: + hs_start[0] = i - 1; + break; + case FILL_REVERSE: + hs_start[0] = cur_size[0] - i; + break; + case FILL_INWARD: + hs_start[0] = i % 2 ? i / 2 : cur_size[0] - i / 2; + break; + case FILL_OUTWARD: + k = (cur_size[0] - i) + 1; + hs_start[0] = k % 2 ? (k / 2) : (hsize_t)((hssize_t)cur_size[0] - (hssize_t)(k / 2)); + break; + case FILL_RANDOM: + for (j = HDrand() % (int)cur_size[0]; had[j]; j = (j + 1) % (int)cur_size[0]) + /*void*/; + hs_start[0] = (hsize_t)j; + had[j] = 1; + break; + case FILL_ALL: + abort(); + default: + /* unknown request */ + HDfprintf(stderr, "Unknown fill style\n"); + goto error; + break; } /* Write the chunk */ - if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_start, NULL, - hs_count, NULL) < 0) goto error; + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_start, NULL, hs_count, NULL) < 0) + goto error; if (H5Dwrite(dset, H5T_NATIVE_INT, mspace, fspace, xfer, &i) < 0) { goto error; } /* Determine overhead */ if (verbose) { - if (H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; - if (HDfstat(fd, &sb) < 0) goto error; - printf("%4lu %8.3f ***\n", - (unsigned long)i, - (double)(sb.st_size - (HDoff_t)(i * sizeof(int))) / (double)i); + if (H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + goto error; + if (HDfstat(fd, &sb) < 0) + goto error; + printf("%4lu %8.3f ***\n", (unsigned long)i, + (double)(sb.st_size - (HDoff_t)(i * sizeof(int))) / (double)i); } } - if(had) { + if (had) { free(had); had = NULL; } /* end if */ @@ -283,53 +282,52 @@ test(fill_t fill_style, const double splits[], if (!verbose) { switch (fill_style) { - case FILL_FORWARD: - sname = "forward"; - break; - case FILL_REVERSE: - sname = "reverse"; - break; - case FILL_INWARD: - sname = "inward"; - break; - case FILL_OUTWARD: - sname = "outward"; - break; - case FILL_RANDOM: - sname = "random"; - break; - case FILL_ALL: - abort(); - default: - /* unknown request */ - HDfprintf(stderr, "Unknown fill style\n"); - goto error; - break; + case FILL_FORWARD: + sname = "forward"; + break; + case FILL_REVERSE: + sname = "reverse"; + break; + case FILL_INWARD: + sname = "inward"; + break; + case FILL_OUTWARD: + sname = "outward"; + break; + case FILL_RANDOM: + sname = "random"; + break; + case FILL_ALL: + abort(); + default: + /* unknown request */ + HDfprintf(stderr, "Unknown fill style\n"); + goto error; + break; } - if (HDfstat(fd, &sb) < 0) goto error; + if (HDfstat(fd, &sb) < 0) + goto error; printf("%-7s %8.3f\n", sname, - (double)(sb.st_size - (HDoff_t)(cur_size[0] * sizeof(int))) / - (double)cur_size[0]); + (double)(sb.st_size - (HDoff_t)(cur_size[0] * sizeof(int))) / (double)cur_size[0]); } HDclose(fd); return 0; - error: +error: H5Dclose(dset); H5Sclose(mspace); H5Sclose(fspace); H5Pclose(dcpl); H5Pclose(xfer); H5Fclose(file); - if(had) + if (had) free(had); HDclose(fd); return 1; } - /*------------------------------------------------------------------------- * Function: main * @@ -349,58 +347,70 @@ test(fill_t fill_style, const double splits[], int main(int argc, char *argv[]) { - hid_t xfer; + hid_t xfer; fill_t fill_style = FILL_ALL; - hbool_t use_cache = FALSE; + hbool_t use_cache = FALSE; double splits[3]; - int i, j, nerrors=0; + int i, j, nerrors = 0; /* Default split ratios */ H5Eset_auto2(H5E_DEFAULT, display_error_cb, NULL); - if((xfer = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; - if(H5Pget_btree_ratios(xfer, splits+0, splits+1, splits+2) < 0) goto error; - if(H5Pclose(xfer) < 0) goto error; + if ((xfer = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if (H5Pget_btree_ratios(xfer, splits + 0, splits + 1, splits + 2) < 0) + goto error; + if (H5Pclose(xfer) < 0) + goto error; /* Parse command-line options */ - for(i = 1, j = 0; i < argc; i++) { + for (i = 1, j = 0; i < argc; i++) { if (!strcmp(argv[i], "forward")) { fill_style = FILL_FORWARD; - } else if (!strcmp(argv[i], "reverse")) { + } + else if (!strcmp(argv[i], "reverse")) { fill_style = FILL_REVERSE; - } else if (!strcmp(argv[i], "inward")) { + } + else if (!strcmp(argv[i], "inward")) { fill_style = FILL_INWARD; - } else if (!strcmp(argv[i], "outward")) { + } + else if (!strcmp(argv[i], "outward")) { fill_style = FILL_OUTWARD; - } else if (!strcmp(argv[i], "random")) { + } + else if (!strcmp(argv[i], "random")) { fill_style = FILL_RANDOM; - } else if (!strcmp(argv[i], "cache")) { + } + else if (!strcmp(argv[i], "cache")) { use_cache = TRUE; - } else if (j<3 && (isdigit(argv[i][0]) || '.'==argv[i][0])) { + } + else if (j < 3 && (isdigit(argv[i][0]) || '.' == argv[i][0])) { splits[j++] = strtod(argv[i], NULL); - } else { + } + else { usage(argv[0]); } } - if (FILL_ALL==fill_style) { + if (FILL_ALL == fill_style) { printf("%-7s %8s\n", "Style", "Bytes/Chunk"); printf("%-7s %8s\n", "-----", "-----------"); nerrors += test(FILL_FORWARD, splits, FALSE, use_cache); nerrors += test(FILL_REVERSE, splits, FALSE, use_cache); - nerrors += test(FILL_INWARD, splits, FALSE, use_cache); + nerrors += test(FILL_INWARD, splits, FALSE, use_cache); nerrors += test(FILL_OUTWARD, splits, FALSE, use_cache); - nerrors += test(FILL_RANDOM, splits, FALSE, use_cache); + nerrors += test(FILL_RANDOM, splits, FALSE, use_cache); } else { - if (use_cache) usage(argv[0]); - nerrors += test(fill_style, splits, TRUE, FALSE); + if (use_cache) + usage(argv[0]); + nerrors += test(fill_style, splits, TRUE, FALSE); } - if (nerrors>0) goto error; + if (nerrors > 0) + goto error; cleanup(); return 0; - error: +error: HDfprintf(stderr, "*** ERRORS DETECTED ***\n"); return 1; } diff --git a/tools/test/perform/perf.c b/tools/test/perform/perf.c index 5b78c52..22aca04 100644 --- a/tools/test/perform/perf.c +++ b/tools/test/perform/perf.c @@ -44,17 +44,17 @@ #endif #if defined(H5_TIME_WITH_SYS_TIME) -# include <sys/time.h> -# include <time.h> +#include <sys/time.h> +#include <time.h> #elif defined(H5_HAVE_SYS_TIME_H) -# include <sys/time.h> +#include <sys/time.h> #else -# include <time.h> +#include <time.h> #endif #include <mpi.h> -#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ -# include <mpio.h> +#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ +#include <mpio.h> #endif /* Macro definitions */ @@ -62,50 +62,46 @@ * if val is false (0), print mesg and if fatal is true (non-zero), die. */ #define H5FATAL 1 -#define VRFY(val, mesg, fatal) do { \ - if (!val) { \ - printf("Proc %d: ", mynod); \ - printf("*** Assertion failed (%s) at line %4d in %s\n", \ - mesg, (int)__LINE__, __FILE__); \ - if (fatal){ \ - fflush(stdout); \ - goto die_jar_jar_die; \ - } \ - } \ -} while(0) -#define RANK 1 +#define VRFY(val, mesg, fatal) \ + do { \ + if (!val) { \ + printf("Proc %d: ", mynod); \ + printf("*** Assertion failed (%s) at line %4d in %s\n", mesg, (int)__LINE__, __FILE__); \ + if (fatal) { \ + fflush(stdout); \ + goto die_jar_jar_die; \ + } \ + } \ + } while (0) +#define RANK 1 #define MAX_PATH 1024 -hsize_t dims[RANK]; /* dataset dim sizes */ +hsize_t dims[RANK]; /* dataset dim sizes */ hsize_t block[RANK], stride[RANK], count[RANK]; hsize_t start[RANK]; -hid_t fid; /* HDF5 file ID */ -hid_t acc_tpl; /* File access templates */ -hid_t sid; /* Dataspace ID */ -hid_t file_dataspace; /* File dataspace ID */ -hid_t mem_dataspace; /* memory dataspace ID */ -hid_t dataset; /* Dataset ID */ -hsize_t opt_alignment = 1; -hsize_t opt_threshold = 1; -int opt_split_vfd = 0; -char *meta_ext, *raw_ext; /* holds the meta and raw file extension if */ - /* opt_split_vfd is set */ - +hid_t fid; /* HDF5 file ID */ +hid_t acc_tpl; /* File access templates */ +hid_t sid; /* Dataspace ID */ +hid_t file_dataspace; /* File dataspace ID */ +hid_t mem_dataspace; /* memory dataspace ID */ +hid_t dataset; /* Dataset ID */ +hsize_t opt_alignment = 1; +hsize_t opt_threshold = 1; +int opt_split_vfd = 0; +char * meta_ext, *raw_ext; /* holds the meta and raw file extension if */ + /* opt_split_vfd is set */ /* DEFAULT VALUES FOR OPTIONS */ -int64_t opt_block = 1048576*16; -int opt_iter = 1; -int opt_stripe = -1; -int opt_correct = 0; -int amode = O_RDWR | O_CREAT; -char opt_file[256] = "perftest.out"; +int64_t opt_block = 1048576 * 16; +int opt_iter = 1; +int opt_stripe = -1; +int opt_correct = 0; +int amode = O_RDWR | O_CREAT; +char opt_file[256] = "perftest.out"; char opt_pvfstab[256] = "notset"; -int opt_pvfstab_set = 0; +int opt_pvfstab_set = 0; -const char *FILENAME[] = { - opt_file, - NULL -}; +const char *FILENAME[] = {opt_file, NULL}; /* function prototypes */ static int parse_args(int argc, char **argv); @@ -115,42 +111,44 @@ static int parse_args(int argc, char **argv); extern char *optarg; #endif -int main(int argc, char **argv) +int +main(int argc, char **argv) { - char *buf, *tmp, *buf2 = NULL, *tmp2 = NULL, *check; - int i, j, mynod=0, nprocs=1, my_correct = 1, correct, myerrno; - double stim, etim; - double write_tim = 0; - double read_tim = 0; - double read_bw, write_bw; - double max_read_tim, max_write_tim; - double min_read_tim, min_write_tim; - double ave_read_tim, ave_write_tim; + char * buf, *tmp, *buf2 = NULL, *tmp2 = NULL, *check; + int i, j, mynod = 0, nprocs = 1, my_correct = 1, correct, myerrno; + double stim, etim; + double write_tim = 0; + double read_tim = 0; + double read_bw, write_bw; + double max_read_tim, max_write_tim; + double min_read_tim, min_write_tim; + double ave_read_tim, ave_write_tim; int64_t iter_jump = 0; - char filename[MAX_PATH]; - herr_t ret; /* Generic return value */ + char filename[MAX_PATH]; + herr_t ret; /* Generic return value */ /* startup MPI and determine the rank of this process */ - MPI_Init(&argc,&argv); + MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &mynod); /* parse the command line arguments */ parse_args(argc, argv); - if (mynod == 0) printf("# Using hdf5-io calls.\n"); + if (mynod == 0) + printf("# Using hdf5-io calls.\n"); - /* kindof a weird hack- if the location of the pvfstab file was - * specified on the command line, then spit out this location into - * the appropriate environment variable: */ + /* kindof a weird hack- if the location of the pvfstab file was + * specified on the command line, then spit out this location into + * the appropriate environment variable: */ #if H5_HAVE_SETENV -/* no setenv or unsetenv */ + /* no setenv or unsetenv */ if (opt_pvfstab_set) { - if((setenv("PVFSTAB_FILE", opt_pvfstab, 1)) < 0){ - perror("setenv"); - goto die_jar_jar_die; - } + if ((setenv("PVFSTAB_FILE", opt_pvfstab, 1)) < 0) { + perror("setenv"); + goto die_jar_jar_die; + } } #endif @@ -160,55 +158,56 @@ int main(int argc, char **argv) iter_jump = nprocs * opt_block; /* setup a buffer of data to write */ - if (!(tmp = (char *) malloc((size_t)opt_block + 256))) { - perror("malloc"); - goto die_jar_jar_die; + if (!(tmp = (char *)malloc((size_t)opt_block + 256))) { + perror("malloc"); + goto die_jar_jar_die; } - buf = tmp + 128 - (((long)tmp) % 128); /* align buffer */ + buf = tmp + 128 - (((long)tmp) % 128); /* align buffer */ if (opt_correct) { - /* do the same buffer setup for verifiable data */ - if (!(tmp2 = (char *) malloc((size_t)opt_block + 256))) { - perror("malloc2"); - goto die_jar_jar_die; - } - buf2 = tmp + 128 - (((long)tmp) % 128); + /* do the same buffer setup for verifiable data */ + if (!(tmp2 = (char *)malloc((size_t)opt_block + 256))) { + perror("malloc2"); + goto die_jar_jar_die; + } + buf2 = tmp + 128 - (((long)tmp) % 128); } /* setup file access template with parallel IO access. */ - if (opt_split_vfd){ - hid_t mpio_pl; - - mpio_pl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_mpio(mpio_pl, MPI_COMM_WORLD, MPI_INFO_NULL); - VRFY((ret >= 0), "", H5FATAL); - - /* set optional allocation alignment */ - if (opt_alignment*opt_threshold != 1){ - ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment ); - VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); - } + if (opt_split_vfd) { + hid_t mpio_pl; + + mpio_pl = H5Pcreate(H5P_FILE_ACCESS); + VRFY((acc_tpl >= 0), "", H5FATAL); + ret = H5Pset_fapl_mpio(mpio_pl, MPI_COMM_WORLD, MPI_INFO_NULL); + VRFY((ret >= 0), "", H5FATAL); + + /* set optional allocation alignment */ + if (opt_alignment * opt_threshold != 1) { + ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment); + VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); + } - /* setup file access template */ - acc_tpl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_split(acc_tpl, meta_ext, mpio_pl, raw_ext, mpio_pl); - VRFY((ret >= 0), "H5Pset_fapl_split succeeded", H5FATAL); - ret = H5Pclose(mpio_pl); - VRFY((ret >= 0), "H5Pclose mpio_pl succeeded", H5FATAL); - }else{ - /* setup file access template */ - acc_tpl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL); - VRFY((ret >= 0), "", H5FATAL); - - /* set optional allocation alignment */ - if (opt_alignment*opt_threshold != 1){ - ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment ); - VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); + /* setup file access template */ + acc_tpl = H5Pcreate(H5P_FILE_ACCESS); + VRFY((acc_tpl >= 0), "", H5FATAL); + ret = H5Pset_fapl_split(acc_tpl, meta_ext, mpio_pl, raw_ext, mpio_pl); + VRFY((ret >= 0), "H5Pset_fapl_split succeeded", H5FATAL); + ret = H5Pclose(mpio_pl); + VRFY((ret >= 0), "H5Pclose mpio_pl succeeded", H5FATAL); } + else { + /* setup file access template */ + acc_tpl = H5Pcreate(H5P_FILE_ACCESS); + VRFY((acc_tpl >= 0), "", H5FATAL); + ret = H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL); + VRFY((ret >= 0), "", H5FATAL); + + /* set optional allocation alignment */ + if (opt_alignment * opt_threshold != 1) { + ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment); + VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); + } } h5_fixname_no_suffix(FILENAME[0], acc_tpl, filename, sizeof filename); @@ -219,14 +218,13 @@ int main(int argc, char **argv) /* define a contiquous dataset of opt_iter*nprocs*opt_block chars */ dims[0] = (hsize_t)opt_iter * (hsize_t)nprocs * (hsize_t)opt_block; - sid = H5Screate_simple(RANK, dims, NULL); + sid = H5Screate_simple(RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded", H5FATAL); - dataset = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_CHAR, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_CHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset >= 0), "H5Dcreate2 succeeded", H5FATAL); /* create the memory dataspace and the file dataspace */ - dims[0] = (hsize_t)opt_block; + dims[0] = (hsize_t)opt_block; mem_dataspace = H5Screate_simple(RANK, dims, NULL); VRFY((mem_dataspace >= 0), "", H5FATAL); file_dataspace = H5Dget_space(dataset); @@ -235,48 +233,46 @@ int main(int argc, char **argv) /* now each process writes a block of opt_block chars in round robbin * fashion until the whole dataset is covered. */ - for(j=0; j < opt_iter; j++) { + for (j = 0; j < opt_iter; j++) { /* setup a file dataspace selection */ - start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block)); + start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block)); stride[0] = block[0] = (hsize_t)opt_block; - count[0]= 1; - ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); + count[0] = 1; + ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded", H5FATAL); - if (opt_correct) /* fill in buffer for iteration */ { - for (i=mynod+j, check=buf; i<opt_block; i++,check++) *check=(char)i; - } + if (opt_correct) /* fill in buffer for iteration */ { + for (i = mynod + j, check = buf; i < opt_block; i++, check++) + *check = (char)i; + } - /* discover the starting time of the operation */ - MPI_Barrier(MPI_COMM_WORLD); - stim = MPI_Wtime(); + /* discover the starting time of the operation */ + MPI_Barrier(MPI_COMM_WORLD); + stim = MPI_Wtime(); /* write data */ - ret = H5Dwrite(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, - H5P_DEFAULT, buf); + ret = H5Dwrite(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, H5P_DEFAULT, buf); VRFY((ret >= 0), "H5Dwrite dataset1 succeeded", !H5FATAL); - /* discover the ending time of the operation */ - etim = MPI_Wtime(); + /* discover the ending time of the operation */ + etim = MPI_Wtime(); - write_tim += (etim - stim); + write_tim += (etim - stim); - /* we are done with this "write" iteration */ + /* we are done with this "write" iteration */ } /* close dataset and file */ - ret=H5Dclose(dataset); + ret = H5Dclose(dataset); VRFY((ret >= 0), "H5Dclose succeeded", H5FATAL); - ret=H5Fclose(fid); + ret = H5Fclose(fid); VRFY((ret >= 0), "H5Fclose succeeded", H5FATAL); - - /* wait for everyone to synchronize at this point */ MPI_Barrier(MPI_COMM_WORLD); /* reopen the file for reading */ - fid=H5Fopen(filename,H5F_ACC_RDONLY,acc_tpl); + fid = H5Fopen(filename, H5F_ACC_RDONLY, acc_tpl); VRFY((fid >= 0), "", H5FATAL); /* open the dataset */ @@ -288,119 +284,111 @@ int main(int argc, char **argv) */ /* we are going to repeat the read the same pattern the write used */ - for (j=0; j < opt_iter; j++) { + for (j = 0; j < opt_iter; j++) { /* setup a file dataspace selection */ - start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block)); + start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block)); stride[0] = block[0] = (hsize_t)opt_block; - count[0]= 1; - ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); + count[0] = 1; + ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded", H5FATAL); - /* seek to the appropriate spot give the current iteration and - * rank within the MPI processes */ + /* seek to the appropriate spot give the current iteration and + * rank within the MPI processes */ - /* discover the start time */ - MPI_Barrier(MPI_COMM_WORLD); - stim = MPI_Wtime(); + /* discover the start time */ + MPI_Barrier(MPI_COMM_WORLD); + stim = MPI_Wtime(); /* read in the file data */ - if (!opt_correct){ + if (!opt_correct) { ret = H5Dread(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, H5P_DEFAULT, buf); } - else{ + else { ret = H5Dread(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, H5P_DEFAULT, buf2); } myerrno = errno; /* discover the end time */ - etim = MPI_Wtime(); - read_tim += (etim - stim); + etim = MPI_Wtime(); + read_tim += (etim - stim); VRFY((ret >= 0), "H5Dwrite dataset1 succeeded", !H5FATAL); - - if (ret < 0) HDfprintf(stderr, "node %d, read error, loc = %" PRId64 ": %s\n", - mynod, mynod*opt_block, strerror(myerrno)); + if (ret < 0) + HDfprintf(stderr, "node %d, read error, loc = %" PRId64 ": %s\n", mynod, mynod * opt_block, + strerror(myerrno)); /* if the user wanted to check correctness, compare the write * buffer to the read buffer */ if (opt_correct && memcmp(buf, buf2, (size_t)opt_block)) { - HDfprintf(stderr, "node %d, correctness test failed\n", mynod); - my_correct = 0; - MPI_Allreduce(&my_correct, &correct, 1, MPI_INT, MPI_MIN, - MPI_COMM_WORLD); + HDfprintf(stderr, "node %d, correctness test failed\n", mynod); + my_correct = 0; + MPI_Allreduce(&my_correct, &correct, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD); } /* we are done with this read iteration */ } /* close dataset and file */ - ret=H5Dclose(dataset); + ret = H5Dclose(dataset); VRFY((ret >= 0), "H5Dclose succeeded", H5FATAL); - ret=H5Fclose(fid); + ret = H5Fclose(fid); VRFY((ret >= 0), "H5Fclose succeeded", H5FATAL); - ret=H5Pclose(acc_tpl); + ret = H5Pclose(acc_tpl); VRFY((ret >= 0), "H5Pclose succeeded", H5FATAL); /* compute the read and write times */ - MPI_Allreduce(&read_tim, &max_read_tim, 1, MPI_DOUBLE, MPI_MAX, - MPI_COMM_WORLD); - MPI_Allreduce(&read_tim, &min_read_tim, 1, MPI_DOUBLE, MPI_MIN, - MPI_COMM_WORLD); - MPI_Allreduce(&read_tim, &ave_read_tim, 1, MPI_DOUBLE, MPI_SUM, - MPI_COMM_WORLD); + MPI_Allreduce(&read_tim, &max_read_tim, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); + MPI_Allreduce(&read_tim, &min_read_tim, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); + MPI_Allreduce(&read_tim, &ave_read_tim, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); /* calculate the average from the sum */ ave_read_tim = ave_read_tim / nprocs; - MPI_Allreduce(&write_tim, &max_write_tim, 1, MPI_DOUBLE, MPI_MAX, - MPI_COMM_WORLD); - MPI_Allreduce(&write_tim, &min_write_tim, 1, MPI_DOUBLE, MPI_MIN, - MPI_COMM_WORLD); - MPI_Allreduce(&write_tim, &ave_write_tim, 1, MPI_DOUBLE, MPI_SUM, - MPI_COMM_WORLD); + MPI_Allreduce(&write_tim, &max_write_tim, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); + MPI_Allreduce(&write_tim, &min_write_tim, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); + MPI_Allreduce(&write_tim, &ave_write_tim, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); /* calculate the average from the sum */ ave_write_tim = ave_write_tim / nprocs; /* print out the results on one node */ if (mynod == 0) { - read_bw = (double)((int64_t)(opt_block*nprocs*opt_iter))/(max_read_tim*1000000.0); - write_bw = (double)((int64_t)(opt_block*nprocs*opt_iter))/(max_write_tim*1000000.0); + read_bw = (double)((int64_t)(opt_block * nprocs * opt_iter)) / (max_read_tim * 1000000.0); + write_bw = (double)((int64_t)(opt_block * nprocs * opt_iter)) / (max_write_tim * 1000000.0); - printf("nr_procs = %d, nr_iter = %d, blk_sz = %ld\n", nprocs, - opt_iter, (long)opt_block); + printf("nr_procs = %d, nr_iter = %d, blk_sz = %ld\n", nprocs, opt_iter, (long)opt_block); - printf("# total_size = %ld\n", (long)(opt_block*nprocs*opt_iter)); + printf("# total_size = %ld\n", (long)(opt_block * nprocs * opt_iter)); - printf("# Write: min_time = %f, max_time = %f, mean_time = %f\n", - min_write_tim, max_write_tim, ave_write_tim); - printf("# Read: min_time = %f, max_time = %f, mean_time = %f\n", - min_read_tim, max_read_tim, ave_read_tim); + printf("# Write: min_time = %f, max_time = %f, mean_time = %f\n", min_write_tim, max_write_tim, + ave_write_tim); + printf("# Read: min_time = %f, max_time = %f, mean_time = %f\n", min_read_tim, max_read_tim, + ave_read_tim); - printf("Write bandwidth = %f Mbytes/sec\n", write_bw); - printf("Read bandwidth = %f Mbytes/sec\n", read_bw); + printf("Write bandwidth = %f Mbytes/sec\n", write_bw); + printf("Read bandwidth = %f Mbytes/sec\n", read_bw); - if (opt_correct) { - printf("Correctness test %s.\n", correct ? "passed" : "failed"); - } + if (opt_correct) { + printf("Correctness test %s.\n", correct ? "passed" : "failed"); + } } - die_jar_jar_die: #if H5_HAVE_SETENV -/* no setenv or unsetenv */ + /* no setenv or unsetenv */ /* clear the environment variable if it was set earlier */ - if (opt_pvfstab_set){ - unsetenv("PVFSTAB_FILE"); + if (opt_pvfstab_set) { + unsetenv("PVFSTAB_FILE"); } #endif free(tmp); - if (opt_correct) free(tmp2); + if (opt_correct) + free(tmp2); MPI_Finalize(); - return(0); + return (0); } static int @@ -432,32 +420,30 @@ parse_args(int argc, char **argv) * e.g., -a4096/512 allocate at 4096 bytes * boundary if request size >= 512. */ - { - char *p; + { + char *p; - opt_alignment = (hsize_t)HDatoi(optarg); - if(NULL != (p = (char*)HDstrchr(optarg, '/'))) - opt_threshold = (hsize_t)HDatoi(p + 1); - } - HDfprintf(stdout, - "alignment/threshold=%" PRIuHSIZE "/%" PRIuHSIZE "\n", - opt_alignment, opt_threshold); + opt_alignment = (hsize_t)HDatoi(optarg); + if (NULL != (p = (char *)HDstrchr(optarg, '/'))) + opt_threshold = (hsize_t)HDatoi(p + 1); + } + HDfprintf(stdout, "alignment/threshold=%" PRIuHSIZE "/%" PRIuHSIZE "\n", opt_alignment, + opt_threshold); break; case '2': /* use 2-files, i.e., split file driver */ - opt_split_vfd=1; + opt_split_vfd = 1; /* get meta and raw file extension. */ /* syntax is <raw_ext>,<meta_ext> */ meta_ext = raw_ext = optarg; - while (*raw_ext != '\0'){ - if (*raw_ext == ','){ + while (*raw_ext != '\0') { + if (*raw_ext == ',') { *raw_ext = '\0'; raw_ext++; break; } raw_ext++; } - printf("split-file-vfd used: %s,%s\n", - meta_ext, raw_ext); + printf("split-file-vfd used: %s,%s\n", meta_ext, raw_ext); break; case 'c': /* correctness */ opt_correct = 1; @@ -468,7 +454,7 @@ parse_args(int argc, char **argv) } } - return(0); + return (0); } /* @@ -479,13 +465,12 @@ parse_args(int argc, char **argv) * End: */ -#else /* H5_HAVE_PARALLEL */ +#else /* H5_HAVE_PARALLEL */ /* dummy program since H5_HAVE_PARALLEL is not configured in */ int main(int H5_ATTR_UNUSED argc, char H5_ATTR_UNUSED **argv) { printf("No parallel performance because parallel is not configured in\n"); - return(0); + return (0); } #endif /* H5_HAVE_PARALLEL */ - diff --git a/tools/test/perform/perf_meta.c b/tools/test/perform/perf_meta.c index 77248cc..7ce5792 100644 --- a/tools/test/perform/perf_meta.c +++ b/tools/test/perform/perf_meta.c @@ -21,39 +21,33 @@ #include "h5test.h" #ifdef H5_HAVE_PARALLEL -#define MAINPROCESS (!mpi_rank) /* define process 0 as main process */ -#endif /*H5_HAVE_PARALLEL*/ +#define MAINPROCESS (!mpi_rank) /* define process 0 as main process */ +#endif /*H5_HAVE_PARALLEL*/ /* File_Access_type bits */ -#define FACC_DEFAULT 0x0 /* serial as default */ -#define FACC_MPIO 0x1 /* MPIO */ +#define FACC_DEFAULT 0x0 /* serial as default */ +#define FACC_MPIO 0x1 /* MPIO */ /* Which test to run */ -int RUN_TEST = 0x0; /* all tests as default */ -int TEST_1 = 0x1; /* Test 1 */ -int TEST_2 = 0x2; /* Test 2 */ -int TEST_3 = 0x4; /* Test 3 */ - +int RUN_TEST = 0x0; /* all tests as default */ +int TEST_1 = 0x1; /* Test 1 */ +int TEST_2 = 0x2; /* Test 2 */ +int TEST_3 = 0x4; /* Test 3 */ -const char *FILENAME[] = { - "meta_perf_1", - "meta_perf_2", - "meta_perf_3", - NULL -}; +const char *FILENAME[] = {"meta_perf_1", "meta_perf_2", "meta_perf_3", NULL}; /* Default values for performance. Can be changed through command line options */ -int NUM_DSETS = 16; -int NUM_ATTRS = 8; -int BATCH_ATTRS = 2; -hbool_t flush_dset = FALSE; -hbool_t flush_attr = FALSE; -int nerrors = 0; /* errors count */ -hid_t fapl; +int NUM_DSETS = 16; +int NUM_ATTRS = 8; +int BATCH_ATTRS = 2; +hbool_t flush_dset = FALSE; +hbool_t flush_attr = FALSE; +int nerrors = 0; /* errors count */ +hid_t fapl; /* Data space IDs */ -hid_t space; -hid_t small_space; +hid_t space; +hid_t small_space; /* Performance data */ typedef struct p_time { @@ -68,11 +62,10 @@ typedef struct p_time { /*Test file access type for parallel. MPIO as default */ int facc_type = FACC_DEFAULT; -double retrieve_time(void); -void perf(p_time *perf_t, double start_t, double end_t); -void print_perf(p_time, p_time, p_time); +double retrieve_time(void); +void perf(p_time *perf_t, double start_t, double end_t); +void print_perf(p_time, p_time, p_time); - /*------------------------------------------------------------------------- * Function: parse_options * @@ -91,108 +84,108 @@ parse_options(int argc, char **argv) int t; /* Use default values */ - if(argc==1) - return(0); - - while (--argc){ - if (**(++argv) != '-'){ - break; - }else{ - switch(*(*argv+1)){ - case 'h': /* Help page */ - return(1); - - case 'd': /* Number of datasets */ - NUM_DSETS = atoi((*argv+1)+1); - if (NUM_DSETS < 0){ - nerrors++; - return(1); - } - break; - - case 'a': /* Number of attributes per dataset */ - NUM_ATTRS = atoi((*argv+1)+1); - if (NUM_ATTRS < 0){ - nerrors++; - return(1); - } - break; - - case 'n': /* Number of attributes to be created in batch */ - BATCH_ATTRS = atoi((*argv+1)+1); - if (BATCH_ATTRS < 0){ - nerrors++; - return(1); - } - break; - - case 'm': /* Use the MPI-IO driver */ - facc_type = FACC_MPIO; - break; - - case 'f': /* Call H5Fflush for each dataset or attribute */ - if(!strcmp("a", (*argv+2))) - flush_attr = TRUE; - else if(!strcmp("d", (*argv+2))) - flush_dset = TRUE; - else { - nerrors++; - return(1); - } - break; - - case 't': /* Which test to run */ - t = atoi((*argv+1)+1); - if (t < 1 || t > 3){ - nerrors++; - return(1); - } - if(t == 1) - RUN_TEST |= TEST_1; - else if(t == 2) - RUN_TEST |= TEST_2; - else - RUN_TEST |= TEST_3; - - break; - - default: nerrors++; - return(1); - } - } + if (argc == 1) + return (0); + + while (--argc) { + if (**(++argv) != '-') { + break; + } + else { + switch (*(*argv + 1)) { + case 'h': /* Help page */ + return (1); + + case 'd': /* Number of datasets */ + NUM_DSETS = atoi((*argv + 1) + 1); + if (NUM_DSETS < 0) { + nerrors++; + return (1); + } + break; + + case 'a': /* Number of attributes per dataset */ + NUM_ATTRS = atoi((*argv + 1) + 1); + if (NUM_ATTRS < 0) { + nerrors++; + return (1); + } + break; + + case 'n': /* Number of attributes to be created in batch */ + BATCH_ATTRS = atoi((*argv + 1) + 1); + if (BATCH_ATTRS < 0) { + nerrors++; + return (1); + } + break; + + case 'm': /* Use the MPI-IO driver */ + facc_type = FACC_MPIO; + break; + + case 'f': /* Call H5Fflush for each dataset or attribute */ + if (!strcmp("a", (*argv + 2))) + flush_attr = TRUE; + else if (!strcmp("d", (*argv + 2))) + flush_dset = TRUE; + else { + nerrors++; + return (1); + } + break; + + case 't': /* Which test to run */ + t = atoi((*argv + 1) + 1); + if (t < 1 || t > 3) { + nerrors++; + return (1); + } + if (t == 1) + RUN_TEST |= TEST_1; + else if (t == 2) + RUN_TEST |= TEST_2; + else + RUN_TEST |= TEST_3; + + break; + + default: + nerrors++; + return (1); + } + } } /*while*/ /* Check valid values */ #ifndef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) - { + if (facc_type == FACC_MPIO) { nerrors++; - return(1); + return (1); } #endif /*H5_HAVE_PARALLEL*/ - if(NUM_ATTRS && !BATCH_ATTRS) + if (NUM_ATTRS && !BATCH_ATTRS) NUM_ATTRS = 0; - if(!NUM_ATTRS && BATCH_ATTRS) + if (!NUM_ATTRS && BATCH_ATTRS) BATCH_ATTRS = 0; - if(!NUM_DSETS) { + if (!NUM_DSETS) { nerrors++; - return(1); + return (1); } - if(NUM_ATTRS && BATCH_ATTRS) { - if(BATCH_ATTRS > NUM_ATTRS || NUM_ATTRS % BATCH_ATTRS) { - nerrors++; - return(1); + if (NUM_ATTRS && BATCH_ATTRS) { + if (BATCH_ATTRS > NUM_ATTRS || NUM_ATTRS % BATCH_ATTRS) { + nerrors++; + return (1); } } - return(0); + return (0); } - /*------------------------------------------------------------------------- * Function: usage * @@ -212,39 +205,38 @@ usage(void) "[-a<num_attributes>]\n" "\t[-n<batch_attributes>] [-f<option>] [-t<test>]\n"); printf("\t-h" - "\t\t\thelp page.\n"); + "\t\t\thelp page.\n"); printf("\t-m" - "\t\t\tset MPIO as the file driver when parallel HDF5\n" - "\t\t\t\tis enabled. -m must be specified\n" - "\t\t\t\twhen running parallel program.\n"); + "\t\t\tset MPIO as the file driver when parallel HDF5\n" + "\t\t\t\tis enabled. -m must be specified\n" + "\t\t\t\twhen running parallel program.\n"); printf("\t-d<num_datasets>" - "\tset number of datasets for meta data \n" - "\t\t\t\tperformance test\n"); + "\tset number of datasets for meta data \n" + "\t\t\t\tperformance test\n"); printf("\t-a<num_attributes>" - "\tset number of attributes per dataset for meta \n" - "\t\t\t\tdata performance test.\n"); + "\tset number of attributes per dataset for meta \n" + "\t\t\t\tdata performance test.\n"); printf("\t-n<batch_attributes>" - "\tset batch number of attributes for dataset \n" - "\t\t\t\tfor meta data performance test.\n"); + "\tset batch number of attributes for dataset \n" + "\t\t\t\tfor meta data performance test.\n"); printf("\t-f<option>" - "\t\tflush data to disk after closing a dataset \n" - "\t\t\t\tor attribute. Valid options are \"d\" for \n" - "\t\t\t\tdataset, \"a\" for attribute. Disabled is \n" - "\t\t\t\tthe default.\n"); + "\t\tflush data to disk after closing a dataset \n" + "\t\t\t\tor attribute. Valid options are \"d\" for \n" + "\t\t\t\tdataset, \"a\" for attribute. Disabled is \n" + "\t\t\t\tthe default.\n"); printf("\t-t<tests>" - "\t\trun specific test. Give only one number each \n" - "\t\t\t\ttime. i.e. \"-t1 -t3\" will run test 1 and 3. \n" - "\t\t\t\tDefault is all three tests. The 3 tests are: \n\n" - "\t\t\t\t1. Create <num_attributes> attributes for each \n" - "\t\t\t\t of <num_datasets> existing datasets.\n" - "\t\t\t\t2. Create <num_attributes> attributes for each \n" - "\t\t\t\t of <num_datasets> new datasets.\n" - "\t\t\t\t3. Create <batch_attributes> attributes for \n" - "\t\t\t\t each of <num_dataset> new datasets for \n" - "\t\t\t\t <num_attributes>/<batch_attributes> times.\n"); + "\t\trun specific test. Give only one number each \n" + "\t\t\t\ttime. i.e. \"-t1 -t3\" will run test 1 and 3. \n" + "\t\t\t\tDefault is all three tests. The 3 tests are: \n\n" + "\t\t\t\t1. Create <num_attributes> attributes for each \n" + "\t\t\t\t of <num_datasets> existing datasets.\n" + "\t\t\t\t2. Create <num_attributes> attributes for each \n" + "\t\t\t\t of <num_datasets> new datasets.\n" + "\t\t\t\t3. Create <batch_attributes> attributes for \n" + "\t\t\t\t each of <num_dataset> new datasets for \n" + "\t\t\t\t <num_attributes>/<batch_attributes> times.\n"); } - /*------------------------------------------------------------------------- * Function: create_dspace * @@ -264,20 +256,20 @@ usage(void) static herr_t create_dspace(void) { - hsize_t dims[2]; - hsize_t small_dims[2]; + hsize_t dims[2]; + hsize_t small_dims[2]; /* Create the data space */ dims[0] = 256; dims[1] = 512; - if((space = H5Screate_simple(2, dims, NULL)) < 0) - goto error; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + goto error; /* Create a small data space for attributes */ small_dims[0] = 16; small_dims[1] = 8; - if((small_space = H5Screate_simple(2, small_dims, NULL)) < 0) - goto error; + if ((small_space = H5Screate_simple(2, small_dims, NULL)) < 0) + goto error; return 0; @@ -285,7 +277,6 @@ error: return -1; } - /*------------------------------------------------------------------------- * Function: create_dsets * @@ -305,20 +296,20 @@ error: static herr_t create_dsets(hid_t file) { - hid_t dataset; - char dset_name[32]; - int i; + hid_t dataset; + char dset_name[32]; + int i; /* * Create a dataset using the default dataset creation properties. */ - for(i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "dataset %d", i); - if((dataset = H5Dcreate2(file, dset_name, H5T_NATIVE_DOUBLE, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < NUM_DSETS; i++) { + HDsprintf(dset_name, "dataset %d", i); + if ((dataset = H5Dcreate2(file, dset_name, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; } /* end for */ @@ -326,10 +317,8 @@ create_dsets(hid_t file) error: return -1; - } - /*------------------------------------------------------------------------- * Function: create_attrs_1 * @@ -349,63 +338,62 @@ error: static herr_t create_attrs_1(void) { - hid_t file, dataset, attr; - char filename[128]; - char dset_name[64]; - char attr_name[128]; - int i, j; - p_time attr_t = {0, 0, 0, 1000000, 0, ""}; - p_time open_t = {0, 0, 0, 1000000, 0, "H5Dopen2"}; - p_time close_t = {0, 0, 0, 1000000, 0, ""}; + hid_t file, dataset, attr; + char filename[128]; + char dset_name[64]; + char attr_name[128]; + int i, j; + p_time attr_t = {0, 0, 0, 1000000, 0, ""}; + p_time open_t = {0, 0, 0, 1000000, 0, "H5Dopen2"}; + p_time close_t = {0, 0, 0, 1000000, 0, ""}; #ifdef H5_HAVE_PARALLEL /* need the rank for printing data */ - int mpi_rank; - if(facc_type == FACC_MPIO) + int mpi_rank; + if (facc_type == FACC_MPIO) MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); #endif /*H5_HAVE_PARALLEL*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, - fapl)) < 0) - goto error; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; - if(create_dsets(file) < 0) - goto error; + if (create_dsets(file) < 0) + goto error; /* * Create all(user specifies the number) attributes for each dataset */ - for(i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "dataset %d", i); + for (i = 0; i < NUM_DSETS; i++) { + HDsprintf(dset_name, "dataset %d", i); open_t.start = retrieve_time(); - if((dataset = H5Dopen2(file, dset_name, H5P_DEFAULT)) < 0) - goto error; - perf(&open_t, open_t.start, retrieve_time()); + if ((dataset = H5Dopen2(file, dset_name, H5P_DEFAULT)) < 0) + goto error; + perf(&open_t, open_t.start, retrieve_time()); - for(j = 0; j < NUM_ATTRS; j++) { + for (j = 0; j < NUM_ATTRS; j++) { HDsprintf(attr_name, "all attrs for each dset %d", j); attr_t.start = retrieve_time(); - if((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, - small_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr) < 0) + if (H5Aclose(attr) < 0) goto error; perf(&attr_t, attr_t.start, retrieve_time()); - if(flush_attr && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + if (flush_attr && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; - } /* end for */ + } /* end for */ - close_t.start = retrieve_time(); - if(H5Dclose(dataset) < 0) + close_t.start = retrieve_time(); + if (H5Dclose(dataset) < 0) goto error; - perf(&close_t, close_t.start, retrieve_time()); - if(flush_dset && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + perf(&close_t, close_t.start, retrieve_time()); + if (flush_dset && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; } /* end for */ - if(facc_type == FACC_MPIO) { + if (facc_type == FACC_MPIO) { #ifdef H5_HAVE_PARALLEL MPI_Barrier(MPI_COMM_WORLD); #endif /*H5_HAVE_PARALLEL*/ @@ -413,21 +401,22 @@ create_attrs_1(void) #ifdef H5_HAVE_PARALLEL if (facc_type == FACC_DEFAULT || (facc_type != FACC_DEFAULT && MAINPROCESS)) /* only process 0 reports */ -#endif /*H5_HAVE_PARALLEL*/ +#endif /*H5_HAVE_PARALLEL*/ { /* Calculate the average time */ open_t.avg = open_t.total / NUM_DSETS; close_t.avg = close_t.total / NUM_DSETS; - if(NUM_ATTRS) - attr_t.avg = attr_t.total / (NUM_ATTRS*NUM_DSETS); + if (NUM_ATTRS) + attr_t.avg = attr_t.total / (NUM_ATTRS * NUM_DSETS); /* Print out the performance result */ - HDfprintf(stderr, "1. Create %d attributes for each of %d existing datasets\n", - NUM_ATTRS, NUM_DSETS); + HDfprintf(stderr, "1. Create %d attributes for each of %d existing datasets\n", NUM_ATTRS, + NUM_DSETS); print_perf(open_t, close_t, attr_t); } - if (H5Fclose(file) < 0) goto error; + if (H5Fclose(file) < 0) + goto error; return 0; @@ -435,7 +424,6 @@ error: return -1; } - /*------------------------------------------------------------------------- * Function: create_attrs_2 * @@ -455,61 +443,61 @@ error: static herr_t create_attrs_2(void) { - hid_t file, dataset, attr; - char filename[128]; - char dset_name[64]; - char attr_name[128]; - int i, j; - p_time attr_t = {0, 0, 0, 1000000, 0, ""}; - p_time create_t = {0, 0, 0, 1000000, 0, "H5Dcreate2"}; - p_time close_t = {0, 0, 0, 1000000, 0, ""}; + hid_t file, dataset, attr; + char filename[128]; + char dset_name[64]; + char attr_name[128]; + int i, j; + p_time attr_t = {0, 0, 0, 1000000, 0, ""}; + p_time create_t = {0, 0, 0, 1000000, 0, "H5Dcreate2"}; + p_time close_t = {0, 0, 0, 1000000, 0, ""}; #ifdef H5_HAVE_PARALLEL /* need the rank for printing data */ - int mpi_rank; - if(facc_type == FACC_MPIO) + int mpi_rank; + if (facc_type == FACC_MPIO) MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); #endif /*H5_HAVE_PARALLEL*/ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto error; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; /* * Create all(user specifies the number) attributes for each new dataset */ - for(i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "dataset %d", i); + for (i = 0; i < NUM_DSETS; i++) { + HDsprintf(dset_name, "dataset %d", i); create_t.start = retrieve_time(); - if((dataset = H5Dcreate2(file, dset_name, H5T_NATIVE_DOUBLE, - space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, dset_name, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - perf(&create_t, create_t.start, retrieve_time()); + perf(&create_t, create_t.start, retrieve_time()); - for(j = 0; j < NUM_ATTRS; j++) { + for (j = 0; j < NUM_ATTRS; j++) { HDsprintf(attr_name, "all attrs for each dset %d", j); attr_t.start = retrieve_time(); - if((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, - small_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr) < 0) + if (H5Aclose(attr) < 0) goto error; perf(&attr_t, attr_t.start, retrieve_time()); - if(flush_attr && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + if (flush_attr && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; - } /* end for */ + } /* end for */ - close_t.start = retrieve_time(); - if(H5Dclose(dataset) < 0) + close_t.start = retrieve_time(); + if (H5Dclose(dataset) < 0) goto error; - perf(&close_t, close_t.start, retrieve_time()); - if(flush_dset && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + perf(&close_t, close_t.start, retrieve_time()); + if (flush_dset && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; } /* end for */ #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) + if (facc_type == FACC_MPIO) MPI_Barrier(MPI_COMM_WORLD); #endif /*H5_HAVE_PARALLEL*/ @@ -521,16 +509,16 @@ create_attrs_2(void) /* Calculate the average time */ create_t.avg = create_t.total / NUM_DSETS; close_t.avg = close_t.total / NUM_DSETS; - if(NUM_ATTRS) - attr_t.avg = attr_t.total / (NUM_ATTRS*NUM_DSETS); + if (NUM_ATTRS) + attr_t.avg = attr_t.total / (NUM_ATTRS * NUM_DSETS); /* Print out the performance result */ - HDfprintf(stderr, "2. Create %d attributes for each of %d new datasets\n", - NUM_ATTRS, NUM_DSETS); + HDfprintf(stderr, "2. Create %d attributes for each of %d new datasets\n", NUM_ATTRS, NUM_DSETS); print_perf(create_t, close_t, attr_t); } - if (H5Fclose(file) < 0) goto error; + if (H5Fclose(file) < 0) + goto error; return 0; @@ -538,7 +526,6 @@ error: return -1; } - /*------------------------------------------------------------------------- * Function: create_attrs_3 * @@ -559,70 +546,69 @@ error: static herr_t create_attrs_3(void) { - hid_t file, dataset, attr; - char filename[128]; - char dset_name[64]; - char attr_name[128]; - int loop_num; - int i, j, k; - p_time attr_t = {0, 0, 0, 1000000, 0, ""}; - p_time open_t = {0, 0, 0, 1000000, 0, "H5Dopen2"}; - p_time close_t = {0, 0, 0, 1000000, 0, ""}; + hid_t file, dataset, attr; + char filename[128]; + char dset_name[64]; + char attr_name[128]; + int loop_num; + int i, j, k; + p_time attr_t = {0, 0, 0, 1000000, 0, ""}; + p_time open_t = {0, 0, 0, 1000000, 0, "H5Dopen2"}; + p_time close_t = {0, 0, 0, 1000000, 0, ""}; #ifdef H5_HAVE_PARALLEL /* need the rank for printing data */ - int mpi_rank; - if(facc_type == FACC_MPIO) + int mpi_rank; + if (facc_type == FACC_MPIO) MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); #endif /*H5_HAVE_PARALLEL*/ h5_fixname(FILENAME[2], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, - fapl)) < 0) - goto error; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; - if(create_dsets(file) < 0) - goto error; + if (create_dsets(file) < 0) + goto error; /* * Create some(user specifies the number) attributes for each dataset * in a loop */ - loop_num = NUM_ATTRS/BATCH_ATTRS; + loop_num = NUM_ATTRS / BATCH_ATTRS; - for(i = 0; i < loop_num; i++) { - for(j = 0; j < NUM_DSETS; j++) { + for (i = 0; i < loop_num; i++) { + for (j = 0; j < NUM_DSETS; j++) { HDsprintf(dset_name, "dataset %d", j); open_t.start = retrieve_time(); - if((dataset = H5Dopen2(file, dset_name, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, dset_name, H5P_DEFAULT)) < 0) goto error; perf(&open_t, open_t.start, retrieve_time()); - for(k = 0; k < BATCH_ATTRS; k++) { + for (k = 0; k < BATCH_ATTRS; k++) { HDsprintf(attr_name, "some attrs for each dset %d %d", i, k); attr_t.start = retrieve_time(); - if((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, - small_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr) < 0) + if (H5Aclose(attr) < 0) goto error; perf(&attr_t, attr_t.start, retrieve_time()); - if(flush_attr && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + if (flush_attr && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; } /* end for */ close_t.start = retrieve_time(); - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; perf(&close_t, close_t.start, retrieve_time()); - if(flush_dset && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + if (flush_dset && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) + if (facc_type == FACC_MPIO) MPI_Barrier(MPI_COMM_WORLD); #endif /*H5_HAVE_PARALLEL*/ @@ -632,17 +618,18 @@ create_attrs_3(void) #endif /*H5_HAVE_PARALLEL*/ { /* Calculate the average time */ - open_t.avg = open_t.total / (loop_num*NUM_DSETS); - close_t.avg = close_t.total / (loop_num*NUM_DSETS); - attr_t.avg = attr_t.total / (NUM_ATTRS*NUM_DSETS); + open_t.avg = open_t.total / (loop_num * NUM_DSETS); + close_t.avg = close_t.total / (loop_num * NUM_DSETS); + attr_t.avg = attr_t.total / (NUM_ATTRS * NUM_DSETS); /* Print out the performance result */ HDfprintf(stderr, "3. Create %d attributes for each of %d existing datasets for %d times\n", - BATCH_ATTRS, NUM_DSETS, loop_num); + BATCH_ATTRS, NUM_DSETS, loop_num); print_perf(open_t, close_t, attr_t); } - if (H5Fclose(file) < 0) goto error; + if (H5Fclose(file) < 0) + goto error; return 0; @@ -650,7 +637,6 @@ error: return -1; } - /*------------------------------------------------------------------------- * Function: retrieve_time * @@ -663,22 +649,23 @@ error: * *------------------------------------------------------------------------- */ -double retrieve_time(void) +double +retrieve_time(void) { #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_DEFAULT) { + if (facc_type == FACC_DEFAULT) { #endif /*H5_HAVE_PARALLEL*/ struct timeval t; HDgettimeofday(&t, NULL); return ((double)t.tv_sec + (double)t.tv_usec / 1000000); #ifdef H5_HAVE_PARALLEL - } else { + } + else { return MPI_Wtime(); } #endif /*H5_HAVE_PARALLEL*/ } - /*------------------------------------------------------------------------- * Function: perf * @@ -692,12 +679,13 @@ double retrieve_time(void) * *------------------------------------------------------------------------- */ -void perf(p_time *perf_t, double start_t, double end_t) +void +perf(p_time *perf_t, double start_t, double end_t) { - double t = end_t - start_t; + double t = end_t - start_t; #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) { + if (facc_type == FACC_MPIO) { double reduced_t; double t_max, t_min; int mpi_size, mpi_rank; @@ -706,36 +694,33 @@ void perf(p_time *perf_t, double start_t, double end_t) MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Barrier(MPI_COMM_WORLD); - MPI_Reduce(&t, &reduced_t, 1, MPI_DOUBLE, MPI_SUM, 0, - MPI_COMM_WORLD); + MPI_Reduce(&t, &reduced_t, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); reduced_t /= mpi_size; - MPI_Reduce(&t, &t_max, 1, MPI_DOUBLE, MPI_MAX, 0, - MPI_COMM_WORLD); - MPI_Reduce(&t, &t_min, 1, MPI_DOUBLE, MPI_MIN, 0, - MPI_COMM_WORLD); + MPI_Reduce(&t, &t_max, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + MPI_Reduce(&t, &t_min, 1, MPI_DOUBLE, MPI_MIN, 0, MPI_COMM_WORLD); if (MAINPROCESS) { perf_t->total += reduced_t; - if(t_max > perf_t->max) - perf_t->max = t_max; - if(t_min < perf_t->min) - perf_t->min = t_min; + if (t_max > perf_t->max) + perf_t->max = t_max; + if (t_min < perf_t->min) + perf_t->min = t_min; } - } else + } + else #endif /*H5_HAVE_PARALLEL*/ { - perf_t->total += t; + perf_t->total += t; - if(t > perf_t->max) - perf_t->max = t; - if(t < perf_t->min) - perf_t->min = t; + if (t > perf_t->max) + perf_t->max = t; + if (t < perf_t->min) + perf_t->min = t; } } - /*------------------------------------------------------------------------- * Function: print_perf * @@ -748,18 +733,18 @@ void perf(p_time *perf_t, double start_t, double end_t) * *------------------------------------------------------------------------- */ -void print_perf(p_time open_t, p_time close_t, p_time attr_t) +void +print_perf(p_time open_t, p_time close_t, p_time attr_t) { - HDfprintf(stderr, "\t%s:\t\tavg=%.6fs;\tmax=%.6fs;\tmin=%.6fs\n", - open_t.func, open_t.avg, open_t.max, open_t.min); - HDfprintf(stderr, "\tH5Dclose:\t\tavg=%.6fs;\tmax=%.6fs;\tmin=%.6fs\n", - close_t.avg, close_t.max, close_t.min); - if(NUM_ATTRS) - HDfprintf(stderr, "\tH5A(create & close):\tavg=%.6fs;\tmax=%.6fs;\tmin=%.6fs\n", - attr_t.avg, attr_t.max, attr_t.min); + HDfprintf(stderr, "\t%s:\t\tavg=%.6fs;\tmax=%.6fs;\tmin=%.6fs\n", open_t.func, open_t.avg, open_t.max, + open_t.min); + HDfprintf(stderr, "\tH5Dclose:\t\tavg=%.6fs;\tmax=%.6fs;\tmin=%.6fs\n", close_t.avg, close_t.max, + close_t.min); + if (NUM_ATTRS) + HDfprintf(stderr, "\tH5A(create & close):\tavg=%.6fs;\tmax=%.6fs;\tmin=%.6fs\n", attr_t.avg, + attr_t.max, attr_t.min); } - /*------------------------------------------------------------------------- * Function: main * @@ -780,16 +765,16 @@ int main(int argc, char **argv) { #ifdef H5_HAVE_PARALLEL - int mpi_size, mpi_rank; /* mpi variables */ -#endif /*H5_HAVE_PARALLEL*/ + int mpi_size, mpi_rank; /* mpi variables */ +#endif /*H5_HAVE_PARALLEL*/ - if(parse_options(argc, argv) != 0) { - usage(); - return 0; + if (parse_options(argc, argv) != 0) { + usage(); + return 0; } #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) { + if (facc_type == FACC_MPIO) { MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -801,33 +786,36 @@ main(int argc, char **argv) #endif /*H5_HAVE_PARALLEL*/ HDfprintf(stderr, "\t\tPerformance result of metadata for datasets and attributes\n\n"); - fapl = H5Pcreate (H5P_FILE_ACCESS); + fapl = H5Pcreate(H5P_FILE_ACCESS); #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) + if (facc_type == FACC_MPIO) H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, MPI_INFO_NULL); #endif /*H5_HAVE_PARALLEL*/ - nerrors += create_dspace() < 0 ?1:0; + nerrors += create_dspace() < 0 ? 1 : 0; - if((RUN_TEST & TEST_1) || !RUN_TEST) - nerrors += create_attrs_1() < 0 ?1:0; - if((RUN_TEST & TEST_2) || !RUN_TEST) - nerrors += create_attrs_2() < 0 ?1:0; - if(((RUN_TEST & TEST_3) || !RUN_TEST) && BATCH_ATTRS && NUM_ATTRS) - nerrors += create_attrs_3() < 0 ?1:0; + if ((RUN_TEST & TEST_1) || !RUN_TEST) + nerrors += create_attrs_1() < 0 ? 1 : 0; + if ((RUN_TEST & TEST_2) || !RUN_TEST) + nerrors += create_attrs_2() < 0 ? 1 : 0; + if (((RUN_TEST & TEST_3) || !RUN_TEST) && BATCH_ATTRS && NUM_ATTRS) + nerrors += create_attrs_3() < 0 ? 1 : 0; - if (H5Sclose(space) < 0) goto error; - if (H5Sclose(small_space) < 0) goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Sclose(small_space) < 0) + goto error; h5_clean_files(FILENAME, fapl); #ifdef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) + if (facc_type == FACC_MPIO) /* MPI_Finalize must be called AFTER H5close which may use MPI calls */ MPI_Finalize(); #endif /*H5_HAVE_PARALLEL*/ - if (nerrors) goto error; + if (nerrors) + goto error; #ifdef H5_HAVE_PARALLEL if (facc_type != FACC_DEFAULT && MAINPROCESS) #endif /*H5_HAVE_PARALLEL*/ @@ -835,14 +823,12 @@ main(int argc, char **argv) return 0; - error: +error: nerrors = MAX(1, nerrors); #ifdef H5_HAVE_PARALLEL if (facc_type != FACC_DEFAULT && MAINPROCESS) #endif /*H5_HAVE_PARALLEL*/ - printf("***** %d PERFORMANCE TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + printf("***** %d PERFORMANCE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return 1; } - diff --git a/tools/test/perform/pio_engine.c b/tools/test/perform/pio_engine.c index cdd698e..4e690d5 100644 --- a/tools/test/perform/pio_engine.c +++ b/tools/test/perform/pio_engine.c @@ -36,64 +36,65 @@ #include <mpi.h> -#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ -# include <mpio.h> -#endif /* !MPI_FILE_NULL */ +#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ +#include <mpio.h> +#endif /* !MPI_FILE_NULL */ #include "pio_perf.h" /* Macro definitions */ #if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 6 -# define H5DCREATE(fd, name, type, space, dcpl) H5Dcreate(fd, name, type, space, dcpl) -# define H5DOPEN(fd, name) H5Dopen(fd, name) +#define H5DCREATE(fd, name, type, space, dcpl) H5Dcreate(fd, name, type, space, dcpl) +#define H5DOPEN(fd, name) H5Dopen(fd, name) #else -# define H5DCREATE(fd, name, type, space, dcpl) H5Dcreate2(fd, name, type, space, H5P_DEFAULT, dcpl, H5P_DEFAULT) -# define H5DOPEN(fd, name) H5Dopen2(fd, name, H5P_DEFAULT) +#define H5DCREATE(fd, name, type, space, dcpl) \ + H5Dcreate2(fd, name, type, space, H5P_DEFAULT, dcpl, H5P_DEFAULT) +#define H5DOPEN(fd, name) H5Dopen2(fd, name, H5P_DEFAULT) #endif /* sizes of various items. these sizes won't change during program execution */ /* The following three must have the same type */ -#define ELMT_H5_TYPE H5T_NATIVE_UCHAR +#define ELMT_H5_TYPE H5T_NATIVE_UCHAR -#define GOTOERROR(errcode) { ret_code = errcode; goto done; } -#define ERRMSG(mesg) { \ - HDfprintf(stderr, "Proc %d: ", pio_mpi_rank_g); \ - HDfprintf(stderr, "*** Assertion failed (%s) at line %4d in %s\n", \ - mesg, (int)__LINE__, __FILE__); \ -} +#define GOTOERROR(errcode) \ + { \ + ret_code = errcode; \ + goto done; \ + } +#define ERRMSG(mesg) \ + { \ + HDfprintf(stderr, "Proc %d: ", pio_mpi_rank_g); \ + HDfprintf(stderr, "*** Assertion failed (%s) at line %4d in %s\n", mesg, (int)__LINE__, __FILE__); \ + } /* verify: if val is false (0), print mesg. */ -#define VRFY(val, mesg) do { \ - if (!val) { \ - ERRMSG(mesg); \ - GOTOERROR(FAIL); \ - } \ -} while(0) - +#define VRFY(val, mesg) \ + do { \ + if (!val) { \ + ERRMSG(mesg); \ + GOTOERROR(FAIL); \ + } \ + } while (0) /* POSIX I/O macros */ #ifdef H5_HAVE_WIN32_API /* Can't link against the library, so this test will use the older, non-Unicode * _open() call on Windows. */ -#define HDopen(S,F,...) _open(S, F | _O_BINARY, __VA_ARGS__) +#define HDopen(S, F, ...) _open(S, F | _O_BINARY, __VA_ARGS__) #endif /* H5_HAVE_WIN32_API */ -#define POSIXCREATE(fn) HDopen(fn, O_CREAT|O_TRUNC|O_RDWR, 0600) -#define POSIXOPEN(fn, F) HDopen(fn, F, 0600) -#define POSIXCLOSE(F) HDclose(F) -#define POSIXSEEK(F,L) HDlseek(F, L, SEEK_SET) -#define POSIXWRITE(F,B,S) HDwrite(F,B,S) -#define POSIXREAD(F,B,S) HDread(F,B,S) - -enum { - PIO_CREATE = 1, - PIO_WRITE = 2, - PIO_READ = 4 -}; +#define POSIXCREATE(fn) HDopen(fn, O_CREAT | O_TRUNC | O_RDWR, 0600) +#define POSIXOPEN(fn, F) HDopen(fn, F, 0600) +#define POSIXCLOSE(F) HDclose(F) +#define POSIXSEEK(F, L) HDlseek(F, L, SEEK_SET) +#define POSIXWRITE(F, B, S) HDwrite(F, B, S) +#define POSIXREAD(F, B, S) HDread(F, B, S) + +enum { PIO_CREATE = 1, PIO_WRITE = 2, PIO_READ = 4 }; /* Global variables */ -static int clean_file_g = -1; /*whether to cleanup temporary test */ +static int clean_file_g = -1; /*whether to cleanup temporary test */ /*files. -1 is not defined; */ /*0 is no cleanup; 1 is do cleanup */ @@ -104,32 +105,30 @@ static int clean_file_g = -1; /*whether to cleanup temporary test */ * is about the best guess. */ #ifndef HDF5_PARAPREFIX -# define HDF5_PARAPREFIX "" -#endif /* !HDF5_PARAPREFIX */ +#define HDF5_PARAPREFIX "" +#endif /* !HDF5_PARAPREFIX */ #ifndef MIN -# define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif /* !MIN */ +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif /* !MIN */ /* the different types of file descriptors we can expect */ typedef union _file_descr { - int posixfd; /* POSIX file handle*/ - MPI_File mpifd; /* MPI file */ - hid_t h5fd; /* HDF5 file */ + int posixfd; /* POSIX file handle*/ + MPI_File mpifd; /* MPI file */ + hid_t h5fd; /* HDF5 file */ } file_descr; /* local functions */ -static char *pio_create_filename(iotype iot, const char *base_name, - char *fullname, size_t size); -static herr_t do_write(results *res, file_descr *fd, parameters *parms, - long ndsets, off_t nelmts, size_t buf_size, void *buffer); -static herr_t do_read(results *res, file_descr *fd, parameters *parms, - long ndsets, off_t nelmts, size_t buf_size, void *buffer /*out*/); -static herr_t do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, - int flags); +static char * pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t size); +static herr_t do_write(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nelmts, + size_t buf_size, void *buffer); +static herr_t do_read(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nelmts, + size_t buf_size, void *buffer /*out*/); +static herr_t do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags); static herr_t do_fclose(iotype iot, file_descr *fd); -static void do_cleanupfile(iotype iot, char *fname); -static off_t sqrto(off_t); +static void do_cleanupfile(iotype iot, char *fname); +static off_t sqrto(off_t); /* * Function: do_pio @@ -139,32 +138,32 @@ static off_t sqrto(off_t); * Modifications: * Added 2D testing (Christian Chilan, 10. August 2005) */ - results +results do_pio(parameters param) { /* return codes */ - herr_t ret_code = 0; /*return code */ - results res; - - file_descr fd; - iotype iot; - - char fname[FILENAME_MAX]; - long nf; - long ndsets; - off_t nbytes; /*number of bytes per dataset */ - off_t snbytes; /*general dataset size */ - /*for 1D, it is the actual dataset size */ - /*for 2D, it is the size of a side of the dataset square */ - char *buffer = NULL; /*data buffer pointer */ - size_t buf_size; /*general buffer size in bytes */ - /*for 1D, it is the actual buffer size */ - /*for 2D, it is the length of the buffer rectangle */ - size_t blk_size; /*data block size in bytes */ - size_t bsize; /*actual buffer size */ + herr_t ret_code = 0; /*return code */ + results res; + + file_descr fd; + iotype iot; + + char fname[FILENAME_MAX]; + long nf; + long ndsets; + off_t nbytes; /*number of bytes per dataset */ + off_t snbytes; /*general dataset size */ + /*for 1D, it is the actual dataset size */ + /*for 2D, it is the size of a side of the dataset square */ + char * buffer = NULL; /*data buffer pointer */ + size_t buf_size; /*general buffer size in bytes */ + /*for 1D, it is the actual buffer size */ + /*for 2D, it is the length of the buffer rectangle */ + size_t blk_size; /*data block size in bytes */ + size_t bsize; /*actual buffer size */ /* HDF5 variables */ - herr_t hrc; /*HDF5 return code */ + herr_t hrc; /*HDF5 return code */ /* Sanity check parameters */ @@ -173,7 +172,7 @@ do_pio(parameters param) switch (iot) { case MPIO: - fd.mpifd = MPI_FILE_NULL; + fd.mpifd = MPI_FILE_NULL; res.timers = io_time_new(MPI_CLOCK); break; case POSIXIO: @@ -181,7 +180,7 @@ do_pio(parameters param) res.timers = io_time_new(MPI_CLOCK); break; case PHDF5: - fd.h5fd = -1; + fd.h5fd = -1; res.timers = io_time_new(MPI_CLOCK); break; default: @@ -190,168 +189,158 @@ do_pio(parameters param) GOTOERROR(FAIL); } - ndsets = param.num_dsets; /* number of datasets per file */ - nbytes = param.num_bytes; /* number of bytes per dataset */ + ndsets = param.num_dsets; /* number of datasets per file */ + nbytes = param.num_bytes; /* number of bytes per dataset */ buf_size = param.buf_size; blk_size = param.blk_size; - if (!param.dim2d){ + if (!param.dim2d) { snbytes = nbytes; /* General dataset size */ - bsize = buf_size; /* Actual buffer size */ + bsize = buf_size; /* Actual buffer size */ } else { - snbytes = sqrto(nbytes); /* General dataset size */ - bsize = buf_size * blk_size; /* Actual buffer size */ + snbytes = sqrto(nbytes); /* General dataset size */ + bsize = buf_size * blk_size; /* Actual buffer size */ } - if (param.num_files < 0 ) { - HDfprintf(stderr, - "number of files must be >= 0 (%ld)\n", - param.num_files); - GOTOERROR(FAIL); + if (param.num_files < 0) { + HDfprintf(stderr, "number of files must be >= 0 (%ld)\n", param.num_files); + GOTOERROR(FAIL); } - if (ndsets < 0 ) { - HDfprintf(stderr, - "number of datasets per file must be >= 0 (%ld)\n", - ndsets); - GOTOERROR(FAIL); + if (ndsets < 0) { + HDfprintf(stderr, "number of datasets per file must be >= 0 (%ld)\n", ndsets); + GOTOERROR(FAIL); } - if (param.num_procs <= 0 ) { - HDfprintf(stderr, - "maximum number of process to use must be > 0 (%d)\n", - param.num_procs); - GOTOERROR(FAIL); + if (param.num_procs <= 0) { + HDfprintf(stderr, "maximum number of process to use must be > 0 (%d)\n", param.num_procs); + GOTOERROR(FAIL); } /* Validate transfer buffer size & block size*/ - if(blk_size<=0) { - HDfprintf(stderr, - "Transfer block size (%zu) must be > 0\n", blk_size); - GOTOERROR(FAIL); - } - if(buf_size<=0) { - HDfprintf(stderr, - "Transfer buffer size (%zu) must be > 0\n", buf_size); - GOTOERROR(FAIL); + if (blk_size <= 0) { + HDfprintf(stderr, "Transfer block size (%zu) must be > 0\n", blk_size); + GOTOERROR(FAIL); } - if ((buf_size % blk_size) != 0){ - HDfprintf(stderr, - "Transfer buffer size (%zu) must be a multiple of the " - "interleaved I/O block size (%zu)\n", - buf_size, blk_size); - GOTOERROR(FAIL); + if (buf_size <= 0) { + HDfprintf(stderr, "Transfer buffer size (%zu) must be > 0\n", buf_size); + GOTOERROR(FAIL); } - if((snbytes%pio_mpi_nprocs_g)!=0) { - HDfprintf(stderr, - "Dataset size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " - "number of processes (%d)\n", - (long long)snbytes, pio_mpi_nprocs_g); - GOTOERROR(FAIL); + if ((buf_size % blk_size) != 0) { + HDfprintf(stderr, + "Transfer buffer size (%zu) must be a multiple of the " + "interleaved I/O block size (%zu)\n", + buf_size, blk_size); + GOTOERROR(FAIL); } - - if (!param.dim2d){ - if(((size_t)(snbytes/pio_mpi_nprocs_g)%buf_size)!=0) { + if ((snbytes % pio_mpi_nprocs_g) != 0) { HDfprintf(stderr, - "Dataset size/process (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " - "trasfer buffer size (%zu)\n", - (long long)(snbytes/pio_mpi_nprocs_g), buf_size); + "Dataset size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " + "number of processes (%d)\n", + (long long)snbytes, pio_mpi_nprocs_g); GOTOERROR(FAIL); + } + + if (!param.dim2d) { + if (((size_t)(snbytes / pio_mpi_nprocs_g) % buf_size) != 0) { + HDfprintf(stderr, + "Dataset size/process (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " + "trasfer buffer size (%zu)\n", + (long long)(snbytes / pio_mpi_nprocs_g), buf_size); + GOTOERROR(FAIL); } } else { - if(((size_t)snbytes%buf_size)!=0) { - HDfprintf(stderr, - "Dataset side size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " - "trasfer buffer size (%zu)\n", - (long long)snbytes, buf_size); - GOTOERROR(FAIL); + if (((size_t)snbytes % buf_size) != 0) { + HDfprintf(stderr, + "Dataset side size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " + "trasfer buffer size (%zu)\n", + (long long)snbytes, buf_size); + GOTOERROR(FAIL); } } /* Allocate transfer buffer */ - if ((buffer = malloc(bsize)) == NULL){ - HDfprintf(stderr, "malloc for transfer buffer size (%zu) failed\n", - bsize); - GOTOERROR(FAIL); + if ((buffer = malloc(bsize)) == NULL) { + HDfprintf(stderr, "malloc for transfer buffer size (%zu) failed\n", bsize); + GOTOERROR(FAIL); } if (pio_debug_level >= 4) { - int myrank; + int myrank; - MPI_Comm_rank(pio_comm_g, &myrank); + MPI_Comm_rank(pio_comm_g, &myrank); - /* output all of the times for all iterations */ - if (myrank == 0) - HDfprintf(output, "Timer details:\n"); + /* output all of the times for all iterations */ + if (myrank == 0) + HDfprintf(output, "Timer details:\n"); } for (nf = 1; nf <= param.num_files; nf++) { - /* - * Write performance measurement - */ - /* Open file for write */ - char base_name[256]; + /* + * Write performance measurement + */ + /* Open file for write */ + char base_name[256]; - HDsprintf(base_name, "#pio_tmp_%lu", nf); - pio_create_filename(iot, base_name, fname, sizeof(fname)); - if (pio_debug_level > 0) - HDfprintf(output, "rank %d: data filename=%s\n", - pio_mpi_rank_g, fname); + HDsprintf(base_name, "#pio_tmp_%lu", nf); + pio_create_filename(iot, base_name, fname, sizeof(fname)); + if (pio_debug_level > 0) + HDfprintf(output, "rank %d: data filename=%s\n", pio_mpi_rank_g, fname); - /* Need barrier to make sure everyone starts at the same time */ - MPI_Barrier(pio_comm_g); + /* Need barrier to make sure everyone starts at the same time */ + MPI_Barrier(pio_comm_g); - io_time_set(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS, TSTART); - hrc = do_fopen(¶m, fname, &fd, PIO_CREATE | PIO_WRITE); + io_time_set(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS, TSTART); + hrc = do_fopen(¶m, fname, &fd, PIO_CREATE | PIO_WRITE); - VRFY((hrc == SUCCESS), "do_fopen failed"); + VRFY((hrc == SUCCESS), "do_fopen failed"); - io_time_set(res.timers, HDF5_FINE_WRITE_FIXED_DIMS, TSTART); - hrc = do_write(&res, &fd, ¶m, ndsets, nbytes, buf_size, buffer); - io_time_set(res.timers, HDF5_FINE_WRITE_FIXED_DIMS, TSTOP); + io_time_set(res.timers, HDF5_FINE_WRITE_FIXED_DIMS, TSTART); + hrc = do_write(&res, &fd, ¶m, ndsets, nbytes, buf_size, buffer); + io_time_set(res.timers, HDF5_FINE_WRITE_FIXED_DIMS, TSTOP); - VRFY((hrc == SUCCESS), "do_write failed"); + VRFY((hrc == SUCCESS), "do_write failed"); - /* Close file for write */ - hrc = do_fclose(iot, &fd); + /* Close file for write */ + hrc = do_fclose(iot, &fd); - io_time_set(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS, TSTOP); - VRFY((hrc == SUCCESS), "do_fclose failed"); + io_time_set(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS, TSTOP); + VRFY((hrc == SUCCESS), "do_fclose failed"); - if (!param.h5_write_only) { - /* - * Read performance measurement - */ - /* Need barrier to make sure everyone is done writing and has - * closed the file. Also to make sure everyone starts reading - * at the same time. - */ - MPI_Barrier(pio_comm_g); + if (!param.h5_write_only) { + /* + * Read performance measurement + */ + /* Need barrier to make sure everyone is done writing and has + * closed the file. Also to make sure everyone starts reading + * at the same time. + */ + MPI_Barrier(pio_comm_g); - /* Open file for read */ - io_time_set(res.timers, HDF5_GROSS_READ_FIXED_DIMS, TSTART); - hrc = do_fopen(¶m, fname, &fd, PIO_READ); + /* Open file for read */ + io_time_set(res.timers, HDF5_GROSS_READ_FIXED_DIMS, TSTART); + hrc = do_fopen(¶m, fname, &fd, PIO_READ); - VRFY((hrc == SUCCESS), "do_fopen failed"); + VRFY((hrc == SUCCESS), "do_fopen failed"); - io_time_set(res.timers, HDF5_FINE_READ_FIXED_DIMS, TSTART); - hrc = do_read(&res, &fd, ¶m, ndsets, nbytes, buf_size, buffer); - io_time_set(res.timers, HDF5_FINE_READ_FIXED_DIMS, TSTOP); - VRFY((hrc == SUCCESS), "do_read failed"); + io_time_set(res.timers, HDF5_FINE_READ_FIXED_DIMS, TSTART); + hrc = do_read(&res, &fd, ¶m, ndsets, nbytes, buf_size, buffer); + io_time_set(res.timers, HDF5_FINE_READ_FIXED_DIMS, TSTOP); + VRFY((hrc == SUCCESS), "do_read failed"); - /* Close file for read */ - hrc = do_fclose(iot, &fd); + /* Close file for read */ + hrc = do_fclose(iot, &fd); - io_time_set(res.timers, HDF5_GROSS_READ_FIXED_DIMS, TSTOP); - VRFY((hrc == SUCCESS), "do_fclose failed"); - } + io_time_set(res.timers, HDF5_GROSS_READ_FIXED_DIMS, TSTOP); + VRFY((hrc == SUCCESS), "do_fclose failed"); + } - /* Need barrier to make sure everyone is done with the file */ - /* before it may be removed by do_cleanupfile */ - MPI_Barrier(pio_comm_g); - do_cleanupfile(iot, fname); + /* Need barrier to make sure everyone is done with the file */ + /* before it may be removed by do_cleanupfile */ + MPI_Barrier(pio_comm_g); + do_cleanupfile(iot, fname); } done: @@ -378,7 +367,7 @@ done: } /* release generic resources */ - if(buffer) + if (buffer) HDfree(buffer); res.ret_code = ret_code; return res; @@ -394,12 +383,12 @@ done: * Programmer: Bill Wendling, 21. November 2001 * Modifications: */ - static char * +static char * pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t size) { const char *prefix, *suffix = ""; - char *ptr, last = '\0'; - size_t i, j; + char * ptr, last = '\0'; + size_t i, j; if (!base_name || !fullname || size < 1) return NULL; @@ -426,7 +415,7 @@ pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si #ifdef HDF5_PARAPREFIX if (!prefix) prefix = HDF5_PARAPREFIX; -#endif /* HDF5_PARAPREFIX */ +#endif /* HDF5_PARAPREFIX */ /* Prepend the prefix value to the base name */ if (prefix && *prefix) { @@ -435,12 +424,12 @@ pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si * directory instead. */ register char *user, *login, *subdir; - user = HDgetenv("USER"); - login = HDgetenv("LOGIN"); + user = HDgetenv("USER"); + login = HDgetenv("LOGIN"); subdir = (user ? user : login); if (subdir) { - for (i = 0; i < size-1 && prefix[i]; i++) + for (i = 0; i < size - 1 && prefix[i]; i++) fullname[i] = prefix[i]; fullname[i++] = '/'; @@ -461,7 +450,7 @@ pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si if (HDstat(fullname, &buf) < 0) /* The directory doesn't exist just yet */ - if (HDmkdir(fullname, (mode_t) 0755) < 0 && errno != EEXIST) { + if (HDmkdir(fullname, (mode_t)0755) < 0 && errno != EEXIST) { /* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory. * Default to PREFIX's original prefix value. */ HDstrcpy(fullname, prefix); @@ -510,62 +499,62 @@ pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si * Modifications: * Added 2D testing (Christian Chilan, 10. August 2005) */ - static herr_t -do_write(results *res, file_descr *fd, parameters *parms, long ndsets, - off_t nbytes, size_t buf_size, void *buffer) +static herr_t +do_write(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nbytes, size_t buf_size, + void *buffer) { - int ret_code = SUCCESS; - int rc; /*routine return code */ - long ndset; - size_t blk_size; /* The block size to subdivide the xfer buffer into */ - off_t nbytes_xfer; /* Total number of bytes transferred so far */ - size_t nbytes_xfer_advance; /* Number of bytes transferred in a single I/O operation */ - size_t nbytes_toxfer; /* Number of bytes to transfer a particular time */ - char dname[64]; - off_t dset_offset=0; /*dataset offset in a file */ - off_t bytes_begin[2]; /*first elmt this process transfer */ - off_t bytes_count; /*number of elmts this process transfer */ - off_t snbytes=0; /*size of a side of the dataset square */ - unsigned char *buf_p; /* Current buffer pointer */ + int ret_code = SUCCESS; + int rc; /*routine return code */ + long ndset; + size_t blk_size; /* The block size to subdivide the xfer buffer into */ + off_t nbytes_xfer; /* Total number of bytes transferred so far */ + size_t nbytes_xfer_advance; /* Number of bytes transferred in a single I/O operation */ + size_t nbytes_toxfer; /* Number of bytes to transfer a particular time */ + char dname[64]; + off_t dset_offset = 0; /*dataset offset in a file */ + off_t bytes_begin[2]; /*first elmt this process transfer */ + off_t bytes_count; /*number of elmts this process transfer */ + off_t snbytes = 0; /*size of a side of the dataset square */ + unsigned char *buf_p; /* Current buffer pointer */ /* POSIX variables */ - off_t file_offset; /* File offset of the next transfer */ - off_t file_offset_advance; /* File offset advance after each I/O operation */ - off_t posix_file_offset; /* Base file offset of the next transfer */ + off_t file_offset; /* File offset of the next transfer */ + off_t file_offset_advance; /* File offset advance after each I/O operation */ + off_t posix_file_offset; /* Base file offset of the next transfer */ /* MPI variables */ - MPI_Offset mpi_file_offset; /* Base file offset of the next transfer*/ - MPI_Offset mpi_offset; /* Offset in MPI file */ - MPI_Offset mpi_offset_advance; /* Offset advance after each I/O operation */ - MPI_Datatype mpi_file_type; /* MPI derived type for 1D file */ - MPI_Datatype mpi_blk_type; /* MPI derived type for 1D buffer */ - MPI_Datatype mpi_cont_type; /* MPI derived type for 2D contiguous file */ - MPI_Datatype mpi_partial_buffer_cont; /* MPI derived type for partial 2D contiguous buffer */ - MPI_Datatype mpi_inter_type; /* MPI derived type for 2D interleaved file */ - MPI_Datatype mpi_partial_buffer_inter; /* MPI derived type for partial 2D interleaved buffer */ - MPI_Datatype mpi_full_buffer; /* MPI derived type for 2D full buffer */ - MPI_Datatype mpi_full_chunk; /* MPI derived type for 2D full chunk */ - MPI_Datatype mpi_chunk_inter_type; /* MPI derived type for 2D chunk interleaved file */ - MPI_Datatype mpi_collective_type; /* Generic MPI derived type for 2D collective access */ - MPI_Status mpi_status; - int mrc; /* MPI return code */ + MPI_Offset mpi_file_offset; /* Base file offset of the next transfer*/ + MPI_Offset mpi_offset; /* Offset in MPI file */ + MPI_Offset mpi_offset_advance; /* Offset advance after each I/O operation */ + MPI_Datatype mpi_file_type; /* MPI derived type for 1D file */ + MPI_Datatype mpi_blk_type; /* MPI derived type for 1D buffer */ + MPI_Datatype mpi_cont_type; /* MPI derived type for 2D contiguous file */ + MPI_Datatype mpi_partial_buffer_cont; /* MPI derived type for partial 2D contiguous buffer */ + MPI_Datatype mpi_inter_type; /* MPI derived type for 2D interleaved file */ + MPI_Datatype mpi_partial_buffer_inter; /* MPI derived type for partial 2D interleaved buffer */ + MPI_Datatype mpi_full_buffer; /* MPI derived type for 2D full buffer */ + MPI_Datatype mpi_full_chunk; /* MPI derived type for 2D full chunk */ + MPI_Datatype mpi_chunk_inter_type; /* MPI derived type for 2D chunk interleaved file */ + MPI_Datatype mpi_collective_type; /* Generic MPI derived type for 2D collective access */ + MPI_Status mpi_status; + int mrc; /* MPI return code */ /* HDF5 variables */ - herr_t hrc; /*HDF5 return code */ - hsize_t h5dims[2]; /*dataset dim sizes */ - hid_t h5dset_space_id = H5I_INVALID_HID; /*dataset space ID */ - hid_t h5mem_space_id = H5I_INVALID_HID; /*memory dataspace ID */ - hid_t h5ds_id = H5I_INVALID_HID; /*dataset handle */ - hsize_t h5block[2]; /*dataspace selection */ - hsize_t h5stride[2]; - hsize_t h5count[2]; - hsize_t h5start[2]; - hssize_t h5offset[2]; /* Selection offset within dataspace */ - hid_t h5dcpl = H5I_INVALID_HID; /* Dataset creation property list */ - hid_t h5dxpl = H5I_INVALID_HID; /* Dataset transfer property list */ + herr_t hrc; /*HDF5 return code */ + hsize_t h5dims[2]; /*dataset dim sizes */ + hid_t h5dset_space_id = H5I_INVALID_HID; /*dataset space ID */ + hid_t h5mem_space_id = H5I_INVALID_HID; /*memory dataspace ID */ + hid_t h5ds_id = H5I_INVALID_HID; /*dataset handle */ + hsize_t h5block[2]; /*dataspace selection */ + hsize_t h5stride[2]; + hsize_t h5count[2]; + hsize_t h5start[2]; + hssize_t h5offset[2]; /* Selection offset within dataspace */ + hid_t h5dcpl = H5I_INVALID_HID; /* Dataset creation property list */ + hid_t h5dxpl = H5I_INVALID_HID; /* Dataset transfer property list */ /* Get the parameters from the parameter block */ - blk_size=parms->blk_size; + blk_size = parms->blk_size; /* There are two kinds of transfer patterns, contiguous and interleaved. * Let 0,1,2,...,n be data accessed by process 0,1,2,...,n @@ -578,20 +567,20 @@ do_write(results *res, file_descr *fd, parameters *parms, long ndsets, */ /* 1D dataspace */ - if (!parms->dim2d){ + if (!parms->dim2d) { /* Contiguous Pattern: */ if (!parms->interleaved) { - bytes_begin[0] = (off_t)(((double)nbytes*pio_mpi_rank_g)/pio_mpi_nprocs_g); + bytes_begin[0] = (off_t)(((double)nbytes * pio_mpi_rank_g) / pio_mpi_nprocs_g); } /* end if */ /* Interleaved Pattern: */ else { - bytes_begin[0] = (off_t)(blk_size*(size_t)pio_mpi_rank_g); + bytes_begin[0] = (off_t)(blk_size * (size_t)pio_mpi_rank_g); } /* end else */ /* Prepare buffer for verifying data */ if (parms->verify) - memset(buffer,pio_mpi_rank_g+1,buf_size); - }/* end if */ + memset(buffer, pio_mpi_rank_g + 1, buf_size); + } /* end if */ /* 2D dataspace */ else { /* nbytes is always the number of bytes per dataset (1D or 2D). If the @@ -601,25 +590,24 @@ do_write(results *res, file_descr *fd, parameters *parms, long ndsets, /* Contiguous Pattern: */ if (!parms->interleaved) { - bytes_begin[0] = (off_t)((double)snbytes*pio_mpi_rank_g / pio_mpi_nprocs_g); + bytes_begin[0] = (off_t)((double)snbytes * pio_mpi_rank_g / pio_mpi_nprocs_g); bytes_begin[1] = 0; } /* end if */ /* Interleaved Pattern: */ else { bytes_begin[0] = 0; - if(!parms->h5_use_chunks || parms->io_type==PHDF5) - bytes_begin[1] = (off_t)(blk_size*(size_t)pio_mpi_rank_g); + if (!parms->h5_use_chunks || parms->io_type == PHDF5) + bytes_begin[1] = (off_t)(blk_size * (size_t)pio_mpi_rank_g); else - bytes_begin[1] = (off_t)(blk_size*blk_size*(size_t)pio_mpi_rank_g); + bytes_begin[1] = (off_t)(blk_size * blk_size * (size_t)pio_mpi_rank_g); } /* end else */ /* Prepare buffer for verifying data */ if (parms->verify) - HDmemset(buffer,pio_mpi_rank_g+1,buf_size*blk_size); + HDmemset(buffer, pio_mpi_rank_g + 1, buf_size * blk_size); } /* end else */ - /* Calculate the total number of bytes (bytes_count) to be * transferred by this process. It may be different for different * transfer pattern due to rounding to integral values. @@ -630,861 +618,887 @@ do_write(results *res, file_descr *fd, parameters *parms, long ndsets, * This way, it eliminates any rounding errors. * (This is tricky, don't mess with the formula, rounding errors * can easily get introduced) */ - bytes_count = (off_t)(((double)nbytes*(pio_mpi_rank_g+1)) / pio_mpi_nprocs_g) - - (off_t)(((double)nbytes*pio_mpi_rank_g) / pio_mpi_nprocs_g); + bytes_count = (off_t)(((double)nbytes * (pio_mpi_rank_g + 1)) / pio_mpi_nprocs_g) - + (off_t)(((double)nbytes * pio_mpi_rank_g) / pio_mpi_nprocs_g); /* debug */ if (pio_debug_level >= 4) { HDprint_rank(output); if (!parms->dim2d) { - HDfprintf(output, "Debug(do_write): " - "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", - buf_size, (long long)bytes_begin[0], - (long long)bytes_count); - } else { - HDfprintf(output, "Debug(do_write): " - "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", - buf_size*blk_size, (long long)bytes_begin[0], - (long long)bytes_begin[1], (long long)bytes_count); + HDfprintf(output, + "Debug(do_write): " + "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH + "d\n", + buf_size, (long long)bytes_begin[0], (long long)bytes_count); + } + else { + HDfprintf(output, + "Debug(do_write): " + "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH + "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", + buf_size * blk_size, (long long)bytes_begin[0], (long long)bytes_begin[1], + (long long)bytes_count); } } /* I/O Access specific setup */ switch (parms->io_type) { - case POSIXIO: - /* No extra setup */ - break; - - case MPIO: /* MPI-I/O setup */ - /* 1D dataspace */ - if (!parms->dim2d){ - /* Build block's derived type */ - mrc = MPI_Type_contiguous((int)blk_size, - MPI_BYTE, &mpi_blk_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Build file's derived type */ - mrc = MPI_Type_vector((int)(buf_size/blk_size), (int)1, - (int)pio_mpi_nprocs_g, mpi_blk_type, &mpi_file_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit file type */ - mrc = MPI_Type_commit( &mpi_file_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Commit buffer type */ - mrc = MPI_Type_commit( &mpi_blk_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - } /* end if */ - /* 2D dataspace */ - else { - /* Build partial buffer derived type for contiguous access */ - - mrc = MPI_Type_contiguous((int)buf_size, MPI_BYTE, - &mpi_partial_buffer_cont); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit partial buffer derived type */ - mrc = MPI_Type_commit(&mpi_partial_buffer_cont); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build contiguous file's derived type */ - mrc = MPI_Type_vector((int)blk_size, (int)1, (int)((size_t)snbytes/buf_size), - mpi_partial_buffer_cont, &mpi_cont_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit contiguous file type */ - mrc = MPI_Type_commit(&mpi_cont_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build partial buffer derived type for interleaved access */ - mrc = MPI_Type_contiguous((int)blk_size, MPI_BYTE, - &mpi_partial_buffer_inter); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit partial buffer derived type */ - mrc = MPI_Type_commit(&mpi_partial_buffer_inter); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build interleaved file's derived type */ - mrc = MPI_Type_vector((int)buf_size, (int)1, (int)((size_t)snbytes/blk_size), - mpi_partial_buffer_inter, &mpi_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit interleaved file type */ - mrc = MPI_Type_commit(&mpi_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build full buffer derived type */ - mrc = MPI_Type_contiguous((int)(blk_size*buf_size), MPI_BYTE, - &mpi_full_buffer); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit full buffer derived type */ - mrc = MPI_Type_commit(&mpi_full_buffer); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build full chunk derived type */ - mrc = MPI_Type_contiguous((int)(blk_size*blk_size), MPI_BYTE, - &mpi_full_chunk); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit full chunk derived type */ - mrc = MPI_Type_commit(&mpi_full_chunk); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build chunk interleaved file's derived type */ - mrc = MPI_Type_vector((int)(buf_size/blk_size), (int)1, (int)((size_t)snbytes/blk_size), - mpi_full_chunk, &mpi_chunk_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit chunk interleaved file type */ - mrc = MPI_Type_commit(&mpi_chunk_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - } /* end else */ - break; - - case PHDF5: /* HDF5 setup */ - /* 1D dataspace */ - if (!parms->dim2d){ - if(nbytes>0) { - /* define a contiguous dataset of nbytes native bytes */ - h5dims[0] = (hsize_t)nbytes; - h5dset_space_id = H5Screate_simple(1, h5dims, NULL); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - - /* Set up the file dset space id to select the pattern to access */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5start[0] = (hsize_t)bytes_begin[0]; - h5stride[0] = h5block[0] = blk_size; - h5count[0] = buf_size/blk_size; - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5start[0] = (hsize_t)bytes_begin[0]; - h5stride[0] = blk_size*(size_t)pio_mpi_nprocs_g; - h5block[0] = blk_size; - h5count[0] = buf_size/blk_size; - } /* end else */ - hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, - h5start, h5stride, h5count, h5block); - VRFY((hrc >= 0), "H5Sselect_hyperslab"); - } /* end if */ - else { - h5dset_space_id = H5Screate(H5S_SCALAR); - VRFY((h5dset_space_id >= 0), "H5Screate"); - } /* end else */ - - /* Create the memory dataspace that corresponds to the xfer buffer */ - if(buf_size>0) { - h5dims[0] = buf_size; - h5mem_space_id = H5Screate_simple(1, h5dims, NULL); - VRFY((h5mem_space_id >= 0), "H5Screate_simple"); - } /* end if */ - else { - h5mem_space_id = H5Screate(H5S_SCALAR); - VRFY((h5mem_space_id >= 0), "H5Screate"); - } /* end else */ - } /* end if */ - /* 2D dataspace */ - else { - if(nbytes>0) { - /* define a contiguous dataset of nbytes native bytes */ - h5dims[0] = (hsize_t)snbytes; - h5dims[1] = (hsize_t)snbytes; - h5dset_space_id = H5Screate_simple(2, h5dims, NULL); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - - /* Set up the file dset space id to select the pattern to access */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5start[0] = (hsize_t)bytes_begin[0]; - h5start[1] = (hsize_t)bytes_begin[1]; - h5stride[0] = 1; - h5stride[1] = h5block[0] = h5block[1] = blk_size; - h5count[0] = 1; - h5count[1] = buf_size/blk_size; - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5start[0] = (hsize_t)bytes_begin[0]; - h5start[1] = (hsize_t)bytes_begin[1]; - h5stride[0] = blk_size; - h5stride[1] = blk_size*(size_t)pio_mpi_nprocs_g; - h5block[0] = h5block[1] = blk_size; - h5count[0] = buf_size/blk_size; - h5count[1] = 1; - } /* end else */ - hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, - h5start, h5stride, h5count, h5block); - VRFY((hrc >= 0), "H5Sselect_hyperslab"); - } /* end if */ - else { - h5dset_space_id = H5Screate(H5S_SCALAR); - VRFY((h5dset_space_id >= 0), "H5Screate"); - } /* end else */ + case POSIXIO: + /* No extra setup */ + break; - /* Create the memory dataspace that corresponds to the xfer buffer */ - if(buf_size>0) { - if (!parms->interleaved){ - h5dims[0] = blk_size; - h5dims[1] = buf_size; - }else{ - h5dims[0] = buf_size; - h5dims[1] = blk_size; - } - h5mem_space_id = H5Screate_simple(2, h5dims, NULL); - VRFY((h5mem_space_id >= 0), "H5Screate_simple"); + case MPIO: /* MPI-I/O setup */ + /* 1D dataspace */ + if (!parms->dim2d) { + /* Build block's derived type */ + mrc = MPI_Type_contiguous((int)blk_size, MPI_BYTE, &mpi_blk_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); + + /* Build file's derived type */ + mrc = MPI_Type_vector((int)(buf_size / blk_size), (int)1, (int)pio_mpi_nprocs_g, mpi_blk_type, + &mpi_file_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); + + /* Commit file type */ + mrc = MPI_Type_commit(&mpi_file_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); + + /* Commit buffer type */ + mrc = MPI_Type_commit(&mpi_blk_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); } /* end if */ + /* 2D dataspace */ else { - h5mem_space_id = H5Screate(H5S_SCALAR); - VRFY((h5mem_space_id >= 0), "H5Screate"); - } /* end else */ - } /* end else */ + /* Build partial buffer derived type for contiguous access */ - /* Create the dataset transfer property list */ - h5dxpl = H5Pcreate(H5P_DATASET_XFER); - if (h5dxpl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } + mrc = MPI_Type_contiguous((int)buf_size, MPI_BYTE, &mpi_partial_buffer_cont); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); - /* Change to collective I/O, if asked */ - if(parms->collective) { - hrc = H5Pset_dxpl_mpio(h5dxpl, H5FD_MPIO_COLLECTIVE); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Set failed\n"); - GOTOERROR(FAIL); - } /* end if */ - } /* end if */ - break; - - default: - break; - } /* end switch */ + /* Commit partial buffer derived type */ + mrc = MPI_Type_commit(&mpi_partial_buffer_cont); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - for (ndset = 1; ndset <= ndsets; ++ndset) { + /* Build contiguous file's derived type */ + mrc = MPI_Type_vector((int)blk_size, (int)1, (int)((size_t)snbytes / buf_size), + mpi_partial_buffer_cont, &mpi_cont_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); - /* Calculate dataset offset within a file */ + /* Commit contiguous file type */ + mrc = MPI_Type_commit(&mpi_cont_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - /* create dataset */ - switch (parms->io_type) { - case POSIXIO: - case MPIO: - /* both posix and mpi io just need dataset offset in file*/ - dset_offset = (ndset - 1) * nbytes; - break; + /* Build partial buffer derived type for interleaved access */ + mrc = MPI_Type_contiguous((int)blk_size, MPI_BYTE, &mpi_partial_buffer_inter); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); - case PHDF5: - h5dcpl = H5Pcreate(H5P_DATASET_CREATE); - if (h5dcpl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } - /* 1D dataspace */ - if (!parms->dim2d){ - /* Make the dataset chunked if asked */ - if(parms->h5_use_chunks) { - /* Set the chunk size to be the same as the buffer size */ - h5dims[0] = blk_size; - hrc = H5Pset_chunk(h5dcpl, 1, h5dims); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Set failed\n"); - GOTOERROR(FAIL); - } /* end if */ - } /* end if */ - }/* end if */ - else{ - /* 2D dataspace */ - if(parms->h5_use_chunks) { - /* Set the chunk size to be the same as the block size */ - h5dims[0] = blk_size; - h5dims[1] = blk_size; - hrc = H5Pset_chunk(h5dcpl, 2, h5dims); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Set failed\n"); - GOTOERROR(FAIL); - } /* end if */ - } /* end if */ - }/* end else */ + /* Commit partial buffer derived type */ + mrc = MPI_Type_commit(&mpi_partial_buffer_inter); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - HDsprintf(dname, "Dataset_%ld", ndset); - h5ds_id = H5DCREATE(fd->h5fd, dname, ELMT_H5_TYPE, - h5dset_space_id, h5dcpl); + /* Build interleaved file's derived type */ + mrc = MPI_Type_vector((int)buf_size, (int)1, (int)((size_t)snbytes / blk_size), + mpi_partial_buffer_inter, &mpi_inter_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); - if (h5ds_id < 0) { - HDfprintf(stderr, "HDF5 Dataset Create failed\n"); - GOTOERROR(FAIL); - } + /* Commit interleaved file type */ + mrc = MPI_Type_commit(&mpi_inter_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - hrc = H5Pclose(h5dcpl); - /* verifying the close of the dcpl */ - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Close failed\n"); - GOTOERROR(FAIL); - } - break; + /* Build full buffer derived type */ + mrc = MPI_Type_contiguous((int)(blk_size * buf_size), MPI_BYTE, &mpi_full_buffer); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); - default: - break; - } + /* Commit full buffer derived type */ + mrc = MPI_Type_commit(&mpi_full_buffer); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - /* The task is to transfer bytes_count bytes, starting at - * bytes_begin position, using transfer buffer of buf_size bytes. - * If interleaved, select buf_size at a time, in round robin - * fashion, according to number of process. Otherwise, select - * all bytes_count in contiguous. - */ - nbytes_xfer = 0 ; + /* Build full chunk derived type */ + mrc = MPI_Type_contiguous((int)(blk_size * blk_size), MPI_BYTE, &mpi_full_chunk); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); - /* 1D dataspace */ - if (!parms->dim2d){ - /* Set base file offset for all I/O patterns and POSIX access */ - posix_file_offset = dset_offset + bytes_begin[0]; + /* Commit full chunk derived type */ + mrc = MPI_Type_commit(&mpi_full_chunk); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - /* Set base file offset for all I/O patterns and MPI access */ - mpi_file_offset = (MPI_Offset)(dset_offset + bytes_begin[0]); - } /* end if */ - else { - /* Set base file offset for all I/O patterns and POSIX access */ - posix_file_offset=dset_offset + bytes_begin[0]*snbytes+ - bytes_begin[1]; + /* Build chunk interleaved file's derived type */ + mrc = MPI_Type_vector((int)(buf_size / blk_size), (int)1, (int)((size_t)snbytes / blk_size), + mpi_full_chunk, &mpi_chunk_inter_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); - /* Set base file offset for all I/O patterns and MPI access */ - mpi_file_offset=(MPI_Offset)(dset_offset + bytes_begin[0]*snbytes+ - bytes_begin[1]); - } /* end else */ + /* Commit chunk interleaved file type */ + mrc = MPI_Type_commit(&mpi_chunk_inter_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - /* Start "raw data" write timer */ - io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTART); + } /* end else */ + break; - while (nbytes_xfer < bytes_count){ - /* Write */ - /* Calculate offset of write within a dataset/file */ - switch (parms->io_type) { - case POSIXIO: + case PHDF5: /* HDF5 setup */ /* 1D dataspace */ - if (!parms->dim2d){ - /* Contiguous pattern */ - if (!parms->interleaved) { - /* Compute file offset */ - file_offset = posix_file_offset + (off_t)nbytes_xfer; - - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); - - /* check if all bytes are written */ - rc = ((ssize_t)buf_size == - POSIXWRITE(fd->posixfd, buffer, buf_size)); - VRFY((rc != 0), "POSIXWRITE"); - - /* Advance global offset in dataset */ - nbytes_xfer+=(ssize_t)buf_size; + if (!parms->dim2d) { + if (nbytes > 0) { + /* define a contiguous dataset of nbytes native bytes */ + h5dims[0] = (hsize_t)nbytes; + h5dset_space_id = H5Screate_simple(1, h5dims, NULL); + VRFY((h5dset_space_id >= 0), "H5Screate_simple"); + + /* Set up the file dset space id to select the pattern to access */ + if (!parms->interleaved) { + /* Contiguous pattern */ + h5start[0] = (hsize_t)bytes_begin[0]; + h5stride[0] = h5block[0] = blk_size; + h5count[0] = buf_size / blk_size; + } /* end if */ + else { + /* Interleaved access pattern */ + /* Skip offset over blocks of other processes */ + h5start[0] = (hsize_t)bytes_begin[0]; + h5stride[0] = blk_size * (size_t)pio_mpi_nprocs_g; + h5block[0] = blk_size; + h5count[0] = buf_size / blk_size; + } /* end else */ + hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, h5start, h5stride, h5count, + h5block); + VRFY((hrc >= 0), "H5Sselect_hyperslab"); } /* end if */ - /* Interleaved access pattern */ else { - /* Set the base of user's buffer */ - buf_p=(unsigned char *)buffer; - - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size; - - /* Loop over the buffers to write */ - while(nbytes_toxfer>0) { - /* Skip offset over blocks of other processes */ - file_offset = posix_file_offset + - (off_t)(nbytes_xfer*pio_mpi_nprocs_g); - - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); - - /* check if all bytes are written */ - rc = ((ssize_t)blk_size == - POSIXWRITE(fd->posixfd, buf_p, blk_size)); - VRFY((rc != 0), "POSIXWRITE"); - - /* Advance location in buffer */ - buf_p+=blk_size; - - /* Advance global offset in dataset */ - nbytes_xfer+=(ssize_t)blk_size; + h5dset_space_id = H5Screate(H5S_SCALAR); + VRFY((h5dset_space_id >= 0), "H5Screate"); + } /* end else */ - /* Decrement number of bytes left this time */ - nbytes_toxfer-=blk_size; - } /* end while */ + /* Create the memory dataspace that corresponds to the xfer buffer */ + if (buf_size > 0) { + h5dims[0] = buf_size; + h5mem_space_id = H5Screate_simple(1, h5dims, NULL); + VRFY((h5mem_space_id >= 0), "H5Screate_simple"); + } /* end if */ + else { + h5mem_space_id = H5Screate(H5S_SCALAR); + VRFY((h5mem_space_id >= 0), "H5Screate"); } /* end else */ - } /* end if */ + } /* end if */ /* 2D dataspace */ else { - /* Contiguous storage */ - if (!parms->h5_use_chunks) { - /* Contiguous access pattern */ + if (nbytes > 0) { + /* define a contiguous dataset of nbytes native bytes */ + h5dims[0] = (hsize_t)snbytes; + h5dims[1] = (hsize_t)snbytes; + h5dset_space_id = H5Screate_simple(2, h5dims, NULL); + VRFY((h5dset_space_id >= 0), "H5Screate_simple"); + + /* Set up the file dset space id to select the pattern to access */ if (!parms->interleaved) { - /* Compute file offset */ - file_offset=posix_file_offset+(off_t)((((size_t)nbytes_xfer/blk_size) - /(size_t)snbytes)*(blk_size*(size_t)snbytes)+(((size_t)nbytes_xfer/blk_size)%(size_t)snbytes)); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = buf_size; - - /* Global offset advance after each I/O operation */ - file_offset_advance = (off_t)snbytes; + /* Contiguous pattern */ + h5start[0] = (hsize_t)bytes_begin[0]; + h5start[1] = (hsize_t)bytes_begin[1]; + h5stride[0] = 1; + h5stride[1] = h5block[0] = h5block[1] = blk_size; + h5count[0] = 1; + h5count[1] = buf_size / blk_size; } /* end if */ - /* Interleaved access pattern */ else { - /* Compute file offset */ - file_offset=posix_file_offset+(off_t)(((((size_t)nbytes_xfer/buf_size) - *(size_t)pio_mpi_nprocs_g)/(size_t)snbytes)*(buf_size*(size_t)snbytes) - +(((size_t)nbytes_xfer/buf_size)*(size_t)pio_mpi_nprocs_g)%(size_t)snbytes); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size; - - /* Global offset advance after each I/O operation */ - file_offset_advance = (off_t)snbytes; + /* Interleaved access pattern */ + /* Skip offset over blocks of other processes */ + h5start[0] = (hsize_t)bytes_begin[0]; + h5start[1] = (hsize_t)bytes_begin[1]; + h5stride[0] = blk_size; + h5stride[1] = blk_size * (size_t)pio_mpi_nprocs_g; + h5block[0] = h5block[1] = blk_size; + h5count[0] = buf_size / blk_size; + h5count[1] = 1; } /* end else */ + hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, h5start, h5stride, h5count, + h5block); + VRFY((hrc >= 0), "H5Sselect_hyperslab"); } /* end if */ - /* Chunked storage */ else { - /*Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute file offset */ - file_offset=posix_file_offset+(off_t)nbytes_xfer; - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * buf_size; + h5dset_space_id = H5Screate(H5S_SCALAR); + VRFY((h5dset_space_id >= 0), "H5Screate"); + } /* end else */ - /* Global offset advance after each I/O operation */ - file_offset_advance = 0; - } /* end if */ - /*Interleaved access pattern */ + /* Create the memory dataspace that corresponds to the xfer buffer */ + if (buf_size > 0) { + if (!parms->interleaved) { + h5dims[0] = blk_size; + h5dims[1] = buf_size; + } else { - /* Compute file offset */ - /* Before simplification */ - /* file_offset=posix_file_offset+(off_t)((nbytes_xfer/(buf_size/blk_size) - *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))*(buf_size/blk_size - *snbytes/blk_size*(blk_size*blk_size))+((nbytes_xfer/(buf_size/blk_size)) - *pio_mpi_nprocs_g)%(snbytes/blk_size*(blk_size*blk_size))); */ - - file_offset=posix_file_offset+(off_t)((((size_t)nbytes_xfer/(buf_size/blk_size) - *(size_t)pio_mpi_nprocs_g)/((size_t)snbytes*blk_size))*(buf_size*(size_t)snbytes)+(((size_t)nbytes_xfer/(buf_size/blk_size)) - *(size_t)pio_mpi_nprocs_g)%((size_t)snbytes*blk_size)); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * blk_size; - - /* Global offset advance after each I/O operation */ - /* file_offset_advance = (off_t)(snbytes/blk_size*(blk_size*blk_size)); */ - file_offset_advance = (off_t)snbytes*(off_t)blk_size; - } /* end else */ + h5dims[0] = buf_size; + h5dims[1] = blk_size; + } + h5mem_space_id = H5Screate_simple(2, h5dims, NULL); + VRFY((h5mem_space_id >= 0), "H5Screate_simple"); + } /* end if */ + else { + h5mem_space_id = H5Screate(H5S_SCALAR); + VRFY((h5mem_space_id >= 0), "H5Screate"); } /* end else */ + } /* end else */ + + /* Create the dataset transfer property list */ + h5dxpl = H5Pcreate(H5P_DATASET_XFER); + if (h5dxpl < 0) { + HDfprintf(stderr, "HDF5 Property List Create failed\n"); + GOTOERROR(FAIL); + } - /* Common code for file access */ + /* Change to collective I/O, if asked */ + if (parms->collective) { + hrc = H5Pset_dxpl_mpio(h5dxpl, H5FD_MPIO_COLLECTIVE); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Property List Set failed\n"); + GOTOERROR(FAIL); + } /* end if */ + } /* end if */ + break; - /* Set the base of user's buffer */ - buf_p = (unsigned char *)buffer; + default: + break; + } /* end switch */ - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size*blk_size; + for (ndset = 1; ndset <= ndsets; ++ndset) { - /* Loop over portions of the buffer to write */ - while(nbytes_toxfer>0){ - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); + /* Calculate dataset offset within a file */ - /* check if all bytes are written */ - rc = ((ssize_t)nbytes_xfer_advance == - POSIXWRITE(fd->posixfd, buf_p, nbytes_xfer_advance)); - VRFY((rc != 0), "POSIXWRITE"); + /* create dataset */ + switch (parms->io_type) { + case POSIXIO: + case MPIO: + /* both posix and mpi io just need dataset offset in file*/ + dset_offset = (ndset - 1) * nbytes; + break; - /* Advance location in buffer */ - buf_p+=nbytes_xfer_advance; + case PHDF5: + h5dcpl = H5Pcreate(H5P_DATASET_CREATE); + if (h5dcpl < 0) { + HDfprintf(stderr, "HDF5 Property List Create failed\n"); + GOTOERROR(FAIL); + } + /* 1D dataspace */ + if (!parms->dim2d) { + /* Make the dataset chunked if asked */ + if (parms->h5_use_chunks) { + /* Set the chunk size to be the same as the buffer size */ + h5dims[0] = blk_size; + hrc = H5Pset_chunk(h5dcpl, 1, h5dims); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Property List Set failed\n"); + GOTOERROR(FAIL); + } /* end if */ + } /* end if */ + } /* end if */ + else { + /* 2D dataspace */ + if (parms->h5_use_chunks) { + /* Set the chunk size to be the same as the block size */ + h5dims[0] = blk_size; + h5dims[1] = blk_size; + hrc = H5Pset_chunk(h5dcpl, 2, h5dims); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Property List Set failed\n"); + GOTOERROR(FAIL); + } /* end if */ + } /* end if */ + } /* end else */ + + HDsprintf(dname, "Dataset_%ld", ndset); + h5ds_id = H5DCREATE(fd->h5fd, dname, ELMT_H5_TYPE, h5dset_space_id, h5dcpl); + + if (h5ds_id < 0) { + HDfprintf(stderr, "HDF5 Dataset Create failed\n"); + GOTOERROR(FAIL); + } - /* Advance global offset in dataset */ - nbytes_xfer+=(ssize_t)nbytes_xfer_advance; + hrc = H5Pclose(h5dcpl); + /* verifying the close of the dcpl */ + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Property List Close failed\n"); + GOTOERROR(FAIL); + } + break; - /* Decrement number of bytes left this time */ - nbytes_toxfer-=nbytes_xfer_advance; + default: + break; + } - /* Partially advance file offset */ - file_offset+=file_offset_advance; - } /* end while */ + /* The task is to transfer bytes_count bytes, starting at + * bytes_begin position, using transfer buffer of buf_size bytes. + * If interleaved, select buf_size at a time, in round robin + * fashion, according to number of process. Otherwise, select + * all bytes_count in contiguous. + */ + nbytes_xfer = 0; - } /* end else */ + /* 1D dataspace */ + if (!parms->dim2d) { + /* Set base file offset for all I/O patterns and POSIX access */ + posix_file_offset = dset_offset + bytes_begin[0]; - break; + /* Set base file offset for all I/O patterns and MPI access */ + mpi_file_offset = (MPI_Offset)(dset_offset + bytes_begin[0]); + } /* end if */ + else { + /* Set base file offset for all I/O patterns and POSIX access */ + posix_file_offset = dset_offset + bytes_begin[0] * snbytes + bytes_begin[1]; - case MPIO: - /* 1D dataspace */ - if (!parms->dim2d){ - /* Independent file access */ - if(!parms->collective) { - /* Contiguous pattern */ - if (!parms->interleaved){ - /* Compute offset in file */ - mpi_offset = mpi_file_offset + - nbytes_xfer; - - /* Perform independent write */ - mrc = MPI_File_write_at(fd->mpifd, mpi_offset, buffer, - (int)(buf_size/blk_size), mpi_blk_type, - &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_WRITE"); - - /* Advance global offset in dataset */ - nbytes_xfer+=(ssize_t)buf_size; - } /* end if */ - /* Interleaved access pattern */ + /* Set base file offset for all I/O patterns and MPI access */ + mpi_file_offset = (MPI_Offset)(dset_offset + bytes_begin[0] * snbytes + bytes_begin[1]); + } /* end else */ + + /* Start "raw data" write timer */ + io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTART); + + while (nbytes_xfer < bytes_count) { + /* Write */ + /* Calculate offset of write within a dataset/file */ + switch (parms->io_type) { + case POSIXIO: + /* 1D dataspace */ + if (!parms->dim2d) { + /* Contiguous pattern */ + if (!parms->interleaved) { + /* Compute file offset */ + file_offset = posix_file_offset + (off_t)nbytes_xfer; + + /* only care if seek returns error */ + rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; + VRFY((rc == 0), "POSIXSEEK"); + + /* check if all bytes are written */ + rc = ((ssize_t)buf_size == POSIXWRITE(fd->posixfd, buffer, buf_size)); + VRFY((rc != 0), "POSIXWRITE"); + + /* Advance global offset in dataset */ + nbytes_xfer += (ssize_t)buf_size; + } /* end if */ + /* Interleaved access pattern */ + else { + /* Set the base of user's buffer */ + buf_p = (unsigned char *)buffer; + + /* Set the number of bytes to transfer this time */ + nbytes_toxfer = buf_size; + + /* Loop over the buffers to write */ + while (nbytes_toxfer > 0) { + /* Skip offset over blocks of other processes */ + file_offset = posix_file_offset + (off_t)(nbytes_xfer * pio_mpi_nprocs_g); + + /* only care if seek returns error */ + rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; + VRFY((rc == 0), "POSIXSEEK"); + + /* check if all bytes are written */ + rc = ((ssize_t)blk_size == POSIXWRITE(fd->posixfd, buf_p, blk_size)); + VRFY((rc != 0), "POSIXWRITE"); + + /* Advance location in buffer */ + buf_p += blk_size; + + /* Advance global offset in dataset */ + nbytes_xfer += (ssize_t)blk_size; + + /* Decrement number of bytes left this time */ + nbytes_toxfer -= blk_size; + } /* end while */ + } /* end else */ + } /* end if */ + /* 2D dataspace */ else { + /* Contiguous storage */ + if (!parms->h5_use_chunks) { + /* Contiguous access pattern */ + if (!parms->interleaved) { + /* Compute file offset */ + file_offset = posix_file_offset + + (off_t)((((size_t)nbytes_xfer / blk_size) / (size_t)snbytes) * + (blk_size * (size_t)snbytes) + + (((size_t)nbytes_xfer / blk_size) % (size_t)snbytes)); + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = buf_size; + + /* Global offset advance after each I/O operation */ + file_offset_advance = (off_t)snbytes; + } /* end if */ + /* Interleaved access pattern */ + else { + /* Compute file offset */ + file_offset = + posix_file_offset + + (off_t)(((((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) / + (size_t)snbytes) * + (buf_size * (size_t)snbytes) + + (((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) % + (size_t)snbytes); + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = blk_size; + + /* Global offset advance after each I/O operation */ + file_offset_advance = (off_t)snbytes; + } /* end else */ + } /* end if */ + /* Chunked storage */ + else { + /*Contiguous access pattern */ + if (!parms->interleaved) { + /* Compute file offset */ + file_offset = posix_file_offset + (off_t)nbytes_xfer; + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = blk_size * buf_size; + + /* Global offset advance after each I/O operation */ + file_offset_advance = 0; + } /* end if */ + /*Interleaved access pattern */ + else { + /* Compute file offset */ + /* Before simplification */ + /* file_offset=posix_file_offset+(off_t)((nbytes_xfer/(buf_size/blk_size) + *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))*(buf_size/blk_size + *snbytes/blk_size*(blk_size*blk_size))+((nbytes_xfer/(buf_size/blk_size)) + *pio_mpi_nprocs_g)%(snbytes/blk_size*(blk_size*blk_size))); */ + + file_offset = posix_file_offset + + (off_t)((((size_t)nbytes_xfer / (buf_size / blk_size) * + (size_t)pio_mpi_nprocs_g) / + ((size_t)snbytes * blk_size)) * + (buf_size * (size_t)snbytes) + + (((size_t)nbytes_xfer / (buf_size / blk_size)) * + (size_t)pio_mpi_nprocs_g) % + ((size_t)snbytes * blk_size)); + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = blk_size * blk_size; + + /* Global offset advance after each I/O operation */ + /* file_offset_advance = (off_t)(snbytes/blk_size*(blk_size*blk_size)); */ + file_offset_advance = (off_t)snbytes * (off_t)blk_size; + } /* end else */ + } /* end else */ + + /* Common code for file access */ + /* Set the base of user's buffer */ - buf_p=(unsigned char *)buffer; + buf_p = (unsigned char *)buffer; /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size; + nbytes_toxfer = buf_size * blk_size; - /* Loop over the buffers to write */ - while(nbytes_toxfer>0) { - /* Skip offset over blocks of other processes */ - mpi_offset = mpi_file_offset + - (nbytes_xfer*pio_mpi_nprocs_g); + /* Loop over portions of the buffer to write */ + while (nbytes_toxfer > 0) { + /* only care if seek returns error */ + rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; + VRFY((rc == 0), "POSIXSEEK"); - /* Perform independent write */ - mrc = MPI_File_write_at(fd->mpifd, mpi_offset, buf_p, - (int)1, mpi_blk_type, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_WRITE"); + /* check if all bytes are written */ + rc = ((ssize_t)nbytes_xfer_advance == + POSIXWRITE(fd->posixfd, buf_p, nbytes_xfer_advance)); + VRFY((rc != 0), "POSIXWRITE"); /* Advance location in buffer */ - buf_p+=blk_size; + buf_p += nbytes_xfer_advance; /* Advance global offset in dataset */ - nbytes_xfer+=(ssize_t)blk_size; + nbytes_xfer += (ssize_t)nbytes_xfer_advance; /* Decrement number of bytes left this time */ - nbytes_toxfer-=blk_size; - } /* end while */ - } /* end else */ - } /* end if */ - /* Collective file access */ - else { - /* Contiguous access pattern */ - if (!parms->interleaved){ - /* Compute offset in file */ - mpi_offset = mpi_file_offset + - nbytes_xfer; - - /* Perform independent write */ - mrc = MPI_File_write_at_all(fd->mpifd, mpi_offset, buffer, - (int)(buf_size/blk_size), mpi_blk_type, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_WRITE"); - - /* Advance global offset in dataset */ - nbytes_xfer+=(ssize_t)buf_size; - } /* end if */ - /* Interleaved access pattern */ - else { - /* Compute offset in file */ - mpi_offset = mpi_file_offset + - (nbytes_xfer*pio_mpi_nprocs_g); - - /* Set the file view */ - mrc = MPI_File_set_view(fd->mpifd, mpi_offset, mpi_blk_type, - mpi_file_type, (char*)"native", h5_io_info_g); - VRFY((mrc==MPI_SUCCESS), "MPIO_VIEW"); - - /* Perform write */ - mrc = MPI_File_write_at_all(fd->mpifd, 0, buffer, - (int)(buf_size/blk_size), mpi_blk_type, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_WRITE"); - - /* Advance global offset in dataset */ - nbytes_xfer+=(ssize_t)buf_size; - } /* end else */ - } /* end else */ - } /* end if */ - /* 2D dataspace */ - else { - /* Contiguous storage */ - if (!parms->h5_use_chunks) { - /* Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute offset in file */ - mpi_offset=mpi_file_offset+(MPI_Offset)((((size_t)nbytes_xfer/blk_size)/(size_t)snbytes)* - (blk_size*(size_t)snbytes))+(MPI_Offset)(((size_t)nbytes_xfer/blk_size)%(size_t)snbytes); + nbytes_toxfer -= nbytes_xfer_advance; - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = buf_size; + /* Partially advance file offset */ + file_offset += file_offset_advance; + } /* end while */ - /* Global offset advance after each I/O operation */ - mpi_offset_advance = snbytes; + } /* end else */ - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_cont_type; - } /* end if */ - /* Interleaved access pattern */ + break; + + case MPIO: + /* 1D dataspace */ + if (!parms->dim2d) { + /* Independent file access */ + if (!parms->collective) { + /* Contiguous pattern */ + if (!parms->interleaved) { + /* Compute offset in file */ + mpi_offset = mpi_file_offset + nbytes_xfer; + + /* Perform independent write */ + mrc = + MPI_File_write_at(fd->mpifd, mpi_offset, buffer, + (int)(buf_size / blk_size), mpi_blk_type, &mpi_status); + VRFY((mrc == MPI_SUCCESS), "MPIO_WRITE"); + + /* Advance global offset in dataset */ + nbytes_xfer += (ssize_t)buf_size; + } /* end if */ + /* Interleaved access pattern */ + else { + /* Set the base of user's buffer */ + buf_p = (unsigned char *)buffer; + + /* Set the number of bytes to transfer this time */ + nbytes_toxfer = buf_size; + + /* Loop over the buffers to write */ + while (nbytes_toxfer > 0) { + /* Skip offset over blocks of other processes */ + mpi_offset = mpi_file_offset + (nbytes_xfer * pio_mpi_nprocs_g); + + /* Perform independent write */ + mrc = MPI_File_write_at(fd->mpifd, mpi_offset, buf_p, (int)1, + mpi_blk_type, &mpi_status); + VRFY((mrc == MPI_SUCCESS), "MPIO_WRITE"); + + /* Advance location in buffer */ + buf_p += blk_size; + + /* Advance global offset in dataset */ + nbytes_xfer += (ssize_t)blk_size; + + /* Decrement number of bytes left this time */ + nbytes_toxfer -= blk_size; + } /* end while */ + } /* end else */ + } /* end if */ + /* Collective file access */ + else { + /* Contiguous access pattern */ + if (!parms->interleaved) { + /* Compute offset in file */ + mpi_offset = mpi_file_offset + nbytes_xfer; + + /* Perform independent write */ + mrc = MPI_File_write_at_all(fd->mpifd, mpi_offset, buffer, + (int)(buf_size / blk_size), mpi_blk_type, + &mpi_status); + VRFY((mrc == MPI_SUCCESS), "MPIO_WRITE"); + + /* Advance global offset in dataset */ + nbytes_xfer += (ssize_t)buf_size; + } /* end if */ + /* Interleaved access pattern */ + else { + /* Compute offset in file */ + mpi_offset = mpi_file_offset + (nbytes_xfer * pio_mpi_nprocs_g); + + /* Set the file view */ + mrc = MPI_File_set_view(fd->mpifd, mpi_offset, mpi_blk_type, mpi_file_type, + (char *)"native", h5_io_info_g); + VRFY((mrc == MPI_SUCCESS), "MPIO_VIEW"); + + /* Perform write */ + mrc = MPI_File_write_at_all(fd->mpifd, 0, buffer, (int)(buf_size / blk_size), + mpi_blk_type, &mpi_status); + VRFY((mrc == MPI_SUCCESS), "MPIO_WRITE"); + + /* Advance global offset in dataset */ + nbytes_xfer += (ssize_t)buf_size; + } /* end else */ + } /* end else */ + } /* end if */ + /* 2D dataspace */ else { - /* Compute offset in file */ - mpi_offset=mpi_file_offset+(MPI_Offset)(((((size_t)nbytes_xfer/buf_size)*(size_t)pio_mpi_nprocs_g)/(size_t)snbytes)* - (buf_size*(size_t)snbytes))+(MPI_Offset)((((size_t)nbytes_xfer/buf_size)*(size_t)pio_mpi_nprocs_g)%(size_t)snbytes); + /* Contiguous storage */ + if (!parms->h5_use_chunks) { + /* Contiguous access pattern */ + if (!parms->interleaved) { + /* Compute offset in file */ + mpi_offset = + mpi_file_offset + + (MPI_Offset)((((size_t)nbytes_xfer / blk_size) / (size_t)snbytes) * + (blk_size * (size_t)snbytes)) + + (MPI_Offset)(((size_t)nbytes_xfer / blk_size) % (size_t)snbytes); + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = buf_size; + + /* Global offset advance after each I/O operation */ + mpi_offset_advance = snbytes; + + /* MPI type to be used for collective access */ + mpi_collective_type = mpi_cont_type; + } /* end if */ + /* Interleaved access pattern */ + else { + /* Compute offset in file */ + mpi_offset = + mpi_file_offset + + (MPI_Offset)( + ((((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) / + (size_t)snbytes) * + (buf_size * (size_t)snbytes)) + + (MPI_Offset)( + (((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) % + (size_t)snbytes); + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = blk_size; + + /* Global offset advance after each I/O operation */ + mpi_offset_advance = snbytes; + + /* MPI type to be used for collective access */ + mpi_collective_type = mpi_inter_type; + } /* end else */ + } /* end if */ + /* Chunked storage */ + else { + /*Contiguous access pattern */ + if (!parms->interleaved) { + /* Compute offset in file */ + mpi_offset = mpi_file_offset + nbytes_xfer; + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = blk_size * buf_size; + + /* Global offset advance after each I/O operation */ + mpi_offset_advance = 0; + + /* MPI type to be used for collective access */ + mpi_collective_type = mpi_full_buffer; + } /* end if */ + /*Interleaved access pattern */ + else { + /* Compute offset in file */ + /* Before simplification */ + /* mpi_offset=mpi_file_offset+(nbytes_xfer/(buf_size/blk_size) + *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))* + (buf_size/blk_size*snbytes/blk_size*(blk_size*blk_size))+ + ((nbytes_xfer/(buf_size/blk_size))*pio_mpi_nprocs_g)%(snbytes + /blk_size*(blk_size*blk_size)); */ + mpi_offset = mpi_file_offset + + (MPI_Offset)((((size_t)nbytes_xfer / (buf_size / blk_size) * + (size_t)pio_mpi_nprocs_g) / + ((size_t)snbytes * blk_size)) * + (buf_size * (size_t)snbytes)) + + (MPI_Offset)((((size_t)nbytes_xfer / (buf_size / blk_size)) * + (size_t)pio_mpi_nprocs_g) % + ((size_t)snbytes * blk_size)); + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = blk_size * blk_size; + + /* Global offset advance after each I/O operation */ + /* mpi_offset_advance = (MPI_Offset)(snbytes/blk_size*(blk_size*blk_size)); */ + mpi_offset_advance = (MPI_Offset)((size_t)snbytes * blk_size); + + /* MPI type to be used for collective access */ + mpi_collective_type = mpi_chunk_inter_type; + } /* end else */ + } /* end else */ + + /* Common code for independent file access */ + if (!parms->collective) { + /* Set the base of user's buffer */ + buf_p = (unsigned char *)buffer; + + /* Set the number of bytes to transfer this time */ + nbytes_toxfer = buf_size * blk_size; + + /* Loop over portions of the buffer to write */ + while (nbytes_toxfer > 0) { + /* Perform independent write */ + mrc = MPI_File_write_at(fd->mpifd, mpi_offset, buf_p, + (int)nbytes_xfer_advance, MPI_BYTE, &mpi_status); + VRFY((mrc == MPI_SUCCESS), "MPIO_WRITE"); + + /* Advance location in buffer */ + buf_p += nbytes_xfer_advance; + + /* Advance global offset in dataset */ + nbytes_xfer += (ssize_t)nbytes_xfer_advance; + + /* Decrement number of bytes left this time */ + nbytes_toxfer -= nbytes_xfer_advance; + + /* Partially advance global offset in dataset */ + mpi_offset += mpi_offset_advance; + } /* end while */ + } /* end if */ + + /* Common code for collective file access */ + else { + /* Set the file view */ + mrc = MPI_File_set_view(fd->mpifd, mpi_offset, MPI_BYTE, mpi_collective_type, + (char *)"native", h5_io_info_g); + VRFY((mrc == MPI_SUCCESS), "MPIO_VIEW"); + + /* Perform write */ + MPI_File_write_at_all(fd->mpifd, 0, buffer, (int)(buf_size * blk_size), MPI_BYTE, + &mpi_status); + VRFY((mrc == MPI_SUCCESS), "MPIO_WRITE"); - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size; - - /* Global offset advance after each I/O operation */ - mpi_offset_advance = snbytes; + /* Advance global offset in dataset */ + nbytes_xfer += (off_t)buf_size * (off_t)blk_size; + } /* end else */ - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_inter_type; } /* end else */ - } /* end if */ - /* Chunked storage */ - else { - /*Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute offset in file */ - mpi_offset=mpi_file_offset+nbytes_xfer; - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * buf_size; - /* Global offset advance after each I/O operation */ - mpi_offset_advance = 0; - - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_full_buffer; + break; + + case PHDF5: + /* 1D dataspace */ + if (!parms->dim2d) { + /* Set up the file dset space id to move the selection to process */ + if (!parms->interleaved) { + /* Contiguous pattern */ + h5offset[0] = nbytes_xfer; + } /* end if */ + else { + /* Interleaved access pattern */ + /* Skip offset over blocks of other processes */ + h5offset[0] = (nbytes_xfer * pio_mpi_nprocs_g); + } /* end else */ + hrc = H5Soffset_simple(h5dset_space_id, h5offset); + VRFY((hrc >= 0), "H5Soffset_simple"); + + /* Write the buffer out */ + hrc = + H5Dwrite(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, h5dset_space_id, h5dxpl, buffer); + VRFY((hrc >= 0), "H5Dwrite"); + + /* Increment number of bytes transferred */ + nbytes_xfer += (ssize_t)buf_size; } /* end if */ - /*Interleaved access pattern */ + /* 2D dataspace */ else { - /* Compute offset in file */ - /* Before simplification */ - /* mpi_offset=mpi_file_offset+(nbytes_xfer/(buf_size/blk_size) - *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))* - (buf_size/blk_size*snbytes/blk_size*(blk_size*blk_size))+ - ((nbytes_xfer/(buf_size/blk_size))*pio_mpi_nprocs_g)%(snbytes - /blk_size*(blk_size*blk_size)); */ - mpi_offset=mpi_file_offset+(MPI_Offset)((((size_t)nbytes_xfer/(buf_size/blk_size) - *(size_t)pio_mpi_nprocs_g)/((size_t)snbytes*blk_size))*(buf_size*(size_t)snbytes)) - +(MPI_Offset)((((size_t)nbytes_xfer/(buf_size/blk_size))*(size_t)pio_mpi_nprocs_g)%((size_t)snbytes*blk_size)); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * blk_size; - - /* Global offset advance after each I/O operation */ - /* mpi_offset_advance = (MPI_Offset)(snbytes/blk_size*(blk_size*blk_size)); */ - mpi_offset_advance = (MPI_Offset)((size_t)snbytes*blk_size); - - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_chunk_inter_type; - } /* end else */ - } /* end else */ - - /* Common code for independent file access */ - if (!parms->collective) { - /* Set the base of user's buffer */ - buf_p = (unsigned char *)buffer; - - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size * blk_size; - - /* Loop over portions of the buffer to write */ - while(nbytes_toxfer>0){ - /* Perform independent write */ - mrc = MPI_File_write_at(fd->mpifd, mpi_offset, buf_p, - (int)nbytes_xfer_advance, MPI_BYTE, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_WRITE"); - - /* Advance location in buffer */ - buf_p+=nbytes_xfer_advance; - - /* Advance global offset in dataset */ - nbytes_xfer+=(ssize_t)nbytes_xfer_advance; - - /* Decrement number of bytes left this time */ - nbytes_toxfer-=nbytes_xfer_advance; - - /* Partially advance global offset in dataset */ - mpi_offset+=mpi_offset_advance; - } /* end while */ - } /* end if */ - - /* Common code for collective file access */ - else { - /* Set the file view */ - mrc = MPI_File_set_view(fd->mpifd, mpi_offset, MPI_BYTE, - mpi_collective_type, (char *)"native", h5_io_info_g); - VRFY((mrc==MPI_SUCCESS), "MPIO_VIEW"); - - /* Perform write */ - MPI_File_write_at_all(fd->mpifd, 0, buffer,(int)(buf_size*blk_size), - MPI_BYTE, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_WRITE"); - - /* Advance global offset in dataset */ - nbytes_xfer+=(off_t)buf_size*(off_t)blk_size; - } /* end else */ - - } /* end else */ - - break; - - case PHDF5: - /* 1D dataspace */ - if (!parms->dim2d){ - /* Set up the file dset space id to move the selection to process */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5offset[0] = nbytes_xfer; - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5offset[0] = (nbytes_xfer*pio_mpi_nprocs_g); - } /* end else */ - hrc = H5Soffset_simple(h5dset_space_id, h5offset); - VRFY((hrc >= 0), "H5Soffset_simple"); - - /* Write the buffer out */ - hrc = H5Dwrite(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, - h5dset_space_id, h5dxpl, buffer); - VRFY((hrc >= 0), "H5Dwrite"); - - /* Increment number of bytes transferred */ - nbytes_xfer += (ssize_t)buf_size; - } /* end if */ - /* 2D dataspace */ - else { - /* Set up the file dset space id to move the selection to process */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5offset[0] = (hssize_t)(((size_t)nbytes_xfer/((size_t)snbytes*blk_size))*blk_size); - h5offset[1] = (hssize_t)(((size_t)nbytes_xfer%((size_t)snbytes*blk_size))/blk_size); - - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5offset[0] = (hssize_t)((((size_t)nbytes_xfer*(size_t)pio_mpi_nprocs_g)/((size_t)snbytes*buf_size))*buf_size); - h5offset[1] = (hssize_t)((((size_t)nbytes_xfer*(size_t)pio_mpi_nprocs_g)%((size_t)snbytes*buf_size))/buf_size); + /* Set up the file dset space id to move the selection to process */ + if (!parms->interleaved) { + /* Contiguous pattern */ + h5offset[0] = + (hssize_t)(((size_t)nbytes_xfer / ((size_t)snbytes * blk_size)) * blk_size); + h5offset[1] = + (hssize_t)(((size_t)nbytes_xfer % ((size_t)snbytes * blk_size)) / blk_size); + + } /* end if */ + else { + /* Interleaved access pattern */ + /* Skip offset over blocks of other processes */ + h5offset[0] = (hssize_t)((((size_t)nbytes_xfer * (size_t)pio_mpi_nprocs_g) / + ((size_t)snbytes * buf_size)) * + buf_size); + h5offset[1] = (hssize_t)((((size_t)nbytes_xfer * (size_t)pio_mpi_nprocs_g) % + ((size_t)snbytes * buf_size)) / + buf_size); - } /* end else */ - hrc = H5Soffset_simple(h5dset_space_id, h5offset); - VRFY((hrc >= 0), "H5Soffset_simple"); + } /* end else */ + hrc = H5Soffset_simple(h5dset_space_id, h5offset); + VRFY((hrc >= 0), "H5Soffset_simple"); - /* Write the buffer out */ - hrc = H5Dwrite(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, - h5dset_space_id, h5dxpl, buffer); - VRFY((hrc >= 0), "H5Dwrite"); + /* Write the buffer out */ + hrc = + H5Dwrite(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, h5dset_space_id, h5dxpl, buffer); + VRFY((hrc >= 0), "H5Dwrite"); - /* Increment number of bytes transferred */ - nbytes_xfer += (off_t)buf_size*(off_t)blk_size; + /* Increment number of bytes transferred */ + nbytes_xfer += (off_t)buf_size * (off_t)blk_size; - } /* end else */ + } /* end else */ - break; + break; - default: - break; - } /* switch (parms->io_type) */ - } /* end while */ + default: + break; + } /* switch (parms->io_type) */ + } /* end while */ - /* Stop "raw data" write timer */ - io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTOP); + /* Stop "raw data" write timer */ + io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTOP); - /* Calculate write time */ + /* Calculate write time */ - /* Close dataset. Only HDF5 needs to do an explicit close. */ - if (parms->io_type == PHDF5) { - hrc = H5Dclose(h5ds_id); + /* Close dataset. Only HDF5 needs to do an explicit close. */ + if (parms->io_type == PHDF5) { + hrc = H5Dclose(h5ds_id); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Close failed\n"); - GOTOERROR(FAIL); - } + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Dataset Close failed\n"); + GOTOERROR(FAIL); + } - h5ds_id = H5I_INVALID_HID; - } /* end if */ - } /* end for */ + h5ds_id = H5I_INVALID_HID; + } /* end if */ + } /* end for */ done: /* release MPI-I/O objects */ if (parms->io_type == MPIO) { /* 1D dataspace */ - if (!parms->dim2d){ + if (!parms->dim2d) { /* Free file type */ - mrc = MPI_Type_free( &mpi_file_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + mrc = MPI_Type_free(&mpi_file_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free buffer type */ - mrc = MPI_Type_free( &mpi_blk_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + mrc = MPI_Type_free(&mpi_blk_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); } /* end if */ /* 2D dataspace */ else { /* Free partial buffer type for contiguous access */ - mrc = MPI_Type_free( &mpi_partial_buffer_cont ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + mrc = MPI_Type_free(&mpi_partial_buffer_cont); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free contiguous file type */ - mrc = MPI_Type_free( &mpi_cont_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + mrc = MPI_Type_free(&mpi_cont_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free partial buffer type for interleaved access */ - mrc = MPI_Type_free( &mpi_partial_buffer_inter ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + mrc = MPI_Type_free(&mpi_partial_buffer_inter); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free interleaved file type */ - mrc = MPI_Type_free( &mpi_inter_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + mrc = MPI_Type_free(&mpi_inter_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free full buffer type */ mrc = MPI_Type_free(&mpi_full_buffer); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free full chunk type */ mrc = MPI_Type_free(&mpi_full_chunk); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free chunk interleaved file type */ mrc = MPI_Type_free(&mpi_chunk_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); } /* end else */ - } /* end if */ + } /* end if */ /* release HDF5 objects */ if (h5dset_space_id != -1) { - hrc = H5Sclose(h5dset_space_id); - if (hrc < 0){ - HDfprintf(stderr, "HDF5 Dataset Space Close failed\n"); - ret_code = FAIL; - } else { - h5dset_space_id = H5I_INVALID_HID; - } + hrc = H5Sclose(h5dset_space_id); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Dataset Space Close failed\n"); + ret_code = FAIL; + } + else { + h5dset_space_id = H5I_INVALID_HID; + } } if (h5mem_space_id != -1) { - hrc = H5Sclose(h5mem_space_id); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Memory Space Close failed\n"); - ret_code = FAIL; - } else { - h5mem_space_id = H5I_INVALID_HID; - } + hrc = H5Sclose(h5mem_space_id); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Memory Space Close failed\n"); + ret_code = FAIL; + } + else { + h5mem_space_id = H5I_INVALID_HID; + } } if (h5dxpl != -1) { - hrc = H5Pclose(h5dxpl); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n"); - ret_code = FAIL; - } else { - h5dxpl = H5I_INVALID_HID; - } + hrc = H5Pclose(h5dxpl); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n"); + ret_code = FAIL; + } + else { + h5dxpl = H5I_INVALID_HID; + } } return ret_code; @@ -1505,62 +1519,62 @@ sqrto(off_t x) * Modifications: * Added 2D testing (Christian Chilan, 10. August 2005) */ - static herr_t -do_read(results *res, file_descr *fd, parameters *parms, long ndsets, - off_t nbytes, size_t buf_size, void *buffer /*out*/) +static herr_t +do_read(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nbytes, size_t buf_size, + void *buffer /*out*/) { - int ret_code = SUCCESS; - int rc; /*routine return code */ - long ndset; - size_t blk_size; /* The block size to subdivide the xfer buffer into */ - size_t bsize; /* Size of the actual buffer */ - off_t nbytes_xfer; /* Total number of bytes transferred so far */ - size_t nbytes_xfer_advance; /* Number of bytes transferred in a single I/O operation */ - size_t nbytes_toxfer; /* Number of bytes to transfer a particular time */ - char dname[64]; - off_t dset_offset=0; /*dataset offset in a file */ - off_t bytes_begin[2]; /*first elmt this process transfer */ - off_t bytes_count; /*number of elmts this process transfer */ - off_t snbytes=0; /*size of a side of the dataset square */ - unsigned char *buf_p; /* Current buffer pointer */ + int ret_code = SUCCESS; + int rc; /*routine return code */ + long ndset; + size_t blk_size; /* The block size to subdivide the xfer buffer into */ + size_t bsize; /* Size of the actual buffer */ + off_t nbytes_xfer; /* Total number of bytes transferred so far */ + size_t nbytes_xfer_advance; /* Number of bytes transferred in a single I/O operation */ + size_t nbytes_toxfer; /* Number of bytes to transfer a particular time */ + char dname[64]; + off_t dset_offset = 0; /*dataset offset in a file */ + off_t bytes_begin[2]; /*first elmt this process transfer */ + off_t bytes_count; /*number of elmts this process transfer */ + off_t snbytes = 0; /*size of a side of the dataset square */ + unsigned char *buf_p; /* Current buffer pointer */ /* POSIX variables */ - off_t file_offset; /* File offset of the next transfer */ - off_t file_offset_advance; /* File offset advance after each I/O operation */ - off_t posix_file_offset; /* Base file offset of the next transfer */ + off_t file_offset; /* File offset of the next transfer */ + off_t file_offset_advance; /* File offset advance after each I/O operation */ + off_t posix_file_offset; /* Base file offset of the next transfer */ /* MPI variables */ - MPI_Offset mpi_file_offset;/* Base file offset of the next transfer*/ - MPI_Offset mpi_offset; /* Offset in MPI file */ - MPI_Offset mpi_offset_advance; /* Offset advance after each I/O operation */ - MPI_Datatype mpi_file_type; /* MPI derived type for 1D file */ - MPI_Datatype mpi_blk_type; /* MPI derived type for 1D buffer */ - MPI_Datatype mpi_cont_type; /* MPI derived type for 2D contiguous file */ - MPI_Datatype mpi_partial_buffer_cont; /* MPI derived type for partial 2D contiguous buffer */ - MPI_Datatype mpi_inter_type; /* MPI derived type for 2D interleaved file */ - MPI_Datatype mpi_partial_buffer_inter; /* MPI derived type for partial 2D interleaved buffer */ - MPI_Datatype mpi_full_buffer; /* MPI derived type for 2D full buffer */ - MPI_Datatype mpi_full_chunk; /* MPI derived type for 2D full chunk */ - MPI_Datatype mpi_chunk_inter_type; /* MPI derived type for 2D chunk interleaved file */ - MPI_Datatype mpi_collective_type; /* Generic MPI derived type for 2D collective access */ - MPI_Status mpi_status; - int mrc; /* MPI return code */ + MPI_Offset mpi_file_offset; /* Base file offset of the next transfer*/ + MPI_Offset mpi_offset; /* Offset in MPI file */ + MPI_Offset mpi_offset_advance; /* Offset advance after each I/O operation */ + MPI_Datatype mpi_file_type; /* MPI derived type for 1D file */ + MPI_Datatype mpi_blk_type; /* MPI derived type for 1D buffer */ + MPI_Datatype mpi_cont_type; /* MPI derived type for 2D contiguous file */ + MPI_Datatype mpi_partial_buffer_cont; /* MPI derived type for partial 2D contiguous buffer */ + MPI_Datatype mpi_inter_type; /* MPI derived type for 2D interleaved file */ + MPI_Datatype mpi_partial_buffer_inter; /* MPI derived type for partial 2D interleaved buffer */ + MPI_Datatype mpi_full_buffer; /* MPI derived type for 2D full buffer */ + MPI_Datatype mpi_full_chunk; /* MPI derived type for 2D full chunk */ + MPI_Datatype mpi_chunk_inter_type; /* MPI derived type for 2D chunk interleaved file */ + MPI_Datatype mpi_collective_type; /* Generic MPI derived type for 2D collective access */ + MPI_Status mpi_status; + int mrc; /* MPI return code */ /* HDF5 variables */ - herr_t hrc; /*HDF5 return code */ - hsize_t h5dims[2]; /*dataset dim sizes */ - hid_t h5dset_space_id = H5I_INVALID_HID; /*dataset space ID */ - hid_t h5mem_space_id = H5I_INVALID_HID; /*memory dataspace ID */ - hid_t h5ds_id = H5I_INVALID_HID; /*dataset handle */ - hsize_t h5block[2]; /*dataspace selection */ - hsize_t h5stride[2]; - hsize_t h5count[2]; - hsize_t h5start[2]; - hssize_t h5offset[2]; /* Selection offset within dataspace */ - hid_t h5dxpl = H5I_INVALID_HID; /* Dataset transfer property list */ + herr_t hrc; /*HDF5 return code */ + hsize_t h5dims[2]; /*dataset dim sizes */ + hid_t h5dset_space_id = H5I_INVALID_HID; /*dataset space ID */ + hid_t h5mem_space_id = H5I_INVALID_HID; /*memory dataspace ID */ + hid_t h5ds_id = H5I_INVALID_HID; /*dataset handle */ + hsize_t h5block[2]; /*dataspace selection */ + hsize_t h5stride[2]; + hsize_t h5count[2]; + hsize_t h5start[2]; + hssize_t h5offset[2]; /* Selection offset within dataspace */ + hid_t h5dxpl = H5I_INVALID_HID; /* Dataset transfer property list */ /* Get the parameters from the parameter block */ - blk_size=parms->blk_size; + blk_size = parms->blk_size; /* There are two kinds of transfer patterns, contiguous and interleaved. * Let 0,1,2,...,n be data accessed by process 0,1,2,...,n @@ -1573,17 +1587,17 @@ do_read(results *res, file_descr *fd, parameters *parms, long ndsets, */ /* 1D dataspace */ - if (!parms->dim2d){ + if (!parms->dim2d) { bsize = buf_size; /* Contiguous Pattern: */ if (!parms->interleaved) { - bytes_begin[0] = (off_t)(((double)nbytes*pio_mpi_rank_g)/pio_mpi_nprocs_g); + bytes_begin[0] = (off_t)(((double)nbytes * pio_mpi_rank_g) / pio_mpi_nprocs_g); } /* end if */ /* Interleaved Pattern: */ else { - bytes_begin[0] = (off_t)blk_size*(off_t)pio_mpi_rank_g; + bytes_begin[0] = (off_t)blk_size * (off_t)pio_mpi_rank_g; } /* end else */ - }/* end if */ + } /* end if */ /* 2D dataspace */ else { /* nbytes is always the number of bytes per dataset (1D or 2D). If the @@ -1595,19 +1609,19 @@ do_read(results *res, file_descr *fd, parameters *parms, long ndsets, /* Contiguous Pattern: */ if (!parms->interleaved) { - bytes_begin[0] = (off_t)((double)snbytes*pio_mpi_rank_g / pio_mpi_nprocs_g); + bytes_begin[0] = (off_t)((double)snbytes * pio_mpi_rank_g / pio_mpi_nprocs_g); bytes_begin[1] = 0; } /* end if */ /* Interleaved Pattern: */ else { bytes_begin[0] = 0; - if (!parms->h5_use_chunks || parms->io_type==PHDF5) - bytes_begin[1] = (off_t)blk_size*(off_t)pio_mpi_rank_g; + if (!parms->h5_use_chunks || parms->io_type == PHDF5) + bytes_begin[1] = (off_t)blk_size * (off_t)pio_mpi_rank_g; else - bytes_begin[1] = (off_t)blk_size*(off_t)blk_size*(off_t)pio_mpi_rank_g; + bytes_begin[1] = (off_t)blk_size * (off_t)blk_size * (off_t)pio_mpi_rank_g; } /* end else */ - } /* end else */ + } /* end else */ /* Calculate the total number of bytes (bytes_count) to be * transferred by this process. It may be different for different @@ -1619,842 +1633,865 @@ do_read(results *res, file_descr *fd, parameters *parms, long ndsets, * This way, it eliminates any rounding errors. * (This is tricky, don't mess with the formula, rounding errors * can easily get introduced) */ - bytes_count = (off_t)(((double)nbytes*(pio_mpi_rank_g+1)) / pio_mpi_nprocs_g) - - (off_t)(((double)nbytes*pio_mpi_rank_g) / pio_mpi_nprocs_g); + bytes_count = (off_t)(((double)nbytes * (pio_mpi_rank_g + 1)) / pio_mpi_nprocs_g) - + (off_t)(((double)nbytes * pio_mpi_rank_g) / pio_mpi_nprocs_g); /* debug */ if (pio_debug_level >= 4) { HDprint_rank(output); if (!parms->dim2d) { - HDfprintf(output, "Debug(do_write): " - "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", - buf_size, (long long)bytes_begin[0], - (long long)bytes_count); - } else { - HDfprintf(output, "Debug(do_write): " - "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", - buf_size*blk_size, (long long)bytes_begin[0], - (long long)bytes_begin[1], (long long)bytes_count); + HDfprintf(output, + "Debug(do_write): " + "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH + "d\n", + buf_size, (long long)bytes_begin[0], (long long)bytes_count); + } + else { + HDfprintf(output, + "Debug(do_write): " + "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH + "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", + buf_size * blk_size, (long long)bytes_begin[0], (long long)bytes_begin[1], + (long long)bytes_count); } } /* I/O Access specific setup */ switch (parms->io_type) { - case POSIXIO: - /* No extra setup */ - break; - - case MPIO: /* MPI-I/O setup */ - /* 1D dataspace */ - if (!parms->dim2d){ - /* Build block's derived type */ - mrc = MPI_Type_contiguous((int)blk_size, - MPI_BYTE, &mpi_blk_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Build file's derived type */ - mrc = MPI_Type_vector((int)(buf_size/blk_size), (int)1, - (int)pio_mpi_nprocs_g, mpi_blk_type, &mpi_file_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit file type */ - mrc = MPI_Type_commit( &mpi_file_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Commit buffer type */ - mrc = MPI_Type_commit( &mpi_blk_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - } /* end if */ - /* 2D dataspace */ - else { - /* Build partial buffer derived type for contiguous access */ - mrc = MPI_Type_contiguous((int)buf_size, MPI_BYTE, - &mpi_partial_buffer_cont); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit partial buffer derived type */ - mrc = MPI_Type_commit(&mpi_partial_buffer_cont); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build contiguous file's derived type */ - mrc = MPI_Type_vector((int)blk_size, (int)1, (int)((size_t)snbytes/buf_size), - mpi_partial_buffer_cont, &mpi_cont_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit contiguous file type */ - mrc = MPI_Type_commit(&mpi_cont_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build partial buffer derived type for interleaved access */ - mrc = MPI_Type_contiguous((int)blk_size, MPI_BYTE, - &mpi_partial_buffer_inter); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit partial buffer derived type */ - mrc = MPI_Type_commit(&mpi_partial_buffer_inter); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build interleaved file's derived type */ - mrc = MPI_Type_vector((int)buf_size, (int)1, (int)((size_t)snbytes/blk_size), - mpi_partial_buffer_inter, &mpi_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit interleaved file type */ - mrc = MPI_Type_commit(&mpi_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build full buffer derived type */ - mrc = MPI_Type_contiguous((int)(blk_size*buf_size), MPI_BYTE, - &mpi_full_buffer); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit full buffer derived type */ - mrc = MPI_Type_commit(&mpi_full_buffer); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build full chunk derived type */ - mrc = MPI_Type_contiguous((int)(blk_size*blk_size), MPI_BYTE, - &mpi_full_chunk); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit full chunk derived type */ - mrc = MPI_Type_commit(&mpi_full_chunk); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - - /* Build chunk interleaved file's derived type */ - mrc = MPI_Type_vector((int)(buf_size/blk_size), (int)1, (int)((size_t)snbytes/blk_size), - mpi_full_chunk, &mpi_chunk_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_CREATE"); - - /* Commit chunk interleaved file type */ - mrc = MPI_Type_commit(&mpi_chunk_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_COMMIT"); - } /* end else */ - break; - - case PHDF5: /* HDF5 setup */ - /* 1D dataspace */ - if (!parms->dim2d){ - if(nbytes>0) { - /* define a contiguous dataset of nbytes native bytes */ - h5dims[0] = (hsize_t)nbytes; - h5dset_space_id = H5Screate_simple(1, h5dims, NULL); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - - /* Set up the file dset space id to select the pattern to access */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5start[0] = (hsize_t)bytes_begin[0]; - h5stride[0] = h5block[0] = blk_size; - h5count[0] = buf_size/blk_size; - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5start[0] = (hsize_t)bytes_begin[0]; - h5stride[0] = blk_size*(size_t)pio_mpi_nprocs_g; - h5block[0] = blk_size; - h5count[0] = buf_size/blk_size; - } /* end else */ - hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, - h5start, h5stride, h5count, h5block); - VRFY((hrc >= 0), "H5Sselect_hyperslab"); - } /* end if */ - else { - h5dset_space_id = H5Screate(H5S_SCALAR); - VRFY((h5dset_space_id >= 0), "H5Screate"); - } /* end else */ + case POSIXIO: + /* No extra setup */ + break; - /* Create the memory dataspace that corresponds to the xfer buffer */ - if(buf_size>0) { - h5dims[0] = buf_size; - h5mem_space_id = H5Screate_simple(1, h5dims, NULL); - VRFY((h5mem_space_id >= 0), "H5Screate_simple"); - } /* end if */ - else { - h5mem_space_id = H5Screate(H5S_SCALAR); - VRFY((h5mem_space_id >= 0), "H5Screate"); - } /* end else */ - } /* end if */ - /* 2D dataspace */ - else { - if(nbytes>0) { - /* define a contiguous dataset of nbytes native bytes */ - h5dims[0] = (hsize_t)snbytes; - h5dims[1] = (hsize_t)snbytes; - h5dset_space_id = H5Screate_simple(2, h5dims, NULL); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - - /* Set up the file dset space id to select the pattern to access */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5start[0] = (hsize_t)bytes_begin[0]; - h5start[1] = (hsize_t)bytes_begin[1]; - h5stride[0] = 1; - h5stride[1] = h5block[0] = h5block[1] = blk_size; - h5count[0] = 1; - h5count[1] = buf_size/blk_size; + case MPIO: /* MPI-I/O setup */ + /* 1D dataspace */ + if (!parms->dim2d) { + /* Build block's derived type */ + mrc = MPI_Type_contiguous((int)blk_size, MPI_BYTE, &mpi_blk_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); + + /* Build file's derived type */ + mrc = MPI_Type_vector((int)(buf_size / blk_size), (int)1, (int)pio_mpi_nprocs_g, mpi_blk_type, + &mpi_file_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); + + /* Commit file type */ + mrc = MPI_Type_commit(&mpi_file_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); + + /* Commit buffer type */ + mrc = MPI_Type_commit(&mpi_blk_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); } /* end if */ + /* 2D dataspace */ else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5start[0] = (hsize_t)bytes_begin[0]; - h5start[1] = (hsize_t)bytes_begin[1]; - h5stride[0] = blk_size; - h5stride[1] = blk_size*(size_t)pio_mpi_nprocs_g; - h5block[0] = h5block[1] = blk_size; - h5count[0] = buf_size/blk_size; - h5count[1] = 1; + /* Build partial buffer derived type for contiguous access */ + mrc = MPI_Type_contiguous((int)buf_size, MPI_BYTE, &mpi_partial_buffer_cont); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); + + /* Commit partial buffer derived type */ + mrc = MPI_Type_commit(&mpi_partial_buffer_cont); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); + + /* Build contiguous file's derived type */ + mrc = MPI_Type_vector((int)blk_size, (int)1, (int)((size_t)snbytes / buf_size), + mpi_partial_buffer_cont, &mpi_cont_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); + + /* Commit contiguous file type */ + mrc = MPI_Type_commit(&mpi_cont_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); + + /* Build partial buffer derived type for interleaved access */ + mrc = MPI_Type_contiguous((int)blk_size, MPI_BYTE, &mpi_partial_buffer_inter); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); + + /* Commit partial buffer derived type */ + mrc = MPI_Type_commit(&mpi_partial_buffer_inter); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); + + /* Build interleaved file's derived type */ + mrc = MPI_Type_vector((int)buf_size, (int)1, (int)((size_t)snbytes / blk_size), + mpi_partial_buffer_inter, &mpi_inter_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); + + /* Commit interleaved file type */ + mrc = MPI_Type_commit(&mpi_inter_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); + + /* Build full buffer derived type */ + mrc = MPI_Type_contiguous((int)(blk_size * buf_size), MPI_BYTE, &mpi_full_buffer); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); + + /* Commit full buffer derived type */ + mrc = MPI_Type_commit(&mpi_full_buffer); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); + + /* Build full chunk derived type */ + mrc = MPI_Type_contiguous((int)(blk_size * blk_size), MPI_BYTE, &mpi_full_chunk); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); + + /* Commit full chunk derived type */ + mrc = MPI_Type_commit(&mpi_full_chunk); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); + + /* Build chunk interleaved file's derived type */ + mrc = MPI_Type_vector((int)(buf_size / blk_size), (int)1, (int)((size_t)snbytes / blk_size), + mpi_full_chunk, &mpi_chunk_inter_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE"); + + /* Commit chunk interleaved file type */ + mrc = MPI_Type_commit(&mpi_chunk_inter_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT"); } /* end else */ - hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, - h5start, h5stride, h5count, h5block); - VRFY((hrc >= 0), "H5Sselect_hyperslab"); - } /* end if */ - else { - h5dset_space_id = H5Screate(H5S_SCALAR); - VRFY((h5dset_space_id >= 0), "H5Screate"); - } /* end else */ - - /* Create the memory dataspace that corresponds to the xfer buffer */ - if(buf_size>0) { - if (!parms->interleaved){ - h5dims[0] = blk_size; - h5dims[1] = buf_size; - }else{ - h5dims[0] = buf_size; - h5dims[1] = blk_size; - } - h5mem_space_id = H5Screate_simple(2, h5dims, NULL); - VRFY((h5mem_space_id >= 0), "H5Screate_simple"); - } /* end if */ - else { - h5mem_space_id = H5Screate(H5S_SCALAR); - VRFY((h5mem_space_id >= 0), "H5Screate"); - } /* end else */ - } /* end else */ - - /* Create the dataset transfer property list */ - h5dxpl = H5Pcreate(H5P_DATASET_XFER); - if (h5dxpl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } - - /* Change to collective I/O, if asked */ - if(parms->collective) { - hrc = H5Pset_dxpl_mpio(h5dxpl, H5FD_MPIO_COLLECTIVE); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Set failed\n"); - GOTOERROR(FAIL); - } /* end if */ - } /* end if */ - break; - - default: - break; - } /* end switch */ - - for (ndset = 1; ndset <= ndsets; ++ndset) { - - /* Calculate dataset offset within a file */ - - /* create dataset */ - switch (parms->io_type) { - case POSIXIO: - case MPIO: - /* both posix and mpi io just need dataset offset in file*/ - dset_offset = (ndset - 1) * nbytes; break; - case PHDF5: - HDsprintf(dname, "Dataset_%ld", ndset); - h5ds_id = H5DOPEN(fd->h5fd, dname); - if (h5ds_id < 0) { - HDfprintf(stderr, "HDF5 Dataset open failed\n"); - GOTOERROR(FAIL); - } - break; - - default: - break; - } - - /* The task is to transfer bytes_count bytes, starting at - * bytes_begin position, using transfer buffer of buf_size bytes. - * If interleaved, select buf_size at a time, in round robin - * fashion, according to number of process. Otherwise, select - * all bytes_count in contiguous. - */ - nbytes_xfer = 0 ; - - /* 1D dataspace */ - if (!parms->dim2d){ - /* Set base file offset for all I/O patterns and POSIX access */ - posix_file_offset = dset_offset + bytes_begin[0]; - - /* Set base file offset for all I/O patterns and MPI access */ - mpi_file_offset = (MPI_Offset)(dset_offset + bytes_begin[0]); - } /* end if */ - else { - /* Set base file offset for all I/O patterns and POSIX access */ - posix_file_offset=dset_offset + bytes_begin[0]*snbytes+ - bytes_begin[1]; - - /* Set base file offset for all I/O patterns and MPI access */ - mpi_file_offset=(MPI_Offset)(dset_offset + bytes_begin[0]*snbytes+ - bytes_begin[1]); - } /* end else */ - - /* Start "raw data" read timer */ - io_time_set(res->timers, HDF5_RAW_READ_FIXED_DIMS, TSTART); - - while (nbytes_xfer < bytes_count){ - /* Read */ - /* Calculate offset of read within a dataset/file */ - switch (parms->io_type) { - case POSIXIO: + case PHDF5: /* HDF5 setup */ /* 1D dataspace */ - if (!parms->dim2d){ - /* Contiguous pattern */ - if (!parms->interleaved) { - /* Compute file offset */ - file_offset = posix_file_offset + (off_t)nbytes_xfer; - - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); - - /* check if all bytes are read */ - rc = ((ssize_t)buf_size == - POSIXREAD(fd->posixfd, buffer, buf_size)); - VRFY((rc != 0), "POSIXREAD"); - - /* Advance global offset in dataset */ - nbytes_xfer+=(off_t)buf_size; + if (!parms->dim2d) { + if (nbytes > 0) { + /* define a contiguous dataset of nbytes native bytes */ + h5dims[0] = (hsize_t)nbytes; + h5dset_space_id = H5Screate_simple(1, h5dims, NULL); + VRFY((h5dset_space_id >= 0), "H5Screate_simple"); + + /* Set up the file dset space id to select the pattern to access */ + if (!parms->interleaved) { + /* Contiguous pattern */ + h5start[0] = (hsize_t)bytes_begin[0]; + h5stride[0] = h5block[0] = blk_size; + h5count[0] = buf_size / blk_size; + } /* end if */ + else { + /* Interleaved access pattern */ + /* Skip offset over blocks of other processes */ + h5start[0] = (hsize_t)bytes_begin[0]; + h5stride[0] = blk_size * (size_t)pio_mpi_nprocs_g; + h5block[0] = blk_size; + h5count[0] = buf_size / blk_size; + } /* end else */ + hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, h5start, h5stride, h5count, + h5block); + VRFY((hrc >= 0), "H5Sselect_hyperslab"); } /* end if */ - /* Interleaved access pattern */ else { - /* Set the base of user's buffer */ - buf_p=(unsigned char *)buffer; - - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size; - - /* Loop over the buffers to read */ - while(nbytes_toxfer>0) { - /* Skip offset over blocks of other processes */ - file_offset = posix_file_offset + - (off_t)(nbytes_xfer*pio_mpi_nprocs_g); - - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); - - /* check if all bytes are read */ - rc = ((ssize_t)blk_size == - POSIXREAD(fd->posixfd, buf_p, blk_size)); - VRFY((rc != 0), "POSIXREAD"); - - /* Advance location in buffer */ - buf_p+=blk_size; - - /* Advance global offset in dataset */ - nbytes_xfer+=(off_t)blk_size; + h5dset_space_id = H5Screate(H5S_SCALAR); + VRFY((h5dset_space_id >= 0), "H5Screate"); + } /* end else */ - /* Decrement number of bytes left this time */ - nbytes_toxfer-=blk_size; - } /* end while */ + /* Create the memory dataspace that corresponds to the xfer buffer */ + if (buf_size > 0) { + h5dims[0] = buf_size; + h5mem_space_id = H5Screate_simple(1, h5dims, NULL); + VRFY((h5mem_space_id >= 0), "H5Screate_simple"); + } /* end if */ + else { + h5mem_space_id = H5Screate(H5S_SCALAR); + VRFY((h5mem_space_id >= 0), "H5Screate"); } /* end else */ - } /* end if */ + } /* end if */ /* 2D dataspace */ else { - /* Contiguous storage */ - if (!parms->h5_use_chunks) { - /* Contiguous access pattern */ + if (nbytes > 0) { + /* define a contiguous dataset of nbytes native bytes */ + h5dims[0] = (hsize_t)snbytes; + h5dims[1] = (hsize_t)snbytes; + h5dset_space_id = H5Screate_simple(2, h5dims, NULL); + VRFY((h5dset_space_id >= 0), "H5Screate_simple"); + + /* Set up the file dset space id to select the pattern to access */ if (!parms->interleaved) { - /* Compute file offset */ - file_offset=posix_file_offset+(off_t)((((size_t)nbytes_xfer/blk_size) - /(size_t)snbytes)*(blk_size*(size_t)snbytes)+(((size_t)nbytes_xfer/blk_size)%(size_t)snbytes)); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = buf_size; - - /* Global offset advance after each I/O operation */ - file_offset_advance = (off_t)snbytes; + /* Contiguous pattern */ + h5start[0] = (hsize_t)bytes_begin[0]; + h5start[1] = (hsize_t)bytes_begin[1]; + h5stride[0] = 1; + h5stride[1] = h5block[0] = h5block[1] = blk_size; + h5count[0] = 1; + h5count[1] = buf_size / blk_size; } /* end if */ - /* Interleaved access pattern */ else { - /* Compute file offset */ - file_offset=posix_file_offset+(off_t)(((((size_t)nbytes_xfer/buf_size) - *(size_t)pio_mpi_nprocs_g)/(size_t)snbytes)*(buf_size*(size_t)snbytes) - +(((size_t)nbytes_xfer/buf_size)*(size_t)pio_mpi_nprocs_g)%(size_t)snbytes); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size; - - /* Global offset advance after each I/O operation */ - file_offset_advance = (off_t)snbytes; + /* Interleaved access pattern */ + /* Skip offset over blocks of other processes */ + h5start[0] = (hsize_t)bytes_begin[0]; + h5start[1] = (hsize_t)bytes_begin[1]; + h5stride[0] = blk_size; + h5stride[1] = blk_size * (size_t)pio_mpi_nprocs_g; + h5block[0] = h5block[1] = blk_size; + h5count[0] = buf_size / blk_size; + h5count[1] = 1; } /* end else */ + hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, h5start, h5stride, h5count, + h5block); + VRFY((hrc >= 0), "H5Sselect_hyperslab"); } /* end if */ - /* Chunked storage */ else { - /*Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute file offset */ - file_offset=posix_file_offset+(off_t)nbytes_xfer; - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * buf_size; + h5dset_space_id = H5Screate(H5S_SCALAR); + VRFY((h5dset_space_id >= 0), "H5Screate"); + } /* end else */ - /* Global offset advance after each I/O operation */ - file_offset_advance = 0; - } /* end if */ - /*Interleaved access pattern */ + /* Create the memory dataspace that corresponds to the xfer buffer */ + if (buf_size > 0) { + if (!parms->interleaved) { + h5dims[0] = blk_size; + h5dims[1] = buf_size; + } else { - /* Compute file offset */ - /* Before simplification */ - /* file_offset=posix_file_offset+(off_t)((nbytes_xfer/(buf_size/blk_size) - *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))*(buf_size/blk_size - *snbytes/blk_size*(blk_size*blk_size))+((nbytes_xfer/(buf_size/blk_size)) - *pio_mpi_nprocs_g)%(snbytes/blk_size*(blk_size*blk_size))); */ - - file_offset=posix_file_offset+(off_t)((((size_t)nbytes_xfer/(buf_size/blk_size) - *(size_t)pio_mpi_nprocs_g)/((size_t)snbytes*blk_size))*(buf_size*(size_t)snbytes)+(((size_t)nbytes_xfer/(buf_size/blk_size)) - *(size_t)pio_mpi_nprocs_g)%((size_t)snbytes*blk_size)); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * blk_size; - - /* Global offset advance after each I/O operation */ - /* file_offset_advance = (off_t)(snbytes/blk_size*(blk_size*blk_size)); */ - file_offset_advance = (off_t)((size_t)snbytes*blk_size); - } /* end else */ + h5dims[0] = buf_size; + h5dims[1] = blk_size; + } + h5mem_space_id = H5Screate_simple(2, h5dims, NULL); + VRFY((h5mem_space_id >= 0), "H5Screate_simple"); + } /* end if */ + else { + h5mem_space_id = H5Screate(H5S_SCALAR); + VRFY((h5mem_space_id >= 0), "H5Screate"); } /* end else */ + } /* end else */ + + /* Create the dataset transfer property list */ + h5dxpl = H5Pcreate(H5P_DATASET_XFER); + if (h5dxpl < 0) { + HDfprintf(stderr, "HDF5 Property List Create failed\n"); + GOTOERROR(FAIL); + } - /* Common code for file access */ + /* Change to collective I/O, if asked */ + if (parms->collective) { + hrc = H5Pset_dxpl_mpio(h5dxpl, H5FD_MPIO_COLLECTIVE); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Property List Set failed\n"); + GOTOERROR(FAIL); + } /* end if */ + } /* end if */ + break; - /* Set the base of user's buffer */ - buf_p = (unsigned char *)buffer; + default: + break; + } /* end switch */ - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size*blk_size; + for (ndset = 1; ndset <= ndsets; ++ndset) { - /* Loop over portions of the buffer to read */ - while(nbytes_toxfer>0){ - /* only care if seek returns error */ - rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); + /* Calculate dataset offset within a file */ - /* check if all bytes are read */ - rc = ((ssize_t)nbytes_xfer_advance == - POSIXREAD(fd->posixfd, buf_p, nbytes_xfer_advance)); - VRFY((rc != 0), "POSIXREAD"); + /* create dataset */ + switch (parms->io_type) { + case POSIXIO: + case MPIO: + /* both posix and mpi io just need dataset offset in file*/ + dset_offset = (ndset - 1) * nbytes; + break; - /* Advance location in buffer */ - buf_p+=nbytes_xfer_advance; + case PHDF5: + HDsprintf(dname, "Dataset_%ld", ndset); + h5ds_id = H5DOPEN(fd->h5fd, dname); + if (h5ds_id < 0) { + HDfprintf(stderr, "HDF5 Dataset open failed\n"); + GOTOERROR(FAIL); + } + break; - /* Advance global offset in dataset */ - nbytes_xfer+=(off_t)nbytes_xfer_advance; + default: + break; + } - /* Decrement number of bytes left this time */ - nbytes_toxfer-=nbytes_xfer_advance; + /* The task is to transfer bytes_count bytes, starting at + * bytes_begin position, using transfer buffer of buf_size bytes. + * If interleaved, select buf_size at a time, in round robin + * fashion, according to number of process. Otherwise, select + * all bytes_count in contiguous. + */ + nbytes_xfer = 0; - /* Partially advance file offset */ - file_offset+=file_offset_advance; - } /* end while */ + /* 1D dataspace */ + if (!parms->dim2d) { + /* Set base file offset for all I/O patterns and POSIX access */ + posix_file_offset = dset_offset + bytes_begin[0]; - } /* end else */ - break; + /* Set base file offset for all I/O patterns and MPI access */ + mpi_file_offset = (MPI_Offset)(dset_offset + bytes_begin[0]); + } /* end if */ + else { + /* Set base file offset for all I/O patterns and POSIX access */ + posix_file_offset = dset_offset + bytes_begin[0] * snbytes + bytes_begin[1]; - case MPIO: - /* 1D dataspace */ - if (!parms->dim2d){ - /* Independent file access */ - if(!parms->collective) { - /* Contiguous pattern */ - if (!parms->interleaved){ - /* Compute offset in file */ - mpi_offset = mpi_file_offset + - nbytes_xfer; - - /* Perform independent read */ - mrc = MPI_File_read_at(fd->mpifd, mpi_offset, buffer, - (int)(buf_size/blk_size), mpi_blk_type, - &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_READ"); - - /* Advance global offset in dataset */ - nbytes_xfer+=(off_t)buf_size; - } /* end if */ - /* Interleaved access pattern */ + /* Set base file offset for all I/O patterns and MPI access */ + mpi_file_offset = (MPI_Offset)(dset_offset + bytes_begin[0] * snbytes + bytes_begin[1]); + } /* end else */ + + /* Start "raw data" read timer */ + io_time_set(res->timers, HDF5_RAW_READ_FIXED_DIMS, TSTART); + + while (nbytes_xfer < bytes_count) { + /* Read */ + /* Calculate offset of read within a dataset/file */ + switch (parms->io_type) { + case POSIXIO: + /* 1D dataspace */ + if (!parms->dim2d) { + /* Contiguous pattern */ + if (!parms->interleaved) { + /* Compute file offset */ + file_offset = posix_file_offset + (off_t)nbytes_xfer; + + /* only care if seek returns error */ + rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; + VRFY((rc == 0), "POSIXSEEK"); + + /* check if all bytes are read */ + rc = ((ssize_t)buf_size == POSIXREAD(fd->posixfd, buffer, buf_size)); + VRFY((rc != 0), "POSIXREAD"); + + /* Advance global offset in dataset */ + nbytes_xfer += (off_t)buf_size; + } /* end if */ + /* Interleaved access pattern */ + else { + /* Set the base of user's buffer */ + buf_p = (unsigned char *)buffer; + + /* Set the number of bytes to transfer this time */ + nbytes_toxfer = buf_size; + + /* Loop over the buffers to read */ + while (nbytes_toxfer > 0) { + /* Skip offset over blocks of other processes */ + file_offset = posix_file_offset + (off_t)(nbytes_xfer * pio_mpi_nprocs_g); + + /* only care if seek returns error */ + rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; + VRFY((rc == 0), "POSIXSEEK"); + + /* check if all bytes are read */ + rc = ((ssize_t)blk_size == POSIXREAD(fd->posixfd, buf_p, blk_size)); + VRFY((rc != 0), "POSIXREAD"); + + /* Advance location in buffer */ + buf_p += blk_size; + + /* Advance global offset in dataset */ + nbytes_xfer += (off_t)blk_size; + + /* Decrement number of bytes left this time */ + nbytes_toxfer -= blk_size; + } /* end while */ + } /* end else */ + } /* end if */ + /* 2D dataspace */ else { + /* Contiguous storage */ + if (!parms->h5_use_chunks) { + /* Contiguous access pattern */ + if (!parms->interleaved) { + /* Compute file offset */ + file_offset = posix_file_offset + + (off_t)((((size_t)nbytes_xfer / blk_size) / (size_t)snbytes) * + (blk_size * (size_t)snbytes) + + (((size_t)nbytes_xfer / blk_size) % (size_t)snbytes)); + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = buf_size; + + /* Global offset advance after each I/O operation */ + file_offset_advance = (off_t)snbytes; + } /* end if */ + /* Interleaved access pattern */ + else { + /* Compute file offset */ + file_offset = + posix_file_offset + + (off_t)(((((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) / + (size_t)snbytes) * + (buf_size * (size_t)snbytes) + + (((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) % + (size_t)snbytes); + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = blk_size; + + /* Global offset advance after each I/O operation */ + file_offset_advance = (off_t)snbytes; + } /* end else */ + } /* end if */ + /* Chunked storage */ + else { + /*Contiguous access pattern */ + if (!parms->interleaved) { + /* Compute file offset */ + file_offset = posix_file_offset + (off_t)nbytes_xfer; + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = blk_size * buf_size; + + /* Global offset advance after each I/O operation */ + file_offset_advance = 0; + } /* end if */ + /*Interleaved access pattern */ + else { + /* Compute file offset */ + /* Before simplification */ + /* file_offset=posix_file_offset+(off_t)((nbytes_xfer/(buf_size/blk_size) + *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))*(buf_size/blk_size + *snbytes/blk_size*(blk_size*blk_size))+((nbytes_xfer/(buf_size/blk_size)) + *pio_mpi_nprocs_g)%(snbytes/blk_size*(blk_size*blk_size))); */ + + file_offset = posix_file_offset + + (off_t)((((size_t)nbytes_xfer / (buf_size / blk_size) * + (size_t)pio_mpi_nprocs_g) / + ((size_t)snbytes * blk_size)) * + (buf_size * (size_t)snbytes) + + (((size_t)nbytes_xfer / (buf_size / blk_size)) * + (size_t)pio_mpi_nprocs_g) % + ((size_t)snbytes * blk_size)); + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = blk_size * blk_size; + + /* Global offset advance after each I/O operation */ + /* file_offset_advance = (off_t)(snbytes/blk_size*(blk_size*blk_size)); */ + file_offset_advance = (off_t)((size_t)snbytes * blk_size); + } /* end else */ + } /* end else */ + + /* Common code for file access */ + /* Set the base of user's buffer */ - buf_p=(unsigned char *)buffer; + buf_p = (unsigned char *)buffer; /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size; + nbytes_toxfer = buf_size * blk_size; - /* Loop over the buffers to read */ - while(nbytes_toxfer>0) { - /* Skip offset over blocks of other processes */ - mpi_offset = mpi_file_offset + - (nbytes_xfer*pio_mpi_nprocs_g); + /* Loop over portions of the buffer to read */ + while (nbytes_toxfer > 0) { + /* only care if seek returns error */ + rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0; + VRFY((rc == 0), "POSIXSEEK"); - /* Perform independent read */ - mrc = MPI_File_read_at(fd->mpifd, mpi_offset, buf_p, - (int)1, mpi_blk_type, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_READ"); + /* check if all bytes are read */ + rc = ((ssize_t)nbytes_xfer_advance == + POSIXREAD(fd->posixfd, buf_p, nbytes_xfer_advance)); + VRFY((rc != 0), "POSIXREAD"); /* Advance location in buffer */ - buf_p+=blk_size; + buf_p += nbytes_xfer_advance; /* Advance global offset in dataset */ - nbytes_xfer+=(off_t)blk_size; + nbytes_xfer += (off_t)nbytes_xfer_advance; /* Decrement number of bytes left this time */ - nbytes_toxfer-=blk_size; - } /* end while */ - } /* end else */ - } /* end if */ - /* Collective file access */ - else { - /* Contiguous access pattern */ - if (!parms->interleaved){ - /* Compute offset in file */ - mpi_offset = mpi_file_offset + - nbytes_xfer; - - /* Perform collective read */ - mrc = MPI_File_read_at_all(fd->mpifd, mpi_offset, buffer, - (int)(buf_size/blk_size), mpi_blk_type, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_READ"); - - /* Advance global offset in dataset */ - nbytes_xfer+=(off_t)buf_size; - } /* end if */ - /* Interleaved access pattern */ - else { - /* Compute offset in file */ - mpi_offset = mpi_file_offset + - (nbytes_xfer*pio_mpi_nprocs_g); - - /* Set the file view */ - mrc = MPI_File_set_view(fd->mpifd, mpi_offset, mpi_blk_type, - mpi_file_type, (char*)"native", h5_io_info_g); - VRFY((mrc==MPI_SUCCESS), "MPIO_VIEW"); - - /* Perform collective read */ - mrc = MPI_File_read_at_all(fd->mpifd, 0, buffer, - (int)(buf_size/blk_size), mpi_blk_type, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_READ"); - - /* Advance global offset in dataset */ - nbytes_xfer+=(off_t)buf_size; - } /* end else */ - } /* end else */ - } /* end if */ - /* 2D dataspace */ - else { - /* Contiguous storage */ - if (!parms->h5_use_chunks) { - /* Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute offset in file */ - mpi_offset=mpi_file_offset+(MPI_Offset)((((size_t)nbytes_xfer/blk_size)/(size_t)snbytes)* - (blk_size*(size_t)snbytes))+(MPI_Offset)(((size_t)nbytes_xfer/blk_size)%(size_t)snbytes); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = buf_size; + nbytes_toxfer -= nbytes_xfer_advance; - /* Global offset advance after each I/O operation */ - mpi_offset_advance = snbytes; + /* Partially advance file offset */ + file_offset += file_offset_advance; + } /* end while */ - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_cont_type; - } /* end if */ - /* Interleaved access pattern */ + } /* end else */ + break; + + case MPIO: + /* 1D dataspace */ + if (!parms->dim2d) { + /* Independent file access */ + if (!parms->collective) { + /* Contiguous pattern */ + if (!parms->interleaved) { + /* Compute offset in file */ + mpi_offset = mpi_file_offset + nbytes_xfer; + + /* Perform independent read */ + mrc = MPI_File_read_at(fd->mpifd, mpi_offset, buffer, + (int)(buf_size / blk_size), mpi_blk_type, &mpi_status); + VRFY((mrc == MPI_SUCCESS), "MPIO_READ"); + + /* Advance global offset in dataset */ + nbytes_xfer += (off_t)buf_size; + } /* end if */ + /* Interleaved access pattern */ + else { + /* Set the base of user's buffer */ + buf_p = (unsigned char *)buffer; + + /* Set the number of bytes to transfer this time */ + nbytes_toxfer = buf_size; + + /* Loop over the buffers to read */ + while (nbytes_toxfer > 0) { + /* Skip offset over blocks of other processes */ + mpi_offset = mpi_file_offset + (nbytes_xfer * pio_mpi_nprocs_g); + + /* Perform independent read */ + mrc = MPI_File_read_at(fd->mpifd, mpi_offset, buf_p, (int)1, mpi_blk_type, + &mpi_status); + VRFY((mrc == MPI_SUCCESS), "MPIO_READ"); + + /* Advance location in buffer */ + buf_p += blk_size; + + /* Advance global offset in dataset */ + nbytes_xfer += (off_t)blk_size; + + /* Decrement number of bytes left this time */ + nbytes_toxfer -= blk_size; + } /* end while */ + } /* end else */ + } /* end if */ + /* Collective file access */ + else { + /* Contiguous access pattern */ + if (!parms->interleaved) { + /* Compute offset in file */ + mpi_offset = mpi_file_offset + nbytes_xfer; + + /* Perform collective read */ + mrc = MPI_File_read_at_all(fd->mpifd, mpi_offset, buffer, + (int)(buf_size / blk_size), mpi_blk_type, + &mpi_status); + VRFY((mrc == MPI_SUCCESS), "MPIO_READ"); + + /* Advance global offset in dataset */ + nbytes_xfer += (off_t)buf_size; + } /* end if */ + /* Interleaved access pattern */ + else { + /* Compute offset in file */ + mpi_offset = mpi_file_offset + (nbytes_xfer * pio_mpi_nprocs_g); + + /* Set the file view */ + mrc = MPI_File_set_view(fd->mpifd, mpi_offset, mpi_blk_type, mpi_file_type, + (char *)"native", h5_io_info_g); + VRFY((mrc == MPI_SUCCESS), "MPIO_VIEW"); + + /* Perform collective read */ + mrc = MPI_File_read_at_all(fd->mpifd, 0, buffer, (int)(buf_size / blk_size), + mpi_blk_type, &mpi_status); + VRFY((mrc == MPI_SUCCESS), "MPIO_READ"); + + /* Advance global offset in dataset */ + nbytes_xfer += (off_t)buf_size; + } /* end else */ + } /* end else */ + } /* end if */ + /* 2D dataspace */ else { - /* Compute offset in file */ - mpi_offset=mpi_file_offset+(MPI_Offset)(((((size_t)nbytes_xfer/buf_size)*(size_t)pio_mpi_nprocs_g)/(size_t)snbytes)* - (buf_size*(size_t)snbytes))+(MPI_Offset)((((size_t)nbytes_xfer/buf_size)*(size_t)pio_mpi_nprocs_g)%(size_t)snbytes); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size; + /* Contiguous storage */ + if (!parms->h5_use_chunks) { + /* Contiguous access pattern */ + if (!parms->interleaved) { + /* Compute offset in file */ + mpi_offset = + mpi_file_offset + + (MPI_Offset)((((size_t)nbytes_xfer / blk_size) / (size_t)snbytes) * + (blk_size * (size_t)snbytes)) + + (MPI_Offset)(((size_t)nbytes_xfer / blk_size) % (size_t)snbytes); + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = buf_size; + + /* Global offset advance after each I/O operation */ + mpi_offset_advance = snbytes; + + /* MPI type to be used for collective access */ + mpi_collective_type = mpi_cont_type; + } /* end if */ + /* Interleaved access pattern */ + else { + /* Compute offset in file */ + mpi_offset = + mpi_file_offset + + (MPI_Offset)( + ((((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) / + (size_t)snbytes) * + (buf_size * (size_t)snbytes)) + + (MPI_Offset)( + (((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) % + (size_t)snbytes); + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = blk_size; + + /* Global offset advance after each I/O operation */ + mpi_offset_advance = snbytes; + + /* MPI type to be used for collective access */ + mpi_collective_type = mpi_inter_type; + } /* end else */ + } /* end if */ + /* Chunked storage */ + else { + /*Contiguous access pattern */ + if (!parms->interleaved) { + /* Compute offset in file */ + mpi_offset = mpi_file_offset + nbytes_xfer; + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = blk_size * buf_size; + + /* Global offset advance after each I/O operation */ + mpi_offset_advance = 0; + + /* MPI type to be used for collective access */ + mpi_collective_type = mpi_full_buffer; + } /* end if */ + /*Interleaved access pattern */ + else { + /* Compute offset in file */ + /* Before simplification */ + /* mpi_offset=mpi_file_offset+(nbytes_xfer/(buf_size/blk_size) + *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))* + (buf_size/blk_size*snbytes/blk_size*(blk_size*blk_size))+ + ((nbytes_xfer/(buf_size/blk_size))*pio_mpi_nprocs_g)%(snbytes + /blk_size*(blk_size*blk_size)); */ + mpi_offset = mpi_file_offset + + (MPI_Offset)((((size_t)nbytes_xfer / (buf_size / blk_size) * + (size_t)pio_mpi_nprocs_g) / + ((size_t)snbytes * blk_size)) * + (buf_size * (size_t)snbytes)) + + (MPI_Offset)((((size_t)nbytes_xfer / (buf_size / blk_size)) * + (size_t)pio_mpi_nprocs_g) % + ((size_t)snbytes * blk_size)); + + /* Number of bytes to be transferred per I/O operation */ + nbytes_xfer_advance = blk_size * blk_size; + + /* Global offset advance after each I/O operation */ + /* mpi_offset_advance = (MPI_Offset)(snbytes/blk_size*(blk_size*blk_size)); */ + mpi_offset_advance = (MPI_Offset)((size_t)snbytes * blk_size); + + /* MPI type to be used for collective access */ + mpi_collective_type = mpi_chunk_inter_type; + } /* end else */ + } /* end else */ + + /* Common code for independent file access */ + if (!parms->collective) { + /* Set the base of user's buffer */ + buf_p = (unsigned char *)buffer; + + /* Set the number of bytes to transfer this time */ + nbytes_toxfer = buf_size * blk_size; + + /* Loop over portions of the buffer to read */ + while (nbytes_toxfer > 0) { + /* Perform independent read */ + mrc = MPI_File_read_at(fd->mpifd, mpi_offset, buf_p, (int)nbytes_xfer_advance, + MPI_BYTE, &mpi_status); + VRFY((mrc == MPI_SUCCESS), "MPIO_READ"); + + /* Advance location in buffer */ + buf_p += nbytes_xfer_advance; + + /* Advance global offset in dataset */ + nbytes_xfer += (off_t)nbytes_xfer_advance; + + /* Decrement number of bytes left this time */ + nbytes_toxfer -= nbytes_xfer_advance; + + /* Partially advance global offset in dataset */ + mpi_offset += mpi_offset_advance; + } /* end while */ + } /* end if */ + + /* Common code for collective file access */ + else { + /* Set the file view */ + mrc = MPI_File_set_view(fd->mpifd, mpi_offset, MPI_BYTE, mpi_collective_type, + (char *)"native", h5_io_info_g); + VRFY((mrc == MPI_SUCCESS), "MPIO_VIEW"); + + /* Perform read */ + MPI_File_read_at_all(fd->mpifd, 0, buffer, (int)(buf_size * blk_size), MPI_BYTE, + &mpi_status); + VRFY((mrc == MPI_SUCCESS), "MPIO_READ"); - /* Global offset advance after each I/O operation */ - mpi_offset_advance = snbytes; + /* Advance global offset in dataset */ + nbytes_xfer += (off_t)buf_size * (off_t)blk_size; + } /* end else */ - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_inter_type; } /* end else */ - } /* end if */ - /* Chunked storage */ - else { - /*Contiguous access pattern */ - if (!parms->interleaved) { - /* Compute offset in file */ - mpi_offset=mpi_file_offset+nbytes_xfer; - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * buf_size; + break; + + case PHDF5: + /* 1D dataspace */ + if (!parms->dim2d) { + /* Set up the file dset space id to move the selection to process */ + if (!parms->interleaved) { + /* Contiguous pattern */ + h5offset[0] = nbytes_xfer; + } /* end if */ + else { + /* Interleaved access pattern */ + /* Skip offset over blocks of other processes */ + h5offset[0] = (nbytes_xfer * pio_mpi_nprocs_g); + } /* end else */ + hrc = H5Soffset_simple(h5dset_space_id, h5offset); + VRFY((hrc >= 0), "H5Soffset_simple"); - /* Global offset advance after each I/O operation */ - mpi_offset_advance = 0; + /* Read the buffer in */ + hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, h5dset_space_id, h5dxpl, buffer); + VRFY((hrc >= 0), "H5Dread"); - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_full_buffer; + /* Increment number of bytes transferred */ + nbytes_xfer += (off_t)buf_size; } /* end if */ - /*Interleaved access pattern */ + /* 2D dataspace */ else { - /* Compute offset in file */ - /* Before simplification */ - /* mpi_offset=mpi_file_offset+(nbytes_xfer/(buf_size/blk_size) - *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))* - (buf_size/blk_size*snbytes/blk_size*(blk_size*blk_size))+ - ((nbytes_xfer/(buf_size/blk_size))*pio_mpi_nprocs_g)%(snbytes - /blk_size*(blk_size*blk_size)); */ - mpi_offset=mpi_file_offset+(MPI_Offset)((((size_t)nbytes_xfer/(buf_size/blk_size) - *(size_t)pio_mpi_nprocs_g)/((size_t)snbytes*blk_size))*(buf_size*(size_t)snbytes)) - +(MPI_Offset)((((size_t)nbytes_xfer/(buf_size/blk_size))*(size_t)pio_mpi_nprocs_g)%((size_t)snbytes*blk_size)); - - /* Number of bytes to be transferred per I/O operation */ - nbytes_xfer_advance = blk_size * blk_size; - - /* Global offset advance after each I/O operation */ - /* mpi_offset_advance = (MPI_Offset)(snbytes/blk_size*(blk_size*blk_size)); */ - mpi_offset_advance = (MPI_Offset)((size_t)snbytes*blk_size); - - /* MPI type to be used for collective access */ - mpi_collective_type = mpi_chunk_inter_type; - } /* end else */ - } /* end else */ - - /* Common code for independent file access */ - if (!parms->collective) { - /* Set the base of user's buffer */ - buf_p = (unsigned char *)buffer; - - /* Set the number of bytes to transfer this time */ - nbytes_toxfer = buf_size * blk_size; - - /* Loop over portions of the buffer to read */ - while(nbytes_toxfer>0){ - /* Perform independent read */ - mrc = MPI_File_read_at(fd->mpifd, mpi_offset, buf_p, - (int)nbytes_xfer_advance, MPI_BYTE, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_READ"); + /* Set up the file dset space id to move the selection to process */ + if (!parms->interleaved) { + /* Contiguous pattern */ + h5offset[0] = + (hssize_t)(((size_t)nbytes_xfer / ((size_t)snbytes * blk_size)) * blk_size); + h5offset[1] = + (hssize_t)(((size_t)nbytes_xfer % ((size_t)snbytes * blk_size)) / blk_size); + } /* end if */ + else { + /* Interleaved access pattern */ + /* Skip offset over blocks of other processes */ + h5offset[0] = (hssize_t)((((size_t)nbytes_xfer * (size_t)pio_mpi_nprocs_g) / + ((size_t)snbytes * buf_size)) * + buf_size); + h5offset[1] = (hssize_t)((((size_t)nbytes_xfer * (size_t)pio_mpi_nprocs_g) % + ((size_t)snbytes * buf_size)) / + buf_size); - /* Advance location in buffer */ - buf_p+=nbytes_xfer_advance; + } /* end else */ + hrc = H5Soffset_simple(h5dset_space_id, h5offset); + VRFY((hrc >= 0), "H5Soffset_simple"); - /* Advance global offset in dataset */ - nbytes_xfer+=(off_t)nbytes_xfer_advance; + /* Write the buffer out */ + hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, h5dset_space_id, h5dxpl, buffer); + VRFY((hrc >= 0), "H5Dread"); - /* Decrement number of bytes left this time */ - nbytes_toxfer-=nbytes_xfer_advance; + /* Increment number of bytes transferred */ + nbytes_xfer += (off_t)buf_size * (off_t)blk_size; - /* Partially advance global offset in dataset */ - mpi_offset+=mpi_offset_advance; - } /* end while */ + } /* end else */ + break; + + default: + break; + } /* switch (parms->io_type) */ + + /* Verify raw data, if asked */ + if (parms->verify) { + /* Verify data read */ + unsigned char *ucharptr = (unsigned char *)buffer; + size_t i; + int nerror = 0; + + for (i = 0; i < bsize; ++i) { + if (*ucharptr++ != pio_mpi_rank_g + 1) { + if (++nerror < 20) { + /* report at most 20 errors */ + HDprint_rank(output); + HDfprintf(output, + "read data error, expected (%d), " + "got (%d)\n", + pio_mpi_rank_g + 1, (int)*(ucharptr - 1)); + } /* end if */ + } /* end if */ + } /* end for */ + if (nerror >= 20) { + HDprint_rank(output); + HDfprintf(output, "..."); + HDfprintf(output, "total read data errors=%d\n", nerror); } /* end if */ + } /* if (parms->verify) */ - /* Common code for collective file access */ - else { - /* Set the file view */ - mrc = MPI_File_set_view(fd->mpifd, mpi_offset, MPI_BYTE, - mpi_collective_type, (char *)"native", h5_io_info_g); - VRFY((mrc==MPI_SUCCESS), "MPIO_VIEW"); - - /* Perform read */ - MPI_File_read_at_all(fd->mpifd, 0, buffer,(int)(buf_size*blk_size), - MPI_BYTE, &mpi_status); - VRFY((mrc==MPI_SUCCESS), "MPIO_READ"); - - /* Advance global offset in dataset */ - nbytes_xfer+=(off_t)buf_size*(off_t)blk_size; - } /* end else */ + } /* end while */ - } /* end else */ - break; + /* Stop "raw data" read timer */ + io_time_set(res->timers, HDF5_RAW_READ_FIXED_DIMS, TSTOP); - case PHDF5: - /* 1D dataspace */ - if (!parms->dim2d){ - /* Set up the file dset space id to move the selection to process */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5offset[0] = nbytes_xfer; - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5offset[0] = (nbytes_xfer*pio_mpi_nprocs_g); - } /* end else */ - hrc = H5Soffset_simple(h5dset_space_id, h5offset); - VRFY((hrc >= 0), "H5Soffset_simple"); - - /* Read the buffer in */ - hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, - h5dset_space_id, h5dxpl, buffer); - VRFY((hrc >= 0), "H5Dread"); + /* Calculate read time */ - /* Increment number of bytes transferred */ - nbytes_xfer += (off_t)buf_size; - } /* end if */ - /* 2D dataspace */ - else { - /* Set up the file dset space id to move the selection to process */ - if (!parms->interleaved){ - /* Contiguous pattern */ - h5offset[0] = (hssize_t)(((size_t)nbytes_xfer/((size_t)snbytes*blk_size))*blk_size); - h5offset[1] = (hssize_t)(((size_t)nbytes_xfer%((size_t)snbytes*blk_size))/blk_size); - } /* end if */ - else { - /* Interleaved access pattern */ - /* Skip offset over blocks of other processes */ - h5offset[0] = (hssize_t)((((size_t)nbytes_xfer*(size_t)pio_mpi_nprocs_g)/((size_t)snbytes*buf_size))*buf_size); - h5offset[1] = (hssize_t)((((size_t)nbytes_xfer*(size_t)pio_mpi_nprocs_g)%((size_t)snbytes*buf_size))/buf_size); + /* Close dataset. Only HDF5 needs to do an explicit close. */ + if (parms->io_type == PHDF5) { + hrc = H5Dclose(h5ds_id); - } /* end else */ - hrc = H5Soffset_simple(h5dset_space_id, h5offset); - VRFY((hrc >= 0), "H5Soffset_simple"); - - /* Write the buffer out */ - hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, - h5dset_space_id, h5dxpl, buffer); - VRFY((hrc >= 0), "H5Dread"); - - /* Increment number of bytes transferred */ - nbytes_xfer += (off_t)buf_size*(off_t)blk_size; - - } /* end else */ - break; + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Dataset Close failed\n"); + GOTOERROR(FAIL); + } - default: - break; - } /* switch (parms->io_type) */ - - /* Verify raw data, if asked */ - if (parms->verify) { - /* Verify data read */ - unsigned char *ucharptr = (unsigned char *)buffer; - size_t i; - int nerror=0; - - for (i = 0; i < bsize; ++i){ - if (*ucharptr++ != pio_mpi_rank_g+1) { - if (++nerror < 20){ - /* report at most 20 errors */ - HDprint_rank(output); - HDfprintf(output, "read data error, expected (%d), " - "got (%d)\n", - pio_mpi_rank_g+1, - (int)*(ucharptr-1)); - } /* end if */ - } /* end if */ - } /* end for */ - if (nerror >= 20) { - HDprint_rank(output); - HDfprintf(output, "..."); - HDfprintf(output, "total read data errors=%d\n", - nerror); + h5ds_id = H5I_INVALID_HID; } /* end if */ - } /* if (parms->verify) */ - - } /* end while */ - - /* Stop "raw data" read timer */ - io_time_set(res->timers, HDF5_RAW_READ_FIXED_DIMS, TSTOP); - - /* Calculate read time */ - - /* Close dataset. Only HDF5 needs to do an explicit close. */ - if (parms->io_type == PHDF5) { - hrc = H5Dclose(h5ds_id); - - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Close failed\n"); - GOTOERROR(FAIL); - } - - h5ds_id = H5I_INVALID_HID; - } /* end if */ - } /* end for */ + } /* end for */ done: /* release MPI-I/O objects */ if (parms->io_type == MPIO) { /* 1D dataspace */ - if (!parms->dim2d){ + if (!parms->dim2d) { /* Free file type */ - mrc = MPI_Type_free( &mpi_file_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + mrc = MPI_Type_free(&mpi_file_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free buffer type */ - mrc = MPI_Type_free( &mpi_blk_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + mrc = MPI_Type_free(&mpi_blk_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); } /* end if */ /* 2D dataspace */ else { /* Free partial buffer type for contiguous access */ - mrc = MPI_Type_free( &mpi_partial_buffer_cont ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + mrc = MPI_Type_free(&mpi_partial_buffer_cont); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free contiguous file type */ - mrc = MPI_Type_free( &mpi_cont_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + mrc = MPI_Type_free(&mpi_cont_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free partial buffer type for interleaved access */ - mrc = MPI_Type_free( &mpi_partial_buffer_inter ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + mrc = MPI_Type_free(&mpi_partial_buffer_inter); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free interleaved file type */ - mrc = MPI_Type_free( &mpi_inter_type ); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + mrc = MPI_Type_free(&mpi_inter_type); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free full buffer type */ mrc = MPI_Type_free(&mpi_full_buffer); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free full chunk type */ mrc = MPI_Type_free(&mpi_full_chunk); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); /* Free chunk interleaved file type */ mrc = MPI_Type_free(&mpi_chunk_inter_type); - VRFY((mrc==MPI_SUCCESS), "MPIO_TYPE_FREE"); + VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE"); } /* end else */ - } /* end if */ + } /* end if */ /* release HDF5 objects */ if (h5dset_space_id != -1) { - hrc = H5Sclose(h5dset_space_id); - if (hrc < 0){ - HDfprintf(stderr, "HDF5 Dataset Space Close failed\n"); - ret_code = FAIL; - } else { - h5dset_space_id = H5I_INVALID_HID; - } + hrc = H5Sclose(h5dset_space_id); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Dataset Space Close failed\n"); + ret_code = FAIL; + } + else { + h5dset_space_id = H5I_INVALID_HID; + } } if (h5mem_space_id != -1) { - hrc = H5Sclose(h5mem_space_id); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Memory Space Close failed\n"); - ret_code = FAIL; - } else { - h5mem_space_id = H5I_INVALID_HID; - } + hrc = H5Sclose(h5mem_space_id); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Memory Space Close failed\n"); + ret_code = FAIL; + } + else { + h5mem_space_id = H5I_INVALID_HID; + } } if (h5dxpl != -1) { - hrc = H5Pclose(h5dxpl); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n"); - ret_code = FAIL; - } else { - h5dxpl = H5I_INVALID_HID; - } + hrc = H5Pclose(h5dxpl); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n"); + ret_code = FAIL; + } + else { + h5dxpl = H5I_INVALID_HID; + } } return ret_code; @@ -2467,11 +2504,11 @@ done: * Programmer: Albert Cheng, Bill Wendling, 2001/12/13 * Modifications: */ - static herr_t +static herr_t do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags) { - int ret_code = SUCCESS, mrc; - hid_t acc_tpl = H5I_INVALID_HID; /* file access templates */ + int ret_code = SUCCESS, mrc; + hid_t acc_tpl = H5I_INVALID_HID; /* file access templates */ switch (param->io_type) { case POSIXIO: @@ -2480,12 +2517,11 @@ do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags) else fd->posixfd = POSIXOPEN(fname, O_RDONLY); - if (fd->posixfd < 0 ) { + if (fd->posixfd < 0) { HDfprintf(stderr, "POSIX File Open failed(%s)\n", fname); GOTOERROR(FAIL); } - /* The perils of POSIX I/O in a parallel environment. The problem is: * * - Process n opens a file with truncation and then starts @@ -2501,8 +2537,8 @@ do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags) case MPIO: if (flags & (PIO_CREATE | PIO_WRITE)) { MPI_File_delete(fname, h5_io_info_g); - mrc = MPI_File_open(pio_comm_g, fname, MPI_MODE_CREATE | MPI_MODE_RDWR, - h5_io_info_g, &fd->mpifd); + mrc = MPI_File_open(pio_comm_g, fname, MPI_MODE_CREATE | MPI_MODE_RDWR, h5_io_info_g, + &fd->mpifd); if (mrc != MPI_SUCCESS) { HDfprintf(stderr, "MPI File Open failed(%s)\n", fname); @@ -2516,7 +2552,8 @@ do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags) HDfprintf(stderr, "MPI_File_set_size failed\n"); GOTOERROR(FAIL); } - } else { + } + else { mrc = MPI_File_open(pio_comm_g, fname, MPI_MODE_RDONLY, h5_io_info_g, &fd->mpifd); if (mrc != MPI_SUCCESS) { HDfprintf(stderr, "MPI File Open failed(%s)\n", fname); @@ -2577,17 +2614,17 @@ done: * Programmer: Albert Cheng, Bill Wendling, 2001/12/13 * Modifications: */ - static herr_t +static herr_t do_fclose(iotype iot, file_descr *fd /*out*/) { herr_t ret_code = SUCCESS, hrc; - int mrc = 0, rc = 0; + int mrc = 0, rc = 0; switch (iot) { case POSIXIO: rc = POSIXCLOSE(fd->posixfd); - if (rc != 0){ + if (rc != 0) { HDfprintf(stderr, "POSIX File Close failed\n"); GOTOERROR(FAIL); } @@ -2598,7 +2635,7 @@ do_fclose(iotype iot, file_descr *fd /*out*/) case MPIO: mrc = MPI_File_close(&fd->mpifd); - if (mrc != MPI_SUCCESS){ + if (mrc != MPI_SUCCESS) { HDfprintf(stderr, "MPI File close failed\n"); GOTOERROR(FAIL); } @@ -2625,7 +2662,6 @@ done: return ret_code; } - /* * Function: do_fclose * Purpose: Cleanup temporary file unless HDF5_NOCLEANUP is set. @@ -2635,17 +2671,17 @@ done: * Programmer: Albert Cheng 2001/12/12 * Modifications: */ - static void +static void do_cleanupfile(iotype iot, char *fname) { if (pio_mpi_rank_g != 0) - return; + return; if (clean_file_g == -1) - clean_file_g = (getenv("HDF5_NOCLEANUP")==NULL) ? 1 : 0; + clean_file_g = (getenv("HDF5_NOCLEANUP") == NULL) ? 1 : 0; - if (clean_file_g){ - switch (iot){ + if (clean_file_g) { + switch (iot) { case POSIXIO: HDremove(fname); break; @@ -2663,51 +2699,49 @@ do_cleanupfile(iotype iot, char *fname) /* instrument the MPI_File_wrirte_xxx and read_xxx calls to measure * pure time spent in MPI_File code. */ -int MPI_File_read_at(MPI_File fh, MPI_Offset offset, void *buf, - int count, MPI_Datatype datatype, MPI_Status *status) +int +MPI_File_read_at(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, + MPI_Status *status) { int err; io_time_set(timer_g, HDF5_MPI_READ, TSTART); - err=PMPI_File_read_at(fh, offset, buf, count, datatype, status); + err = PMPI_File_read_at(fh, offset, buf, count, datatype, status); io_time_set(timer_g, HDF5_MPI_READ, TSTOP); return err; } - -int MPI_File_read_at_all(MPI_File fh, MPI_Offset offset, void *buf, - int count, MPI_Datatype datatype, MPI_Status *status) +int +MPI_File_read_at_all(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, + MPI_Status *status) { int err; io_time_set(timer_g, HDF5_MPI_READ, TSTART); - err=PMPI_File_read_at_all(fh, offset, buf, count, datatype, status); + err = PMPI_File_read_at_all(fh, offset, buf, count, datatype, status); io_time_set(timer_g, HDF5_MPI_READ, TSTOP); return err; } -int MPI_File_write_at(MPI_File fh, MPI_Offset offset, void *buf, - int count, MPI_Datatype datatype, MPI_Status *status) +int +MPI_File_write_at(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, + MPI_Status *status) { int err; io_time_set(timer_g, HDF5_MPI_WRITE, TSTART); - err=PMPI_File_write_at(fh, offset, buf, count, datatype, status); + err = PMPI_File_write_at(fh, offset, buf, count, datatype, status); io_time_set(timer_g, HDF5_MPI_WRITE, TSTOP); return err; } -int MPI_File_write_at_all(MPI_File fh, MPI_Offset offset, void *buf, - int count, MPI_Datatype datatype, MPI_Status *status) +int +MPI_File_write_at_all(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, + MPI_Status *status) { int err; io_time_set(timer_g, HDF5_MPI_WRITE, TSTART); - err=PMPI_File_write_at_all(fh, offset, buf, count, datatype, status); + err = PMPI_File_write_at_all(fh, offset, buf, count, datatype, status); io_time_set(timer_g, HDF5_MPI_WRITE, TSTOP); return err; } -#endif /* TIME_MPI */ +#endif /* TIME_MPI */ #endif /* H5_HAVE_PARALLEL */ - - - - - diff --git a/tools/test/perform/pio_perf.c b/tools/test/perform/pio_perf.c index cb15f64..f1b8c4f 100644 --- a/tools/test/perform/pio_perf.c +++ b/tools/test/perform/pio_perf.c @@ -70,48 +70,48 @@ #include "pio_perf.h" /* useful macros */ -#define TAB_SPACE 4 +#define TAB_SPACE 4 -#define ONE_KB 1024 -#define ONE_MB (ONE_KB * ONE_KB) -#define ONE_GB (ONE_MB * ONE_KB) +#define ONE_KB 1024 +#define ONE_MB (ONE_KB * ONE_KB) +#define ONE_GB (ONE_MB * ONE_KB) -#define PIO_POSIX 0x1 -#define PIO_MPI 0x2 -#define PIO_HDF5 0x4 +#define PIO_POSIX 0x1 +#define PIO_MPI 0x2 +#define PIO_HDF5 0x4 #ifdef STANDALONE -#define DBL_EPSILON 2.2204460492503131e-16 -#define H5_DBL_ABS_EQUAL(X,Y) (fabs((X)-(Y)) < DBL_EPSILON) +#define DBL_EPSILON 2.2204460492503131e-16 +#define H5_DBL_ABS_EQUAL(X, Y) (fabs((X) - (Y)) < DBL_EPSILON) #endif /* report 0.0 in case t is zero too */ -#define MB_PER_SEC(bytes,t) (H5_DBL_ABS_EQUAL((t), 0.0) ? 0.0 : ((((double)bytes) / ONE_MB) / (t))) +#define MB_PER_SEC(bytes, t) (H5_DBL_ABS_EQUAL((t), 0.0) ? 0.0 : ((((double)bytes) / ONE_MB) / (t))) #ifndef TRUE -#define TRUE 1 -#endif /* TRUE */ +#define TRUE 1 +#endif /* TRUE */ #ifndef FALSE -#define FALSE (!TRUE) -#endif /* FALSE */ +#define FALSE (!TRUE) +#endif /* FALSE */ /* global variables */ -FILE *output; /* output file */ -int comm_world_rank_g; /* my rank in MPI_COMM_RANK */ -int comm_world_nprocs_g;/* num. of processes of MPI_COMM_WORLD */ -MPI_Comm pio_comm_g; /* Communicator to run the PIO */ -int pio_mpi_rank_g; /* MPI rank of pio_comm_g */ -int pio_mpi_nprocs_g; /* Number of processes of pio_comm_g */ -int pio_debug_level = 0;/* The debug level: - * 0 - Off - * 1 - Minimal - * 2 - Some more - * 3 - Maximal - * 4 - Maximal & then some - */ +FILE * output; /* output file */ +int comm_world_rank_g; /* my rank in MPI_COMM_RANK */ +int comm_world_nprocs_g; /* num. of processes of MPI_COMM_WORLD */ +MPI_Comm pio_comm_g; /* Communicator to run the PIO */ +int pio_mpi_rank_g; /* MPI rank of pio_comm_g */ +int pio_mpi_nprocs_g; /* Number of processes of pio_comm_g */ +int pio_debug_level = 0; /* The debug level: + * 0 - Off + * 1 - Minimal + * 2 - Some more + * 3 - Maximal + * 4 - Maximal & then some + */ /* local variables */ -static const char *progname = "h5perf"; +static const char *progname = "h5perf"; /* * Command-line options: The user can specify short or long-named @@ -122,14 +122,13 @@ static const char *progname = "h5perf"; static const char *s_opts = "a:A:B:cCd:D:e:F:ghi:Imno:p:P:stT:wx:X:"; #else static const char *s_opts = "a:A:bB:cCd:D:e:F:ghi:Imno:p:P:stT:wx:X:"; -#endif /* 1 */ -static struct long_options l_opts[] = { - { "align", require_arg, 'a' }, - { "alig", require_arg, 'a' }, - { "ali", require_arg, 'a' }, - { "al", require_arg, 'a' }, - { "api", require_arg, 'A' }, - { "ap", require_arg, 'A' }, +#endif /* 1 */ +static struct long_options l_opts[] = {{"align", require_arg, 'a'}, + {"alig", require_arg, 'a'}, + {"ali", require_arg, 'a'}, + {"al", require_arg, 'a'}, + {"api", require_arg, 'A'}, + {"ap", require_arg, 'A'}, #if 0 /* a sighting of the elusive binary option */ { "binary", no_arg, 'b' }, @@ -137,185 +136,183 @@ static struct long_options l_opts[] = { { "bina", no_arg, 'b' }, { "bin", no_arg, 'b' }, { "bi", no_arg, 'b' }, -#endif /* 0 */ - { "block-size", require_arg, 'B' }, - { "block-siz", require_arg, 'B' }, - { "block-si", require_arg, 'B' }, - { "block-s", require_arg, 'B' }, - { "block-", require_arg, 'B' }, - { "block", require_arg, 'B' }, - { "bloc", require_arg, 'B' }, - { "blo", require_arg, 'B' }, - { "bl", require_arg, 'B' }, - { "chunk", no_arg, 'c' }, - { "chun", no_arg, 'c' }, - { "chu", no_arg, 'c' }, - { "ch", no_arg, 'c' }, - { "collective", no_arg, 'C' }, - { "collectiv", no_arg, 'C' }, - { "collecti", no_arg, 'C' }, - { "collect", no_arg, 'C' }, - { "collec", no_arg, 'C' }, - { "colle", no_arg, 'C' }, - { "coll", no_arg, 'C' }, - { "col", no_arg, 'C' }, - { "co", no_arg, 'C' }, - { "debug", require_arg, 'D' }, - { "debu", require_arg, 'D' }, - { "deb", require_arg, 'D' }, - { "de", require_arg, 'D' }, - { "geometry", no_arg, 'g' }, - { "geometr", no_arg, 'g' }, - { "geomet", no_arg, 'g' }, - { "geome", no_arg, 'g' }, - { "geom", no_arg, 'g' }, - { "geo", no_arg, 'g' }, - { "ge", no_arg, 'g' }, - { "help", no_arg, 'h' }, - { "hel", no_arg, 'h' }, - { "he", no_arg, 'h' }, - { "interleaved", require_arg, 'I' }, - { "interleave", require_arg, 'I' }, - { "interleav", require_arg, 'I' }, - { "interlea", require_arg, 'I' }, - { "interle", require_arg, 'I' }, - { "interl", require_arg, 'I' }, - { "inter", require_arg, 'I' }, - { "inte", require_arg, 'I' }, - { "int", require_arg, 'I' }, - { "in", require_arg, 'I' }, - { "max-num-processes", require_arg, 'P' }, - { "max-num-processe", require_arg, 'P' }, - { "max-num-process", require_arg, 'P' }, - { "max-num-proces", require_arg, 'P' }, - { "max-num-proce", require_arg, 'P' }, - { "max-num-proc", require_arg, 'P' }, - { "max-num-pro", require_arg, 'P' }, - { "max-num-pr", require_arg, 'P' }, - { "max-num-p", require_arg, 'P' }, - { "min-num-processes", require_arg, 'p' }, - { "min-num-processe", require_arg, 'p' }, - { "min-num-process", require_arg, 'p' }, - { "min-num-proces", require_arg, 'p' }, - { "min-num-proce", require_arg, 'p' }, - { "min-num-proc", require_arg, 'p' }, - { "min-num-pro", require_arg, 'p' }, - { "min-num-pr", require_arg, 'p' }, - { "min-num-p", require_arg, 'p' }, - { "max-xfer-size", require_arg, 'X' }, - { "max-xfer-siz", require_arg, 'X' }, - { "max-xfer-si", require_arg, 'X' }, - { "max-xfer-s", require_arg, 'X' }, - { "max-xfer", require_arg, 'X' }, - { "max-xfe", require_arg, 'X' }, - { "max-xf", require_arg, 'X' }, - { "max-x", require_arg, 'X' }, - { "min-xfer-size", require_arg, 'x' }, - { "min-xfer-siz", require_arg, 'x' }, - { "min-xfer-si", require_arg, 'x' }, - { "min-xfer-s", require_arg, 'x' }, - { "min-xfer", require_arg, 'x' }, - { "min-xfe", require_arg, 'x' }, - { "min-xf", require_arg, 'x' }, - { "min-x", require_arg, 'x' }, - { "num-bytes", require_arg, 'e' }, - { "num-byte", require_arg, 'e' }, - { "num-byt", require_arg, 'e' }, - { "num-by", require_arg, 'e' }, - { "num-b", require_arg, 'e' }, - { "num-dsets", require_arg, 'd' }, - { "num-dset", require_arg, 'd' }, - { "num-dse", require_arg, 'd' }, - { "num-ds", require_arg, 'd' }, - { "num-d", require_arg, 'd' }, - { "num-files", require_arg, 'F' }, - { "num-file", require_arg, 'F' }, - { "num-fil", require_arg, 'F' }, - { "num-fi", require_arg, 'F' }, - { "num-f", require_arg, 'F' }, - { "num-iterations", require_arg, 'i' }, - { "num-iteration", require_arg, 'i' }, - { "num-iteratio", require_arg, 'i' }, - { "num-iterati", require_arg, 'i' }, - { "num-iterat", require_arg, 'i' }, - { "num-itera", require_arg, 'i' }, - { "num-iter", require_arg, 'i' }, - { "num-ite", require_arg, 'i' }, - { "num-it", require_arg, 'i' }, - { "num-i", require_arg, 'i' }, - { "output", require_arg, 'o' }, - { "outpu", require_arg, 'o' }, - { "outp", require_arg, 'o' }, - { "out", require_arg, 'o' }, - { "ou", require_arg, 'o' }, - { "threshold", require_arg, 'T' }, - { "threshol", require_arg, 'T' }, - { "thresho", require_arg, 'T' }, - { "thresh", require_arg, 'T' }, - { "thres", require_arg, 'T' }, - { "thre", require_arg, 'T' }, - { "thr", require_arg, 'T' }, - { "th", require_arg, 'T' }, - { "write-only", require_arg, 'w' }, - { "write-onl", require_arg, 'w' }, - { "write-on", require_arg, 'w' }, - { "write-o", require_arg, 'w' }, - { "write", require_arg, 'w' }, - { "writ", require_arg, 'w' }, - { "wri", require_arg, 'w' }, - { "wr", require_arg, 'w' }, - { NULL, 0, '\0' } -}; +#endif /* 0 */ + {"block-size", require_arg, 'B'}, + {"block-siz", require_arg, 'B'}, + {"block-si", require_arg, 'B'}, + {"block-s", require_arg, 'B'}, + {"block-", require_arg, 'B'}, + {"block", require_arg, 'B'}, + {"bloc", require_arg, 'B'}, + {"blo", require_arg, 'B'}, + {"bl", require_arg, 'B'}, + {"chunk", no_arg, 'c'}, + {"chun", no_arg, 'c'}, + {"chu", no_arg, 'c'}, + {"ch", no_arg, 'c'}, + {"collective", no_arg, 'C'}, + {"collectiv", no_arg, 'C'}, + {"collecti", no_arg, 'C'}, + {"collect", no_arg, 'C'}, + {"collec", no_arg, 'C'}, + {"colle", no_arg, 'C'}, + {"coll", no_arg, 'C'}, + {"col", no_arg, 'C'}, + {"co", no_arg, 'C'}, + {"debug", require_arg, 'D'}, + {"debu", require_arg, 'D'}, + {"deb", require_arg, 'D'}, + {"de", require_arg, 'D'}, + {"geometry", no_arg, 'g'}, + {"geometr", no_arg, 'g'}, + {"geomet", no_arg, 'g'}, + {"geome", no_arg, 'g'}, + {"geom", no_arg, 'g'}, + {"geo", no_arg, 'g'}, + {"ge", no_arg, 'g'}, + {"help", no_arg, 'h'}, + {"hel", no_arg, 'h'}, + {"he", no_arg, 'h'}, + {"interleaved", require_arg, 'I'}, + {"interleave", require_arg, 'I'}, + {"interleav", require_arg, 'I'}, + {"interlea", require_arg, 'I'}, + {"interle", require_arg, 'I'}, + {"interl", require_arg, 'I'}, + {"inter", require_arg, 'I'}, + {"inte", require_arg, 'I'}, + {"int", require_arg, 'I'}, + {"in", require_arg, 'I'}, + {"max-num-processes", require_arg, 'P'}, + {"max-num-processe", require_arg, 'P'}, + {"max-num-process", require_arg, 'P'}, + {"max-num-proces", require_arg, 'P'}, + {"max-num-proce", require_arg, 'P'}, + {"max-num-proc", require_arg, 'P'}, + {"max-num-pro", require_arg, 'P'}, + {"max-num-pr", require_arg, 'P'}, + {"max-num-p", require_arg, 'P'}, + {"min-num-processes", require_arg, 'p'}, + {"min-num-processe", require_arg, 'p'}, + {"min-num-process", require_arg, 'p'}, + {"min-num-proces", require_arg, 'p'}, + {"min-num-proce", require_arg, 'p'}, + {"min-num-proc", require_arg, 'p'}, + {"min-num-pro", require_arg, 'p'}, + {"min-num-pr", require_arg, 'p'}, + {"min-num-p", require_arg, 'p'}, + {"max-xfer-size", require_arg, 'X'}, + {"max-xfer-siz", require_arg, 'X'}, + {"max-xfer-si", require_arg, 'X'}, + {"max-xfer-s", require_arg, 'X'}, + {"max-xfer", require_arg, 'X'}, + {"max-xfe", require_arg, 'X'}, + {"max-xf", require_arg, 'X'}, + {"max-x", require_arg, 'X'}, + {"min-xfer-size", require_arg, 'x'}, + {"min-xfer-siz", require_arg, 'x'}, + {"min-xfer-si", require_arg, 'x'}, + {"min-xfer-s", require_arg, 'x'}, + {"min-xfer", require_arg, 'x'}, + {"min-xfe", require_arg, 'x'}, + {"min-xf", require_arg, 'x'}, + {"min-x", require_arg, 'x'}, + {"num-bytes", require_arg, 'e'}, + {"num-byte", require_arg, 'e'}, + {"num-byt", require_arg, 'e'}, + {"num-by", require_arg, 'e'}, + {"num-b", require_arg, 'e'}, + {"num-dsets", require_arg, 'd'}, + {"num-dset", require_arg, 'd'}, + {"num-dse", require_arg, 'd'}, + {"num-ds", require_arg, 'd'}, + {"num-d", require_arg, 'd'}, + {"num-files", require_arg, 'F'}, + {"num-file", require_arg, 'F'}, + {"num-fil", require_arg, 'F'}, + {"num-fi", require_arg, 'F'}, + {"num-f", require_arg, 'F'}, + {"num-iterations", require_arg, 'i'}, + {"num-iteration", require_arg, 'i'}, + {"num-iteratio", require_arg, 'i'}, + {"num-iterati", require_arg, 'i'}, + {"num-iterat", require_arg, 'i'}, + {"num-itera", require_arg, 'i'}, + {"num-iter", require_arg, 'i'}, + {"num-ite", require_arg, 'i'}, + {"num-it", require_arg, 'i'}, + {"num-i", require_arg, 'i'}, + {"output", require_arg, 'o'}, + {"outpu", require_arg, 'o'}, + {"outp", require_arg, 'o'}, + {"out", require_arg, 'o'}, + {"ou", require_arg, 'o'}, + {"threshold", require_arg, 'T'}, + {"threshol", require_arg, 'T'}, + {"thresho", require_arg, 'T'}, + {"thresh", require_arg, 'T'}, + {"thres", require_arg, 'T'}, + {"thre", require_arg, 'T'}, + {"thr", require_arg, 'T'}, + {"th", require_arg, 'T'}, + {"write-only", require_arg, 'w'}, + {"write-onl", require_arg, 'w'}, + {"write-on", require_arg, 'w'}, + {"write-o", require_arg, 'w'}, + {"write", require_arg, 'w'}, + {"writ", require_arg, 'w'}, + {"wri", require_arg, 'w'}, + {"wr", require_arg, 'w'}, + {NULL, 0, '\0'}}; struct options { - long io_types; /* bitmask of which I/O types to test */ - const char *output_file; /* file to print report to */ - long num_dsets; /* number of datasets */ - long num_files; /* number of files */ - off_t num_bpp; /* number of bytes per proc per dset */ - int num_iters; /* number of iterations */ - int max_num_procs; /* maximum number of processes to use */ - int min_num_procs; /* minimum number of processes to use */ - size_t max_xfer_size; /* maximum transfer buffer size */ - size_t min_xfer_size; /* minimum transfer buffer size */ - size_t blk_size; /* Block size */ - unsigned interleaved; /* Interleaved vs. contiguous blocks */ - unsigned collective; /* Collective vs. independent I/O */ - unsigned dim2d; /* 1D vs. 2D geometry */ - int print_times; /* print times as well as throughputs */ - int print_raw; /* print raw data throughput info */ - off_t h5_alignment; /* alignment in HDF5 file */ - off_t h5_threshold; /* threshold for alignment in HDF5 file */ - int h5_use_chunks; /* Make HDF5 dataset chunked */ - int h5_write_only; /* Perform the write tests only */ - int verify; /* Verify data correctness */ + long io_types; /* bitmask of which I/O types to test */ + const char *output_file; /* file to print report to */ + long num_dsets; /* number of datasets */ + long num_files; /* number of files */ + off_t num_bpp; /* number of bytes per proc per dset */ + int num_iters; /* number of iterations */ + int max_num_procs; /* maximum number of processes to use */ + int min_num_procs; /* minimum number of processes to use */ + size_t max_xfer_size; /* maximum transfer buffer size */ + size_t min_xfer_size; /* minimum transfer buffer size */ + size_t blk_size; /* Block size */ + unsigned interleaved; /* Interleaved vs. contiguous blocks */ + unsigned collective; /* Collective vs. independent I/O */ + unsigned dim2d; /* 1D vs. 2D geometry */ + int print_times; /* print times as well as throughputs */ + int print_raw; /* print raw data throughput info */ + off_t h5_alignment; /* alignment in HDF5 file */ + off_t h5_threshold; /* threshold for alignment in HDF5 file */ + int h5_use_chunks; /* Make HDF5 dataset chunked */ + int h5_write_only; /* Perform the write tests only */ + int verify; /* Verify data correctness */ }; typedef struct _minmax { double min; double max; double sum; - int num; + int num; } minmax; /* local functions */ -static off_t parse_size_directive(const char *size); +static off_t parse_size_directive(const char *size); static struct options *parse_command_line(int argc, char *argv[]); -static void run_test_loop(struct options *options); -static int run_test(iotype iot, parameters parms, struct options *opts); -static void output_all_info(minmax *mm, int count, int indent_level); -static void get_minmax(minmax *mm, double val); -static minmax accumulate_minmax_stuff(minmax *mm, int count); -static int create_comm_world(int num_procs, int *doing_pio); -static int destroy_comm_world(void); -static void output_results(const struct options *options, const char *name, - minmax *table, int table_size, off_t data_size); -static void output_times(const struct options *options, const char *name, - minmax *table, int table_size); -static void output_report(const char *fmt, ...); -static void print_indent(register int indent); -static void usage(const char *prog); -static void report_parameters(struct options *opts); +static void run_test_loop(struct options *options); +static int run_test(iotype iot, parameters parms, struct options *opts); +static void output_all_info(minmax *mm, int count, int indent_level); +static void get_minmax(minmax *mm, double val); +static minmax accumulate_minmax_stuff(minmax *mm, int count); +static int create_comm_world(int num_procs, int *doing_pio); +static int destroy_comm_world(void); +static void output_results(const struct options *options, const char *name, minmax *table, int table_size, + off_t data_size); +static void output_times(const struct options *options, const char *name, minmax *table, int table_size); +static void output_report(const char *fmt, ...); +static void print_indent(register int indent); +static void usage(const char *prog); +static void report_parameters(struct options *opts); static off_t squareo(off_t); /* @@ -329,9 +326,9 @@ static off_t squareo(off_t); int main(int argc, char *argv[]) { - int ret; - int exit_value = EXIT_SUCCESS; - struct options *opts = NULL; + int ret; + int exit_value = EXIT_SUCCESS; + struct options *opts = NULL; #ifndef STANDALONE /* Initialize h5tools lib */ @@ -430,26 +427,25 @@ static void run_test_loop(struct options *opts) { parameters parms; - int num_procs; - int doing_pio; /* if this process is doing PIO */ - - parms.num_files = opts->num_files; - parms.num_dsets = opts->num_dsets; - parms.num_iters = opts->num_iters; - parms.blk_size = opts->blk_size; - parms.interleaved = opts->interleaved; - parms.collective = opts->collective; - parms.dim2d = opts->dim2d; - parms.h5_align = (hsize_t)opts->h5_alignment; - parms.h5_thresh = (hsize_t)opts->h5_threshold; + int num_procs; + int doing_pio; /* if this process is doing PIO */ + + parms.num_files = opts->num_files; + parms.num_dsets = opts->num_dsets; + parms.num_iters = opts->num_iters; + parms.blk_size = opts->blk_size; + parms.interleaved = opts->interleaved; + parms.collective = opts->collective; + parms.dim2d = opts->dim2d; + parms.h5_align = (hsize_t)opts->h5_alignment; + parms.h5_thresh = (hsize_t)opts->h5_threshold; parms.h5_use_chunks = opts->h5_use_chunks; parms.h5_write_only = opts->h5_write_only; - parms.verify = opts->verify; + parms.verify = opts->verify; /* start with max_num_procs and decrement it by half for each loop. */ /* if performance needs restart, fewer processes may be needed. */ - for (num_procs = opts->max_num_procs; - num_procs >= opts->min_num_procs; num_procs >>= 1) { + for (num_procs = opts->max_num_procs; num_procs >= opts->min_num_procs; num_procs >>= 1) { register size_t buf_size; parms.num_procs = num_procs; @@ -458,42 +454,41 @@ run_test_loop(struct options *opts) /* do something harsh */ } - /* only processes doing PIO will run the tests */ - if (doing_pio){ + /* only processes doing PIO will run the tests */ + if (doing_pio) { output_report("Number of processors = %ld\n", parms.num_procs); /* multiply the xfer buffer size by 2 for each loop iteration */ - for (buf_size = opts->min_xfer_size; - buf_size <= opts->max_xfer_size; buf_size <<= 1) { + for (buf_size = opts->min_xfer_size; buf_size <= opts->max_xfer_size; buf_size <<= 1) { parms.buf_size = buf_size; - if (parms.dim2d){ - parms.num_bytes = squareo(opts->num_bpp * parms.num_procs); - if (parms.interleaved) - output_report("Transfer Buffer Size: %ldx%ld bytes, File size: %.2f MB\n", - buf_size, opts->blk_size, - ((double)parms.num_dsets * (double)parms.num_bytes) - / ONE_MB); - else - output_report("Transfer Buffer Size: %ldx%ld bytes, File size: %.2f MB\n", - opts->blk_size, buf_size, - ((double)parms.num_dsets * (double)parms.num_bytes) - / ONE_MB); - - print_indent(1); - output_report(" # of files: %ld, # of datasets: %ld, dataset size: %.2fx%.2f KB\n", - parms.num_files, parms.num_dsets, (double)(opts->num_bpp*parms.num_procs)/ONE_KB, - (double)(opts->num_bpp*parms.num_procs)/ONE_KB); - } - else{ - parms.num_bytes = (off_t)opts->num_bpp*parms.num_procs; - output_report("Transfer Buffer Size: %ld bytes, File size: %.2f MB\n", - buf_size,((double)parms.num_dsets * (double)parms.num_bytes) / ONE_MB); - - print_indent(1); - output_report(" # of files: %ld, # of datasets: %ld, dataset size: %.2f MB\n", - parms.num_files, parms.num_dsets, (double)(opts->num_bpp*parms.num_procs)/ONE_MB); - } + if (parms.dim2d) { + parms.num_bytes = squareo(opts->num_bpp * parms.num_procs); + if (parms.interleaved) + output_report("Transfer Buffer Size: %ldx%ld bytes, File size: %.2f MB\n", buf_size, + opts->blk_size, + ((double)parms.num_dsets * (double)parms.num_bytes) / ONE_MB); + else + output_report("Transfer Buffer Size: %ldx%ld bytes, File size: %.2f MB\n", + opts->blk_size, buf_size, + ((double)parms.num_dsets * (double)parms.num_bytes) / ONE_MB); + + print_indent(1); + output_report(" # of files: %ld, # of datasets: %ld, dataset size: %.2fx%.2f KB\n", + parms.num_files, parms.num_dsets, + (double)(opts->num_bpp * parms.num_procs) / ONE_KB, + (double)(opts->num_bpp * parms.num_procs) / ONE_KB); + } + else { + parms.num_bytes = (off_t)opts->num_bpp * parms.num_procs; + output_report("Transfer Buffer Size: %ld bytes, File size: %.2f MB\n", buf_size, + ((double)parms.num_dsets * (double)parms.num_bytes) / ONE_MB); + + print_indent(1); + output_report(" # of files: %ld, # of datasets: %ld, dataset size: %.2f MB\n", + parms.num_files, parms.num_dsets, + (double)(opts->num_bpp * parms.num_procs) / ONE_MB); + } if (opts->io_types & PIO_POSIX) run_test(POSIXIO, parms, opts); @@ -505,14 +500,14 @@ run_test_loop(struct options *opts) run_test(PHDF5, parms, opts); /* Run the tests once if buf_size==0, but then break out */ - if(buf_size==0) + if (buf_size == 0) break; } if (destroy_comm_world() != SUCCESS) { /* do something harsh */ } - } + } } } @@ -526,36 +521,36 @@ run_test_loop(struct options *opts) static int run_test(iotype iot, parameters parms, struct options *opts) { - results res; - register int i, ret_value = SUCCESS; - int comm_size; - off_t raw_size; - minmax *write_mpi_mm_table=NULL; - minmax *write_mm_table=NULL; - minmax *write_gross_mm_table=NULL; - minmax *write_raw_mm_table=NULL; - minmax *read_mpi_mm_table=NULL; - minmax *read_mm_table=NULL; - minmax *read_gross_mm_table=NULL; - minmax *read_raw_mm_table=NULL; - minmax *read_open_mm_table=NULL; - minmax *read_close_mm_table=NULL; - minmax *write_open_mm_table=NULL; - minmax *write_close_mm_table=NULL; - minmax write_mpi_mm = {0.0, 0.0, 0.0, 0}; - minmax write_mm = {0.0, 0.0, 0.0, 0}; - minmax write_gross_mm = {0.0, 0.0, 0.0, 0}; - minmax write_raw_mm = {0.0, 0.0, 0.0, 0}; - minmax read_mpi_mm = {0.0, 0.0, 0.0, 0}; - minmax read_mm = {0.0, 0.0, 0.0, 0}; - minmax read_gross_mm = {0.0, 0.0, 0.0, 0}; - minmax read_raw_mm = {0.0, 0.0, 0.0, 0}; - minmax read_open_mm = {0.0, 0.0, 0.0, 0}; - minmax read_close_mm = {0.0, 0.0, 0.0, 0}; - minmax write_open_mm = {0.0, 0.0, 0.0, 0}; - minmax write_close_mm = {0.0, 0.0, 0.0, 0}; - - raw_size = parms.num_files * (off_t)parms.num_dsets * (off_t)parms.num_bytes; + results res; + register int i, ret_value = SUCCESS; + int comm_size; + off_t raw_size; + minmax * write_mpi_mm_table = NULL; + minmax * write_mm_table = NULL; + minmax * write_gross_mm_table = NULL; + minmax * write_raw_mm_table = NULL; + minmax * read_mpi_mm_table = NULL; + minmax * read_mm_table = NULL; + minmax * read_gross_mm_table = NULL; + minmax * read_raw_mm_table = NULL; + minmax * read_open_mm_table = NULL; + minmax * read_close_mm_table = NULL; + minmax * write_open_mm_table = NULL; + minmax * write_close_mm_table = NULL; + minmax write_mpi_mm = {0.0, 0.0, 0.0, 0}; + minmax write_mm = {0.0, 0.0, 0.0, 0}; + minmax write_gross_mm = {0.0, 0.0, 0.0, 0}; + minmax write_raw_mm = {0.0, 0.0, 0.0, 0}; + minmax read_mpi_mm = {0.0, 0.0, 0.0, 0}; + minmax read_mm = {0.0, 0.0, 0.0, 0}; + minmax read_gross_mm = {0.0, 0.0, 0.0, 0}; + minmax read_raw_mm = {0.0, 0.0, 0.0, 0}; + minmax read_open_mm = {0.0, 0.0, 0.0, 0}; + minmax read_close_mm = {0.0, 0.0, 0.0, 0}; + minmax write_open_mm = {0.0, 0.0, 0.0, 0}; + minmax write_close_mm = {0.0, 0.0, 0.0, 0}; + + raw_size = parms.num_files * (off_t)parms.num_dsets * (off_t)parms.num_bytes; parms.io_type = iot; print_indent(2); output_report("IO API = "); @@ -578,19 +573,19 @@ run_test(iotype iot, parameters parms, struct options *opts) /* allocate space for tables minmax and that it is sufficient */ /* to initialize all elements to zeros by calloc. */ - write_mpi_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - write_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - write_gross_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - write_raw_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - write_open_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - write_close_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); + write_mpi_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax)); + write_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax)); + write_gross_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax)); + write_raw_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax)); + write_open_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax)); + write_close_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax)); if (!parms.h5_write_only) { - read_mpi_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - read_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - read_gross_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - read_raw_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - read_open_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); - read_close_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax)); + read_mpi_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax)); + read_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax)); + read_gross_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax)); + read_raw_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax)); + read_open_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax)); + read_close_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax)); } /* Do IO iteration times, collecting statistics each time */ @@ -672,10 +667,9 @@ run_test(iotype iot, parameters parms, struct options *opts) get_minmax(&read_close_mm, t); read_close_mm_table[i] = read_close_mm; + } - } - - io_time_destroy(res.timers); + io_time_destroy(res.timers); } /* @@ -692,7 +686,7 @@ run_test(iotype iot, parameters parms, struct options *opts) output_all_info(write_raw_mm_table, parms.num_iters, 4); } - output_results(opts,"Raw Data Write",write_raw_mm_table,parms.num_iters,raw_size); + output_results(opts, "Raw Data Write", write_raw_mm_table, parms.num_iters, raw_size); } /* end if */ /* show mpi write statics */ @@ -713,7 +707,7 @@ run_test(iotype iot, parameters parms, struct options *opts) output_all_info(write_mm_table, parms.num_iters, 4); } - output_results(opts,"Write",write_mm_table,parms.num_iters,raw_size); + output_results(opts, "Write", write_mm_table, parms.num_iters, raw_size); /* accumulate and output the max, min, and average "gross write" times */ if (pio_debug_level >= 3) { @@ -723,27 +717,27 @@ run_test(iotype iot, parameters parms, struct options *opts) output_all_info(write_gross_mm_table, parms.num_iters, 4); } - output_results(opts,"Write Open-Close",write_gross_mm_table,parms.num_iters,raw_size); + output_results(opts, "Write Open-Close", write_gross_mm_table, parms.num_iters, raw_size); if (opts->print_times) { - output_times(opts,"Write File Open",write_open_mm_table,parms.num_iters); - output_times(opts,"Write File Close",write_close_mm_table,parms.num_iters); + output_times(opts, "Write File Open", write_open_mm_table, parms.num_iters); + output_times(opts, "Write File Close", write_close_mm_table, parms.num_iters); } /* Print out time from open to first write */ if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Write file open details:\n"); - output_all_info(write_open_mm_table, parms.num_iters, 4); + /* output all of the times for all iterations */ + print_indent(3); + output_report("Write file open details:\n"); + output_all_info(write_open_mm_table, parms.num_iters, 4); } /* Print out time from last write to close */ if (pio_debug_level >= 3) { - /* output all of the times for all iterations */ - print_indent(3); - output_report("Write file close details:\n"); - output_all_info(write_close_mm_table, parms.num_iters, 4); + /* output all of the times for all iterations */ + print_indent(3); + output_report("Write file close details:\n"); + output_all_info(write_close_mm_table, parms.num_iters, 4); } if (!parms.h5_write_only) { @@ -758,8 +752,7 @@ run_test(iotype iot, parameters parms, struct options *opts) output_all_info(read_raw_mm_table, parms.num_iters, 4); } - output_results(opts, "Raw Data Read", read_raw_mm_table, - parms.num_iters, raw_size); + output_results(opts, "Raw Data Read", read_raw_mm_table, parms.num_iters, raw_size); } /* end if */ /* show mpi read statics */ @@ -790,11 +783,11 @@ run_test(iotype iot, parameters parms, struct options *opts) output_all_info(read_gross_mm_table, parms.num_iters, 4); } - output_results(opts, "Read Open-Close", read_gross_mm_table,parms.num_iters, raw_size); + output_results(opts, "Read Open-Close", read_gross_mm_table, parms.num_iters, raw_size); if (opts->print_times) { - output_times(opts,"Read File Open",read_open_mm_table,parms.num_iters); - output_times(opts,"Read File Close",read_close_mm_table,parms.num_iters); + output_times(opts, "Read File Open", read_open_mm_table, parms.num_iters); + output_times(opts, "Read File Close", read_close_mm_table, parms.num_iters); } /* Print out time from open to first read */ @@ -812,7 +805,6 @@ run_test(iotype iot, parameters parms, struct options *opts) output_report("Read file close details:\n"); output_all_info(read_close_mm_table, parms.num_iters, 4); } - } /* clean up our mess */ @@ -890,7 +882,7 @@ get_minmax(minmax *mm, double val) static minmax accumulate_minmax_stuff(minmax *mm, int count) { - int i; + int i; minmax total_mm; total_mm.sum = 0.0f; @@ -926,9 +918,9 @@ static int create_comm_world(int num_procs, int *doing_pio) { /* MPI variables */ - int mrc; /* return values */ - int color; /* for communicator creation */ - int myrank, nprocs; + int mrc; /* return values */ + int color; /* for communicator creation */ + int myrank, nprocs; pio_comm_g = MPI_COMM_NULL; @@ -939,15 +931,14 @@ create_comm_world(int num_procs, int *doing_pio) MPI_Comm_size(MPI_COMM_WORLD, &nprocs); if (num_procs > nprocs) { - HDfprintf(stderr, - "number of process(%d) must be <= number of processes in MPI_COMM_WORLD(%d)\n", - num_procs, nprocs); + HDfprintf(stderr, "number of process(%d) must be <= number of processes in MPI_COMM_WORLD(%d)\n", + num_procs, nprocs); goto error_done; } MPI_Comm_rank(MPI_COMM_WORLD, &myrank); color = (myrank < num_procs); - mrc = MPI_Comm_split(MPI_COMM_WORLD, color, myrank, &pio_comm_g); + mrc = MPI_Comm_split(MPI_COMM_WORLD, color, myrank, &pio_comm_g); if (mrc != MPI_SUCCESS) { HDfprintf(stderr, "MPI_Comm_split failed\n"); @@ -985,7 +976,7 @@ error_done: static int destroy_comm_world(void) { - int mrc = SUCCESS; /* return code */ + int mrc = SUCCESS; /* return code */ /* release MPI resources */ if (pio_comm_g != MPI_COMM_NULL) @@ -1003,63 +994,60 @@ destroy_comm_world(void) * Modifications: */ static void -output_results(const struct options *opts, const char *name, minmax *table, - int table_size,off_t data_size) +output_results(const struct options *opts, const char *name, minmax *table, int table_size, off_t data_size) { - minmax total_mm; + minmax total_mm; total_mm = accumulate_minmax_stuff(table, table_size); print_indent(3); - output_report("%s (%d iteration(s)):\n", name,table_size); + output_report("%s (%d iteration(s)):\n", name, table_size); /* Note: The maximum throughput uses the minimum amount of time & vice versa */ print_indent(4); - output_report("Maximum Throughput: %6.2f MB/s", MB_PER_SEC(data_size,total_mm.min)); - if(opts->print_times) + output_report("Maximum Throughput: %6.2f MB/s", MB_PER_SEC(data_size, total_mm.min)); + if (opts->print_times) output_report(" (%7.3f s)\n", total_mm.min); else output_report("\n"); print_indent(4); - output_report("Average Throughput: %6.2f MB/s", - MB_PER_SEC(data_size,total_mm.sum / total_mm.num)); - if(opts->print_times) + output_report("Average Throughput: %6.2f MB/s", MB_PER_SEC(data_size, total_mm.sum / total_mm.num)); + if (opts->print_times) output_report(" (%7.3f s)\n", (total_mm.sum / total_mm.num)); else output_report("\n"); print_indent(4); - output_report("Minimum Throughput: %6.2f MB/s", MB_PER_SEC(data_size,total_mm.max)); - if(opts->print_times) + output_report("Minimum Throughput: %6.2f MB/s", MB_PER_SEC(data_size, total_mm.max)); + if (opts->print_times) output_report(" (%7.3f s)\n", total_mm.max); else output_report("\n"); - } static void -output_times(const struct options *opts, const char *name, minmax *table, - int table_size) +output_times(const struct options *opts, const char *name, minmax *table, int table_size) { - minmax total_mm; + minmax total_mm; total_mm = accumulate_minmax_stuff(table, table_size); print_indent(3); - output_report("%s (%d iteration(s)):\n", name,table_size); + output_report("%s (%d iteration(s)):\n", name, table_size); /* Note: The maximum throughput uses the minimum amount of time & vice versa */ print_indent(4); - output_report("Minimum Accumulated Time using %d file(s): %7.5f s\n", opts->num_files,(total_mm.min)); + output_report("Minimum Accumulated Time using %d file(s): %7.5f s\n", opts->num_files, (total_mm.min)); print_indent(4); - output_report("Average Accumulated Time using %d file(s): %7.5f s\n", opts->num_files,(total_mm.sum / total_mm.num)); + output_report("Average Accumulated Time using %d file(s): %7.5f s\n", opts->num_files, + (total_mm.sum / total_mm.num)); print_indent(4); - output_report("Maximum Accumulated Time using %d file(s): %7.5f s\n", opts->num_files,(total_mm.max)); + output_report("Maximum Accumulated Time using %d file(s): %7.5f s\n", opts->num_files, (total_mm.max)); } /* @@ -1101,10 +1089,10 @@ print_indent(register int indent) MPI_Comm_rank(pio_comm_g, &myrank); if (myrank == 0) { - indent *= TAB_SPACE; + indent *= TAB_SPACE; - for (; indent > 0; --indent) - HDfputc(' ', output); + for (; indent > 0; --indent) + HDfputc(' ', output); } } @@ -1114,14 +1102,28 @@ recover_size_and_print(long long val, const char *end) if (val >= ONE_KB && (val % ONE_KB) == 0) { if (val >= ONE_MB && (val % ONE_MB) == 0) { if (val >= ONE_GB && (val % ONE_GB) == 0) - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""GB%s", val / ONE_GB, end); + HDfprintf(output, + "%" H5_PRINTF_LL_WIDTH "d" + "GB%s", + val / ONE_GB, end); else - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""MB%s", val / ONE_MB, end); - } else { - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""KB%s", val / ONE_KB, end); + HDfprintf(output, + "%" H5_PRINTF_LL_WIDTH "d" + "MB%s", + val / ONE_MB, end); + } + else { + HDfprintf(output, + "%" H5_PRINTF_LL_WIDTH "d" + "KB%s", + val / ONE_KB, end); } - } else { - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""%s", val, end); + } + else { + HDfprintf(output, + "%" H5_PRINTF_LL_WIDTH "d" + "%s", + val, end); } } @@ -1129,11 +1131,11 @@ static void print_io_api(long io_types) { if (io_types & PIO_POSIX) - HDfprintf(output, "posix "); + HDfprintf(output, "posix "); if (io_types & PIO_MPI) - HDfprintf(output, "mpiio "); + HDfprintf(output, "mpiio "); if (io_types & PIO_HDF5) - HDfprintf(output, "phdf5 "); + HDfprintf(output, "phdf5 "); HDfprintf(output, "\n"); } @@ -1142,90 +1144,84 @@ report_parameters(struct options *opts) { int rank = comm_world_rank_g; - print_version("HDF5 Library"); /* print library version */ + print_version("HDF5 Library"); /* print library version */ HDfprintf(output, "rank %d: ==== Parameters ====\n", rank); HDfprintf(output, "rank %d: IO API=", rank); print_io_api(opts->io_types); - HDfprintf(output, "rank %d: Number of files=%ld\n", rank, - opts->num_files); - HDfprintf(output, "rank %d: Number of datasets=%ld\n", rank, - opts->num_dsets); - HDfprintf(output, "rank %d: Number of iterations=%d\n", rank, - opts->num_iters); - HDfprintf(output, "rank %d: Number of processes=%d:%d\n", rank, - opts->min_num_procs, opts->max_num_procs); - - if (opts->dim2d){ - HDfprintf(output, "rank %d: Number of bytes per process per dataset=", rank); - recover_size_and_print((long long)(opts->num_bpp * opts->num_bpp * opts->min_num_procs), ":"); - recover_size_and_print((long long)(opts->num_bpp * opts->num_bpp * opts->max_num_procs), "\n"); - - HDfprintf(output, "rank %d: Size of dataset(s)=", rank); - recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs), "x"); - recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs), ":"); - recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs), "x"); - recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs), "\n"); - - HDfprintf(output, "rank %d: File size=", rank); - recover_size_and_print((long long)(squareo(opts->num_bpp * opts->min_num_procs) - * opts->num_dsets), ":"); - recover_size_and_print((long long)(squareo(opts->num_bpp * opts->max_num_procs) - * opts->num_dsets), "\n"); - - HDfprintf(output, "rank %d: Transfer buffer size=", rank); - if(opts->interleaved){ - recover_size_and_print((long long)opts->min_xfer_size, "x"); - recover_size_and_print((long long)opts->blk_size, ":"); - recover_size_and_print((long long)opts->max_xfer_size, "x"); + HDfprintf(output, "rank %d: Number of files=%ld\n", rank, opts->num_files); + HDfprintf(output, "rank %d: Number of datasets=%ld\n", rank, opts->num_dsets); + HDfprintf(output, "rank %d: Number of iterations=%d\n", rank, opts->num_iters); + HDfprintf(output, "rank %d: Number of processes=%d:%d\n", rank, opts->min_num_procs, opts->max_num_procs); + + if (opts->dim2d) { + HDfprintf(output, "rank %d: Number of bytes per process per dataset=", rank); + recover_size_and_print((long long)(opts->num_bpp * opts->num_bpp * opts->min_num_procs), ":"); + recover_size_and_print((long long)(opts->num_bpp * opts->num_bpp * opts->max_num_procs), "\n"); + + HDfprintf(output, "rank %d: Size of dataset(s)=", rank); + recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs), "x"); + recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs), ":"); + recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs), "x"); + recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs), "\n"); + + HDfprintf(output, "rank %d: File size=", rank); + recover_size_and_print((long long)(squareo(opts->num_bpp * opts->min_num_procs) * opts->num_dsets), + ":"); + recover_size_and_print((long long)(squareo(opts->num_bpp * opts->max_num_procs) * opts->num_dsets), + "\n"); + + HDfprintf(output, "rank %d: Transfer buffer size=", rank); + if (opts->interleaved) { + recover_size_and_print((long long)opts->min_xfer_size, "x"); + recover_size_and_print((long long)opts->blk_size, ":"); + recover_size_and_print((long long)opts->max_xfer_size, "x"); + recover_size_and_print((long long)opts->blk_size, "\n"); + } + else { + recover_size_and_print((long long)opts->blk_size, "x"); + recover_size_and_print((long long)opts->min_xfer_size, ":"); + recover_size_and_print((long long)opts->blk_size, "x"); + recover_size_and_print((long long)opts->max_xfer_size, "\n"); + } + HDfprintf(output, "rank %d: Block size=", rank); + recover_size_and_print((long long)opts->blk_size, "x"); recover_size_and_print((long long)opts->blk_size, "\n"); } - else{ - recover_size_and_print((long long)opts->blk_size, "x"); + else { + HDfprintf(output, "rank %d: Number of bytes per process per dataset=", rank); + recover_size_and_print((long long)opts->num_bpp, "\n"); + + HDfprintf(output, "rank %d: Size of dataset(s)=", rank); + recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs), ":"); + recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs), "\n"); + + HDfprintf(output, "rank %d: File size=", rank); + recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs * opts->num_dsets), ":"); + recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs * opts->num_dsets), "\n"); + + HDfprintf(output, "rank %d: Transfer buffer size=", rank); recover_size_and_print((long long)opts->min_xfer_size, ":"); - recover_size_and_print((long long)opts->blk_size, "x"); recover_size_and_print((long long)opts->max_xfer_size, "\n"); - } - HDfprintf(output, "rank %d: Block size=", rank); - recover_size_and_print((long long)opts->blk_size, "x"); - recover_size_and_print((long long)opts->blk_size, "\n"); - } - else{ - HDfprintf(output, "rank %d: Number of bytes per process per dataset=", rank); - recover_size_and_print((long long)opts->num_bpp, "\n"); - - HDfprintf(output, "rank %d: Size of dataset(s)=", rank); - recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs), ":"); - recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs), "\n"); - - HDfprintf(output, "rank %d: File size=", rank); - recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs - * opts->num_dsets), ":"); - recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs - * opts->num_dsets), "\n"); - - HDfprintf(output, "rank %d: Transfer buffer size=", rank); - recover_size_and_print((long long)opts->min_xfer_size, ":"); - recover_size_and_print((long long)opts->max_xfer_size, "\n"); - HDfprintf(output, "rank %d: Block size=", rank); - recover_size_and_print((long long)opts->blk_size, "\n"); + HDfprintf(output, "rank %d: Block size=", rank); + recover_size_and_print((long long)opts->blk_size, "\n"); } HDfprintf(output, "rank %d: Block Pattern in Dataset=", rank); - if(opts->interleaved) + if (opts->interleaved) HDfprintf(output, "Interleaved\n"); else HDfprintf(output, "Contiguous\n"); HDfprintf(output, "rank %d: I/O Method for MPI and HDF5=", rank); - if(opts->collective) + if (opts->collective) HDfprintf(output, "Collective\n"); else HDfprintf(output, "Independent\n"); HDfprintf(output, "rank %d: Geometry=", rank); - if(opts->dim2d) + if (opts->dim2d) HDfprintf(output, "2D\n"); else HDfprintf(output, "1D\n"); @@ -1233,7 +1229,7 @@ report_parameters(struct options *opts) HDfprintf(output, "rank %d: VFL used for HDF5 I/O=%s\n", rank, "MPI-IO driver"); HDfprintf(output, "rank %d: Data storage method in HDF5=", rank); - if(opts->h5_use_chunks) + if (opts->h5_use_chunks) HDfprintf(output, "Chunked\n"); else HDfprintf(output, "Contiguous\n"); @@ -1241,8 +1237,7 @@ report_parameters(struct options *opts) { char *prefix = HDgetenv("HDF5_PARAPREFIX"); - HDfprintf(output, "rank %d: Env HDF5_PARAPREFIX=%s\n", rank, - (prefix ? prefix : "not set")); + HDfprintf(output, "rank %d: Env HDF5_PARAPREFIX=%s\n", rank, (prefix ? prefix : "not set")); } HDfprintf(output, "rank %d: ", rank); @@ -1264,45 +1259,44 @@ report_parameters(struct options *opts) static struct options * parse_command_line(int argc, char *argv[]) { - register int opt; + register int opt; struct options *cl_opts; cl_opts = (struct options *)malloc(sizeof(struct options)); - cl_opts->output_file = NULL; - cl_opts->io_types = 0; /* will set default after parsing options */ - cl_opts->num_dsets = 1; - cl_opts->num_files = 1; - cl_opts->num_bpp = 0; - cl_opts->num_iters = 1; + cl_opts->output_file = NULL; + cl_opts->io_types = 0; /* will set default after parsing options */ + cl_opts->num_dsets = 1; + cl_opts->num_files = 1; + cl_opts->num_bpp = 0; + cl_opts->num_iters = 1; cl_opts->max_num_procs = comm_world_nprocs_g; cl_opts->min_num_procs = 1; cl_opts->max_xfer_size = 0; cl_opts->min_xfer_size = 0; - cl_opts->blk_size = 0; - cl_opts->interleaved = 0; /* Default to contiguous blocks in dataset */ - cl_opts->collective = 0; /* Default to independent I/O access */ - cl_opts->dim2d = 0; /* Default to 1D */ - cl_opts->print_times = FALSE; /* Printing times is off by default */ - cl_opts->print_raw = FALSE; /* Printing raw data throughput is off by default */ - cl_opts->h5_alignment = 1; /* No alignment for HDF5 objects by default */ - cl_opts->h5_threshold = 1; /* No threshold for aligning HDF5 objects by default */ + cl_opts->blk_size = 0; + cl_opts->interleaved = 0; /* Default to contiguous blocks in dataset */ + cl_opts->collective = 0; /* Default to independent I/O access */ + cl_opts->dim2d = 0; /* Default to 1D */ + cl_opts->print_times = FALSE; /* Printing times is off by default */ + cl_opts->print_raw = FALSE; /* Printing raw data throughput is off by default */ + cl_opts->h5_alignment = 1; /* No alignment for HDF5 objects by default */ + cl_opts->h5_threshold = 1; /* No threshold for aligning HDF5 objects by default */ cl_opts->h5_use_chunks = FALSE; /* Don't chunk the HDF5 dataset by default */ cl_opts->h5_write_only = FALSE; /* Do both read and write by default */ - cl_opts->verify = FALSE; /* No Verify data correctness by default */ + cl_opts->verify = FALSE; /* No Verify data correctness by default */ while ((opt = get_option(argc, (const char **)argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { - case 'a': - cl_opts->h5_alignment = parse_size_directive(opt_arg); - break; - case 'A': - { + case 'a': + cl_opts->h5_alignment = parse_size_directive(opt_arg); + break; + case 'A': { const char *end = opt_arg; while (end && *end != '\0') { char buf[10]; - int i; + int i; HDmemset(buf, '\0', sizeof(buf)); @@ -1312,13 +1306,15 @@ parse_command_line(int argc, char *argv[]) if (!HDstrcasecmp(buf, "phdf5")) { cl_opts->io_types |= PIO_HDF5; - } else if (!HDstrcasecmp(buf, "mpiio")) { + } + else if (!HDstrcasecmp(buf, "mpiio")) { cl_opts->io_types |= PIO_MPI; - } else if (!HDstrcasecmp(buf, "posix")) { + } + else if (!HDstrcasecmp(buf, "posix")) { cl_opts->io_types |= PIO_POSIX; - } else { - HDfprintf(stderr, "pio_perf: invalid --api option %s\n", - buf); + } + else { + HDfprintf(stderr, "pio_perf: invalid --api option %s\n", buf); HDexit(EXIT_FAILURE); } @@ -1334,27 +1330,26 @@ parse_command_line(int argc, char *argv[]) case 'b': /* the future "binary" option */ break; -#endif /* 0 */ - case 'B': - cl_opts->blk_size = (size_t)parse_size_directive(opt_arg); - break; - case 'c': - /* Turn on chunked HDF5 dataset creation */ - cl_opts->h5_use_chunks = TRUE; - break; - case 'C': - cl_opts->collective = 1; - break; - case 'd': - cl_opts->num_dsets = atoi(opt_arg); - break; - case 'D': - { +#endif /* 0 */ + case 'B': + cl_opts->blk_size = (size_t)parse_size_directive(opt_arg); + break; + case 'c': + /* Turn on chunked HDF5 dataset creation */ + cl_opts->h5_use_chunks = TRUE; + break; + case 'C': + cl_opts->collective = 1; + break; + case 'd': + cl_opts->num_dsets = atoi(opt_arg); + break; + case 'D': { const char *end = opt_arg; while (end && *end != '\0') { char buf[10]; - int i; + int i; HDmemset(buf, '\0', sizeof(buf)); @@ -1367,8 +1362,7 @@ parse_command_line(int argc, char *argv[]) for (j = 0; j < 10 && buf[j] != '\0'; ++j) if (!isdigit(buf[j])) { - HDfprintf(stderr, "pio_perf: invalid --debug option %s\n", - buf); + HDfprintf(stderr, "pio_perf: invalid --debug option %s\n", buf); HDexit(EXIT_FAILURE); } @@ -1378,23 +1372,24 @@ parse_command_line(int argc, char *argv[]) pio_debug_level = 4; else if (pio_debug_level < 0) pio_debug_level = 0; - } else { + } + else { switch (*buf) { - case 'r': - /* Turn on raw data throughput info */ - cl_opts->print_raw = TRUE; - break; - case 't': - /* Turn on time printing */ - cl_opts->print_times = TRUE; - break; - case 'v': - /* Turn on verify data correctness*/ - cl_opts->verify = TRUE; - break; - default: - HDfprintf(stderr, "pio_perf: invalid --debug option %s\n", buf); - HDexit(EXIT_FAILURE); + case 'r': + /* Turn on raw data throughput info */ + cl_opts->print_raw = TRUE; + break; + case 't': + /* Turn on time printing */ + cl_opts->print_times = TRUE; + break; + case 'v': + /* Turn on verify data correctness*/ + cl_opts->verify = TRUE; + break; + default: + HDfprintf(stderr, "pio_perf: invalid --debug option %s\n", buf); + HDexit(EXIT_FAILURE); } } @@ -1406,53 +1401,52 @@ parse_command_line(int argc, char *argv[]) } break; - case 'e': - cl_opts->num_bpp = parse_size_directive(opt_arg); - break; - case 'F': - cl_opts->num_files = HDatoi(opt_arg); - break; - case 'g': - cl_opts->dim2d = 1; - break; - case 'i': - cl_opts->num_iters = HDatoi(opt_arg); - break; - case 'I': - cl_opts->interleaved = 1; - break; - case 'o': - cl_opts->output_file = opt_arg; - break; - case 'p': - cl_opts->min_num_procs = HDatoi(opt_arg); - break; - case 'P': - cl_opts->max_num_procs = HDatoi(opt_arg); - break; - case 'T': - cl_opts->h5_threshold = parse_size_directive(opt_arg); - break; - case 'w': - cl_opts->h5_write_only = TRUE; - break; - case 'x': - cl_opts->min_xfer_size = (size_t)parse_size_directive(opt_arg); - break; - case 'X': - cl_opts->max_xfer_size = (size_t)parse_size_directive(opt_arg); - break; - case 'h': - case '?': - default: - usage(progname); - HDfree(cl_opts); - return NULL; + case 'e': + cl_opts->num_bpp = parse_size_directive(opt_arg); + break; + case 'F': + cl_opts->num_files = HDatoi(opt_arg); + break; + case 'g': + cl_opts->dim2d = 1; + break; + case 'i': + cl_opts->num_iters = HDatoi(opt_arg); + break; + case 'I': + cl_opts->interleaved = 1; + break; + case 'o': + cl_opts->output_file = opt_arg; + break; + case 'p': + cl_opts->min_num_procs = HDatoi(opt_arg); + break; + case 'P': + cl_opts->max_num_procs = HDatoi(opt_arg); + break; + case 'T': + cl_opts->h5_threshold = parse_size_directive(opt_arg); + break; + case 'w': + cl_opts->h5_write_only = TRUE; + break; + case 'x': + cl_opts->min_xfer_size = (size_t)parse_size_directive(opt_arg); + break; + case 'X': + cl_opts->max_xfer_size = (size_t)parse_size_directive(opt_arg); + break; + case 'h': + case '?': + default: + usage(progname); + HDfree(cl_opts); + return NULL; } } - - if (cl_opts->num_bpp == 0){ + if (cl_opts->num_bpp == 0) { if (cl_opts->dim2d == 0) cl_opts->num_bpp = 256 * ONE_KB; else @@ -1463,38 +1457,37 @@ parse_command_line(int argc, char *argv[]) cl_opts->max_xfer_size = (size_t)cl_opts->num_bpp; if (cl_opts->min_xfer_size == 0) - cl_opts->min_xfer_size = (size_t)(cl_opts->num_bpp)/2; + cl_opts->min_xfer_size = (size_t)(cl_opts->num_bpp) / 2; if (cl_opts->blk_size == 0) - cl_opts->blk_size = (size_t)(cl_opts->num_bpp)/2; - + cl_opts->blk_size = (size_t)(cl_opts->num_bpp) / 2; /* set default if none specified yet */ if (!cl_opts->io_types) - cl_opts->io_types = PIO_HDF5 | PIO_MPI | PIO_POSIX; /* run all API */ + cl_opts->io_types = PIO_HDF5 | PIO_MPI | PIO_POSIX; /* run all API */ /* verify parameters sanity. Adjust if needed. */ /* cap xfer_size with bytes per process */ if (!cl_opts->dim2d) { if (cl_opts->min_xfer_size > (size_t)cl_opts->num_bpp) - cl_opts->min_xfer_size = (size_t)cl_opts->num_bpp; + cl_opts->min_xfer_size = (size_t)cl_opts->num_bpp; if (cl_opts->max_xfer_size > (size_t)cl_opts->num_bpp) - cl_opts->max_xfer_size = (size_t)cl_opts->num_bpp; + cl_opts->max_xfer_size = (size_t)cl_opts->num_bpp; } if (cl_opts->min_xfer_size > cl_opts->max_xfer_size) - cl_opts->min_xfer_size = cl_opts->max_xfer_size; - if (cl_opts->blk_size > (size_t)cl_opts->num_bpp ) + cl_opts->min_xfer_size = cl_opts->max_xfer_size; + if (cl_opts->blk_size > (size_t)cl_opts->num_bpp) cl_opts->blk_size = (size_t)cl_opts->num_bpp; /* check range of number of processes */ if (cl_opts->min_num_procs <= 0) - cl_opts->min_num_procs = 1; + cl_opts->min_num_procs = 1; if (cl_opts->max_num_procs <= 0) - cl_opts->max_num_procs = 1; + cl_opts->max_num_procs = 1; if (cl_opts->min_num_procs > cl_opts->max_num_procs) - cl_opts->min_num_procs = cl_opts->max_num_procs; + cl_opts->min_num_procs = cl_opts->max_num_procs; /* check iteration */ if (cl_opts->num_iters <= 0) - cl_opts->num_iters = 1; + cl_opts->num_iters = 1; return cl_opts; } @@ -1572,7 +1565,7 @@ usage(const char *prog) HDprintf(" -A AL, --api=AL Which APIs to test [default: all of them]\n"); #if 0 HDprintf(" -b, --binary The elusive binary option\n"); -#endif /* 0 */ +#endif /* 0 */ HDprintf(" -B S, --block-size=S Block size within transfer buffer\n"); HDprintf(" (see below for description)\n"); HDprintf(" [default: half the number of bytes per process\n"); @@ -1615,7 +1608,7 @@ usage(const char *prog) HDprintf(" M - Megabyte (%d)\n", ONE_MB); HDprintf(" G - Gigabyte (%d)\n", ONE_GB); HDprintf("\n"); - HDprintf(" Example: '37M' is 37 megabytes or %d bytes\n", 37*ONE_MB); + HDprintf(" Example: '37M' is 37 megabytes or %d bytes\n", 37 * ONE_MB); HDprintf("\n"); HDprintf(" AL - is an API list. Valid values are:\n"); HDprintf(" phdf5 - Parallel HDF5\n"); diff --git a/tools/test/perform/pio_perf.h b/tools/test/perform/pio_perf.h index 55d721e..cc1a65c 100644 --- a/tools/test/perform/pio_perf.h +++ b/tools/test/perform/pio_perf.h @@ -36,67 +36,65 @@ typedef enum iotype_ { } iotype; typedef struct parameters_ { - iotype io_type; /* The type of IO test to perform */ - int num_procs; /* Maximum number of processes to use */ - long num_files; /* Number of files to create */ - long num_dsets; /* Number of datasets to create */ - off_t num_bytes; /* Number of bytes in each dset */ - int num_iters; /* Number of times to loop doing the IO */ - size_t buf_size; /* Buffer size */ - size_t blk_size; /* Block size */ - unsigned interleaved; /* Interleaved vs. contiguous blocks */ - unsigned collective; /* Collective vs. independent I/O */ - unsigned dim2d; /* 1D vs. 2D */ - hsize_t h5_align; /* HDF5 object alignment */ - hsize_t h5_thresh; /* HDF5 object alignment threshold */ - int h5_use_chunks; /* Make HDF5 dataset chunked */ - int h5_write_only; /* Perform the write tests only */ - int verify; /* Verify data correctness */ + iotype io_type; /* The type of IO test to perform */ + int num_procs; /* Maximum number of processes to use */ + long num_files; /* Number of files to create */ + long num_dsets; /* Number of datasets to create */ + off_t num_bytes; /* Number of bytes in each dset */ + int num_iters; /* Number of times to loop doing the IO */ + size_t buf_size; /* Buffer size */ + size_t blk_size; /* Block size */ + unsigned interleaved; /* Interleaved vs. contiguous blocks */ + unsigned collective; /* Collective vs. independent I/O */ + unsigned dim2d; /* 1D vs. 2D */ + hsize_t h5_align; /* HDF5 object alignment */ + hsize_t h5_thresh; /* HDF5 object alignment threshold */ + int h5_use_chunks; /* Make HDF5 dataset chunked */ + int h5_write_only; /* Perform the write tests only */ + int verify; /* Verify data correctness */ } parameters; typedef struct results_ { - herr_t ret_code; - io_time_t *timers; + herr_t ret_code; + io_time_t *timers; } results; #ifndef SUCCESS -#define SUCCESS 0 -#endif /* !SUCCESS */ +#define SUCCESS 0 +#endif /* !SUCCESS */ #ifndef FAIL -#define FAIL -1 -#endif /* !FAIL */ +#define FAIL -1 +#endif /* !FAIL */ -extern FILE *output; /* output file */ -extern io_time_t *timer_g; /* timer: global for stub functions */ -extern int comm_world_rank_g; /* my rank in MPI_COMM_RANK */ -extern int comm_world_nprocs_g;/* num. of processes of MPI_COMM_WORLD */ -extern MPI_Comm pio_comm_g; /* Communicator to run the PIO */ -extern int pio_mpi_rank_g; /* MPI rank of pio_comm_g */ -extern int pio_mpi_nprocs_g; /* number of processes of pio_comm_g */ -extern int pio_debug_level; /* The debug level: - * 0 - Off - * 1 - Minimal - * 2 - Some more - * 3 - Maximal - * 4 - Even More Debugging (timer stuff) - */ +extern FILE * output; /* output file */ +extern io_time_t *timer_g; /* timer: global for stub functions */ +extern int comm_world_rank_g; /* my rank in MPI_COMM_RANK */ +extern int comm_world_nprocs_g; /* num. of processes of MPI_COMM_WORLD */ +extern MPI_Comm pio_comm_g; /* Communicator to run the PIO */ +extern int pio_mpi_rank_g; /* MPI rank of pio_comm_g */ +extern int pio_mpi_nprocs_g; /* number of processes of pio_comm_g */ +extern int pio_debug_level; /* The debug level: + * 0 - Off + * 1 - Minimal + * 2 - Some more + * 3 - Maximal + * 4 - Even More Debugging (timer stuff) + */ -#define HDprint_rank(f) /* print rank in MPI_COMM_WORLD */ \ - HDfprintf(f, "%d: ", comm_world_rank_g); -#define HDprint_size(f) /* print size of MPI_COMM_WORLD */ \ - HDfprintf(f, "%d", comm_world_nprocs_g); -#define HDprint_rank_size(f) /* print rank/size of MPI_COMM_WORLD */ \ +#define HDprint_rank(f) /* print rank in MPI_COMM_WORLD */ HDfprintf(f, "%d: ", comm_world_rank_g); +#define HDprint_size(f) /* print size of MPI_COMM_WORLD */ HDfprintf(f, "%d", comm_world_nprocs_g); +#define HDprint_rank_size(f) /* print rank/size of MPI_COMM_WORLD */ \ HDfprintf(f, "%d/%d: ", comm_world_rank_g, comm_world_nprocs_g); #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif /* __cplusplus */ extern results do_pio(parameters param); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* PIO_PERF_H__ */ +#endif /* PIO_PERF_H__ */ diff --git a/tools/test/perform/pio_standalone.c b/tools/test/perform/pio_standalone.c index 8cdca85..9d88727 100644 --- a/tools/test/perform/pio_standalone.c +++ b/tools/test/perform/pio_standalone.c @@ -10,7 +10,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /* This file contains the definition of functions required to build h5perf in * STANDALONE mode. * Created: Christian Chilan, 2005/5/18. @@ -19,31 +18,31 @@ #include "pio_perf.h" #ifdef STANDALONE -MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ +MPI_Info h5_io_info_g = MPI_INFO_NULL; /* MPI INFO object for IO */ #endif /** From h5tools_utils.c **/ /* global variables */ -int nCols = 80; +int nCols = 80; /* ``get_option'' variables */ -int opt_err = 1; /*get_option prints errors if this is on */ -int opt_ind = 1; /*token pointer */ -const char *opt_arg; /*flag argument (or value) */ - +int opt_err = 1; /*get_option prints errors if this is on */ +int opt_ind = 1; /*token pointer */ +const char *opt_arg; /*flag argument (or value) */ int get_option(int argc, const char **argv, const char *opts, const struct long_options *l_opts) { - static int sp = 1; /* character index in current token */ - int opt_opt = '?'; /* option character passed back to user */ + static int sp = 1; /* character index in current token */ + int opt_opt = '?'; /* option character passed back to user */ if (sp == 1) { /* check for more flag-like tokens */ if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') { return EOF; - } else if (HDstrcmp(argv[opt_ind], "--") == 0) { + } + else if (HDstrcmp(argv[opt_ind], "--") == 0) { opt_ind++; return EOF; } @@ -52,7 +51,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') { /* long command line option */ const char *arg = &argv[opt_ind][2]; - int i; + int i; for (i = 0; l_opts && l_opts[i].name; i++) { size_t len = HDstrlen(l_opts[i].name); @@ -64,22 +63,21 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (l_opts[i].has_arg != no_arg) { if (arg[len] == '=') { opt_arg = &arg[len + 1]; - } else if (opt_ind < (argc - 1) && argv[opt_ind + 1][0] != '-') { + } + else if (opt_ind < (argc - 1) && argv[opt_ind + 1][0] != '-') { opt_arg = argv[++opt_ind]; - } else if (l_opts[i].has_arg == require_arg) { + } + else if (l_opts[i].has_arg == require_arg) { if (opt_err) - HDfprintf(stderr, - "%s: option required for \"--%s\" flag\n", - argv[0], arg); + HDfprintf(stderr, "%s: option required for \"--%s\" flag\n", argv[0], arg); opt_opt = '?'; } - } else { + } + else { if (arg[len] == '=') { if (opt_err) - HDfprintf(stderr, - "%s: no option required for \"%s\" flag\n", - argv[0], arg); + HDfprintf(stderr, "%s: no option required for \"%s\" flag\n", argv[0], arg); opt_opt = '?'; } @@ -101,8 +99,9 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti opt_ind++; sp = 1; - } else { - register char *cp; /* pointer into current token */ + } + else { + register char *cp; /* pointer into current token */ /* short command line option */ opt_opt = argv[opt_ind][sp]; @@ -110,8 +109,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (opt_opt == ':' || (cp = strchr(opts, opt_opt)) == 0) { if (opt_err) - HDfprintf(stderr, "%s: unknown option \"%c\"\n", - argv[0], opt_opt); + HDfprintf(stderr, "%s: unknown option \"%c\"\n", argv[0], opt_opt); /* if no chars left in this token, move to next token */ if (argv[opt_ind][++sp] == '\0') { @@ -127,20 +125,21 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (argv[opt_ind][sp + 1] != '\0') { /* flag value is rest of current token */ opt_arg = &argv[opt_ind++][sp + 1]; - } else if (++opt_ind >= argc) { + } + else if (++opt_ind >= argc) { if (opt_err) - HDfprintf(stderr, - "%s: value expected for option \"%c\"\n", - argv[0], opt_opt); + HDfprintf(stderr, "%s: value expected for option \"%c\"\n", argv[0], opt_opt); opt_opt = '?'; - } else { + } + else { /* flag value is next token */ opt_arg = argv[opt_ind++]; } sp = 1; - } else { + } + else { /* set up to look at next char in token, next time */ if (argv[opt_ind][++sp] == '\0') { /* no more in current token, so setup next token */ @@ -156,12 +155,10 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti return opt_opt; } - void print_version(const char *progname) { - printf("%s: Version %u.%u.%u%s%s\n", - progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, + printf("%s: Version %u.%u.%u%s%s\n", progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, H5_VERS_SUBRELEASE[0] ? "-" : "", H5_VERS_SUBRELEASE); } @@ -182,16 +179,17 @@ print_version(const char *progname) int h5_set_info_object(void) { - char *envp; /* environment pointer */ - int ret_value=0; + char *envp; /* environment pointer */ + int ret_value = 0; /* handle any MPI INFO hints via $HDF5_MPI_INFO */ - if ((envp = HDgetenv("HDF5_MPI_INFO")) != NULL){ + if ((envp = HDgetenv("HDF5_MPI_INFO")) != NULL) { char *next, *valp; valp = envp = next = HDstrdup(envp); - if (!valp) return 0; + if (!valp) + return 0; /* create an INFO object if not created yet */ if (h5_io_info_g == MPI_INFO_NULL) @@ -199,14 +197,14 @@ h5_set_info_object(void) do { size_t len; - char *key_val, *endp, *namep; + char * key_val, *endp, *namep; if (*valp == ';') valp++; /* copy key/value pair into temporary buffer */ - len = strcspn(valp, ";"); - next = &valp[len]; + len = strcspn(valp, ";"); + next = &valp[len]; key_val = (char *)HDcalloc(1, len + 1); /* increment the next pointer past the terminating semicolon */ @@ -219,7 +217,8 @@ h5_set_info_object(void) while (*namep && (*namep == ' ' || *namep == '\t')) namep++; - if (!*namep) continue; /* was all white space, so move to next k/v pair */ + if (!*namep) + continue; /* was all white space, so move to next k/v pair */ /* eat up any ending white spaces */ endp = &namep[HDstrlen(namep) - 1]; @@ -230,7 +229,7 @@ h5_set_info_object(void) /* find the '=' */ valp = HDstrchr(namep, '='); - if (valp != NULL) { /* it's a valid key/value pairing */ + if (valp != NULL) { /* it's a valid key/value pairing */ char *tmp_val = valp + 1; /* change '=' to \0, move valp down one */ @@ -263,7 +262,6 @@ h5_set_info_object(void) return ret_value; } - /* * Function: h5_dump_info_object * Purpose: Display content of an MPI Info object @@ -274,25 +272,23 @@ h5_set_info_object(void) void h5_dump_info_object(MPI_Info info) { - char key[MPI_MAX_INFO_KEY+1]; - char value[MPI_MAX_INFO_VAL+1]; - int flag; - int i, nkeys; + char key[MPI_MAX_INFO_KEY + 1]; + char value[MPI_MAX_INFO_VAL + 1]; + int flag; + int i, nkeys; HDprintf("Dumping MPI Info Object (up to %d bytes per item):\n", MPI_MAX_INFO_VAL); - if (info==MPI_INFO_NULL){ - HDprintf("object is MPI_INFO_NULL\n"); + if (info == MPI_INFO_NULL) { + HDprintf("object is MPI_INFO_NULL\n"); } else { - MPI_Info_get_nkeys(info, &nkeys); - HDprintf("object has %d items\n", nkeys); - for (i=0; i<nkeys; i++){ - MPI_Info_get_nthkey(info, i, key); - MPI_Info_get(info, key, MPI_MAX_INFO_VAL, value, &flag); - HDprintf("%s=%s\n", key, value); - } - + MPI_Info_get_nkeys(info, &nkeys); + HDprintf("object has %d items\n", nkeys); + for (i = 0; i < nkeys; i++) { + MPI_Info_get_nthkey(info, i, key); + MPI_Info_get(info, key, MPI_MAX_INFO_VAL, value, &flag); + HDprintf("%s=%s\n", key, value); + } } } -#endif /* STANDALONE */ - +#endif /* STANDALONE */ diff --git a/tools/test/perform/pio_standalone.h b/tools/test/perform/pio_standalone.h index 55880e3..d64f421 100644 --- a/tools/test/perform/pio_standalone.h +++ b/tools/test/perform/pio_standalone.h @@ -19,450 +19,449 @@ /** From H5private.h **/ -#include "H5public.h" /* Include Public Definitions */ - +#include "H5public.h" /* Include Public Definitions */ /* * Include ANSI-C header files. */ #ifdef H5_STDC_HEADERS -# include <assert.h> -# include <ctype.h> -# include <errno.h> -# include <fcntl.h> -# include <float.h> -# include <limits.h> -# include <math.h> -# include <signal.h> -# include <stdarg.h> -# include <stdio.h> -# include <stdlib.h> -# include <string.h> +#include <assert.h> +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <float.h> +#include <limits.h> +#include <math.h> +#include <signal.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #endif /* * Redefine all the POSIX functions. We should never see a POSIX * function (or any other non-HDF5 function) in the source! */ -#define HDabort() abort() -#define HDabs(X) abs(X) +#define HDabort() abort() +#define HDabs(X) abs(X) #ifdef H5_HAVE_WIN32_API -#define HDaccess(F,M) _access(F, M) -#define R_OK 4 /* Test for read permission. */ -#define W_OK 2 /* Test for write permission. */ -#define X_OK 1 /* Test for execute permission. */ -#define F_OK 0 /* Test for existence. */ -#else /* H5_HAVE_WIN32_API */ -#define HDaccess(F,M) access(F, M) +#define HDaccess(F, M) _access(F, M) +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK 1 /* Test for execute permission. */ +#define F_OK 0 /* Test for existence. */ +#else /* H5_HAVE_WIN32_API */ +#define HDaccess(F, M) access(F, M) #ifndef F_OK -#define F_OK 00 +#define F_OK 00 #define W_OK 02 #define R_OK 04 #endif #endif /* H5_HAVE_WIN32_API */ -#define HDacos(X) acos(X) +#define HDacos(X) acos(X) #ifdef H5_HAVE_ALARM -#define HDalarm(N) alarm(N) +#define HDalarm(N) alarm(N) #else /* H5_HAVE_ALARM */ -#define HDalarm(N) (0) +#define HDalarm(N) (0) #endif /* H5_HAVE_ALARM */ -#define HDasctime(T) asctime(T) -#define HDasin(X) asin(X) -#define HDasprintf asprintf /*varargs*/ -#define HDassert(X) assert(X) -#define HDatan(X) atan(X) -#define HDatan2(X,Y) atan2(X,Y) -#define HDatexit(F) atexit(F) -#define HDatof(S) atof(S) -#define HDatoi(S) atoi(S) -#define HDatol(S) atol(S) -#define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F) -#define HDcalloc(N,Z) calloc(N,Z) -#define HDceil(X) ceil(X) -#define HDcfgetispeed(T) cfgetispeed(T) -#define HDcfgetospeed(T) cfgetospeed(T) -#define HDcfsetispeed(T,S) cfsetispeed(T,S) -#define HDcfsetospeed(T,S) cfsetospeed(T,S) -#define HDchdir(S) chdir(S) -#define HDchmod(S,M) chmod(S,M) -#define HDchown(S,O,G) chown(S,O,G) -#define HDclearerr(F) clearerr(F) -#define HDclock() clock() -#define HDclose(F) close(F) -#define HDclosedir(D) closedir(D) -#define HDcos(X) cos(X) -#define HDcosh(X) cosh(X) -#define HDcreat(S,M) creat(S,M) -#define HDctermid(S) ctermid(S) -#define HDctime(T) ctime(T) -#define HDcuserid(S) cuserid(S) +#define HDasctime(T) asctime(T) +#define HDasin(X) asin(X) +#define HDasprintf asprintf /*varargs*/ +#define HDassert(X) assert(X) +#define HDatan(X) atan(X) +#define HDatan2(X, Y) atan2(X, Y) +#define HDatexit(F) atexit(F) +#define HDatof(S) atof(S) +#define HDatoi(S) atoi(S) +#define HDatol(S) atol(S) +#define HDbsearch(K, B, N, Z, F) bsearch(K, B, N, Z, F) +#define HDcalloc(N, Z) calloc(N, Z) +#define HDceil(X) ceil(X) +#define HDcfgetispeed(T) cfgetispeed(T) +#define HDcfgetospeed(T) cfgetospeed(T) +#define HDcfsetispeed(T, S) cfsetispeed(T, S) +#define HDcfsetospeed(T, S) cfsetospeed(T, S) +#define HDchdir(S) chdir(S) +#define HDchmod(S, M) chmod(S, M) +#define HDchown(S, O, G) chown(S, O, G) +#define HDclearerr(F) clearerr(F) +#define HDclock() clock() +#define HDclose(F) close(F) +#define HDclosedir(D) closedir(D) +#define HDcos(X) cos(X) +#define HDcosh(X) cosh(X) +#define HDcreat(S, M) creat(S, M) +#define HDctermid(S) ctermid(S) +#define HDctime(T) ctime(T) +#define HDcuserid(S) cuserid(S) #ifdef H5_HAVE_DIFFTIME -#define HDdifftime(X,Y) difftime(X,Y) +#define HDdifftime(X, Y) difftime(X, Y) #else -#define HDdifftime(X,Y) ((double)(X)-(double)(Y)) +#define HDdifftime(X, Y) ((double)(X) - (double)(Y)) #endif -#define HDdiv(X,Y) div(X,Y) -#define HDdup(F) dup(F) -#define HDdup2(F,I) dup2(F,I) +#define HDdiv(X, Y) div(X, Y) +#define HDdup(F) dup(F) +#define HDdup2(F, I) dup2(F, I) /* execl() variable arguments */ /* execle() variable arguments */ /* execlp() variable arguments */ -#define HDexecv(S,AV) execv(S,AV) -#define HDexecve(S,AV,E) execve(S,AV,E) -#define HDexecvp(S,AV) execvp(S,AV) -#define HDexit(N) exit(N) -#define HD_exit(N) _exit(N) -#define HDexp(X) exp(X) -#define HDfabs(X) fabs(X) +#define HDexecv(S, AV) execv(S, AV) +#define HDexecve(S, AV, E) execve(S, AV, E) +#define HDexecvp(S, AV) execvp(S, AV) +#define HDexit(N) exit(N) +#define HD_exit(N) _exit(N) +#define HDexp(X) exp(X) +#define HDfabs(X) fabs(X) /* use ABS() because fabsf() fabsl() are not common yet. */ -#define HDfabsf(X) ABS(X) -#define HDfabsl(X) ABS(X) -#define HDfclose(F) fclose(F) +#define HDfabsf(X) ABS(X) +#define HDfabsl(X) ABS(X) +#define HDfclose(F) fclose(F) /* fcntl() variable arguments */ -#define HDfdopen(N,S) fdopen(N,S) -#define HDfeof(F) feof(F) -#define HDferror(F) ferror(F) -#define HDfflush(F) fflush(F) -#define HDfgetc(F) fgetc(F) -#define HDfgetpos(F,P) fgetpos(F,P) -#define HDfgets(S,N,F) fgets(S,N,F) +#define HDfdopen(N, S) fdopen(N, S) +#define HDfeof(F) feof(F) +#define HDferror(F) ferror(F) +#define HDfflush(F) fflush(F) +#define HDfgetc(F) fgetc(F) +#define HDfgetpos(F, P) fgetpos(F, P) +#define HDfgets(S, N, F) fgets(S, N, F) #ifdef H5_HAVE_WIN32_API -#define HDfileno(F) _fileno(F) +#define HDfileno(F) _fileno(F) #else /* H5_HAVE_WIN32_API */ -#define HDfileno(F) fileno(F) +#define HDfileno(F) fileno(F) #endif /* H5_HAVE_WIN32_API */ -#define HDfloor(X) floor(X) -#define HDfmod(X,Y) fmod(X,Y) -#define HDfopen(S,M) fopen(S,M) -#define HDfork() fork() -#define HDfpathconf(F,N) fpathconf(F,N) -#define HDfprintf fprintf -#define HDfputc(C,F) fputc(C,F) -#define HDfputs(S,F) fputs(S,F) -#define HDfread(M,Z,N,F) fread(M,Z,N,F) -#define HDfree(M) free(M) -#define HDfreopen(S,M,F) freopen(S,M,F) -#define HDfrexp(X,N) frexp(X,N) +#define HDfloor(X) floor(X) +#define HDfmod(X, Y) fmod(X, Y) +#define HDfopen(S, M) fopen(S, M) +#define HDfork() fork() +#define HDfpathconf(F, N) fpathconf(F, N) +#define HDfprintf fprintf +#define HDfputc(C, F) fputc(C, F) +#define HDfputs(S, F) fputs(S, F) +#define HDfread(M, Z, N, F) fread(M, Z, N, F) +#define HDfree(M) free(M) +#define HDfreopen(S, M, F) freopen(S, M, F) +#define HDfrexp(X, N) frexp(X, N) /* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */ #ifdef H5_HAVE_FREXPF -#define HDfrexpf(X,N) frexpf(X,N) +#define HDfrexpf(X, N) frexpf(X, N) #else /* H5_HAVE_FREXPF */ -#define HDfrexpf(X,N) frexp(X,N) +#define HDfrexpf(X, N) frexp(X, N) #endif /* H5_HAVE_FREXPF */ #ifdef H5_HAVE_FREXPL -#define HDfrexpl(X,N) frexpl(X,N) +#define HDfrexpl(X, N) frexpl(X, N) #else /* H5_HAVE_FREXPL */ -#define HDfrexpl(X,N) frexp(X,N) +#define HDfrexpl(X, N) frexp(X, N) #endif /* H5_HAVE_FREXPL */ /* fscanf() variable arguments */ #ifdef H5_HAVE_FSEEKO - #define HDfseek(F,O,W) fseeko(F,O,W) +#define HDfseek(F, O, W) fseeko(F, O, W) #else - #define HDfseek(F,O,W) fseek(F,O,W) +#define HDfseek(F, O, W) fseek(F, O, W) #endif -#define HDfsetpos(F,P) fsetpos(F,P) +#define HDfsetpos(F, P) fsetpos(F, P) /* definitions related to the file stat utilities. * Windows have its own function names. * For Unix, if off_t is not 64bit big, try use the pseudo-standard * xxx64 versions if available. */ #ifdef H5_HAVE_WIN32_API - #define HDfstat(F,B) _fstati64(F,B) - #define HDlstat(S,B) _lstati64(S,B) - #define HDstat(S,B) _stati64(S,B) - typedef struct _stati64 h5_stat_t; - typedef __int64 h5_stat_size_t; - #define HDoff_t __int64 -#elif H5_SIZEOF_OFF_T!=8 && H5_SIZEOF_OFF64_T==8 && defined(H5_HAVE_STAT64) - #define HDfstat(F,B) fstat64(F,B) - #define HDlstat(S,B) lstat64(S,B) - #define HDstat(S,B) stat64(S,B) - typedef struct stat64 h5_stat_t; - typedef off64_t h5_stat_size_t; - #define HDoff_t off64_t +#define HDfstat(F, B) _fstati64(F, B) +#define HDlstat(S, B) _lstati64(S, B) +#define HDstat(S, B) _stati64(S, B) +typedef struct _stati64 h5_stat_t; +typedef __int64 h5_stat_size_t; +#define HDoff_t __int64 +#elif H5_SIZEOF_OFF_T != 8 && H5_SIZEOF_OFF64_T == 8 && defined(H5_HAVE_STAT64) +#define HDfstat(F, B) fstat64(F, B) +#define HDlstat(S, B) lstat64(S, B) +#define HDstat(S, B) stat64(S, B) +typedef struct stat64 h5_stat_t; +typedef off64_t h5_stat_size_t; +#define HDoff_t off64_t #else - #define HDfstat(F,B) fstat(F,B) - #define HDlstat(S,B) lstat(S,B) - #define HDstat(S,B) stat(S,B) - typedef struct stat h5_stat_t; - typedef off_t h5_stat_size_t; - #define HDoff_t off_t +#define HDfstat(F, B) fstat(F, B) +#define HDlstat(S, B) lstat(S, B) +#define HDstat(S, B) stat(S, B) +typedef struct stat h5_stat_t; +typedef off_t h5_stat_size_t; +#define HDoff_t off_t #endif -#define HDftell(F) ftell(F) -#define HDftruncate(F,L) ftruncate(F,L) -#define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F) -#define HDgetc(F) getc(F) -#define HDgetchar() getchar() -#define HDgetcwd(S,Z) getcwd(S,Z) -#define HDgetegid() getegid() -#define HDgetenv(S) getenv(S) -#define HDgeteuid() geteuid() -#define HDgetgid() getgid() -#define HDgetgrgid(G) getgrgid(G) -#define HDgetgrnam(S) getgrnam(S) -#define HDgetgroups(Z,G) getgroups(Z,G) +#define HDftell(F) ftell(F) +#define HDftruncate(F, L) ftruncate(F, L) +#define HDfwrite(M, Z, N, F) fwrite(M, Z, N, F) +#define HDgetc(F) getc(F) +#define HDgetchar() getchar() +#define HDgetcwd(S, Z) getcwd(S, Z) +#define HDgetegid() getegid() +#define HDgetenv(S) getenv(S) +#define HDgeteuid() geteuid() +#define HDgetgid() getgid() +#define HDgetgrgid(G) getgrgid(G) +#define HDgetgrnam(S) getgrnam(S) +#define HDgetgroups(Z, G) getgroups(Z, G) #ifdef H5_HAVE_WIN32_API -#define HDgetlogin() Wgetlogin() +#define HDgetlogin() Wgetlogin() #else /* H5_HAVE_WIN32_API */ -#define HDgetlogin() getlogin() +#define HDgetlogin() getlogin() #endif /* H5_HAVE_WIN32_API */ -#define HDgetpgrp() getpgrp() -#define HDgetpid() getpid() -#define HDgetppid() getppid() -#define HDgetpwnam(S) getpwnam(S) -#define HDgetpwuid(U) getpwuid(U) -#define HDgetrusage(X,S) getrusage(X,S) +#define HDgetpgrp() getpgrp() +#define HDgetpid() getpid() +#define HDgetppid() getppid() +#define HDgetpwnam(S) getpwnam(S) +#define HDgetpwuid(U) getpwuid(U) +#define HDgetrusage(X, S) getrusage(X, S) /* Don't define a macro for gets() - it was removed in C11 */ #ifdef H5_HAVE_WIN32_API - H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); -#define HDgettimeofday(V,Z) Wgettimeofday(V,Z) +H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); +#define HDgettimeofday(V, Z) Wgettimeofday(V, Z) #else /* H5_HAVE_WIN32_API */ -#define HDgettimeofday(S,P) gettimeofday(S,P) +#define HDgettimeofday(S, P) gettimeofday(S, P) #endif /* H5_HAVE_WIN32_API */ -#define HDgetuid() getuid() -#define HDgmtime(T) gmtime(T) -#define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ -#define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ -#define HDisatty(F) isatty(F) -#define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ -#define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ -#define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ -#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ -#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ -#define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ -#define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ -#define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ -#define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ -#define HDkill(P,S) kill(P,S) -#define HDlabs(X) labs(X) -#define HDldexp(X,N) ldexp(X,N) -#define HDldiv(X,Y) ldiv(X,Y) -#define HDlink(OLD,NEW) link(OLD,NEW) -#define HDlocaleconv() localeconv() -#define HDlocaltime(T) localtime(T) -#define HDlog(X) log(X) -#define HDlog10(X) log10(X) -#define HDlongjmp(J,N) longjmp(J,N) +#define HDgetuid() getuid() +#define HDgmtime(T) gmtime(T) +#define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ +#define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ +#define HDisatty(F) isatty(F) +#define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ +#define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ +#define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ +#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ +#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ +#define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ +#define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ +#define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ +#define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ +#define HDkill(P, S) kill(P, S) +#define HDlabs(X) labs(X) +#define HDldexp(X, N) ldexp(X, N) +#define HDldiv(X, Y) ldiv(X, Y) +#define HDlink(OLD, NEW) link(OLD, NEW) +#define HDlocaleconv() localeconv() +#define HDlocaltime(T) localtime(T) +#define HDlog(X) log(X) +#define HDlog10(X) log10(X) +#define HDlongjmp(J, N) longjmp(J, N) #ifdef H5_HAVE_WIN32_API - #define HDlseek(F,O,W) _lseeki64(F,O,W) +#define HDlseek(F, O, W) _lseeki64(F, O, W) #else - #ifdef H5_HAVE_LSEEK64 - #define HDlseek(F,O,W) lseek64(F,O,W) - #else - #define HDlseek(F,O,W) lseek(F,O,W) - #endif +#ifdef H5_HAVE_LSEEK64 +#define HDlseek(F, O, W) lseek64(F, O, W) +#else +#define HDlseek(F, O, W) lseek(F, O, W) +#endif #endif -#define HDmalloc(Z) malloc(Z) -#define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z) -#define HDmblen(S,N) mblen(S,N) -#define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z) -#define HDmbtowc(P,S,Z) mbtowc(P,S,Z) -#define HDmemchr(S,C,Z) memchr(S,C,Z) -#define HDmemcmp(X,Y,Z) memcmp(X,Y,Z) +#define HDmalloc(Z) malloc(Z) +#define HDposix_memalign(P, A, Z) posix_memalign(P, A, Z) +#define HDmblen(S, N) mblen(S, N) +#define HDmbstowcs(P, S, Z) mbstowcs(P, S, Z) +#define HDmbtowc(P, S, Z) mbtowc(P, S, Z) +#define HDmemchr(S, C, Z) memchr(S, C, Z) +#define HDmemcmp(X, Y, Z) memcmp(X, Y, Z) /* * The (char*) casts are required for the DEC when optimizations are turned * on and the source and/or destination are not aligned. */ -#define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z) -#define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z) +#define HDmemcpy(X, Y, Z) memcpy((char *)(X), (const char *)(Y), Z) +#define HDmemmove(X, Y, Z) memmove((char *)(X), (const char *)(Y), Z) /* * The (void*) cast just avoids a compiler warning in H5_HAVE_VISUAL_STUDIO */ #ifdef H5_HAVE_VISUAL_STUDIO -#define HDmemset(X,C,Z) memset((void*)(X),C,Z) +#define HDmemset(X, C, Z) memset((void *)(X), C, Z) #else /* H5_HAVE_VISUAL_STUDIO */ -#define HDmemset(X,C,Z) memset(X,C,Z) +#define HDmemset(X, C, Z) memset(X, C, Z) #endif /* H5_HAVE_VISUAL_STUDIO */ #ifdef H5_HAVE_WIN32_API -#define HDmkdir(S,M) _mkdir(S) +#define HDmkdir(S, M) _mkdir(S) #else /* H5_HAVE_WIN32_API */ -#define HDmkdir(S,M) mkdir(S,M) +#define HDmkdir(S, M) mkdir(S, M) #endif /* H5_HAVE_WIN32_API */ -#define HDmkfifo(S,M) mkfifo(S,M) -#define HDmktime(T) mktime(T) -#define HDmodf(X,Y) modf(X,Y) +#define HDmkfifo(S, M) mkfifo(S, M) +#define HDmktime(T) mktime(T) +#define HDmodf(X, Y) modf(X, Y) #ifdef _O_BINARY -#define HDopen(S,F,M) open(S,F|_O_BINARY,M) +#define HDopen(S, F, M) open(S, F | _O_BINARY, M) #else -#define HDopen(S,F,M) open(S,F,M) +#define HDopen(S, F, M) open(S, F, M) #endif -#define HDopendir(S) opendir(S) -#define HDpathconf(S,N) pathconf(S,N) -#define HDpause() pause() -#define HDperror(S) perror(S) -#define HDpipe(F) pipe(F) -#define HDpow(X,Y) pow(X,Y) +#define HDopendir(S) opendir(S) +#define HDpathconf(S, N) pathconf(S, N) +#define HDpause() pause() +#define HDperror(S) perror(S) +#define HDpipe(F) pipe(F) +#define HDpow(X, Y) pow(X, Y) /* printf() variable arguments */ -#define HDprintf(...) HDfprintf(stdout, __VA_ARGS__) -#define HDputc(C,F) putc(C,F) -#define HDputchar(C) putchar(C) -#define HDputs(S) puts(S) -#define HDqsort(M,N,Z,F) qsort(M,N,Z,F) -#define HDraise(N) raise(N) +#define HDprintf(...) HDfprintf(stdout, __VA_ARGS__) +#define HDputc(C, F) putc(C, F) +#define HDputchar(C) putchar(C) +#define HDputs(S) puts(S) +#define HDqsort(M, N, Z, F) qsort(M, N, Z, F) +#define HDraise(N) raise(N) #ifdef H5_HAVE_RAND_R -#define HDrandom() HDrand() +#define HDrandom() HDrand() H5_DLL int HDrand(void); #elif H5_HAVE_RANDOM -#define HDrand() random() -#define HDrandom() random() +#define HDrand() random() +#define HDrandom() random() #else -#define HDrand() rand() -#define HDrandom() rand() +#define HDrand() rand() +#define HDrandom() rand() #endif -#define HDread(F,M,Z) read(F,M,Z) -#define HDreaddir(D) readdir(D) -#define HDrealloc(M,Z) realloc(M,Z) -#define HDremove(S) remove(S) -#define HDrename(OLD,NEW) rename(OLD,NEW) -#define HDrewind(F) rewind(F) -#define HDrewinddir(D) rewinddir(D) -#define HDrmdir(S) rmdir(S) +#define HDread(F, M, Z) read(F, M, Z) +#define HDreaddir(D) readdir(D) +#define HDrealloc(M, Z) realloc(M, Z) +#define HDremove(S) remove(S) +#define HDrename(OLD, NEW) rename(OLD, NEW) +#define HDrewind(F) rewind(F) +#define HDrewinddir(D) rewinddir(D) +#define HDrmdir(S) rmdir(S) /* scanf() variable arguments */ -#define HDsetbuf(F,S) setbuf(F,S) -#define HDsetgid(G) setgid(G) -#define HDsetjmp(J) setjmp(J) -#define HDsetlocale(N,S) setlocale(N,S) -#define HDsetpgid(P,PG) setpgid(P,PG) -#define HDsetsid() setsid() -#define HDsetuid(U) setuid(U) +#define HDsetbuf(F, S) setbuf(F, S) +#define HDsetgid(G) setgid(G) +#define HDsetjmp(J) setjmp(J) +#define HDsetlocale(N, S) setlocale(N, S) +#define HDsetpgid(P, PG) setpgid(P, PG) +#define HDsetsid() setsid() +#define HDsetuid(U) setuid(U) /* Windows does not permit setting the buffer size to values less than 2. */ #ifndef H5_HAVE_WIN32_API -#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z) +#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, Z) #else -#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2)) +#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, (Z > 1 ? Z : 2)) #endif -#define HDsigaddset(S,N) sigaddset(S,N) -#define HDsigdelset(S,N) sigdelset(S,N) -#define HDsigemptyset(S) sigemptyset(S) -#define HDsigfillset(S) sigfillset(S) -#define HDsigismember(S,N) sigismember(S,N) -#define HDsiglongjmp(J,N) siglongjmp(J,N) -#define HDsignal(N,F) signal(N,F) -#define HDsigpending(S) sigpending(S) -#define HDsigprocmask(H,S,O) sigprocmask(H,S,O) -#define HDsigsetjmp(J,N) sigsetjmp(J,N) -#define HDsigsuspend(S) sigsuspend(S) -#define HDsin(X) sin(X) -#define HDsinh(X) sinh(X) -#define HDsleep(N) sleep(N) +#define HDsigaddset(S, N) sigaddset(S, N) +#define HDsigdelset(S, N) sigdelset(S, N) +#define HDsigemptyset(S) sigemptyset(S) +#define HDsigfillset(S) sigfillset(S) +#define HDsigismember(S, N) sigismember(S, N) +#define HDsiglongjmp(J, N) siglongjmp(J, N) +#define HDsignal(N, F) signal(N, F) +#define HDsigpending(S) sigpending(S) +#define HDsigprocmask(H, S, O) sigprocmask(H, S, O) +#define HDsigsetjmp(J, N) sigsetjmp(J, N) +#define HDsigsuspend(S) sigsuspend(S) +#define HDsin(X) sin(X) +#define HDsinh(X) sinh(X) +#define HDsleep(N) sleep(N) #ifdef H5_HAVE_WIN32_API -H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...); -#define HDsnprintf c99_snprintf /*varargs*/ +H5_DLL int c99_snprintf(char *str, size_t size, const char *format, ...); +#define HDsnprintf c99_snprintf /*varargs*/ #else -#define HDsnprintf snprintf /*varargs*/ +#define HDsnprintf snprintf /*varargs*/ #endif /* sprintf() variable arguments */ -#define HDsprintf sprintf /*varargs*/ -#define HDsqrt(X) sqrt(X) +#define HDsprintf sprintf /*varargs*/ +#define HDsqrt(X) sqrt(X) #ifdef H5_HAVE_RAND_R H5_DLL void HDsrand(unsigned int seed); -#define HDsrandom(S) HDsrand(S) +#define HDsrandom(S) HDsrand(S) #elif H5_HAVE_RANDOM -#define HDsrand(S) srandom(S) -#define HDsrandom(S) srandom(S) +#define HDsrand(S) srandom(S) +#define HDsrandom(S) srandom(S) #else -#define HDsrand(S) srand(S) -#define HDsrandom(S) srand(S) +#define HDsrand(S) srand(S) +#define HDsrandom(S) srand(S) #endif /* sscanf() variable arguments */ #ifdef H5_HAVE_WIN32_API -#define HDstrcasecmp(A,B) _stricmp(A,B) +#define HDstrcasecmp(A, B) _stricmp(A, B) #else -#define HDstrcasecmp(X,Y) strcasecmp(X,Y) +#define HDstrcasecmp(X, Y) strcasecmp(X, Y) #endif -#define HDstrcat(X,Y) strcat(X,Y) -#define HDstrchr(S,C) strchr(S,C) -#define HDstrcmp(X,Y) strcmp(X,Y) -#define HDstrcoll(X,Y) strcoll(X,Y) -#define HDstrcpy(X,Y) strcpy(X,Y) -#define HDstrcspn(X,Y) strcspn(X,Y) -#define HDstrerror(N) strerror(N) -#define HDstrftime(S,Z,F,T) strftime(S,Z,F,T) -#define HDstrlen(S) strlen(S) -#define HDstrncat(X,Y,Z) strncat(X,Y,Z) -#define HDstrncmp(X,Y,Z) strncmp(X,Y,Z) -#define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) -#define HDstrpbrk(X,Y) strpbrk(X,Y) -#define HDstrrchr(S,C) strrchr(S,C) -#define HDstrspn(X,Y) strspn(X,Y) -#define HDstrstr(X,Y) strstr(X,Y) -#define HDstrtod(S,R) strtod(S,R) -#define HDstrtok(X,Y) strtok(X,Y) -#define HDstrtol(S,R,N) strtol(S,R,N) -H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); -#define HDstrtoul(S,R,N) strtoul(S,R,N) +#define HDstrcat(X, Y) strcat(X, Y) +#define HDstrchr(S, C) strchr(S, C) +#define HDstrcmp(X, Y) strcmp(X, Y) +#define HDstrcoll(X, Y) strcoll(X, Y) +#define HDstrcpy(X, Y) strcpy(X, Y) +#define HDstrcspn(X, Y) strcspn(X, Y) +#define HDstrerror(N) strerror(N) +#define HDstrftime(S, Z, F, T) strftime(S, Z, F, T) +#define HDstrlen(S) strlen(S) +#define HDstrncat(X, Y, Z) strncat(X, Y, Z) +#define HDstrncmp(X, Y, Z) strncmp(X, Y, Z) +#define HDstrncpy(X, Y, Z) strncpy(X, Y, Z) +#define HDstrpbrk(X, Y) strpbrk(X, Y) +#define HDstrrchr(S, C) strrchr(S, C) +#define HDstrspn(X, Y) strspn(X, Y) +#define HDstrstr(X, Y) strstr(X, Y) +#define HDstrtod(S, R) strtod(S, R) +#define HDstrtok(X, Y) strtok(X, Y) +#define HDstrtol(S, R, N) strtol(S, R, N) +H5_DLL int64_t HDstrtoll(const char *s, const char **rest, int base); +#define HDstrtoul(S, R, N) strtoul(S, R, N) #ifdef H5_HAVE_WIN32_API -#define HDstrtoull(S,R,N) _strtoui64(S,R,N) +#define HDstrtoull(S, R, N) _strtoui64(S, R, N) #else -#define HDstrtoull(S,R,N) strtoull(S,R,N) +#define HDstrtoull(S, R, N) strtoull(S, R, N) #endif -#define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z) -#define HDsysconf(N) sysconf(N) -#define HDsystem(S) system(S) -#define HDtan(X) tan(X) -#define HDtanh(X) tanh(X) -#define HDtcdrain(F) tcdrain(F) -#define HDtcflow(F,A) tcflow(F,A) -#define HDtcflush(F,N) tcflush(F,N) -#define HDtcgetattr(F,T) tcgetattr(F,T) -#define HDtcgetpgrp(F) tcgetpgrp(F) -#define HDtcsendbreak(F,N) tcsendbreak(F,N) -#define HDtcsetattr(F,O,T) tcsetattr(F,O,T) -#define HDtcsetpgrp(F,N) tcsetpgrp(F,N) -#define HDtime(T) time(T) -#define HDtimes(T) times(T) -#define HDtmpfile() tmpfile() -#define HDtmpnam(S) tmpnam(S) -#define HDtolower(C) tolower(C) -#define HDtoupper(C) toupper(C) -#define HDttyname(F) ttyname(F) -#define HDtzset() tzset() -#define HDumask(N) umask(N) -#define HDuname(S) uname(S) -#define HDungetc(C,F) ungetc(C,F) +#define HDstrxfrm(X, Y, Z) strxfrm(X, Y, Z) +#define HDsysconf(N) sysconf(N) +#define HDsystem(S) system(S) +#define HDtan(X) tan(X) +#define HDtanh(X) tanh(X) +#define HDtcdrain(F) tcdrain(F) +#define HDtcflow(F, A) tcflow(F, A) +#define HDtcflush(F, N) tcflush(F, N) +#define HDtcgetattr(F, T) tcgetattr(F, T) +#define HDtcgetpgrp(F) tcgetpgrp(F) +#define HDtcsendbreak(F, N) tcsendbreak(F, N) +#define HDtcsetattr(F, O, T) tcsetattr(F, O, T) +#define HDtcsetpgrp(F, N) tcsetpgrp(F, N) +#define HDtime(T) time(T) +#define HDtimes(T) times(T) +#define HDtmpfile() tmpfile() +#define HDtmpnam(S) tmpnam(S) +#define HDtolower(C) tolower(C) +#define HDtoupper(C) toupper(C) +#define HDttyname(F) ttyname(F) +#define HDtzset() tzset() +#define HDumask(N) umask(N) +#define HDuname(S) uname(S) +#define HDungetc(C, F) ungetc(C, F) #ifdef H5_HAVE_WIN32_API -#define HDunlink(S) _unlink(S) +#define HDunlink(S) _unlink(S) #else -#define HDunlink(S) unlink(S) +#define HDunlink(S) unlink(S) #endif -#define HDutime(S,T) utime(S,T) -#define HDva_arg(A,T) va_arg(A,T) -#define HDva_end(A) va_end(A) -#define HDva_start(A,P) va_start(A,P) -#define HDvasprintf(RET,FMT,A) vasprintf(RET,FMT,A) -#define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A) -#define HDvprintf(FMT,A) vprintf(FMT,A) -#define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A) +#define HDutime(S, T) utime(S, T) +#define HDva_arg(A, T) va_arg(A, T) +#define HDva_end(A) va_end(A) +#define HDva_start(A, P) va_start(A, P) +#define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A) +#define HDvfprintf(F, FMT, A) vfprintf(F, FMT, A) +#define HDvprintf(FMT, A) vprintf(FMT, A) +#define HDvsprintf(S, FMT, A) vsprintf(S, FMT, A) #ifdef H5_HAVE_WIN32_API -H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap); -#define HDvsnprintf c99_vsnprintf +H5_DLL int c99_vsnprintf(char *str, size_t size, const char *format, va_list ap); +#define HDvsnprintf c99_vsnprintf #else -# define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A) +#define HDvsnprintf(S, N, FMT, A) vsnprintf(S, N, FMT, A) #endif -#define HDwait(W) wait(W) -#define HDwaitpid(P,W,O) waitpid(P,W,O) -#define HDwcstombs(S,P,Z) wcstombs(S,P,Z) -#define HDwctomb(S,C) wctomb(S,C) -#define HDwrite(F,M,Z) write(F,M,Z) +#define HDwait(W) wait(W) +#define HDwaitpid(P, W, O) waitpid(P, W, O) +#define HDwcstombs(S, P, Z) wcstombs(S, P, Z) +#define HDwctomb(S, C) wctomb(S, C) +#define HDwrite(F, M, Z) write(F, M, Z) /* * And now for a couple non-Posix functions... Watch out for systems that * define these in terms of macros. */ #ifdef H5_HAVE_WIN32_API -#define HDstrdup(S) _strdup(S) +#define HDstrdup(S) _strdup(S) #else /* H5_HAVE_WIN32_API */ #if !defined strdup && !defined H5_HAVE_STRDUP -extern char *strdup(const char *s); +extern char * strdup(const char *s); #endif -#define HDstrdup(S) strdup(S) +#define HDstrdup(S) strdup(S) #endif /* H5_HAVE_WIN32_API */ @@ -470,52 +469,47 @@ extern char *strdup(const char *s); * HDF Boolean type. */ #ifndef FALSE -# define FALSE false +#define FALSE false #endif #ifndef TRUE -# define TRUE true +#define TRUE true #endif /** From h5test.h **/ #ifdef H5_HAVE_PARALLEL -extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ +extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ #endif #ifdef H5_HAVE_PARALLEL -int h5_set_info_object(void); +int h5_set_info_object(void); void h5_dump_info_object(MPI_Info info); #endif - - /** From h5tools_utils.h **/ -extern int opt_err; /* getoption prints errors if this is on */ -extern int opt_ind; /* token pointer */ -extern const char *opt_arg; /* flag argument (or value) */ - +extern int opt_err; /* getoption prints errors if this is on */ +extern int opt_ind; /* token pointer */ +extern const char *opt_arg; /* flag argument (or value) */ enum { - no_arg = 0, /* doesn't take an argument */ - require_arg, /* requires an argument */ - optional_arg /* argument is optional */ + no_arg = 0, /* doesn't take an argument */ + require_arg, /* requires an argument */ + optional_arg /* argument is optional */ }; - typedef struct long_options { - const char *name; /* name of the long option */ - int has_arg; /* whether we should look for an arg */ - char shortval; /* the shortname equivalent of long arg - * this gets returned from get_option */ + const char *name; /* name of the long option */ + int has_arg; /* whether we should look for an arg */ + char shortval; /* the shortname equivalent of long arg + * this gets returned from get_option */ } long_options; -extern int get_option(int argc, const char **argv, const char *opt, - const struct long_options *l_opt); +extern int get_option(int argc, const char **argv, const char *opt, const struct long_options *l_opt); -extern int nCols; /*max number of columns for outputting */ +extern int nCols; /*max number of columns for outputting */ /* Definitions of useful routines */ -extern void print_version(const char *progname); +extern void print_version(const char *progname); #endif diff --git a/tools/test/perform/sio_engine.c b/tools/test/perform/sio_engine.c index 2e61e74..11001c6 100644 --- a/tools/test/perform/sio_engine.c +++ b/tools/test/perform/sio_engine.c @@ -37,88 +37,88 @@ /* Macro definitions */ /* sizes of various items. these sizes won't change during program execution */ -#define ELMT_H5_TYPE H5T_NATIVE_UCHAR +#define ELMT_H5_TYPE H5T_NATIVE_UCHAR -#define GOTOERROR(errcode) { ret_code = errcode; goto done; } -#define ERRMSG(mesg) { \ - HDfprintf(stderr, "*** Assertion failed (%s) at line %4d in %s\n", \ - mesg, (int)__LINE__, __FILE__); \ -} +#define GOTOERROR(errcode) \ + { \ + ret_code = errcode; \ + goto done; \ + } +#define ERRMSG(mesg) \ + { \ + HDfprintf(stderr, "*** Assertion failed (%s) at line %4d in %s\n", mesg, (int)__LINE__, __FILE__); \ + } /* verify: if val is false (0), print mesg. */ -#define VRFY(val, mesg) do { \ - if (!val) { \ - ERRMSG(mesg); \ - GOTOERROR(FAIL); \ - } \ -} while(0) +#define VRFY(val, mesg) \ + do { \ + if (!val) { \ + ERRMSG(mesg); \ + GOTOERROR(FAIL); \ + } \ + } while (0) /* POSIX I/O macros */ #ifdef H5_HAVE_WIN32_API /* Can't link against the library, so this test will use the older, non-Unicode * _open() call on Windows. */ -#define HDopen(S,F,...) _open(S, F | _O_BINARY, __VA_ARGS__) +#define HDopen(S, F, ...) _open(S, F | _O_BINARY, __VA_ARGS__) #endif /* H5_HAVE_WIN32_API */ -#define POSIXCREATE(fn) HDopen(fn, O_CREAT|O_TRUNC|O_RDWR, 0600) -#define POSIXOPEN(fn, F) HDopen(fn, F, 0600) -#define POSIXCLOSE(F) HDclose(F) -#define POSIXSEEK(F,L) HDlseek(F, L, SEEK_SET) -#define POSIXWRITE(F,B,S) HDwrite(F,B,S) -#define POSIXREAD(F,B,S) HDread(F,B,S) - -enum { - SIO_CREATE = 1, - SIO_WRITE = 2, - SIO_READ = 4 -}; +#define POSIXCREATE(fn) HDopen(fn, O_CREAT | O_TRUNC | O_RDWR, 0600) +#define POSIXOPEN(fn, F) HDopen(fn, F, 0600) +#define POSIXCLOSE(F) HDclose(F) +#define POSIXSEEK(F, L) HDlseek(F, L, SEEK_SET) +#define POSIXWRITE(F, B, S) HDwrite(F, B, S) +#define POSIXREAD(F, B, S) HDread(F, B, S) + +enum { SIO_CREATE = 1, SIO_WRITE = 2, SIO_READ = 4 }; /* Global variables */ -static int clean_file_g = -1; /*whether to cleanup temporary test */ +static int clean_file_g = -1; /*whether to cleanup temporary test */ /*files. -1 is not defined; */ /*0 is no cleanup; 1 is do cleanup */ /* the different types of file descriptors we can expect */ typedef union _file_descr { - int posixfd; /* POSIX file handle*/ - hid_t h5fd; /* HDF5 file */ + int posixfd; /* POSIX file handle*/ + hid_t h5fd; /* HDF5 file */ } file_descr; /* local functions */ -static char *sio_create_filename(iotype iot, const char *base_name, - char *fullname, size_t size, parameters *param); +static char * sio_create_filename(iotype iot, const char *base_name, char *fullname, size_t size, + parameters *param); static herr_t do_write(results *res, file_descr *fd, parameters *parms, void *buffer); static herr_t do_read(results *res, file_descr *fd, parameters *parms, void *buffer); static herr_t dset_write(int local_dim, file_descr *fd, parameters *parms, void *buffer); static herr_t posix_buffer_write(int local_dim, file_descr *fd, parameters *parms, void *buffer); static herr_t dset_read(int localrank, file_descr *fd, parameters *parms, void *buffer, const char *buffer2); static herr_t posix_buffer_read(int local_dim, file_descr *fd, parameters *parms, void *buffer); -static herr_t do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, - int flags); -hid_t set_vfd(parameters *param); +static herr_t do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags); +hid_t set_vfd(parameters *param); static herr_t do_fclose(iotype iot, file_descr *fd); -static void do_cleanupfile(iotype iot, char *fname); +static void do_cleanupfile(iotype iot, char *fname); /* global variables */ -static HDoff_t offset[MAX_DIMS]; /* dataset size in bytes */ -static size_t buf_offset[MAX_DIMS]; /* dataset size in bytes */ -static int order[MAX_DIMS]; /* dimension access order */ -static size_t linear_buf_size; /* linear buffer size */ -static int cont_dim; /* lowest dimension for contiguous POSIX - access */ -static size_t cont_size; /* size of contiguous POSIX access */ -static hid_t fapl; /* file access list */ -static unsigned char *buf_p; /* buffer pointer */ -static const char *multi_letters = "msbrglo"; /* string for multi driver */ +static HDoff_t offset[MAX_DIMS]; /* dataset size in bytes */ +static size_t buf_offset[MAX_DIMS]; /* dataset size in bytes */ +static int order[MAX_DIMS]; /* dimension access order */ +static size_t linear_buf_size; /* linear buffer size */ +static int cont_dim; /* lowest dimension for contiguous POSIX + access */ +static size_t cont_size; /* size of contiguous POSIX access */ +static hid_t fapl; /* file access list */ +static unsigned char *buf_p; /* buffer pointer */ +static const char * multi_letters = "msbrglo"; /* string for multi driver */ /* HDF5 global variables */ -static hsize_t h5count[MAX_DIMS]; /*selection count */ -static hssize_t h5offset[MAX_DIMS]; /* Selection offset within dataspace */ -static hid_t h5dset_space_id = H5I_INVALID_HID; /*dataset space ID */ -static hid_t h5mem_space_id = H5I_INVALID_HID; /*memory dataspace ID */ -static hid_t h5ds_id = H5I_INVALID_HID; /*dataset handle */ -static hid_t h5dcpl = H5I_INVALID_HID; /* Dataset creation property list */ -static hid_t h5dxpl = H5I_INVALID_HID; /* Dataset transfer property list */ +static hsize_t h5count[MAX_DIMS]; /*selection count */ +static hssize_t h5offset[MAX_DIMS]; /* Selection offset within dataspace */ +static hid_t h5dset_space_id = H5I_INVALID_HID; /*dataset space ID */ +static hid_t h5mem_space_id = H5I_INVALID_HID; /*memory dataspace ID */ +static hid_t h5ds_id = H5I_INVALID_HID; /*dataset handle */ +static hid_t h5dcpl = H5I_INVALID_HID; /* Dataset creation property list */ +static hid_t h5dxpl = H5I_INVALID_HID; /* Dataset transfer property list */ /* * Function: do_sio @@ -130,18 +130,18 @@ static hid_t h5dxpl = H5I_INVALID_HID; /* Dataset transfer prop void do_sio(parameters param, results *res) { - char *buffer = NULL; /*data buffer pointer */ - size_t buf_size[MAX_DIMS]; /* general buffer size in bytes */ - file_descr fd; /* file handles */ - iotype iot; /* API type */ - char base_name[256]; /* test file base name */ + char * buffer = NULL; /*data buffer pointer */ + size_t buf_size[MAX_DIMS]; /* general buffer size in bytes */ + file_descr fd; /* file handles */ + iotype iot; /* API type */ + char base_name[256]; /* test file base name */ /* return codes */ - herr_t ret_code = 0; /*return code */ + herr_t ret_code = 0; /*return code */ - char fname[FILENAME_MAX]; /* test file name */ - int i; + char fname[FILENAME_MAX]; /* test file name */ + int i; /* HDF5 variables */ - herr_t hrc; /*HDF5 return code */ + herr_t hrc; /*HDF5 return code */ /* Sanity check parameters */ @@ -149,55 +149,53 @@ do_sio(parameters param, results *res) iot = param.io_type; switch (iot) { - case POSIXIO: - fd.posixfd = -1; - res->timers = io_time_new(SYS_CLOCK); - break; - case HDF5: - fd.h5fd = -1; - res->timers = io_time_new(SYS_CLOCK); - break; - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot); - GOTOERROR(FAIL); + case POSIXIO: + fd.posixfd = -1; + res->timers = io_time_new(SYS_CLOCK); + break; + case HDF5: + fd.h5fd = -1; + res->timers = io_time_new(SYS_CLOCK); + break; + default: + /* unknown request */ + HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot); + GOTOERROR(FAIL); } linear_buf_size = 1; - for (i=0; i<param.rank; i++){ + for (i = 0; i < param.rank; i++) { buf_size[i] = param.buf_size[i]; - order[i] = param.order[i]; + order[i] = param.order[i]; linear_buf_size *= buf_size[i]; buf_offset[i] = 0; - offset[i] = 0; + offset[i] = 0; /* Validate transfer buffer size */ - if (param.buf_size[i]<=0) { - HDfprintf(stderr, - "Transfer buffer size[%d] (%zu) must be > 0\n", i,buf_size[i]); + if (param.buf_size[i] <= 0) { + HDfprintf(stderr, "Transfer buffer size[%d] (%zu) must be > 0\n", i, buf_size[i]); GOTOERROR(FAIL); } - if ((param.dset_size[i]%param.buf_size[i])!=0) { + if ((param.dset_size[i] % param.buf_size[i]) != 0) { HDfprintf(stderr, - "Dataset size[%d] (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " - "trasfer buffer size[%d] (%zu)\n",param.rank, - (long long)param.dset_size[i], param.rank, param.buf_size[i]); + "Dataset size[%d] (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " + "trasfer buffer size[%d] (%zu)\n", + param.rank, (long long)param.dset_size[i], param.rank, param.buf_size[i]); GOTOERROR(FAIL); } - } /* Allocate transfer buffer */ - if ((buffer = (char *)malloc(linear_buf_size)) == NULL){ + if ((buffer = (char *)malloc(linear_buf_size)) == NULL) { HDfprintf(stderr, "malloc for transfer buffer size (%zu) failed\n", linear_buf_size); GOTOERROR(FAIL); } if (sio_debug_level >= 4) - /* output all of the times for all iterations */ + /* output all of the times for all iterations */ HDfprintf(output, "Timer details:\n"); /* @@ -209,8 +207,7 @@ do_sio(parameters param, results *res) sio_create_filename(iot, base_name, fname, sizeof(fname), ¶m); if (sio_debug_level > 0) - HDfprintf(output, "data filename=%s\n", - fname); + HDfprintf(output, "data filename=%s\n", fname); io_time_set(res->timers, HDF5_GROSS_WRITE_FIXED_DIMS, TSTART); hrc = do_fopen(¶m, fname, &fd, SIO_CREATE | SIO_WRITE); @@ -288,36 +285,36 @@ done: * Programmer: Bill Wendling, 21. November 2001 * Modifications: Support for file drivers. Christian Chilan, April, 2008 */ - static char * +static char * sio_create_filename(iotype iot, const char *base_name, char *fullname, size_t size, parameters *param) { - const char *prefix, *suffix=""; - char *ptr, last = '\0'; - size_t i, j; - vfdtype vfd; + const char *prefix, *suffix = ""; + char * ptr, last = '\0'; + size_t i, j; + vfdtype vfd; vfd = param->vfd; if (!base_name || !fullname || size < 1) - return NULL; + return NULL; memset(fullname, 0, size); switch (iot) { - case POSIXIO: - suffix = ".posix"; - break; - case HDF5: - suffix = ".h5"; - if (vfd == family) - suffix = "%05d.h5"; - else if (vfd == multi) - suffix = NULL; - break; - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot); - HDassert(0 && "Unknown IO type"); - break; + case POSIXIO: + suffix = ".posix"; + break; + case HDF5: + suffix = ".h5"; + if (vfd == family) + suffix = "%05d.h5"; + else if (vfd == multi) + suffix = NULL; + break; + default: + /* unknown request */ + HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot); + HDassert(0 && "Unknown IO type"); + break; } /* First use the environment variable and then try the constant */ @@ -325,57 +322,61 @@ sio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si #ifdef HDF5_PREFIX if (!prefix) - prefix = HDF5_PREFIX; -#endif /* HDF5_PREFIX */ + prefix = HDF5_PREFIX; +#endif /* HDF5_PREFIX */ /* Prepend the prefix value to the base name */ if (prefix && *prefix) { - /* If the prefix specifies the HDF5_PREFIX directory, then - * default to using the "/tmp/$USER" or "/tmp/$LOGIN" - * directory instead. */ - register char *user, *login, *subdir; - - user = HDgetenv("USER"); - login = HDgetenv("LOGIN"); - subdir = (user ? user : login); - - if (subdir) { - for (i = 0; i < size-1 && prefix[i]; i++) - fullname[i] = prefix[i]; - - fullname[i++] = '/'; - - for (j = 0; i < size && subdir[j]; i++, j++) - fullname[i] = subdir[j]; - } else { - /* We didn't append the prefix yet */ - HDstrncpy(fullname, prefix, size); - fullname[size - 1] = '\0'; - } + /* If the prefix specifies the HDF5_PREFIX directory, then + * default to using the "/tmp/$USER" or "/tmp/$LOGIN" + * directory instead. */ + register char *user, *login, *subdir; - if ((HDstrlen(fullname) + HDstrlen(base_name) + 1) < size) { - /* Append the base_name with a slash first. Multiple slashes are - * handled below. */ - h5_stat_t buf; - - if (HDstat(fullname, &buf) < 0) - /* The directory doesn't exist just yet */ - if (HDmkdir(fullname, 0755) < 0 && errno != EEXIST) { - /* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory. - * Default to PREFIX's original prefix value. */ - HDstrcpy(fullname, prefix); + user = HDgetenv("USER"); + login = HDgetenv("LOGIN"); + subdir = (user ? user : login); + + if (subdir) { + for (i = 0; i < size - 1 && prefix[i]; i++) + fullname[i] = prefix[i]; + + fullname[i++] = '/'; + + for (j = 0; i < size && subdir[j]; i++, j++) + fullname[i] = subdir[j]; + } + else { + /* We didn't append the prefix yet */ + HDstrncpy(fullname, prefix, size); + fullname[size - 1] = '\0'; } - HDstrcat(fullname, "/"); - HDstrcat(fullname, base_name); - } else { + if ((HDstrlen(fullname) + HDstrlen(base_name) + 1) < size) { + /* Append the base_name with a slash first. Multiple slashes are + * handled below. */ + h5_stat_t buf; + + if (HDstat(fullname, &buf) < 0) + /* The directory doesn't exist just yet */ + if (HDmkdir(fullname, 0755) < 0 && errno != EEXIST) { + /* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory. + * Default to PREFIX's original prefix value. */ + HDstrcpy(fullname, prefix); + } + + HDstrcat(fullname, "/"); + HDstrcat(fullname, base_name); + } + else { + /* Buffer is too small */ + return NULL; + } + } + else if (strlen(base_name) >= size) { /* Buffer is too small */ return NULL; } - } else if (strlen(base_name) >= size) { - /* Buffer is too small */ - return NULL; - } else { + else { HDstrcpy(fullname, base_name); } @@ -408,159 +409,155 @@ sio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si static herr_t do_write(results *res, file_descr *fd, parameters *parms, void *buffer) { - int ret_code = SUCCESS; - char dname[64]; - int i; - size_t u; + int ret_code = SUCCESS; + char dname[64]; + int i; + size_t u; /* HDF5 variables */ - herr_t hrc; /*HDF5 return code */ - hsize_t h5dims[MAX_DIMS]; /*dataset dim sizes */ - hsize_t h5chunk[MAX_DIMS]; /*dataset dim sizes */ - hsize_t h5block[MAX_DIMS]; /*dataspace selection */ - hsize_t h5stride[MAX_DIMS]; /*selection stride */ - hsize_t h5start[MAX_DIMS]; /*selection start */ - hsize_t h5maxdims[MAX_DIMS]; - int rank; /*rank of dataset */ + herr_t hrc; /*HDF5 return code */ + hsize_t h5dims[MAX_DIMS]; /*dataset dim sizes */ + hsize_t h5chunk[MAX_DIMS]; /*dataset dim sizes */ + hsize_t h5block[MAX_DIMS]; /*dataspace selection */ + hsize_t h5stride[MAX_DIMS]; /*selection stride */ + hsize_t h5start[MAX_DIMS]; /*selection start */ + hsize_t h5maxdims[MAX_DIMS]; + int rank; /*rank of dataset */ /* Prepare buffer for verifying data */ -/* if (parms->verify) - memset(buffer,1,linear_buf_size); */ + /* if (parms->verify) + memset(buffer,1,linear_buf_size); */ - buf_p=(unsigned char *)buffer; + buf_p = (unsigned char *)buffer; - for(u = 0; u < linear_buf_size; u++) + for (u = 0; u < linear_buf_size; u++) buf_p[u] = u % 128; rank = parms->rank; - for(i = 0; i < rank; i++) + for (i = 0; i < rank; i++) h5offset[i] = offset[i] = 0; /* I/O Access specific setup */ switch (parms->io_type) { - case POSIXIO: + case POSIXIO: /* determine lowest dimension for contiguous POSIX access */ cont_dim = rank; - for (i=rank-1; i>=0; i--) { - if (parms->buf_size[i]==parms->dset_size[i]) + for (i = rank - 1; i >= 0; i--) { + if (parms->buf_size[i] == parms->dset_size[i]) cont_dim = i; else break; } /* determine size of the contiguous POSIX access */ - cont_size = (!cont_dim)? 1 : parms->buf_size[cont_dim-1]; - for (i=cont_dim; i<rank; i++) + cont_size = (!cont_dim) ? 1 : parms->buf_size[cont_dim - 1]; + for (i = cont_dim; i < rank; i++) cont_size *= parms->buf_size[i]; - break; - - case HDF5: /* HDF5 setup */ + break; - for (i=0; i < rank; i++){ - h5dims[i] = parms->dset_size[i]; - h5start[i] = 0; - h5stride[i] = 1; - h5block[i] = 1; - h5count[i] = parms->buf_size[i]; - h5chunk[i] = parms->chk_size[i]; - h5maxdims[i] = H5S_UNLIMITED; + case HDF5: /* HDF5 setup */ - } + for (i = 0; i < rank; i++) { + h5dims[i] = parms->dset_size[i]; + h5start[i] = 0; + h5stride[i] = 1; + h5block[i] = 1; + h5count[i] = parms->buf_size[i]; + h5chunk[i] = parms->chk_size[i]; + h5maxdims[i] = H5S_UNLIMITED; + } - if (parms->h5_use_chunks && parms->h5_extendable) { - h5dset_space_id = H5Screate_simple(rank, h5count, h5maxdims); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - } - else { - h5dset_space_id = H5Screate_simple(rank, h5dims, NULL); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - } + if (parms->h5_use_chunks && parms->h5_extendable) { + h5dset_space_id = H5Screate_simple(rank, h5count, h5maxdims); + VRFY((h5dset_space_id >= 0), "H5Screate_simple"); + } + else { + h5dset_space_id = H5Screate_simple(rank, h5dims, NULL); + VRFY((h5dset_space_id >= 0), "H5Screate_simple"); + } - hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, - h5start, h5stride, h5count, h5block); - VRFY((hrc >= 0), "H5Sselect_hyperslab"); + hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, h5start, h5stride, h5count, h5block); + VRFY((hrc >= 0), "H5Sselect_hyperslab"); - /* Create the memory dataspace that corresponds to the xfer buffer */ - h5mem_space_id = H5Screate_simple(rank, h5count, NULL); - VRFY((h5mem_space_id >= 0), "H5Screate_simple"); + /* Create the memory dataspace that corresponds to the xfer buffer */ + h5mem_space_id = H5Screate_simple(rank, h5count, NULL); + VRFY((h5mem_space_id >= 0), "H5Screate_simple"); - /* Create the dataset transfer property list */ - h5dxpl = H5Pcreate(H5P_DATASET_XFER); - if (h5dxpl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } + /* Create the dataset transfer property list */ + h5dxpl = H5Pcreate(H5P_DATASET_XFER); + if (h5dxpl < 0) { + HDfprintf(stderr, "HDF5 Property List Create failed\n"); + GOTOERROR(FAIL); + } - break; + break; - default: - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); - GOTOERROR(FAIL); - break; + default: + HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); + GOTOERROR(FAIL); + break; } /* end switch */ - /* create dataset */ switch (parms->io_type) { case POSIXIO: - break; + break; case HDF5: h5dcpl = H5Pcreate(H5P_DATASET_CREATE); - if (h5dcpl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } - - if(parms->h5_use_chunks) { - /* Set the chunk size to be the same as the buffer size */ - hrc = H5Pset_chunk(h5dcpl, rank, h5chunk); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Set failed\n"); + if (h5dcpl < 0) { + HDfprintf(stderr, "HDF5 Property List Create failed\n"); GOTOERROR(FAIL); - } /* end if */ - } /* end if */ - - HDsprintf(dname, "Dataset_%ld", (unsigned long)parms->num_bytes); - h5ds_id = H5Dcreate2(fd->h5fd, dname, ELMT_H5_TYPE, - h5dset_space_id, H5P_DEFAULT, h5dcpl, H5P_DEFAULT); + } - if (h5ds_id < 0) { - HDfprintf(stderr, "HDF5 Dataset Create failed\n"); - GOTOERROR(FAIL); - } + if (parms->h5_use_chunks) { + /* Set the chunk size to be the same as the buffer size */ + hrc = H5Pset_chunk(h5dcpl, rank, h5chunk); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Property List Set failed\n"); + GOTOERROR(FAIL); + } /* end if */ + } /* end if */ + + HDsprintf(dname, "Dataset_%ld", (unsigned long)parms->num_bytes); + h5ds_id = + H5Dcreate2(fd->h5fd, dname, ELMT_H5_TYPE, h5dset_space_id, H5P_DEFAULT, h5dcpl, H5P_DEFAULT); + + if (h5ds_id < 0) { + HDfprintf(stderr, "HDF5 Dataset Create failed\n"); + GOTOERROR(FAIL); + } - hrc = H5Pclose(h5dcpl); - /* verifying the close of the dcpl */ - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Property List Close failed\n"); - GOTOERROR(FAIL); - } - break; + hrc = H5Pclose(h5dcpl); + /* verifying the close of the dcpl */ + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Property List Close failed\n"); + GOTOERROR(FAIL); + } + break; default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); - GOTOERROR(FAIL); - break; + /* unknown request */ + HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); + GOTOERROR(FAIL); + break; } /* Start "raw data" write timer */ io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTART); /* Perform write */ - hrc = dset_write(rank-1, fd, parms, buffer); + hrc = dset_write(rank - 1, fd, parms, buffer); if (hrc < 0) { HDfprintf(stderr, "Error in dataset write\n"); GOTOERROR(FAIL); } - /* Stop "raw data" write timer */ io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTOP); @@ -583,10 +580,11 @@ done: /* release HDF5 objects */ if (h5dset_space_id != -1) { hrc = H5Sclose(h5dset_space_id); - if (hrc < 0){ + if (hrc < 0) { HDfprintf(stderr, "HDF5 Dataset Space Close failed\n"); ret_code = FAIL; - } else { + } + else { h5dset_space_id = H5I_INVALID_HID; } } @@ -596,7 +594,8 @@ done: if (hrc < 0) { HDfprintf(stderr, "HDF5 Memory Space Close failed\n"); ret_code = FAIL; - } else { + } + else { h5mem_space_id = H5I_INVALID_HID; } } @@ -606,7 +605,8 @@ done: if (hrc < 0) { HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n"); ret_code = FAIL; - } else { + } + else { h5dxpl = H5I_INVALID_HID; } } @@ -624,73 +624,72 @@ done: static herr_t dset_write(int local_dim, file_descr *fd, parameters *parms, void *buffer) { - int cur_dim = order[local_dim]-1; - int ret_code = SUCCESS; - int k; - hsize_t dims[MAX_DIMS], maxdims[MAX_DIMS]; + int cur_dim = order[local_dim] - 1; + int ret_code = SUCCESS; + int k; + hsize_t dims[MAX_DIMS], maxdims[MAX_DIMS]; hsize_t i; - int j; - herr_t hrc; + int j; + herr_t hrc; /* iterates according to the dimensions in order array */ - for (i=0; i < parms->dset_size[cur_dim]; i += parms->buf_size[cur_dim]){ + for (i = 0; i < parms->dset_size[cur_dim]; i += parms->buf_size[cur_dim]) { h5offset[cur_dim] = (hssize_t)i; - offset[cur_dim] = (HDoff_t)i; - - if (local_dim > 0){ + offset[cur_dim] = (HDoff_t)i; - dset_write(local_dim-1, fd, parms, buffer); + if (local_dim > 0) { - }else{ + dset_write(local_dim - 1, fd, parms, buffer); + } + else { switch (parms->io_type) { - case POSIXIO: - /* initialize POSIX offset in the buffer */ - for(j = 0; j < parms->rank; j++) - buf_offset[j] = 0; - buf_p = (unsigned char *)buffer; - /* write POSIX buffer */ - posix_buffer_write(0, fd, parms, buffer); - break; + case POSIXIO: + /* initialize POSIX offset in the buffer */ + for (j = 0; j < parms->rank; j++) + buf_offset[j] = 0; + buf_p = (unsigned char *)buffer; + /* write POSIX buffer */ + posix_buffer_write(0, fd, parms, buffer); + break; - case HDF5: - /* if dimensions are extendable, extend them as needed during access */ - if (parms->h5_use_chunks && parms->h5_extendable) { + case HDF5: + /* if dimensions are extendable, extend them as needed during access */ + if (parms->h5_use_chunks && parms->h5_extendable) { - hrc=H5Sget_simple_extent_dims(h5dset_space_id,dims,maxdims); - VRFY((hrc >= 0), "H5Sget_simple_extent_dims"); + hrc = H5Sget_simple_extent_dims(h5dset_space_id, dims, maxdims); + VRFY((hrc >= 0), "H5Sget_simple_extent_dims"); - for (k=0; k < parms->rank; k++){ + for (k = 0; k < parms->rank; k++) { - HDassert(h5offset[k] >= 0); - if (dims[k] <= (hsize_t)h5offset[k]) { - dims[k] = dims[k]+h5count[k]; - hrc=H5Sset_extent_simple(h5dset_space_id,parms->rank,dims,maxdims); - VRFY((hrc >= 0), "H5Sset_extent_simple"); - hrc=H5Dset_extent(h5ds_id,dims); - VRFY((hrc >= 0), "H5Dextend"); + HDassert(h5offset[k] >= 0); + if (dims[k] <= (hsize_t)h5offset[k]) { + dims[k] = dims[k] + h5count[k]; + hrc = H5Sset_extent_simple(h5dset_space_id, parms->rank, dims, maxdims); + VRFY((hrc >= 0), "H5Sset_extent_simple"); + hrc = H5Dset_extent(h5ds_id, dims); + VRFY((hrc >= 0), "H5Dextend"); + } } } - } - /* applies offset */ - hrc = H5Soffset_simple(h5dset_space_id, h5offset); - VRFY((hrc >= 0), "H5Soffset_simple"); + /* applies offset */ + hrc = H5Soffset_simple(h5dset_space_id, h5offset); + VRFY((hrc >= 0), "H5Soffset_simple"); - /* Write the buffer out */ - hrc=H5Sget_simple_extent_dims(h5dset_space_id,dims,maxdims); - hrc = H5Dwrite(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, - h5dset_space_id, h5dxpl, buffer); - VRFY((hrc >= 0), "H5Dwrite"); + /* Write the buffer out */ + hrc = H5Sget_simple_extent_dims(h5dset_space_id, dims, maxdims); + hrc = H5Dwrite(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, h5dset_space_id, h5dxpl, buffer); + VRFY((hrc >= 0), "H5Dwrite"); - break; + break; - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); - HDassert(0 && "Unknown IO type"); - break; + default: + /* unknown request */ + HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); + HDassert(0 && "Unknown IO type"); + break; } /* switch (parms->io_type) */ } } @@ -709,35 +708,36 @@ done: static herr_t posix_buffer_write(int local_dim, file_descr *fd, parameters *parms, void *buffer) { - int ret_code = SUCCESS; + int ret_code = SUCCESS; /* if dimension is not contiguous, call recursively */ - if (local_dim < parms->rank-1 && local_dim != cont_dim) { + if (local_dim < parms->rank - 1 && local_dim != cont_dim) { size_t u; - for(u = 0; u < parms->buf_size[local_dim]; u ++) { + for (u = 0; u < parms->buf_size[local_dim]; u++) { buf_offset[local_dim] = u; - posix_buffer_write(local_dim+1, fd, parms, buffer); + posix_buffer_write(local_dim + 1, fd, parms, buffer); /* if next dimension is cont_dim, it will fill out the buffer traversing the entire dimension local_dim without the need of performing iteration */ - if (local_dim+1==cont_dim) + if (local_dim + 1 == cont_dim) break; } - /* otherwise, perform contiguous POSIX access */ - } else { + /* otherwise, perform contiguous POSIX access */ + } + else { HDoff_t d_offset; HDoff_t linear_dset_offset = 0; - int i, j, rc; + int i, j, rc; buf_offset[local_dim] = 0; /* determine offset in the buffer */ - for(i = 0; i < parms->rank; i++) { + for (i = 0; i < parms->rank; i++) { d_offset = 1; - for(j = i + 1; j < parms->rank; j++) + for (j = i + 1; j < parms->rank; j++) d_offset *= (HDoff_t)parms->dset_size[j]; linear_dset_offset += (offset[i] + (HDoff_t)buf_offset[i]) * d_offset; @@ -745,15 +745,13 @@ posix_buffer_write(int local_dim, file_descr *fd, parameters *parms, void *buffe /* only care if seek returns error */ rc = POSIXSEEK(fd->posixfd, linear_dset_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); + VRFY((rc == 0), "POSIXSEEK"); /* check if all bytes are written */ - rc = ((ssize_t)cont_size == - POSIXWRITE(fd->posixfd, buf_p, cont_size)); + rc = ((ssize_t)cont_size == POSIXWRITE(fd->posixfd, buf_p, cont_size)); VRFY((rc != 0), "POSIXWRITE"); /* Advance location in buffer */ buf_p += cont_size; - } done: @@ -770,110 +768,108 @@ done: static herr_t do_read(results *res, file_descr *fd, parameters *parms, void *buffer) { - char *buffer2 = NULL; /* Buffer for data verification */ - int ret_code = SUCCESS; - char dname[64]; - int i; - size_t u; + char * buffer2 = NULL; /* Buffer for data verification */ + int ret_code = SUCCESS; + char dname[64]; + int i; + size_t u; /* HDF5 variables */ - herr_t hrc; /*HDF5 return code */ - hsize_t h5dims[MAX_DIMS]; /*dataset dim sizes */ - hsize_t h5block[MAX_DIMS]; /*dataspace selection */ - hsize_t h5stride[MAX_DIMS]; /*selection stride */ - hsize_t h5start[MAX_DIMS]; /*selection start */ - int rank; + herr_t hrc; /*HDF5 return code */ + hsize_t h5dims[MAX_DIMS]; /*dataset dim sizes */ + hsize_t h5block[MAX_DIMS]; /*dataspace selection */ + hsize_t h5stride[MAX_DIMS]; /*selection stride */ + hsize_t h5start[MAX_DIMS]; /*selection start */ + int rank; /* Allocate data verification buffer */ - if(NULL == (buffer2 = (char *)malloc(linear_buf_size))) { + if (NULL == (buffer2 = (char *)malloc(linear_buf_size))) { HDfprintf(stderr, "malloc for data verification buffer size (%zu) failed\n", linear_buf_size); GOTOERROR(FAIL); } /* end if */ /* Prepare buffer for verifying data */ - for(u = 0; u < linear_buf_size; u++) + for (u = 0; u < linear_buf_size; u++) buffer2[u] = (char)(u % 128); rank = parms->rank; - for(i = 0; i < rank; i++) + for (i = 0; i < rank; i++) h5offset[i] = offset[i] = 0; /* I/O Access specific setup */ switch (parms->io_type) { - case POSIXIO: + case POSIXIO: cont_dim = rank; - for (i=rank-1; i>=0; i--) { - if (parms->buf_size[i]==parms->dset_size[i]) + for (i = rank - 1; i >= 0; i--) { + if (parms->buf_size[i] == parms->dset_size[i]) cont_dim = i; else break; } - cont_size = (!cont_dim)? 1 : parms->buf_size[cont_dim-1]; - for (i=cont_dim; i<rank; i++) + cont_size = (!cont_dim) ? 1 : parms->buf_size[cont_dim - 1]; + for (i = cont_dim; i < rank; i++) cont_size *= parms->buf_size[i]; - break; + break; - case HDF5: /* HDF5 setup */ - for (i=0; i < rank; i++){ - h5dims[i] = parms->dset_size[i]; - h5start[i] = 0; - h5stride[i] = 1; - h5block[i] = 1; - h5count[i] = parms->buf_size[i]; - } + case HDF5: /* HDF5 setup */ + for (i = 0; i < rank; i++) { + h5dims[i] = parms->dset_size[i]; + h5start[i] = 0; + h5stride[i] = 1; + h5block[i] = 1; + h5count[i] = parms->buf_size[i]; + } - h5dset_space_id = H5Screate_simple(rank, h5dims, NULL); - VRFY((h5dset_space_id >= 0), "H5Screate_simple"); + h5dset_space_id = H5Screate_simple(rank, h5dims, NULL); + VRFY((h5dset_space_id >= 0), "H5Screate_simple"); - hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, - h5start, h5stride, h5count, h5block); - VRFY((hrc >= 0), "H5Sselect_hyperslab"); + hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, h5start, h5stride, h5count, h5block); + VRFY((hrc >= 0), "H5Sselect_hyperslab"); - /* Create the memory dataspace that corresponds to the xfer buffer */ - h5mem_space_id = H5Screate_simple(rank, h5count, NULL); - VRFY((h5mem_space_id >= 0), "H5Screate_simple"); + /* Create the memory dataspace that corresponds to the xfer buffer */ + h5mem_space_id = H5Screate_simple(rank, h5count, NULL); + VRFY((h5mem_space_id >= 0), "H5Screate_simple"); - /* Create the dataset transfer property list */ - h5dxpl = H5Pcreate(H5P_DATASET_XFER); - if (h5dxpl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } - break; + /* Create the dataset transfer property list */ + h5dxpl = H5Pcreate(H5P_DATASET_XFER); + if (h5dxpl < 0) { + HDfprintf(stderr, "HDF5 Property List Create failed\n"); + GOTOERROR(FAIL); + } + break; - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); - GOTOERROR(FAIL); - break; + default: + /* unknown request */ + HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); + GOTOERROR(FAIL); + break; } /* end switch */ - /* create dataset */ switch (parms->io_type) { case POSIXIO: - break; + break; case HDF5: - HDsprintf(dname, "Dataset_%ld", (long)parms->num_bytes); - h5ds_id = H5Dopen2(fd->h5fd, dname, H5P_DEFAULT); - if (h5ds_id < 0) { - HDfprintf(stderr, "HDF5 Dataset open failed\n"); - GOTOERROR(FAIL); - } - break; + HDsprintf(dname, "Dataset_%ld", (long)parms->num_bytes); + h5ds_id = H5Dopen2(fd->h5fd, dname, H5P_DEFAULT); + if (h5ds_id < 0) { + HDfprintf(stderr, "HDF5 Dataset open failed\n"); + GOTOERROR(FAIL); + } + break; default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); - GOTOERROR(FAIL); - break; + /* unknown request */ + HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); + GOTOERROR(FAIL); + break; } /* end switch */ /* Start "raw data" read timer */ io_time_set(res->timers, HDF5_RAW_READ_FIXED_DIMS, TSTART); - hrc = dset_read(rank-1, fd, parms, buffer, buffer2); + hrc = dset_read(rank - 1, fd, parms, buffer, buffer2); if (hrc < 0) { HDfprintf(stderr, "Error in dataset read\n"); @@ -890,8 +886,8 @@ do_read(results *res, file_descr *fd, parameters *parms, void *buffer) hrc = H5Dclose(h5ds_id); if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Close failed\n"); - GOTOERROR(FAIL); + HDfprintf(stderr, "HDF5 Dataset Close failed\n"); + GOTOERROR(FAIL); } h5ds_id = H5I_INVALID_HID; @@ -901,37 +897,40 @@ done: /* release HDF5 objects */ if (h5dset_space_id != -1) { - hrc = H5Sclose(h5dset_space_id); - if (hrc < 0){ - HDfprintf(stderr, "HDF5 Dataset Space Close failed\n"); - ret_code = FAIL; - } else { - h5dset_space_id = H5I_INVALID_HID; - } + hrc = H5Sclose(h5dset_space_id); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Dataset Space Close failed\n"); + ret_code = FAIL; + } + else { + h5dset_space_id = H5I_INVALID_HID; + } } if (h5mem_space_id != -1) { - hrc = H5Sclose(h5mem_space_id); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Memory Space Close failed\n"); - ret_code = FAIL; - } else { - h5mem_space_id = H5I_INVALID_HID; - } + hrc = H5Sclose(h5mem_space_id); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Memory Space Close failed\n"); + ret_code = FAIL; + } + else { + h5mem_space_id = H5I_INVALID_HID; + } } if (h5dxpl != -1) { - hrc = H5Pclose(h5dxpl); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n"); - ret_code = FAIL; - } else { - h5dxpl = H5I_INVALID_HID; - } + hrc = H5Pclose(h5dxpl); + if (hrc < 0) { + HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n"); + ret_code = FAIL; + } + else { + h5dxpl = H5I_INVALID_HID; + } } /* release generic resources */ - if(buffer2) + if (buffer2) free(buffer2); return ret_code; @@ -946,53 +945,52 @@ done: */ static herr_t -dset_read(int local_dim, file_descr *fd, parameters *parms, void *buffer, - const char *buffer2) +dset_read(int local_dim, file_descr *fd, parameters *parms, void *buffer, const char *buffer2) { - int cur_dim = order[local_dim]-1; + int cur_dim = order[local_dim] - 1; hsize_t i; - int j; - herr_t hrc; - int ret_code = SUCCESS; + int j; + herr_t hrc; + int ret_code = SUCCESS; /* iterate on the current dimension */ - for (i=0; i < parms->dset_size[cur_dim]; i += parms->buf_size[cur_dim]){ + for (i = 0; i < parms->dset_size[cur_dim]; i += parms->buf_size[cur_dim]) { h5offset[cur_dim] = (hssize_t)i; - offset[cur_dim] = (HDoff_t)i; + offset[cur_dim] = (HDoff_t)i; /* if traverse in order array is incomplete, recurse */ - if (local_dim > 0){ + if (local_dim > 0) { - ret_code = dset_read(local_dim-1, fd, parms, buffer, buffer2); + ret_code = dset_read(local_dim - 1, fd, parms, buffer, buffer2); - /* otherwise, write buffer into dataset */ - }else{ + /* otherwise, write buffer into dataset */ + } + else { switch (parms->io_type) { - case POSIXIO: - for (j=0; j<parms->rank; j++) { - buf_offset[j] = 0; - } - buf_p = (unsigned char*)buffer; - posix_buffer_read(0, fd, parms, buffer); - break; + case POSIXIO: + for (j = 0; j < parms->rank; j++) { + buf_offset[j] = 0; + } + buf_p = (unsigned char *)buffer; + posix_buffer_read(0, fd, parms, buffer); + break; - case HDF5: - hrc = H5Soffset_simple(h5dset_space_id, h5offset); - VRFY((hrc >= 0), "H5Soffset_simple"); - /* Read the buffer out */ - hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, - h5dset_space_id, h5dxpl, buffer); - VRFY((hrc >= 0), "H5Dread"); - break; + case HDF5: + hrc = H5Soffset_simple(h5dset_space_id, h5offset); + VRFY((hrc >= 0), "H5Soffset_simple"); + /* Read the buffer out */ + hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, h5dset_space_id, h5dxpl, buffer); + VRFY((hrc >= 0), "H5Dread"); + break; - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); - HDassert(0 && "Unknown IO type"); - break; + default: + /* unknown request */ + HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type); + HDassert(0 && "Unknown IO type"); + break; } /* switch (parms->io_type) */ } } @@ -1011,30 +1009,31 @@ done: static herr_t posix_buffer_read(int local_dim, file_descr *fd, parameters *parms, void *buffer) { - int ret_code = SUCCESS; + int ret_code = SUCCESS; /* if local dimension is not contiguous, recurse */ - if (local_dim < parms->rank-1 && local_dim != cont_dim) { + if (local_dim < parms->rank - 1 && local_dim != cont_dim) { size_t u; - for(u = 0; u < parms->buf_size[local_dim]; u++) { + for (u = 0; u < parms->buf_size[local_dim]; u++) { buf_offset[local_dim] = u; - ret_code = posix_buffer_read(local_dim+1, fd, parms, buffer); - if (local_dim+1==cont_dim) + ret_code = posix_buffer_read(local_dim + 1, fd, parms, buffer); + if (local_dim + 1 == cont_dim) break; } - /* otherwise, perform contiguous POSIX access */ - } else { + /* otherwise, perform contiguous POSIX access */ + } + else { HDoff_t d_offset; HDoff_t linear_dset_offset = 0; - int i, j, rc; + int i, j, rc; buf_offset[local_dim] = 0; /* determine offset in buffer */ - for (i=0; i<parms->rank; i++){ - d_offset=1; + for (i = 0; i < parms->rank; i++) { + d_offset = 1; - for (j=i+1; j<parms->rank; j++) + for (j = i + 1; j < parms->rank; j++) d_offset *= (HDoff_t)parms->dset_size[j]; linear_dset_offset += (offset[i] + (HDoff_t)buf_offset[i]) * d_offset; @@ -1042,21 +1041,18 @@ posix_buffer_read(int local_dim, file_descr *fd, parameters *parms, void *buffer /* only care if seek returns error */ rc = POSIXSEEK(fd->posixfd, linear_dset_offset) < 0 ? -1 : 0; - VRFY((rc==0), "POSIXSEEK"); + VRFY((rc == 0), "POSIXSEEK"); /* check if all bytes are read */ - rc = ((ssize_t)cont_size == - POSIXREAD(fd->posixfd, buf_p, cont_size)); + rc = ((ssize_t)cont_size == POSIXREAD(fd->posixfd, buf_p, cont_size)); VRFY((rc != 0), "POSIXREAD"); /* Advance location in buffer */ buf_p += cont_size; - } done: return ret_code; } - /* * Function: do_fopen * Purpose: Open the specified file. @@ -1064,62 +1060,62 @@ done: * Programmer: Albert Cheng, Bill Wendling, 2001/12/13 * Modifications: Support for file drivers, Christian Chilan, April, 2008 */ - static herr_t +static herr_t do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags) { - int ret_code = SUCCESS; + int ret_code = SUCCESS; hid_t fcpl; switch (param->io_type) { - case POSIXIO: - if (flags & (SIO_CREATE | SIO_WRITE)) - fd->posixfd = POSIXCREATE(fname); - else - fd->posixfd = POSIXOPEN(fname, O_RDONLY); - - if (fd->posixfd < 0 ) { - HDfprintf(stderr, "POSIX File Open failed(%s)\n", fname); - GOTOERROR(FAIL); - } + case POSIXIO: + if (flags & (SIO_CREATE | SIO_WRITE)) + fd->posixfd = POSIXCREATE(fname); + else + fd->posixfd = POSIXOPEN(fname, O_RDONLY); - break; + if (fd->posixfd < 0) { + HDfprintf(stderr, "POSIX File Open failed(%s)\n", fname); + GOTOERROR(FAIL); + } - case HDF5: + break; - fapl = set_vfd(param); + case HDF5: - if (fapl < 0) { - HDfprintf(stderr, "HDF5 Property List Create failed\n"); - GOTOERROR(FAIL); - } + fapl = set_vfd(param); - fcpl = H5Pcreate(H5P_FILE_CREATE); - if(param->page_size) { - H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1); - H5Pset_file_space_page_size(fcpl, param->page_size); - if(param->page_buffer_size) - H5Pset_page_buffer_size(fapl, param->page_buffer_size, 0, 0); - } + if (fapl < 0) { + HDfprintf(stderr, "HDF5 Property List Create failed\n"); + GOTOERROR(FAIL); + } - /* create the parallel file */ - if (flags & (SIO_CREATE | SIO_WRITE)) { - fd->h5fd = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl); - } else { - fd->h5fd = H5Fopen(fname, H5F_ACC_RDONLY, fapl); - } + fcpl = H5Pcreate(H5P_FILE_CREATE); + if (param->page_size) { + H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1); + H5Pset_file_space_page_size(fcpl, param->page_size); + if (param->page_buffer_size) + H5Pset_page_buffer_size(fapl, param->page_buffer_size, 0, 0); + } + /* create the parallel file */ + if (flags & (SIO_CREATE | SIO_WRITE)) { + fd->h5fd = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl); + } + else { + fd->h5fd = H5Fopen(fname, H5F_ACC_RDONLY, fapl); + } - if (fd->h5fd < 0) { - HDfprintf(stderr, "HDF5 File Create failed(%s)\n", fname); - GOTOERROR(FAIL); - } - break; + if (fd->h5fd < 0) { + HDfprintf(stderr, "HDF5 File Create failed(%s)\n", fname); + GOTOERROR(FAIL); + } + break; - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)param->io_type); - GOTOERROR(FAIL); - break; + default: + /* unknown request */ + HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)param->io_type); + GOTOERROR(FAIL); + break; } done: @@ -1137,69 +1133,78 @@ done: hid_t set_vfd(parameters *param) { - hid_t my_fapl = H5I_INVALID_HID; - vfdtype vfd; + hid_t my_fapl = H5I_INVALID_HID; + vfdtype vfd; vfd = param->vfd; - if ((my_fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1; + if ((my_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + return -1; if (vfd == sec2) { /* Unix read() and write() system calls */ - if (H5Pset_fapl_sec2(my_fapl)<0) return -1; - } else if (vfd == stdio) { + if (H5Pset_fapl_sec2(my_fapl) < 0) + return -1; + } + else if (vfd == stdio) { /* Standard C fread() and fwrite() system calls */ - if (H5Pset_fapl_stdio(my_fapl)<0) return -1; - } else if (vfd == core) { + if (H5Pset_fapl_stdio(my_fapl) < 0) + return -1; + } + else if (vfd == core) { /* In-core temporary file with 1MB increment */ - if (H5Pset_fapl_core(my_fapl, (size_t)1024*1024, TRUE)<0) return -1; - } else if (vfd == split) { + if (H5Pset_fapl_core(my_fapl, (size_t)1024 * 1024, TRUE) < 0) + return -1; + } + else if (vfd == split) { /* Split meta data and raw data each using default driver */ - if (H5Pset_fapl_split(my_fapl, - "-m.h5", H5P_DEFAULT, - "-r.h5", H5P_DEFAULT)<0) + if (H5Pset_fapl_split(my_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) return -1; - } else if (vfd == multi) { + } + else if (vfd == multi) { /* Multi-file driver, general case of the split driver */ - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; + H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - H5FD_mem_t mt; + char sv[H5FD_MEM_NTYPES][1024]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + H5FD_mem_t mt; HDmemset(memb_map, 0, sizeof memb_map); HDmemset(memb_fapl, 0, sizeof memb_fapl); HDmemset(memb_name, 0, sizeof memb_name); HDmemset(memb_addr, 0, sizeof memb_addr); - HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); - for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) { + HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { memb_fapl[mt] = H5P_DEFAULT; HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; - memb_addr[mt] = (haddr_t)MAX(mt - 1,0) * (HADDR_MAX / 10); + memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); } - if (H5Pset_fapl_multi(my_fapl, memb_map, memb_fapl, memb_name, - memb_addr, FALSE)<0) { + if (H5Pset_fapl_multi(my_fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) { return -1; } - } else if (vfd == family) { - hsize_t fam_size = 1*1024*1024; /*100 MB*/ + } + else if (vfd == family) { + hsize_t fam_size = 1 * 1024 * 1024; /*100 MB*/ /* Family of files, each 1MB and using the default driver */ /* if ((val=HDstrtok(NULL, " \t\n\r"))) fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); */ - if (H5Pset_fapl_family(my_fapl, fam_size, H5P_DEFAULT)<0) + if (H5Pset_fapl_family(my_fapl, fam_size, H5P_DEFAULT) < 0) return -1; - } else if (vfd == direct) { + } + else if (vfd == direct) { #ifdef H5_HAVE_DIRECT /* Linux direct read() and write() system calls. Set memory boundary, file block size, * and copy buffer size to the default values. */ - if (H5Pset_fapl_direct(my_fapl, 1024, 4096, 8*4096)<0) return -1; + if (H5Pset_fapl_direct(my_fapl, 1024, 4096, 8 * 4096) < 0) + return -1; #endif - } else { + } + else { /* Unknown driver */ return -1; } @@ -1214,47 +1219,46 @@ set_vfd(parameters *param) * Programmer: Albert Cheng, Bill Wendling, 2001/12/13 * Modifications: */ - static herr_t +static herr_t do_fclose(iotype iot, file_descr *fd /*out*/) { herr_t ret_code = SUCCESS, hrc; - int rc = 0; + int rc = 0; switch (iot) { - case POSIXIO: - rc = POSIXCLOSE(fd->posixfd); + case POSIXIO: + rc = POSIXCLOSE(fd->posixfd); - if (rc != 0){ - HDfprintf(stderr, "POSIX File Close failed\n"); - GOTOERROR(FAIL); - } + if (rc != 0) { + HDfprintf(stderr, "POSIX File Close failed\n"); + GOTOERROR(FAIL); + } - fd->posixfd = -1; - break; + fd->posixfd = -1; + break; - case HDF5: - hrc = H5Fclose(fd->h5fd); + case HDF5: + hrc = H5Fclose(fd->h5fd); - if (hrc < 0) { - HDfprintf(stderr, "HDF5 File Close failed\n"); - GOTOERROR(FAIL); - } + if (hrc < 0) { + HDfprintf(stderr, "HDF5 File Close failed\n"); + GOTOERROR(FAIL); + } - fd->h5fd = -1; - break; + fd->h5fd = -1; + break; - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot); - GOTOERROR(FAIL); - break; + default: + /* unknown request */ + HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot); + GOTOERROR(FAIL); + break; } done: return ret_code; } - /* * Function: do_cleanupfile * Purpose: Cleanup temporary file unless HDF5_NOCLEANUP is set. @@ -1272,63 +1276,63 @@ H5_GCC_DIAG_OFF("format-nonliteral") static void do_cleanupfile(iotype iot, char *filename) { - char temp[2048]; - int j; - hid_t driver; + char temp[2048]; + int j; + hid_t driver; if (clean_file_g == -1) - clean_file_g = (HDgetenv("HDF5_NOCLEANUP")==NULL) ? 1 : 0; + clean_file_g = (HDgetenv("HDF5_NOCLEANUP") == NULL) ? 1 : 0; - if (clean_file_g){ + if (clean_file_g) { - switch (iot) { - case POSIXIO: - HDremove(filename); - break; + switch (iot) { + case POSIXIO: + HDremove(filename); + break; - case HDF5: - driver = H5Pget_driver(fapl); + case HDF5: + driver = H5Pget_driver(fapl); - if (driver == H5FD_FAMILY) { - for (j = 0; /*void*/; j++) { - HDsnprintf(temp, sizeof temp, filename, j); + if (driver == H5FD_FAMILY) { + for (j = 0; /*void*/; j++) { + HDsnprintf(temp, sizeof temp, filename, j); - if (HDaccess(temp, F_OK) < 0) - break; + if (HDaccess(temp, F_OK) < 0) + break; - HDremove(temp); + HDremove(temp); + } } - } else if (driver == H5FD_CORE) { - hbool_t backing; /* Whether the core file has backing store */ - - H5Pget_fapl_core(fapl,NULL,&backing); + else if (driver == H5FD_CORE) { + hbool_t backing; /* Whether the core file has backing store */ - /* If the file was stored to disk with bacing store, remove it */ - if(backing) - HDremove(filename); + H5Pget_fapl_core(fapl, NULL, &backing); - } else if (driver == H5FD_MULTI) { - H5FD_mem_t mt; - assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); + /* If the file was stored to disk with bacing store, remove it */ + if (backing) + HDremove(filename); + } + else if (driver == H5FD_MULTI) { + H5FD_mem_t mt; + assert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { - HDsnprintf(temp, sizeof temp, "%s-%c.h5", - filename, multi_letters[mt]); - HDremove(temp); /*don't care if it fails*/ + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { + HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]); + HDremove(temp); /*don't care if it fails*/ + } } - } else { - HDremove(filename); - } - H5Pclose(fapl); - break; + else { + HDremove(filename); + } + H5Pclose(fapl); + break; - default: - /* unknown request */ - HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot); - HDassert(0 && "Unknown IO type"); - break; + default: + /* unknown request */ + HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot); + HDassert(0 && "Unknown IO type"); + break; } } } H5_GCC_DIAG_ON("format-nonliteral") - diff --git a/tools/test/perform/sio_perf.c b/tools/test/perform/sio_perf.c index 0656e94..fb31080 100644 --- a/tools/test/perform/sio_perf.c +++ b/tools/test/perform/sio_perf.c @@ -51,42 +51,42 @@ #include "hdf5.h" - /* our header files */ #include "sio_perf.h" /* useful macros */ -#define TAB_SPACE 4 +#define TAB_SPACE 4 -#define ONE_KB 1024 -#define ONE_MB (ONE_KB * ONE_KB) -#define ONE_GB (ONE_MB * ONE_KB) +#define ONE_KB 1024 +#define ONE_MB (ONE_KB * ONE_KB) +#define ONE_GB (ONE_MB * ONE_KB) -#define SIO_POSIX 0x1 -#define SIO_HDF5 0x4 +#define SIO_POSIX 0x1 +#define SIO_HDF5 0x4 /* report 0.0 in case t is zero too */ -#define MB_PER_SEC(bytes,t) (H5_DBL_ABS_EQUAL(t, (double)0.0F) ? (double)0.0F : ((((double)bytes) / (double)ONE_MB) / (t))) +#define MB_PER_SEC(bytes, t) \ + (H5_DBL_ABS_EQUAL(t, (double)0.0F) ? (double)0.0F : ((((double)bytes) / (double)ONE_MB) / (t))) #ifndef TRUE -#define TRUE 1 -#endif /* TRUE */ +#define TRUE 1 +#endif /* TRUE */ #ifndef FALSE -#define FALSE (!TRUE) -#endif /* FALSE */ +#define FALSE (!TRUE) +#endif /* FALSE */ /* global variables */ -FILE *output; /* output file */ -int sio_debug_level = 0;/* The debug level: - * 0 - Off - * 1 - Minimal - * 2 - Some more - * 3 - Maximal - * 4 - Maximal & then some - */ +FILE *output; /* output file */ +int sio_debug_level = 0; /* The debug level: + * 0 - Off + * 1 - Minimal + * 2 - Some more + * 3 - Maximal + * 4 - Maximal & then some + */ /* local variables */ -static const char *progname = "h5perf_serial"; +static const char *progname = "h5perf_serial"; /* * Command-line options: The user can specify short or long-named @@ -98,14 +98,13 @@ static const char *progname = "h5perf_serial"; * It seems that only the options that accept additional information * such as dataset size (-e) require the colon next to it. */ -static const char *s_opts = "a:A:B:c:Cd:D:e:F:ghi:Imno:p:P:r:stT:v:wx:X:"; -static struct long_options l_opts[] = { - { "align", require_arg, 'a' }, - { "alig", require_arg, 'a' }, - { "ali", require_arg, 'a' }, - { "al", require_arg, 'a' }, - { "api", require_arg, 'A' }, - { "ap", require_arg, 'A' }, +static const char * s_opts = "a:A:B:c:Cd:D:e:F:ghi:Imno:p:P:r:stT:v:wx:X:"; +static struct long_options l_opts[] = {{"align", require_arg, 'a'}, + {"alig", require_arg, 'a'}, + {"ali", require_arg, 'a'}, + {"al", require_arg, 'a'}, + {"api", require_arg, 'A'}, + {"ap", require_arg, 'A'}, #if 0 /* a sighting of the elusive binary option */ { "binary", no_arg, 'b' }, @@ -113,204 +112,203 @@ static struct long_options l_opts[] = { { "bina", no_arg, 'b' }, { "bin", no_arg, 'b' }, { "bi", no_arg, 'b' }, -#endif /* 0 */ - { "block-size", require_arg, 'B' }, - { "block-siz", require_arg, 'B' }, - { "block-si", require_arg, 'B' }, - { "block-s", require_arg, 'B' }, - { "block-", require_arg, 'B' }, - { "block", require_arg, 'B' }, - { "bloc", require_arg, 'B' }, - { "blo", require_arg, 'B' }, - { "bl", require_arg, 'B' }, - { "chunk", no_arg, 'c' }, - { "chun", no_arg, 'c' }, - { "chu", no_arg, 'c' }, - { "ch", no_arg, 'c' }, - { "collective", no_arg, 'C' }, - { "collectiv", no_arg, 'C' }, - { "collecti", no_arg, 'C' }, - { "collect", no_arg, 'C' }, - { "collec", no_arg, 'C' }, - { "colle", no_arg, 'C' }, - { "coll", no_arg, 'C' }, - { "col", no_arg, 'C' }, - { "co", no_arg, 'C' }, - { "debug", require_arg, 'D' }, - { "debu", require_arg, 'D' }, - { "deb", require_arg, 'D' }, - { "de", require_arg, 'D' }, - { "file-driver", require_arg, 'v' }, - { "file-drive", require_arg, 'v' }, - { "file-driv", require_arg, 'v' }, - { "file-dri", require_arg, 'v' }, - { "file-dr", require_arg, 'v' }, - { "file-d", require_arg, 'v' }, - { "file-", require_arg, 'v' }, - { "file", require_arg, 'v' }, - { "fil", require_arg, 'v' }, - { "fi", require_arg, 'v' }, - { "geometry", no_arg, 'g' }, - { "geometr", no_arg, 'g' }, - { "geomet", no_arg, 'g' }, - { "geome", no_arg, 'g' }, - { "geom", no_arg, 'g' }, - { "geo", no_arg, 'g' }, - { "ge", no_arg, 'g' }, - { "help", no_arg, 'h' }, - { "hel", no_arg, 'h' }, - { "he", no_arg, 'h' }, - { "interleaved", require_arg, 'I' }, - { "interleave", require_arg, 'I' }, - { "interleav", require_arg, 'I' }, - { "interlea", require_arg, 'I' }, - { "interle", require_arg, 'I' }, - { "interl", require_arg, 'I' }, - { "inter", require_arg, 'I' }, - { "inte", require_arg, 'I' }, - { "int", require_arg, 'I' }, - { "in", require_arg, 'I' }, - { "max-num-processes", require_arg, 'P' }, - { "max-num-processe", require_arg, 'P' }, - { "max-num-process", require_arg, 'P' }, - { "max-num-proces", require_arg, 'P' }, - { "max-num-proce", require_arg, 'P' }, - { "max-num-proc", require_arg, 'P' }, - { "max-num-pro", require_arg, 'P' }, - { "max-num-pr", require_arg, 'P' }, - { "max-num-p", require_arg, 'P' }, - { "min-num-processes", require_arg, 'p' }, - { "min-num-processe", require_arg, 'p' }, - { "min-num-process", require_arg, 'p' }, - { "min-num-proces", require_arg, 'p' }, - { "min-num-proce", require_arg, 'p' }, - { "min-num-proc", require_arg, 'p' }, - { "min-num-pro", require_arg, 'p' }, - { "min-num-pr", require_arg, 'p' }, - { "min-num-p", require_arg, 'p' }, - { "max-xfer-size", require_arg, 'X' }, - { "max-xfer-siz", require_arg, 'X' }, - { "max-xfer-si", require_arg, 'X' }, - { "max-xfer-s", require_arg, 'X' }, - { "max-xfer", require_arg, 'X' }, - { "max-xfe", require_arg, 'X' }, - { "max-xf", require_arg, 'X' }, - { "max-x", require_arg, 'X' }, - { "min-xfer-size", require_arg, 'x' }, - { "min-xfer-siz", require_arg, 'x' }, - { "min-xfer-si", require_arg, 'x' }, - { "min-xfer-s", require_arg, 'x' }, - { "min-xfer", require_arg, 'x' }, - { "min-xfe", require_arg, 'x' }, - { "min-xf", require_arg, 'x' }, - { "min-x", require_arg, 'x' }, - { "num-bytes", require_arg, 'e' }, - { "num-byte", require_arg, 'e' }, - { "num-byt", require_arg, 'e' }, - { "num-by", require_arg, 'e' }, - { "num-b", require_arg, 'e' }, - { "num-dsets", require_arg, 'd' }, - { "num-dset", require_arg, 'd' }, - { "num-dse", require_arg, 'd' }, - { "num-ds", require_arg, 'd' }, - { "num-d", require_arg, 'd' }, - { "num-files", require_arg, 'F' }, - { "num-file", require_arg, 'F' }, - { "num-fil", require_arg, 'F' }, - { "num-fi", require_arg, 'F' }, - { "num-f", require_arg, 'F' }, - { "num-iterations", require_arg, 'i' }, - { "num-iteration", require_arg, 'i' }, - { "num-iteratio", require_arg, 'i' }, - { "num-iterati", require_arg, 'i' }, - { "num-iterat", require_arg, 'i' }, - { "num-itera", require_arg, 'i' }, - { "num-iter", require_arg, 'i' }, - { "num-ite", require_arg, 'i' }, - { "num-it", require_arg, 'i' }, - { "num-i", require_arg, 'i' }, - { "order", require_arg, 'r' }, - { "orde", require_arg, 'r' }, - { "ord", require_arg, 'r' }, - { "or", require_arg, 'r' }, - { "output", require_arg, 'o' }, - { "outpu", require_arg, 'o' }, - { "outp", require_arg, 'o' }, - { "out", require_arg, 'o' }, - { "ou", require_arg, 'o' }, - { "extendable", no_arg, 't' }, - { "extendabl", no_arg, 't' }, - { "extendab", no_arg, 't' }, - { "extenda", no_arg, 't' }, - { "extend", no_arg, 't' }, - { "exten", no_arg, 't' }, - { "exte", no_arg, 't' }, - { "ext", no_arg, 't' }, - { "ex", no_arg, 't' }, - { "threshold", require_arg, 'T' }, - { "threshol", require_arg, 'T' }, - { "thresho", require_arg, 'T' }, - { "thresh", require_arg, 'T' }, - { "thres", require_arg, 'T' }, - { "thre", require_arg, 'T' }, - { "thr", require_arg, 'T' }, - { "th", require_arg, 'T' }, - { "write-only", require_arg, 'w' }, - { "write-onl", require_arg, 'w' }, - { "write-on", require_arg, 'w' }, - { "write-o", require_arg, 'w' }, - { "write", require_arg, 'w' }, - { "writ", require_arg, 'w' }, - { "wri", require_arg, 'w' }, - { "wr", require_arg, 'w' }, - { NULL, 0, '\0' } -}; +#endif /* 0 */ + {"block-size", require_arg, 'B'}, + {"block-siz", require_arg, 'B'}, + {"block-si", require_arg, 'B'}, + {"block-s", require_arg, 'B'}, + {"block-", require_arg, 'B'}, + {"block", require_arg, 'B'}, + {"bloc", require_arg, 'B'}, + {"blo", require_arg, 'B'}, + {"bl", require_arg, 'B'}, + {"chunk", no_arg, 'c'}, + {"chun", no_arg, 'c'}, + {"chu", no_arg, 'c'}, + {"ch", no_arg, 'c'}, + {"collective", no_arg, 'C'}, + {"collectiv", no_arg, 'C'}, + {"collecti", no_arg, 'C'}, + {"collect", no_arg, 'C'}, + {"collec", no_arg, 'C'}, + {"colle", no_arg, 'C'}, + {"coll", no_arg, 'C'}, + {"col", no_arg, 'C'}, + {"co", no_arg, 'C'}, + {"debug", require_arg, 'D'}, + {"debu", require_arg, 'D'}, + {"deb", require_arg, 'D'}, + {"de", require_arg, 'D'}, + {"file-driver", require_arg, 'v'}, + {"file-drive", require_arg, 'v'}, + {"file-driv", require_arg, 'v'}, + {"file-dri", require_arg, 'v'}, + {"file-dr", require_arg, 'v'}, + {"file-d", require_arg, 'v'}, + {"file-", require_arg, 'v'}, + {"file", require_arg, 'v'}, + {"fil", require_arg, 'v'}, + {"fi", require_arg, 'v'}, + {"geometry", no_arg, 'g'}, + {"geometr", no_arg, 'g'}, + {"geomet", no_arg, 'g'}, + {"geome", no_arg, 'g'}, + {"geom", no_arg, 'g'}, + {"geo", no_arg, 'g'}, + {"ge", no_arg, 'g'}, + {"help", no_arg, 'h'}, + {"hel", no_arg, 'h'}, + {"he", no_arg, 'h'}, + {"interleaved", require_arg, 'I'}, + {"interleave", require_arg, 'I'}, + {"interleav", require_arg, 'I'}, + {"interlea", require_arg, 'I'}, + {"interle", require_arg, 'I'}, + {"interl", require_arg, 'I'}, + {"inter", require_arg, 'I'}, + {"inte", require_arg, 'I'}, + {"int", require_arg, 'I'}, + {"in", require_arg, 'I'}, + {"max-num-processes", require_arg, 'P'}, + {"max-num-processe", require_arg, 'P'}, + {"max-num-process", require_arg, 'P'}, + {"max-num-proces", require_arg, 'P'}, + {"max-num-proce", require_arg, 'P'}, + {"max-num-proc", require_arg, 'P'}, + {"max-num-pro", require_arg, 'P'}, + {"max-num-pr", require_arg, 'P'}, + {"max-num-p", require_arg, 'P'}, + {"min-num-processes", require_arg, 'p'}, + {"min-num-processe", require_arg, 'p'}, + {"min-num-process", require_arg, 'p'}, + {"min-num-proces", require_arg, 'p'}, + {"min-num-proce", require_arg, 'p'}, + {"min-num-proc", require_arg, 'p'}, + {"min-num-pro", require_arg, 'p'}, + {"min-num-pr", require_arg, 'p'}, + {"min-num-p", require_arg, 'p'}, + {"max-xfer-size", require_arg, 'X'}, + {"max-xfer-siz", require_arg, 'X'}, + {"max-xfer-si", require_arg, 'X'}, + {"max-xfer-s", require_arg, 'X'}, + {"max-xfer", require_arg, 'X'}, + {"max-xfe", require_arg, 'X'}, + {"max-xf", require_arg, 'X'}, + {"max-x", require_arg, 'X'}, + {"min-xfer-size", require_arg, 'x'}, + {"min-xfer-siz", require_arg, 'x'}, + {"min-xfer-si", require_arg, 'x'}, + {"min-xfer-s", require_arg, 'x'}, + {"min-xfer", require_arg, 'x'}, + {"min-xfe", require_arg, 'x'}, + {"min-xf", require_arg, 'x'}, + {"min-x", require_arg, 'x'}, + {"num-bytes", require_arg, 'e'}, + {"num-byte", require_arg, 'e'}, + {"num-byt", require_arg, 'e'}, + {"num-by", require_arg, 'e'}, + {"num-b", require_arg, 'e'}, + {"num-dsets", require_arg, 'd'}, + {"num-dset", require_arg, 'd'}, + {"num-dse", require_arg, 'd'}, + {"num-ds", require_arg, 'd'}, + {"num-d", require_arg, 'd'}, + {"num-files", require_arg, 'F'}, + {"num-file", require_arg, 'F'}, + {"num-fil", require_arg, 'F'}, + {"num-fi", require_arg, 'F'}, + {"num-f", require_arg, 'F'}, + {"num-iterations", require_arg, 'i'}, + {"num-iteration", require_arg, 'i'}, + {"num-iteratio", require_arg, 'i'}, + {"num-iterati", require_arg, 'i'}, + {"num-iterat", require_arg, 'i'}, + {"num-itera", require_arg, 'i'}, + {"num-iter", require_arg, 'i'}, + {"num-ite", require_arg, 'i'}, + {"num-it", require_arg, 'i'}, + {"num-i", require_arg, 'i'}, + {"order", require_arg, 'r'}, + {"orde", require_arg, 'r'}, + {"ord", require_arg, 'r'}, + {"or", require_arg, 'r'}, + {"output", require_arg, 'o'}, + {"outpu", require_arg, 'o'}, + {"outp", require_arg, 'o'}, + {"out", require_arg, 'o'}, + {"ou", require_arg, 'o'}, + {"extendable", no_arg, 't'}, + {"extendabl", no_arg, 't'}, + {"extendab", no_arg, 't'}, + {"extenda", no_arg, 't'}, + {"extend", no_arg, 't'}, + {"exten", no_arg, 't'}, + {"exte", no_arg, 't'}, + {"ext", no_arg, 't'}, + {"ex", no_arg, 't'}, + {"threshold", require_arg, 'T'}, + {"threshol", require_arg, 'T'}, + {"thresho", require_arg, 'T'}, + {"thresh", require_arg, 'T'}, + {"thres", require_arg, 'T'}, + {"thre", require_arg, 'T'}, + {"thr", require_arg, 'T'}, + {"th", require_arg, 'T'}, + {"write-only", require_arg, 'w'}, + {"write-onl", require_arg, 'w'}, + {"write-on", require_arg, 'w'}, + {"write-o", require_arg, 'w'}, + {"write", require_arg, 'w'}, + {"writ", require_arg, 'w'}, + {"wri", require_arg, 'w'}, + {"wr", require_arg, 'w'}, + {NULL, 0, '\0'}}; struct options { - long io_types; /* bitmask of which I/O types to test */ - const char *output_file; /* file to print report to */ - long num_dsets; /* number of datasets */ - long num_files; /* number of files */ - off_t num_bpp; /* number of bytes per proc per dset */ - int num_iters; /* number of iterations */ - hsize_t dset_size[MAX_DIMS]; /* Dataset size */ - size_t buf_size[MAX_DIMS]; /* Buffer size */ - size_t chk_size[MAX_DIMS]; /* Chunk size */ - int order[MAX_DIMS]; /* Dimension access order */ - int dset_rank; /* Rank */ - int buf_rank; /* Rank */ - int order_rank; /* Rank */ - int chk_rank; /* Rank */ - int print_times; /* print times as well as throughputs */ - int print_raw; /* print raw data throughput info */ - hsize_t h5_alignment; /* alignment in HDF5 file */ - hsize_t h5_threshold; /* threshold for alignment in HDF5 file */ - int h5_use_chunks; /* Make HDF5 dataset chunked */ - int h5_write_only; /* Perform the write tests only */ - int h5_extendable; /* Perform the write tests only */ - int verify; /* Verify data correctness */ - vfdtype vfd; /* File driver */ - size_t page_buffer_size; - size_t page_size; + long io_types; /* bitmask of which I/O types to test */ + const char *output_file; /* file to print report to */ + long num_dsets; /* number of datasets */ + long num_files; /* number of files */ + off_t num_bpp; /* number of bytes per proc per dset */ + int num_iters; /* number of iterations */ + hsize_t dset_size[MAX_DIMS]; /* Dataset size */ + size_t buf_size[MAX_DIMS]; /* Buffer size */ + size_t chk_size[MAX_DIMS]; /* Chunk size */ + int order[MAX_DIMS]; /* Dimension access order */ + int dset_rank; /* Rank */ + int buf_rank; /* Rank */ + int order_rank; /* Rank */ + int chk_rank; /* Rank */ + int print_times; /* print times as well as throughputs */ + int print_raw; /* print raw data throughput info */ + hsize_t h5_alignment; /* alignment in HDF5 file */ + hsize_t h5_threshold; /* threshold for alignment in HDF5 file */ + int h5_use_chunks; /* Make HDF5 dataset chunked */ + int h5_write_only; /* Perform the write tests only */ + int h5_extendable; /* Perform the write tests only */ + int verify; /* Verify data correctness */ + vfdtype vfd; /* File driver */ + size_t page_buffer_size; + size_t page_size; }; typedef struct _minmax { double min; double max; double sum; - int num; + int num; } minmax; /* local functions */ -static hsize_t parse_size_directive(const char *size); +static hsize_t parse_size_directive(const char *size); static struct options *parse_command_line(int argc, const char *argv[]); -static void run_test_loop(struct options *options); -static int run_test(iotype iot, parameters parms, struct options *opts); -static void output_all_info(minmax *mm, int count, int indent_level); -static void get_minmax(minmax *mm, double val); -static void accumulate_minmax_stuff(const minmax *mm, int count, minmax *total_mm); -static void output_results(const struct options *options, const char *name, - minmax *table, int table_size, off_t data_size); +static void run_test_loop(struct options *options); +static int run_test(iotype iot, parameters parms, struct options *opts); +static void output_all_info(minmax *mm, int count, int indent_level); +static void get_minmax(minmax *mm, double val); +static void accumulate_minmax_stuff(const minmax *mm, int count, minmax *total_mm); +static void output_results(const struct options *options, const char *name, minmax *table, int table_size, + off_t data_size); static void output_report(const char *fmt, ...); static void print_indent(register int indent); static void usage(const char *prog); @@ -326,8 +324,8 @@ static void report_parameters(struct options *opts); int main(int argc, const char *argv[]) { - int exit_value = EXIT_SUCCESS; - struct options *opts = NULL; + int exit_value = EXIT_SUCCESS; + struct options *opts = NULL; #ifndef STANDALONE /* Initialize h5tools lib */ @@ -389,35 +387,35 @@ run_test_loop(struct options *opts) size_t buf_bytes; /* load options into parameter structure */ - parms.num_files = opts->num_files; - parms.num_dsets = opts->num_dsets; - parms.num_iters = opts->num_iters; - parms.rank = opts->dset_rank; - parms.h5_align = opts->h5_alignment; - parms.h5_thresh = opts->h5_threshold; - parms.h5_use_chunks = opts->h5_use_chunks; - parms.h5_extendable = opts->h5_extendable; - parms.h5_write_only = opts->h5_write_only; - parms.verify = opts->verify; - parms.vfd = opts->vfd; + parms.num_files = opts->num_files; + parms.num_dsets = opts->num_dsets; + parms.num_iters = opts->num_iters; + parms.rank = opts->dset_rank; + parms.h5_align = opts->h5_alignment; + parms.h5_thresh = opts->h5_threshold; + parms.h5_use_chunks = opts->h5_use_chunks; + parms.h5_extendable = opts->h5_extendable; + parms.h5_write_only = opts->h5_write_only; + parms.verify = opts->verify; + parms.vfd = opts->vfd; parms.page_buffer_size = opts->page_buffer_size; - parms.page_size = opts->page_size; + parms.page_size = opts->page_size; /* load multidimensional options */ parms.num_bytes = 1; - buf_bytes = 1; - for (i=0; i<parms.rank; i++){ - parms.buf_size[i] = opts->buf_size[i]; + buf_bytes = 1; + for (i = 0; i < parms.rank; i++) { + parms.buf_size[i] = opts->buf_size[i]; parms.dset_size[i] = opts->dset_size[i]; - parms.chk_size[i] = opts->chk_size[i]; - parms.order[i] = opts->order[i]; + parms.chk_size[i] = opts->chk_size[i]; + parms.order[i] = opts->order[i]; parms.num_bytes *= opts->dset_size[i]; buf_bytes *= opts->buf_size[i]; } /* print size information */ output_report("Transfer Buffer Size (bytes): %d\n", buf_bytes); - output_report("File Size(MB): %.2f\n",((double)parms.num_bytes) / ONE_MB); + output_report("File Size(MB): %.2f\n", ((double)parms.num_bytes) / ONE_MB); print_indent(0); if (opts->io_types & SIO_POSIX) @@ -438,27 +436,27 @@ run_test_loop(struct options *opts) static int run_test(iotype iot, parameters parms, struct options *opts) { - results res; - register int i, ret_value = SUCCESS; - off_t raw_size; - minmax *write_sys_mm_table=NULL; - minmax *write_mm_table=NULL; - minmax *write_gross_mm_table=NULL; - minmax *write_raw_mm_table=NULL; - minmax *read_sys_mm_table=NULL; - minmax *read_mm_table=NULL; - minmax *read_gross_mm_table=NULL; - minmax *read_raw_mm_table=NULL; - minmax write_sys_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax write_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax write_gross_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax write_raw_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax read_sys_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax read_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax read_gross_mm = {0.0F, 0.0F, 0.0F, 0}; - minmax read_raw_mm = {0.0F, 0.0F, 0.0F, 0}; - - raw_size = (off_t)parms.num_bytes; + results res; + register int i, ret_value = SUCCESS; + off_t raw_size; + minmax * write_sys_mm_table = NULL; + minmax * write_mm_table = NULL; + minmax * write_gross_mm_table = NULL; + minmax * write_raw_mm_table = NULL; + minmax * read_sys_mm_table = NULL; + minmax * read_mm_table = NULL; + minmax * read_gross_mm_table = NULL; + minmax * read_raw_mm_table = NULL; + minmax write_sys_mm = {0.0F, 0.0F, 0.0F, 0}; + minmax write_mm = {0.0F, 0.0F, 0.0F, 0}; + minmax write_gross_mm = {0.0F, 0.0F, 0.0F, 0}; + minmax write_raw_mm = {0.0F, 0.0F, 0.0F, 0}; + minmax read_sys_mm = {0.0F, 0.0F, 0.0F, 0}; + minmax read_mm = {0.0F, 0.0F, 0.0F, 0}; + minmax read_gross_mm = {0.0F, 0.0F, 0.0F, 0}; + minmax read_raw_mm = {0.0F, 0.0F, 0.0F, 0}; + + raw_size = (off_t)parms.num_bytes; parms.io_type = iot; print_indent(2); output_report("IO API = "); @@ -479,16 +477,16 @@ run_test(iotype iot, parameters parms, struct options *opts) /* allocate space for tables minmax and that it is sufficient */ /* to initialize all elements to zeros by calloc. */ - write_sys_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - write_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - write_gross_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - write_raw_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); + write_sys_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax)); + write_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax)); + write_gross_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax)); + write_raw_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax)); if (!parms.h5_write_only) { - read_sys_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - read_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - read_gross_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); - read_raw_mm_table = (minmax *)calloc((size_t)parms.num_iters , sizeof(minmax)); + read_sys_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax)); + read_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax)); + read_gross_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax)); + read_raw_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax)); } /* Do IO iteration times, collecting statistics each time */ @@ -563,7 +561,7 @@ run_test(iotype iot, parameters parms, struct options *opts) output_all_info(write_raw_mm_table, parms.num_iters, 4); } - output_results(opts,"Raw Data Write",write_raw_mm_table,parms.num_iters,raw_size); + output_results(opts, "Raw Data Write", write_raw_mm_table, parms.num_iters, raw_size); } /* end if */ /* show sys write statics */ @@ -585,7 +583,7 @@ run_test(iotype iot, parameters parms, struct options *opts) output_all_info(write_mm_table, parms.num_iters, 4); } - output_results(opts,"Write",write_mm_table,parms.num_iters,raw_size); + output_results(opts, "Write", write_mm_table, parms.num_iters, raw_size); /* accumulate and output the max, min, and average "gross write" times */ if (sio_debug_level >= 3) { @@ -595,7 +593,7 @@ run_test(iotype iot, parameters parms, struct options *opts) output_all_info(write_gross_mm_table, parms.num_iters, 4); } - output_results(opts,"Write Open-Close",write_gross_mm_table,parms.num_iters,raw_size); + output_results(opts, "Write Open-Close", write_gross_mm_table, parms.num_iters, raw_size); if (!parms.h5_write_only) { /* Read statistics */ @@ -609,8 +607,7 @@ run_test(iotype iot, parameters parms, struct options *opts) output_all_info(read_raw_mm_table, parms.num_iters, 4); } - output_results(opts, "Raw Data Read", read_raw_mm_table, - parms.num_iters, raw_size); + output_results(opts, "Raw Data Read", read_raw_mm_table, parms.num_iters, raw_size); } /* end if */ /* show mpi read statics */ @@ -642,8 +639,7 @@ run_test(iotype iot, parameters parms, struct options *opts) output_all_info(read_gross_mm_table, parms.num_iters, 4); } - output_results(opts, "Read Open-Close", read_gross_mm_table, - parms.num_iters, raw_size); + output_results(opts, "Read Open-Close", read_gross_mm_table, parms.num_iters, raw_size); } /* clean up our mess */ @@ -733,7 +729,6 @@ accumulate_minmax_stuff(const minmax *mm, int count, minmax *total_mm) } } - /* * Function: output_results * Purpose: Print information about the time & bandwidth for a given @@ -743,36 +738,34 @@ accumulate_minmax_stuff(const minmax *mm, int count, minmax *total_mm) * Modifications: */ static void -output_results(const struct options *opts, const char *name, minmax *table, - int table_size,off_t data_size) +output_results(const struct options *opts, const char *name, minmax *table, int table_size, off_t data_size) { - minmax total_mm; + minmax total_mm; accumulate_minmax_stuff(table, table_size, &total_mm); print_indent(3); - output_report("%s (%d iteration(s)):\n", name,table_size); + output_report("%s (%d iteration(s)):\n", name, table_size); /* Note: The maximum throughput uses the minimum amount of time & vice versa */ print_indent(4); - output_report("Maximum Throughput: %6.2f MB/s", MB_PER_SEC(data_size,total_mm.min)); - if(opts->print_times) + output_report("Maximum Throughput: %6.2f MB/s", MB_PER_SEC(data_size, total_mm.min)); + if (opts->print_times) output_report(" (%7.3f s)\n", total_mm.min); else output_report("\n"); print_indent(4); - output_report("Average Throughput: %6.2f MB/s", - MB_PER_SEC(data_size,total_mm.sum / total_mm.num)); - if(opts->print_times) + output_report("Average Throughput: %6.2f MB/s", MB_PER_SEC(data_size, total_mm.sum / total_mm.num)); + if (opts->print_times) output_report(" (%7.3f s)\n", (total_mm.sum / total_mm.num)); else output_report("\n"); print_indent(4); - output_report("Minimum Throughput: %6.2f MB/s", MB_PER_SEC(data_size,total_mm.max)); - if(opts->print_times) + output_report("Minimum Throughput: %6.2f MB/s", MB_PER_SEC(data_size, total_mm.max)); + if (opts->print_times) output_report(" (%7.3f s)\n", total_mm.max); else output_report("\n"); @@ -788,11 +781,11 @@ output_results(const struct options *opts, const char *name, minmax *table, static void output_report(const char *fmt, ...) { - va_list ap; + va_list ap; - HDva_start(ap, fmt); - HDvfprintf(output, fmt, ap); - HDva_end(ap); + HDva_start(ap, fmt); + HDvfprintf(output, fmt, ap); + HDva_end(ap); } /* @@ -818,14 +811,28 @@ recover_size_and_print(long long val, const char *end) if (val >= ONE_KB && (val % ONE_KB) == 0) { if (val >= ONE_MB && (val % ONE_MB) == 0) { if (val >= ONE_GB && (val % ONE_GB) == 0) - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""GB%s", val / ONE_GB, end); + HDfprintf(output, + "%" H5_PRINTF_LL_WIDTH "d" + "GB%s", + val / ONE_GB, end); else - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""MB%s", val / ONE_MB, end); - } else { - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""KB%s", val / ONE_KB, end); + HDfprintf(output, + "%" H5_PRINTF_LL_WIDTH "d" + "MB%s", + val / ONE_MB, end); + } + else { + HDfprintf(output, + "%" H5_PRINTF_LL_WIDTH "d" + "KB%s", + val / ONE_KB, end); } - } else { - HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""%s", val, end); + } + else { + HDfprintf(output, + "%" H5_PRINTF_LL_WIDTH "d" + "%s", + val, end); } } @@ -833,9 +840,9 @@ static void print_io_api(long io_types) { if (io_types & SIO_POSIX) - HDfprintf(output, "posix "); + HDfprintf(output, "posix "); if (io_types & SIO_HDF5) - HDfprintf(output, "hdf5 "); + HDfprintf(output, "hdf5 "); HDfprintf(output, "\n"); } @@ -845,30 +852,28 @@ report_parameters(struct options *opts) int i, rank; rank = opts->dset_rank; - print_version("HDF5 Library"); /* print library version */ + print_version("HDF5 Library"); /* print library version */ HDfprintf(output, "==== Parameters ====\n"); HDfprintf(output, "IO API="); print_io_api(opts->io_types); - HDfprintf(output, "Number of iterations=%d\n", - opts->num_iters); + HDfprintf(output, "Number of iterations=%d\n", opts->num_iters); HDfprintf(output, "Dataset size="); - for (i=0; i<rank; i++) + for (i = 0; i < rank; i++) recover_size_and_print((long long)opts->dset_size[i], " "); HDfprintf(output, "\n"); - HDfprintf(output, "Transfer buffer size="); - for (i=0; i<rank; i++) + for (i = 0; i < rank; i++) recover_size_and_print((long long)opts->buf_size[i], " "); HDfprintf(output, "\n"); - if(opts->page_size) { + if (opts->page_size) { HDfprintf(output, "Page Aggregation Enabled. Page size = %zu\n", opts->page_size); - if(opts->page_buffer_size) + if (opts->page_buffer_size) HDfprintf(output, "Page Buffering Enabled. Page Buffer size = %zu\n", opts->page_buffer_size); else HDfprintf(output, "Page Buffering Disabled\n"); @@ -877,7 +882,7 @@ report_parameters(struct options *opts) HDfprintf(output, "Page Aggregation Disabled\n"); HDfprintf(output, "Dimension access order="); - for (i=0; i<rank; i++) + for (i = 0; i < rank; i++) recover_size_and_print((long long)opts->order[i], " "); HDfprintf(output, "\n"); @@ -885,11 +890,11 @@ report_parameters(struct options *opts) HDfprintf(output, "HDF5 data storage method="); - if (opts->h5_use_chunks){ + if (opts->h5_use_chunks) { HDfprintf(output, "Chunked\n"); HDfprintf(output, "HDF5 chunk size="); - for (i=0; i<rank; i++) + for (i = 0; i < rank; i++) recover_size_and_print((long long)opts->chk_size[i], " "); HDfprintf(output, "\n"); @@ -906,19 +911,25 @@ report_parameters(struct options *opts) } HDfprintf(output, "HDF5 file driver="); - if (opts->vfd==sec2) { + if (opts->vfd == sec2) { HDfprintf(output, "sec2\n"); - } else if (opts->vfd==stdio) { + } + else if (opts->vfd == stdio) { HDfprintf(output, "stdio\n"); - } else if (opts->vfd==core) { + } + else if (opts->vfd == core) { HDfprintf(output, "core\n"); - } else if (opts->vfd==split) { + } + else if (opts->vfd == split) { HDfprintf(output, "split\n"); - } else if (opts->vfd==multi) { + } + else if (opts->vfd == multi) { HDfprintf(output, "multi\n"); - } else if (opts->vfd==family) { + } + else if (opts->vfd == family) { HDfprintf(output, "family\n"); - } else if (opts->vfd==direct) { + } + else if (opts->vfd == direct) { HDfprintf(output, "direct\n"); } } @@ -926,8 +937,7 @@ report_parameters(struct options *opts) { char *prefix = HDgetenv("HDF5_PREFIX"); - HDfprintf(output, "Env HDF5_PREFIX=%s\n", - (prefix ? prefix : "not set")); + HDfprintf(output, "Env HDF5_PREFIX=%s\n", (prefix ? prefix : "not set")); } HDfprintf(output, "==== End of Parameters ====\n"); @@ -946,57 +956,56 @@ report_parameters(struct options *opts) static struct options * parse_command_line(int argc, const char *argv[]) { - int opt; + int opt; struct options *cl_opts; - int i, default_rank, actual_rank, ranks[4]; + int i, default_rank, actual_rank, ranks[4]; cl_opts = (struct options *)HDmalloc(sizeof(struct options)); cl_opts->page_buffer_size = 0; - cl_opts->page_size = 0; + cl_opts->page_size = 0; cl_opts->output_file = NULL; - cl_opts->io_types = 0; /* will set default after parsing options */ - cl_opts->num_iters = 1; + cl_opts->io_types = 0; /* will set default after parsing options */ + cl_opts->num_iters = 1; default_rank = 2; - cl_opts->dset_rank = 0; - cl_opts->buf_rank = 0; - cl_opts->chk_rank = 0; + cl_opts->dset_rank = 0; + cl_opts->buf_rank = 0; + cl_opts->chk_rank = 0; cl_opts->order_rank = 0; - for(i = 0; i < MAX_DIMS; i++) { - cl_opts->buf_size[i] = (size_t)((i + 1) * 10); + for (i = 0; i < MAX_DIMS; i++) { + cl_opts->buf_size[i] = (size_t)((i + 1) * 10); cl_opts->dset_size[i] = (hsize_t)((i + 1) * 100); - cl_opts->chk_size[i] = (size_t)((i + 1) * 10); - cl_opts->order[i] = i + 1; + cl_opts->chk_size[i] = (size_t)((i + 1) * 10); + cl_opts->order[i] = i + 1; } cl_opts->vfd = sec2; - cl_opts->print_times = FALSE; /* Printing times is off by default */ - cl_opts->print_raw = FALSE; /* Printing raw data throughput is off by default */ - cl_opts->h5_alignment = 1; /* No alignment for HDF5 objects by default */ - cl_opts->h5_threshold = 1; /* No threshold for aligning HDF5 objects by default */ + cl_opts->print_times = FALSE; /* Printing times is off by default */ + cl_opts->print_raw = FALSE; /* Printing raw data throughput is off by default */ + cl_opts->h5_alignment = 1; /* No alignment for HDF5 objects by default */ + cl_opts->h5_threshold = 1; /* No threshold for aligning HDF5 objects by default */ cl_opts->h5_use_chunks = FALSE; /* Don't chunk the HDF5 dataset by default */ cl_opts->h5_write_only = FALSE; /* Do both read and write by default */ cl_opts->h5_extendable = FALSE; /* Use extendable dataset */ - cl_opts->verify = FALSE; /* No Verify data correctness by default */ + cl_opts->verify = FALSE; /* No Verify data correctness by default */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { - case 'a': - cl_opts->h5_alignment = parse_size_directive(opt_arg); - break; - case 'G': - cl_opts->page_size = parse_size_directive(opt_arg); - break; - case 'b': - cl_opts->page_buffer_size = parse_size_directive(opt_arg); - break; - case 'A': - { + case 'a': + cl_opts->h5_alignment = parse_size_directive(opt_arg); + break; + case 'G': + cl_opts->page_size = parse_size_directive(opt_arg); + break; + case 'b': + cl_opts->page_buffer_size = parse_size_directive(opt_arg); + break; + case 'A': { const char *end = opt_arg; while (end && *end != '\0') { char buf[10]; @@ -1009,11 +1018,12 @@ parse_command_line(int argc, const char *argv[]) if (!HDstrcasecmp(buf, "hdf5")) { cl_opts->io_types |= SIO_HDF5; - } else if (!HDstrcasecmp(buf, "posix")) { + } + else if (!HDstrcasecmp(buf, "posix")) { cl_opts->io_types |= SIO_POSIX; - } else { - HDfprintf(stderr, "sio_perf: invalid --api option %s\n", - buf); + } + else { + HDfprintf(stderr, "sio_perf: invalid --api option %s\n", buf); HDexit(EXIT_FAILURE); } @@ -1029,40 +1039,38 @@ parse_command_line(int argc, const char *argv[]) case 'b': /* the future "binary" option */ break; -#endif /* 0 */ - case 'c': - /* Turn on chunked HDF5 dataset creation */ - cl_opts->h5_use_chunks = 1; - { - const char *end = opt_arg; - int j = 0; +#endif /* 0 */ + case 'c': + /* Turn on chunked HDF5 dataset creation */ + cl_opts->h5_use_chunks = 1; + { + const char *end = opt_arg; + int j = 0; - while (end && *end != '\0') { - char buf[10]; + while (end && *end != '\0') { + char buf[10]; - HDmemset(buf, '\0', sizeof(buf)); + HDmemset(buf, '\0', sizeof(buf)); - for (i = 0; *end != '\0' && *end != ','; ++end) - if (HDisalnum(*end) && i < 10) - buf[i++] = *end; + for (i = 0; *end != '\0' && *end != ','; ++end) + if (HDisalnum(*end) && i < 10) + buf[i++] = *end; - cl_opts->chk_size[j] = parse_size_directive(buf); + cl_opts->chk_size[j] = parse_size_directive(buf); - j++; + j++; - if (*end == '\0') - break; + if (*end == '\0') + break; - end++; + end++; + } + cl_opts->chk_rank = j; } - cl_opts->chk_rank = j; - } - - break; + break; - case 'D': - { + case 'D': { const char *end = opt_arg; while (end && *end != '\0') { @@ -1079,8 +1087,7 @@ parse_command_line(int argc, const char *argv[]) for (j = 0; j < 10 && buf[j] != '\0'; ++j) if (!HDisdigit(buf[j])) { - HDfprintf(stderr, "sio_perf: invalid --debug option %s\n", - buf); + HDfprintf(stderr, "sio_perf: invalid --debug option %s\n", buf); HDexit(EXIT_FAILURE); } @@ -1090,23 +1097,24 @@ parse_command_line(int argc, const char *argv[]) sio_debug_level = 4; else if (sio_debug_level < 0) sio_debug_level = 0; - } else { + } + else { switch (*buf) { - case 'r': - /* Turn on raw data throughput info */ - cl_opts->print_raw = TRUE; - break; - case 't': - /* Turn on time printing */ - cl_opts->print_times = TRUE; - break; - case 'v': - /* Turn on verify data correctness*/ - cl_opts->verify = TRUE; - break; - default: - HDfprintf(stderr, "sio_perf: invalid --debug option %s\n", buf); - HDexit(EXIT_FAILURE); + case 'r': + /* Turn on raw data throughput info */ + cl_opts->print_raw = TRUE; + break; + case 't': + /* Turn on time printing */ + cl_opts->print_times = TRUE; + break; + case 'v': + /* Turn on verify data correctness*/ + cl_opts->verify = TRUE; + break; + default: + HDfprintf(stderr, "sio_perf: invalid --debug option %s\n", buf); + HDexit(EXIT_FAILURE); } } @@ -1118,10 +1126,9 @@ parse_command_line(int argc, const char *argv[]) } break; - case 'e': - { + case 'e': { const char *end = opt_arg; - int j = 0; + int j = 0; while (end && *end != '\0') { char buf[10]; @@ -1146,46 +1153,51 @@ parse_command_line(int argc, const char *argv[]) break; - case 'i': - cl_opts->num_iters = HDatoi(opt_arg); - break; - case 'o': - cl_opts->output_file = opt_arg; - break; - case 'T': - cl_opts->h5_threshold = parse_size_directive(opt_arg); - break; - case 'v': - if (!HDstrcasecmp(opt_arg, "sec2")) { - cl_opts->vfd=sec2; - } else if (!HDstrcasecmp(opt_arg, "stdio")) { - cl_opts->vfd=stdio; - } else if (!HDstrcasecmp(opt_arg, "core")) { - cl_opts->vfd=core; - } else if (!HDstrcasecmp(opt_arg, "split")) { - cl_opts->vfd=split; - } else if (!HDstrcasecmp(opt_arg, "multi")) { - cl_opts->vfd=multi; - } else if (!HDstrcasecmp(opt_arg, "family")) { - cl_opts->vfd=family; - } else if (!HDstrcasecmp(opt_arg, "direct")) { - cl_opts->vfd=direct; - } else { - HDfprintf(stderr, "sio_perf: invalid --api option %s\n", - opt_arg); - HDexit(EXIT_FAILURE); - } - break; - case 'w': - cl_opts->h5_write_only = TRUE; - break; - case 't': - cl_opts->h5_extendable = TRUE; - break; - case 'x': - { + case 'i': + cl_opts->num_iters = HDatoi(opt_arg); + break; + case 'o': + cl_opts->output_file = opt_arg; + break; + case 'T': + cl_opts->h5_threshold = parse_size_directive(opt_arg); + break; + case 'v': + if (!HDstrcasecmp(opt_arg, "sec2")) { + cl_opts->vfd = sec2; + } + else if (!HDstrcasecmp(opt_arg, "stdio")) { + cl_opts->vfd = stdio; + } + else if (!HDstrcasecmp(opt_arg, "core")) { + cl_opts->vfd = core; + } + else if (!HDstrcasecmp(opt_arg, "split")) { + cl_opts->vfd = split; + } + else if (!HDstrcasecmp(opt_arg, "multi")) { + cl_opts->vfd = multi; + } + else if (!HDstrcasecmp(opt_arg, "family")) { + cl_opts->vfd = family; + } + else if (!HDstrcasecmp(opt_arg, "direct")) { + cl_opts->vfd = direct; + } + else { + HDfprintf(stderr, "sio_perf: invalid --api option %s\n", opt_arg); + HDexit(EXIT_FAILURE); + } + break; + case 'w': + cl_opts->h5_write_only = TRUE; + break; + case 't': + cl_opts->h5_extendable = TRUE; + break; + case 'x': { const char *end = opt_arg; - int j = 0; + int j = 0; while (end && *end != '\0') { char buf[10]; @@ -1210,10 +1222,9 @@ parse_command_line(int argc, const char *argv[]) break; - case 'r': - { + case 'r': { const char *end = opt_arg; - int j = 0; + int j = 0; while (end && *end != '\0') { char buf[10]; @@ -1239,12 +1250,12 @@ parse_command_line(int argc, const char *argv[]) break; - case 'h': - case '?': - default: - usage(progname); - HDfree(cl_opts); - return NULL; + case 'h': + case '?': + default: + usage(progname); + HDfree(cl_opts); + return NULL; } } @@ -1256,8 +1267,8 @@ parse_command_line(int argc, const char *argv[]) ranks[2] = cl_opts->order_rank; ranks[3] = cl_opts->chk_rank; - for (i=0; i<4; i++) { - if (ranks[i]>0) { + for (i = 0; i < 4; i++) { + if (ranks[i] > 0) { if (!actual_rank) { actual_rank = ranks[i]; } @@ -1271,12 +1282,12 @@ parse_command_line(int argc, const char *argv[]) if (!actual_rank) actual_rank = default_rank; - cl_opts->dset_rank = actual_rank; - cl_opts->buf_rank = actual_rank; + cl_opts->dset_rank = actual_rank; + cl_opts->buf_rank = actual_rank; cl_opts->order_rank = actual_rank; - cl_opts->chk_rank = actual_rank; + cl_opts->chk_rank = actual_rank; - for (i=0; i<actual_rank; i++) { + for (i = 0; i < actual_rank; i++) { if (cl_opts->order[i] > actual_rank) { exit(EXIT_FAILURE); } @@ -1314,7 +1325,7 @@ static hsize_t parse_size_directive(const char *size) { hsize_t s; - char *endptr; + char * endptr; s = HDstrtoull(size, &endptr, 10); @@ -1358,71 +1369,70 @@ static void usage(const char *prog) { print_version(prog); - HDprintf("usage: %s [OPTIONS]\n", prog); - HDprintf(" OPTIONS\n"); - HDprintf(" -h Print an usage message and exit\n"); - HDprintf(" -A AL Which APIs to test\n"); - HDprintf(" [default: all of them]\n"); - HDprintf(" -c SL Selects chunked storage and defines chunks dimensions\n"); - HDprintf(" and sizes\n"); - HDprintf(" [default: Off]\n"); - HDprintf(" -e SL Dimensions and sizes of dataset\n"); - HDprintf(" [default: 100,200]\n"); - HDprintf(" -i N Number of iterations to perform\n"); - HDprintf(" [default: 1]\n"); - HDprintf(" -r NL Dimension access order (see below for description)\n"); - HDprintf(" [default: 1,2]\n"); - HDprintf(" -t Selects extendable dimensions for HDF5 dataset\n"); - HDprintf(" [default: Off]\n"); - HDprintf(" -v VFD Selects file driver for HDF5 access\n"); - HDprintf(" [default: sec2]\n"); - HDprintf(" -w Perform write tests, not the read tests\n"); - HDprintf(" [default: Off]\n"); - HDprintf(" -x SL Dimensions and sizes of the transfer buffer\n"); - HDprintf(" [default: 10,20]\n"); - HDprintf("\n"); - HDprintf(" N - is an integer > 0.\n"); - HDprintf("\n"); - HDprintf(" S - is a size specifier, an integer > 0 followed by a size indicator:\n"); - HDprintf(" K - Kilobyte (%d)\n", ONE_KB); - HDprintf(" M - Megabyte (%d)\n", ONE_MB); - HDprintf(" G - Gigabyte (%d)\n", ONE_GB); - HDprintf("\n"); - HDprintf(" Example: '37M' is 37 megabytes or %d bytes\n", 37*ONE_MB); - HDprintf("\n"); - HDprintf(" AL - is an API list. Valid values are:\n"); - HDprintf(" hdf5 - HDF5\n"); - HDprintf(" posix - POSIX\n"); - HDprintf("\n"); - HDprintf(" Example: -A posix,hdf5\n"); - HDprintf("\n"); - HDprintf(" NL - is list of integers (N) separated by commas.\n"); - HDprintf("\n"); - HDprintf(" Example: 1,2,3\n"); - HDprintf("\n"); - HDprintf(" SL - is list of size specifiers (S) separated by commas.\n"); - HDprintf("\n"); - HDprintf(" Example: 2K,2K,3K\n"); - HDprintf("\n"); - HDprintf(" The example defines an object (dataset, tranfer buffer) with three\n"); - HDprintf(" dimensions. Be aware that as the number of dimensions increases, the\n"); - HDprintf(" the total size of the object increases exponentially.\n"); - HDprintf("\n"); - HDprintf(" VFD - is an HDF5 file driver specifier. Valid values are:\n"); - HDprintf(" sec2, stdio, core, split, multi, family, direct\n"); - HDprintf("\n"); - HDprintf(" Dimension access order:\n"); - HDprintf(" Data access starts at the cardinal origin of the dataset using the\n"); - HDprintf(" transfer buffer. The next access occurs on a dataset region next to\n"); - HDprintf(" the previous one. For a multidimensional dataset, there are several\n"); - HDprintf(" directions as to where to proceed. This can be specified in the dimension\n"); - HDprintf(" access order. For example, -r 1,2 states that the tool should traverse\n"); - HDprintf(" dimension 1 first, and then dimension 2.\n"); - HDprintf("\n"); - HDprintf(" Environment variables:\n"); - HDprintf(" HDF5_NOCLEANUP Do not remove data files if set [default remove]\n"); - HDprintf(" HDF5_PREFIX Data file prefix\n"); - HDprintf("\n"); - HDfflush(stdout); + HDprintf("usage: %s [OPTIONS]\n", prog); + HDprintf(" OPTIONS\n"); + HDprintf(" -h Print an usage message and exit\n"); + HDprintf(" -A AL Which APIs to test\n"); + HDprintf(" [default: all of them]\n"); + HDprintf(" -c SL Selects chunked storage and defines chunks dimensions\n"); + HDprintf(" and sizes\n"); + HDprintf(" [default: Off]\n"); + HDprintf(" -e SL Dimensions and sizes of dataset\n"); + HDprintf(" [default: 100,200]\n"); + HDprintf(" -i N Number of iterations to perform\n"); + HDprintf(" [default: 1]\n"); + HDprintf(" -r NL Dimension access order (see below for description)\n"); + HDprintf(" [default: 1,2]\n"); + HDprintf(" -t Selects extendable dimensions for HDF5 dataset\n"); + HDprintf(" [default: Off]\n"); + HDprintf(" -v VFD Selects file driver for HDF5 access\n"); + HDprintf(" [default: sec2]\n"); + HDprintf(" -w Perform write tests, not the read tests\n"); + HDprintf(" [default: Off]\n"); + HDprintf(" -x SL Dimensions and sizes of the transfer buffer\n"); + HDprintf(" [default: 10,20]\n"); + HDprintf("\n"); + HDprintf(" N - is an integer > 0.\n"); + HDprintf("\n"); + HDprintf(" S - is a size specifier, an integer > 0 followed by a size indicator:\n"); + HDprintf(" K - Kilobyte (%d)\n", ONE_KB); + HDprintf(" M - Megabyte (%d)\n", ONE_MB); + HDprintf(" G - Gigabyte (%d)\n", ONE_GB); + HDprintf("\n"); + HDprintf(" Example: '37M' is 37 megabytes or %d bytes\n", 37 * ONE_MB); + HDprintf("\n"); + HDprintf(" AL - is an API list. Valid values are:\n"); + HDprintf(" hdf5 - HDF5\n"); + HDprintf(" posix - POSIX\n"); + HDprintf("\n"); + HDprintf(" Example: -A posix,hdf5\n"); + HDprintf("\n"); + HDprintf(" NL - is list of integers (N) separated by commas.\n"); + HDprintf("\n"); + HDprintf(" Example: 1,2,3\n"); + HDprintf("\n"); + HDprintf(" SL - is list of size specifiers (S) separated by commas.\n"); + HDprintf("\n"); + HDprintf(" Example: 2K,2K,3K\n"); + HDprintf("\n"); + HDprintf(" The example defines an object (dataset, tranfer buffer) with three\n"); + HDprintf(" dimensions. Be aware that as the number of dimensions increases, the\n"); + HDprintf(" the total size of the object increases exponentially.\n"); + HDprintf("\n"); + HDprintf(" VFD - is an HDF5 file driver specifier. Valid values are:\n"); + HDprintf(" sec2, stdio, core, split, multi, family, direct\n"); + HDprintf("\n"); + HDprintf(" Dimension access order:\n"); + HDprintf(" Data access starts at the cardinal origin of the dataset using the\n"); + HDprintf(" transfer buffer. The next access occurs on a dataset region next to\n"); + HDprintf(" the previous one. For a multidimensional dataset, there are several\n"); + HDprintf(" directions as to where to proceed. This can be specified in the dimension\n"); + HDprintf(" access order. For example, -r 1,2 states that the tool should traverse\n"); + HDprintf(" dimension 1 first, and then dimension 2.\n"); + HDprintf("\n"); + HDprintf(" Environment variables:\n"); + HDprintf(" HDF5_NOCLEANUP Do not remove data files if set [default remove]\n"); + HDprintf(" HDF5_PREFIX Data file prefix\n"); + HDprintf("\n"); + HDfflush(stdout); } /* end usage() */ - diff --git a/tools/test/perform/sio_perf.h b/tools/test/perform/sio_perf.h index d26c78b..4e11db1 100644 --- a/tools/test/perform/sio_perf.h +++ b/tools/test/perform/sio_perf.h @@ -48,57 +48,57 @@ typedef enum vfdtype_ { } vfdtype; typedef struct parameters_ { - iotype io_type; /* The type of IO test to perform */ - vfdtype vfd; - long num_files; /* Number of files to create */ - long num_dsets; /* Number of datasets to create */ - hsize_t num_bytes; /* Number of bytes in each dset */ - int num_iters; /* Number of times to loop doing the IO */ - int rank; /* Rank of dataset */ - hsize_t dset_size[MAX_DIMS]; /* Dataset size */ - size_t buf_size[MAX_DIMS]; /* Buffer size */ - size_t chk_size[MAX_DIMS]; /* Chunk size */ - int order[MAX_DIMS]; /* Buffer size */ - hsize_t h5_align; /* HDF5 object alignment */ - hsize_t h5_thresh; /* HDF5 object alignment threshold */ - int h5_use_chunks; /* Make HDF5 dataset chunked */ - int h5_extendable; /* Make HDF5 dataset chunked */ - int h5_write_only; /* Perform the write tests only */ - int verify; /* Verify data correctness */ - size_t page_size; - size_t page_buffer_size; + iotype io_type; /* The type of IO test to perform */ + vfdtype vfd; + long num_files; /* Number of files to create */ + long num_dsets; /* Number of datasets to create */ + hsize_t num_bytes; /* Number of bytes in each dset */ + int num_iters; /* Number of times to loop doing the IO */ + int rank; /* Rank of dataset */ + hsize_t dset_size[MAX_DIMS]; /* Dataset size */ + size_t buf_size[MAX_DIMS]; /* Buffer size */ + size_t chk_size[MAX_DIMS]; /* Chunk size */ + int order[MAX_DIMS]; /* Buffer size */ + hsize_t h5_align; /* HDF5 object alignment */ + hsize_t h5_thresh; /* HDF5 object alignment threshold */ + int h5_use_chunks; /* Make HDF5 dataset chunked */ + int h5_extendable; /* Make HDF5 dataset chunked */ + int h5_write_only; /* Perform the write tests only */ + int verify; /* Verify data correctness */ + size_t page_size; + size_t page_buffer_size; } parameters; typedef struct results_ { - herr_t ret_code; - io_time_t *timers; + herr_t ret_code; + io_time_t *timers; } results; #ifndef SUCCESS -#define SUCCESS 0 -#endif /* !SUCCESS */ +#define SUCCESS 0 +#endif /* !SUCCESS */ #ifndef FAIL -#define FAIL -1 -#endif /* !FAIL */ +#define FAIL -1 +#endif /* !FAIL */ -extern FILE *output; /* output file */ -extern io_time_t *timer_g; /* timer: global for stub functions */ -extern int sio_debug_level; /* The debug level: - * 0 - Off - * 1 - Minimal - * 2 - Some more - * 3 - Maximal - * 4 - Even More Debugging (timer stuff) - */ +extern FILE * output; /* output file */ +extern io_time_t *timer_g; /* timer: global for stub functions */ +extern int sio_debug_level; /* The debug level: + * 0 - Off + * 1 - Minimal + * 2 - Some more + * 3 - Maximal + * 4 - Even More Debugging (timer stuff) + */ #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif /* __cplusplus */ extern void do_sio(parameters param, results *res); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* PIO_PERF_H__ */ +#endif /* PIO_PERF_H__ */ diff --git a/tools/test/perform/sio_standalone.c b/tools/test/perform/sio_standalone.c index ac191e5..2fb5737 100644 --- a/tools/test/perform/sio_standalone.c +++ b/tools/test/perform/sio_standalone.c @@ -10,7 +10,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /* This file contains the definition of functions required to build h5perf in * STANDALONE mode. * Created: Christian Chilan, 2005/5/18. @@ -18,29 +17,28 @@ #include "sio_perf.h" - /** From h5tools_utils.c **/ /* global variables */ -int nCols = 80; +int nCols = 80; /* ``get_option'' variables */ -int opt_err = 1; /*get_option prints errors if this is on */ -int opt_ind = 1; /*token pointer */ -const char *opt_arg; /*flag argument (or value) */ - +int opt_err = 1; /*get_option prints errors if this is on */ +int opt_ind = 1; /*token pointer */ +const char *opt_arg; /*flag argument (or value) */ int get_option(int argc, const char **argv, const char *opts, const struct long_options *l_opts) { - static int sp = 1; /* character index in current token */ - int opt_opt = '?'; /* option character passed back to user */ + static int sp = 1; /* character index in current token */ + int opt_opt = '?'; /* option character passed back to user */ if (sp == 1) { /* check for more flag-like tokens */ if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') { return EOF; - } else if (HDstrcmp(argv[opt_ind], "--") == 0) { + } + else if (HDstrcmp(argv[opt_ind], "--") == 0) { opt_ind++; return EOF; } @@ -49,7 +47,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') { /* long command line option */ const char *arg = &argv[opt_ind][2]; - int i; + int i; for (i = 0; l_opts && l_opts[i].name; i++) { size_t len = HDstrlen(l_opts[i].name); @@ -61,22 +59,21 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (l_opts[i].has_arg != no_arg) { if (arg[len] == '=') { opt_arg = &arg[len + 1]; - } else if (opt_ind < (argc - 1) && argv[opt_ind + 1][0] != '-') { + } + else if (opt_ind < (argc - 1) && argv[opt_ind + 1][0] != '-') { opt_arg = argv[++opt_ind]; - } else if (l_opts[i].has_arg == require_arg) { + } + else if (l_opts[i].has_arg == require_arg) { if (opt_err) - HDfprintf(stderr, - "%s: option required for \"--%s\" flag\n", - argv[0], arg); + HDfprintf(stderr, "%s: option required for \"--%s\" flag\n", argv[0], arg); opt_opt = '?'; } - } else { + } + else { if (arg[len] == '=') { if (opt_err) - HDfprintf(stderr, - "%s: no option required for \"%s\" flag\n", - argv[0], arg); + HDfprintf(stderr, "%s: no option required for \"%s\" flag\n", argv[0], arg); opt_opt = '?'; } @@ -98,8 +95,9 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti opt_ind++; sp = 1; - } else { - register char *cp; /* pointer into current token */ + } + else { + register char *cp; /* pointer into current token */ /* short command line option */ opt_opt = argv[opt_ind][sp]; @@ -107,8 +105,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (opt_opt == ':' || (cp = strchr(opts, opt_opt)) == 0) { if (opt_err) - HDfprintf(stderr, "%s: unknown option \"%c\"\n", - argv[0], opt_opt); + HDfprintf(stderr, "%s: unknown option \"%c\"\n", argv[0], opt_opt); /* if no chars left in this token, move to next token */ if (argv[opt_ind][++sp] == '\0') { @@ -124,20 +121,21 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (argv[opt_ind][sp + 1] != '\0') { /* flag value is rest of current token */ opt_arg = &argv[opt_ind++][sp + 1]; - } else if (++opt_ind >= argc) { + } + else if (++opt_ind >= argc) { if (opt_err) - HDfprintf(stderr, - "%s: value expected for option \"%c\"\n", - argv[0], opt_opt); + HDfprintf(stderr, "%s: value expected for option \"%c\"\n", argv[0], opt_opt); opt_opt = '?'; - } else { + } + else { /* flag value is next token */ opt_arg = argv[opt_ind++]; } sp = 1; - } else { + } + else { /* set up to look at next char in token, next time */ if (argv[opt_ind][++sp] == '\0') { /* no more in current token, so setup next token */ @@ -153,12 +151,9 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti return opt_opt; } - void print_version(const char *progname) { - printf("%s: Version %u.%u.%u%s%s\n", - progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, + printf("%s: Version %u.%u.%u%s%s\n", progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, H5_VERS_SUBRELEASE[0] ? "-" : "", H5_VERS_SUBRELEASE); } - diff --git a/tools/test/perform/sio_standalone.h b/tools/test/perform/sio_standalone.h index 74a6245..4001257 100644 --- a/tools/test/perform/sio_standalone.h +++ b/tools/test/perform/sio_standalone.h @@ -19,465 +19,464 @@ /** From H5private.h **/ -#include "H5public.h" /* Include Public Definitions */ - +#include "H5public.h" /* Include Public Definitions */ /* * Include ANSI-C header files. */ #ifdef H5_STDC_HEADERS -# include <assert.h> -# include <ctype.h> -# include <errno.h> -# include <fcntl.h> -# include <float.h> -# include <limits.h> -# include <math.h> -# include <signal.h> -# include <stdarg.h> -# include <stdio.h> -# include <stdlib.h> -# include <string.h> +#include <assert.h> +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <float.h> +#include <limits.h> +#include <math.h> +#include <signal.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #endif /* maximum of two, three, or four values */ #undef MAX -#define MAX(a,b) (((a)>(b)) ? (a) : (b)) -#define MAX2(a,b) MAX(a,b) -#define MAX3(a,b,c) MAX(a,MAX(b,c)) -#define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define MAX2(a, b) MAX(a, b) +#define MAX3(a, b, c) MAX(a, MAX(b, c)) +#define MAX4(a, b, c, d) MAX(MAX(a, b), MAX(c, d)) -#define H5_FLT_ABS_EQUAL(X,Y) (HDfabsf((X)-(Y)) < FLT_EPSILON) -#define H5_DBL_ABS_EQUAL(X,Y) (HDfabs ((X)-(Y)) < DBL_EPSILON) -#define H5_LDBL_ABS_EQUAL(X,Y) (HDfabsl((X)-(Y)) < LDBL_EPSILON) +#define H5_FLT_ABS_EQUAL(X, Y) (HDfabsf((X) - (Y)) < FLT_EPSILON) +#define H5_DBL_ABS_EQUAL(X, Y) (HDfabs((X) - (Y)) < DBL_EPSILON) +#define H5_LDBL_ABS_EQUAL(X, Y) (HDfabsl((X) - (Y)) < LDBL_EPSILON) -#define H5_FLT_REL_EQUAL(X,Y,M) (HDfabsf(((Y)-(X)) / (X)) < (M)) -#define H5_DBL_REL_EQUAL(X,Y,M) (HDfabs (((Y)-(X)) / (X)) < (M)) -#define H5_LDBL_REL_EQUAL(X,Y,M) (HDfabsl(((Y)-(X)) / (X)) < (M)) +#define H5_FLT_REL_EQUAL(X, Y, M) (HDfabsf(((Y) - (X)) / (X)) < (M)) +#define H5_DBL_REL_EQUAL(X, Y, M) (HDfabs(((Y) - (X)) / (X)) < (M)) +#define H5_LDBL_REL_EQUAL(X, Y, M) (HDfabsl(((Y) - (X)) / (X)) < (M)) /* * Redefine all the POSIX functions. We should never see a POSIX * function (or any other non-HDF5 function) in the source! */ -#define HDabort() abort() -#define HDabs(X) abs(X) +#define HDabort() abort() +#define HDabs(X) abs(X) #ifdef H5_HAVE_WIN32_API -#define HDaccess(F,M) _access(F, M) -#define R_OK 4 /* Test for read permission. */ -#define W_OK 2 /* Test for write permission. */ -#define X_OK 1 /* Test for execute permission. */ -#define F_OK 0 /* Test for existence. */ -#else /* H5_HAVE_WIN32_API */ -#define HDaccess(F,M) access(F, M) +#define HDaccess(F, M) _access(F, M) +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK 1 /* Test for execute permission. */ +#define F_OK 0 /* Test for existence. */ +#else /* H5_HAVE_WIN32_API */ +#define HDaccess(F, M) access(F, M) #ifndef F_OK -#define F_OK 00 +#define F_OK 00 #define W_OK 02 #define R_OK 04 #endif #endif /* H5_HAVE_WIN32_API */ -#define HDacos(X) acos(X) +#define HDacos(X) acos(X) #ifdef H5_HAVE_ALARM -#define HDalarm(N) alarm(N) +#define HDalarm(N) alarm(N) #else /* H5_HAVE_ALARM */ -#define HDalarm(N) (0) +#define HDalarm(N) (0) #endif /* H5_HAVE_ALARM */ -#define HDasctime(T) asctime(T) -#define HDasin(X) asin(X) -#define HDasprintf asprintf /*varargs*/ -#define HDassert(X) assert(X) -#define HDatan(X) atan(X) -#define HDatan2(X,Y) atan2(X,Y) -#define HDatexit(F) atexit(F) -#define HDatof(S) atof(S) -#define HDatoi(S) atoi(S) -#define HDatol(S) atol(S) -#define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F) -#define HDcalloc(N,Z) calloc(N,Z) -#define HDceil(X) ceil(X) -#define HDcfgetispeed(T) cfgetispeed(T) -#define HDcfgetospeed(T) cfgetospeed(T) -#define HDcfsetispeed(T,S) cfsetispeed(T,S) -#define HDcfsetospeed(T,S) cfsetospeed(T,S) -#define HDchdir(S) chdir(S) -#define HDchmod(S,M) chmod(S,M) -#define HDchown(S,O,G) chown(S,O,G) -#define HDclearerr(F) clearerr(F) -#define HDclock() clock() -#define HDclose(F) close(F) -#define HDclosedir(D) closedir(D) -#define HDcos(X) cos(X) -#define HDcosh(X) cosh(X) -#define HDcreat(S,M) creat(S,M) -#define HDctermid(S) ctermid(S) -#define HDctime(T) ctime(T) -#define HDcuserid(S) cuserid(S) +#define HDasctime(T) asctime(T) +#define HDasin(X) asin(X) +#define HDasprintf asprintf /*varargs*/ +#define HDassert(X) assert(X) +#define HDatan(X) atan(X) +#define HDatan2(X, Y) atan2(X, Y) +#define HDatexit(F) atexit(F) +#define HDatof(S) atof(S) +#define HDatoi(S) atoi(S) +#define HDatol(S) atol(S) +#define HDbsearch(K, B, N, Z, F) bsearch(K, B, N, Z, F) +#define HDcalloc(N, Z) calloc(N, Z) +#define HDceil(X) ceil(X) +#define HDcfgetispeed(T) cfgetispeed(T) +#define HDcfgetospeed(T) cfgetospeed(T) +#define HDcfsetispeed(T, S) cfsetispeed(T, S) +#define HDcfsetospeed(T, S) cfsetospeed(T, S) +#define HDchdir(S) chdir(S) +#define HDchmod(S, M) chmod(S, M) +#define HDchown(S, O, G) chown(S, O, G) +#define HDclearerr(F) clearerr(F) +#define HDclock() clock() +#define HDclose(F) close(F) +#define HDclosedir(D) closedir(D) +#define HDcos(X) cos(X) +#define HDcosh(X) cosh(X) +#define HDcreat(S, M) creat(S, M) +#define HDctermid(S) ctermid(S) +#define HDctime(T) ctime(T) +#define HDcuserid(S) cuserid(S) #ifdef H5_HAVE_DIFFTIME -#define HDdifftime(X,Y) difftime(X,Y) +#define HDdifftime(X, Y) difftime(X, Y) #else -#define HDdifftime(X,Y) ((double)(X)-(double)(Y)) +#define HDdifftime(X, Y) ((double)(X) - (double)(Y)) #endif -#define HDdiv(X,Y) div(X,Y) -#define HDdup(F) dup(F) -#define HDdup2(F,I) dup2(F,I) +#define HDdiv(X, Y) div(X, Y) +#define HDdup(F) dup(F) +#define HDdup2(F, I) dup2(F, I) /* execl() variable arguments */ /* execle() variable arguments */ /* execlp() variable arguments */ -#define HDexecv(S,AV) execv(S,AV) -#define HDexecve(S,AV,E) execve(S,AV,E) -#define HDexecvp(S,AV) execvp(S,AV) -#define HDexit(N) exit(N) -#define HD_exit(N) _exit(N) -#define HDexp(X) exp(X) -#define HDfabs(X) fabs(X) +#define HDexecv(S, AV) execv(S, AV) +#define HDexecve(S, AV, E) execve(S, AV, E) +#define HDexecvp(S, AV) execvp(S, AV) +#define HDexit(N) exit(N) +#define HD_exit(N) _exit(N) +#define HDexp(X) exp(X) +#define HDfabs(X) fabs(X) /* use ABS() because fabsf() fabsl() are not common yet. */ -#define HDfabsf(X) ABS(X) -#define HDfabsl(X) ABS(X) -#define HDfclose(F) fclose(F) +#define HDfabsf(X) ABS(X) +#define HDfabsl(X) ABS(X) +#define HDfclose(F) fclose(F) /* fcntl() variable arguments */ -#define HDfdopen(N,S) fdopen(N,S) -#define HDfeof(F) feof(F) -#define HDferror(F) ferror(F) -#define HDfflush(F) fflush(F) -#define HDfgetc(F) fgetc(F) -#define HDfgetpos(F,P) fgetpos(F,P) -#define HDfgets(S,N,F) fgets(S,N,F) +#define HDfdopen(N, S) fdopen(N, S) +#define HDfeof(F) feof(F) +#define HDferror(F) ferror(F) +#define HDfflush(F) fflush(F) +#define HDfgetc(F) fgetc(F) +#define HDfgetpos(F, P) fgetpos(F, P) +#define HDfgets(S, N, F) fgets(S, N, F) #ifdef H5_HAVE_WIN32_API -#define HDfileno(F) _fileno(F) +#define HDfileno(F) _fileno(F) #else /* H5_HAVE_WIN32_API */ -#define HDfileno(F) fileno(F) +#define HDfileno(F) fileno(F) #endif /* H5_HAVE_WIN32_API */ -#define HDfloor(X) floor(X) -#define HDfmod(X,Y) fmod(X,Y) -#define HDfopen(S,M) fopen(S,M) -#define HDfork() fork() -#define HDfpathconf(F,N) fpathconf(F,N) -#define HDfprintf fprintf -#define HDfputc(C,F) fputc(C,F) -#define HDfputs(S,F) fputs(S,F) -#define HDfread(M,Z,N,F) fread(M,Z,N,F) -#define HDfree(M) free(M) -#define HDfreopen(S,M,F) freopen(S,M,F) -#define HDfrexp(X,N) frexp(X,N) +#define HDfloor(X) floor(X) +#define HDfmod(X, Y) fmod(X, Y) +#define HDfopen(S, M) fopen(S, M) +#define HDfork() fork() +#define HDfpathconf(F, N) fpathconf(F, N) +#define HDfprintf fprintf +#define HDfputc(C, F) fputc(C, F) +#define HDfputs(S, F) fputs(S, F) +#define HDfread(M, Z, N, F) fread(M, Z, N, F) +#define HDfree(M) free(M) +#define HDfreopen(S, M, F) freopen(S, M, F) +#define HDfrexp(X, N) frexp(X, N) /* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */ #ifdef H5_HAVE_FREXPF -#define HDfrexpf(X,N) frexpf(X,N) +#define HDfrexpf(X, N) frexpf(X, N) #else /* H5_HAVE_FREXPF */ -#define HDfrexpf(X,N) frexp(X,N) +#define HDfrexpf(X, N) frexp(X, N) #endif /* H5_HAVE_FREXPF */ #ifdef H5_HAVE_FREXPL -#define HDfrexpl(X,N) frexpl(X,N) +#define HDfrexpl(X, N) frexpl(X, N) #else /* H5_HAVE_FREXPL */ -#define HDfrexpl(X,N) frexp(X,N) +#define HDfrexpl(X, N) frexp(X, N) #endif /* H5_HAVE_FREXPL */ /* fscanf() variable arguments */ #ifdef H5_HAVE_FSEEKO - #define HDfseek(F,O,W) fseeko(F,O,W) +#define HDfseek(F, O, W) fseeko(F, O, W) #else - #define HDfseek(F,O,W) fseek(F,O,W) +#define HDfseek(F, O, W) fseek(F, O, W) #endif -#define HDfsetpos(F,P) fsetpos(F,P) +#define HDfsetpos(F, P) fsetpos(F, P) /* definitions related to the file stat utilities. * Windows have its own function names. * For Unix, if off_t is not 64bit big, try use the pseudo-standard * xxx64 versions if available. */ #ifdef H5_HAVE_WIN32_API - #define HDfstat(F,B) _fstati64(F,B) - #define HDlstat(S,B) _lstati64(S,B) - #define HDstat(S,B) _stati64(S,B) - typedef struct _stati64 h5_stat_t; - typedef __int64 h5_stat_size_t; - #define HDoff_t __int64 -#elif H5_SIZEOF_OFF_T!=8 && H5_SIZEOF_OFF64_T==8 && defined(H5_HAVE_STAT64) - #define HDfstat(F,B) fstat64(F,B) - #define HDlstat(S,B) lstat64(S,B) - #define HDstat(S,B) stat64(S,B) - typedef struct stat64 h5_stat_t; - typedef off64_t h5_stat_size_t; - #define HDoff_t off64_t +#define HDfstat(F, B) _fstati64(F, B) +#define HDlstat(S, B) _lstati64(S, B) +#define HDstat(S, B) _stati64(S, B) +typedef struct _stati64 h5_stat_t; +typedef __int64 h5_stat_size_t; +#define HDoff_t __int64 +#elif H5_SIZEOF_OFF_T != 8 && H5_SIZEOF_OFF64_T == 8 && defined(H5_HAVE_STAT64) +#define HDfstat(F, B) fstat64(F, B) +#define HDlstat(S, B) lstat64(S, B) +#define HDstat(S, B) stat64(S, B) +typedef struct stat64 h5_stat_t; +typedef off64_t h5_stat_size_t; +#define HDoff_t off64_t #else - #define HDfstat(F,B) fstat(F,B) - #define HDlstat(S,B) lstat(S,B) - #define HDstat(S,B) stat(S,B) - typedef struct stat h5_stat_t; - typedef off_t h5_stat_size_t; - #define HDoff_t off_t +#define HDfstat(F, B) fstat(F, B) +#define HDlstat(S, B) lstat(S, B) +#define HDstat(S, B) stat(S, B) +typedef struct stat h5_stat_t; +typedef off_t h5_stat_size_t; +#define HDoff_t off_t #endif -#define HDftell(F) ftell(F) -#define HDftruncate(F,L) ftruncate(F,L) -#define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F) -#define HDgetc(F) getc(F) -#define HDgetchar() getchar() -#define HDgetcwd(S,Z) getcwd(S,Z) -#define HDgetegid() getegid() -#define HDgetenv(S) getenv(S) -#define HDgeteuid() geteuid() -#define HDgetgid() getgid() -#define HDgetgrgid(G) getgrgid(G) -#define HDgetgrnam(S) getgrnam(S) -#define HDgetgroups(Z,G) getgroups(Z,G) +#define HDftell(F) ftell(F) +#define HDftruncate(F, L) ftruncate(F, L) +#define HDfwrite(M, Z, N, F) fwrite(M, Z, N, F) +#define HDgetc(F) getc(F) +#define HDgetchar() getchar() +#define HDgetcwd(S, Z) getcwd(S, Z) +#define HDgetegid() getegid() +#define HDgetenv(S) getenv(S) +#define HDgeteuid() geteuid() +#define HDgetgid() getgid() +#define HDgetgrgid(G) getgrgid(G) +#define HDgetgrnam(S) getgrnam(S) +#define HDgetgroups(Z, G) getgroups(Z, G) #ifdef H5_HAVE_WIN32_API -#define HDgetlogin() Wgetlogin() +#define HDgetlogin() Wgetlogin() #else /* H5_HAVE_WIN32_API */ -#define HDgetlogin() getlogin() +#define HDgetlogin() getlogin() #endif /* H5_HAVE_WIN32_API */ -#define HDgetpgrp() getpgrp() -#define HDgetpid() getpid() -#define HDgetppid() getppid() -#define HDgetpwnam(S) getpwnam(S) -#define HDgetpwuid(U) getpwuid(U) -#define HDgetrusage(X,S) getrusage(X,S) +#define HDgetpgrp() getpgrp() +#define HDgetpid() getpid() +#define HDgetppid() getppid() +#define HDgetpwnam(S) getpwnam(S) +#define HDgetpwuid(U) getpwuid(U) +#define HDgetrusage(X, S) getrusage(X, S) /* Don't define a macro for gets() - it was removed in C11 */ #ifdef H5_HAVE_WIN32_API - H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); -#define HDgettimeofday(V,Z) Wgettimeofday(V,Z) +H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); +#define HDgettimeofday(V, Z) Wgettimeofday(V, Z) #else /* H5_HAVE_WIN32_API */ -#define HDgettimeofday(S,P) gettimeofday(S,P) +#define HDgettimeofday(S, P) gettimeofday(S, P) #endif /* H5_HAVE_WIN32_API */ -#define HDgetuid() getuid() -#define HDgmtime(T) gmtime(T) -#define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ -#define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ -#define HDisatty(F) isatty(F) -#define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ -#define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ -#define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ -#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ -#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ -#define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ -#define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ -#define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ -#define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ -#define HDkill(P,S) kill(P,S) -#define HDlabs(X) labs(X) -#define HDldexp(X,N) ldexp(X,N) -#define HDldiv(X,Y) ldiv(X,Y) -#define HDlink(OLD,NEW) link(OLD,NEW) -#define HDlocaleconv() localeconv() -#define HDlocaltime(T) localtime(T) -#define HDlog(X) log(X) -#define HDlog10(X) log10(X) -#define HDlongjmp(J,N) longjmp(J,N) +#define HDgetuid() getuid() +#define HDgmtime(T) gmtime(T) +#define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ +#define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ +#define HDisatty(F) isatty(F) +#define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ +#define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ +#define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ +#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ +#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ +#define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ +#define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ +#define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ +#define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ +#define HDkill(P, S) kill(P, S) +#define HDlabs(X) labs(X) +#define HDldexp(X, N) ldexp(X, N) +#define HDldiv(X, Y) ldiv(X, Y) +#define HDlink(OLD, NEW) link(OLD, NEW) +#define HDlocaleconv() localeconv() +#define HDlocaltime(T) localtime(T) +#define HDlog(X) log(X) +#define HDlog10(X) log10(X) +#define HDlongjmp(J, N) longjmp(J, N) #ifdef H5_HAVE_WIN32_API - #define HDlseek(F,O,W) _lseeki64(F,O,W) +#define HDlseek(F, O, W) _lseeki64(F, O, W) #else - #ifdef H5_HAVE_LSEEK64 - #define HDlseek(F,O,W) lseek64(F,O,W) - #else - #define HDlseek(F,O,W) lseek(F,O,W) - #endif +#ifdef H5_HAVE_LSEEK64 +#define HDlseek(F, O, W) lseek64(F, O, W) +#else +#define HDlseek(F, O, W) lseek(F, O, W) +#endif #endif -#define HDmalloc(Z) malloc(Z) -#define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z) -#define HDmblen(S,N) mblen(S,N) -#define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z) -#define HDmbtowc(P,S,Z) mbtowc(P,S,Z) -#define HDmemchr(S,C,Z) memchr(S,C,Z) -#define HDmemcmp(X,Y,Z) memcmp(X,Y,Z) +#define HDmalloc(Z) malloc(Z) +#define HDposix_memalign(P, A, Z) posix_memalign(P, A, Z) +#define HDmblen(S, N) mblen(S, N) +#define HDmbstowcs(P, S, Z) mbstowcs(P, S, Z) +#define HDmbtowc(P, S, Z) mbtowc(P, S, Z) +#define HDmemchr(S, C, Z) memchr(S, C, Z) +#define HDmemcmp(X, Y, Z) memcmp(X, Y, Z) /* * The (char*) casts are required for the DEC when optimizations are turned * on and the source and/or destination are not aligned. */ -#define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z) -#define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z) +#define HDmemcpy(X, Y, Z) memcpy((char *)(X), (const char *)(Y), Z) +#define HDmemmove(X, Y, Z) memmove((char *)(X), (const char *)(Y), Z) /* * The (void*) cast just avoids a compiler warning in H5_HAVE_VISUAL_STUDIO */ #ifdef H5_HAVE_VISUAL_STUDIO -#define HDmemset(X,C,Z) memset((void*)(X),C,Z) +#define HDmemset(X, C, Z) memset((void *)(X), C, Z) #else /* H5_HAVE_VISUAL_STUDIO */ -#define HDmemset(X,C,Z) memset(X,C,Z) +#define HDmemset(X, C, Z) memset(X, C, Z) #endif /* H5_HAVE_VISUAL_STUDIO */ #ifdef H5_HAVE_WIN32_API -#define HDmkdir(S,M) _mkdir(S) +#define HDmkdir(S, M) _mkdir(S) #else /* H5_HAVE_WIN32_API */ -#define HDmkdir(S,M) mkdir(S,M) +#define HDmkdir(S, M) mkdir(S, M) #endif /* H5_HAVE_WIN32_API */ -#define HDmkfifo(S,M) mkfifo(S,M) -#define HDmktime(T) mktime(T) -#define HDmodf(X,Y) modf(X,Y) +#define HDmkfifo(S, M) mkfifo(S, M) +#define HDmktime(T) mktime(T) +#define HDmodf(X, Y) modf(X, Y) #ifdef _O_BINARY -#define HDopen(S,F,M) open(S,F|_O_BINARY,M) +#define HDopen(S, F, M) open(S, F | _O_BINARY, M) #else -#define HDopen(S,F,M) open(S,F,M) +#define HDopen(S, F, M) open(S, F, M) #endif -#define HDopendir(S) opendir(S) -#define HDpathconf(S,N) pathconf(S,N) -#define HDpause() pause() -#define HDperror(S) perror(S) -#define HDpipe(F) pipe(F) -#define HDpow(X,Y) pow(X,Y) +#define HDopendir(S) opendir(S) +#define HDpathconf(S, N) pathconf(S, N) +#define HDpause() pause() +#define HDperror(S) perror(S) +#define HDpipe(F) pipe(F) +#define HDpow(X, Y) pow(X, Y) /* printf() variable arguments */ -#define HDprintf(...) HDfprintf(stdout, __VA_ARGS__) -#define HDputc(C,F) putc(C,F) -#define HDputchar(C) putchar(C) -#define HDputs(S) puts(S) -#define HDqsort(M,N,Z,F) qsort(M,N,Z,F) -#define HDraise(N) raise(N) +#define HDprintf(...) HDfprintf(stdout, __VA_ARGS__) +#define HDputc(C, F) putc(C, F) +#define HDputchar(C) putchar(C) +#define HDputs(S) puts(S) +#define HDqsort(M, N, Z, F) qsort(M, N, Z, F) +#define HDraise(N) raise(N) #ifdef H5_HAVE_RAND_R -#define HDrandom() HDrand() +#define HDrandom() HDrand() H5_DLL int HDrand(void); #elif H5_HAVE_RANDOM -#define HDrand() random() -#define HDrandom() random() +#define HDrand() random() +#define HDrandom() random() #else -#define HDrand() rand() -#define HDrandom() rand() +#define HDrand() rand() +#define HDrandom() rand() #endif -#define HDread(F,M,Z) read(F,M,Z) -#define HDreaddir(D) readdir(D) -#define HDrealloc(M,Z) realloc(M,Z) -#define HDremove(S) remove(S) -#define HDrename(OLD,NEW) rename(OLD,NEW) -#define HDrewind(F) rewind(F) -#define HDrewinddir(D) rewinddir(D) -#define HDrmdir(S) rmdir(S) +#define HDread(F, M, Z) read(F, M, Z) +#define HDreaddir(D) readdir(D) +#define HDrealloc(M, Z) realloc(M, Z) +#define HDremove(S) remove(S) +#define HDrename(OLD, NEW) rename(OLD, NEW) +#define HDrewind(F) rewind(F) +#define HDrewinddir(D) rewinddir(D) +#define HDrmdir(S) rmdir(S) /* scanf() variable arguments */ -#define HDsetbuf(F,S) setbuf(F,S) -#define HDsetgid(G) setgid(G) -#define HDsetjmp(J) setjmp(J) -#define HDsetlocale(N,S) setlocale(N,S) -#define HDsetpgid(P,PG) setpgid(P,PG) -#define HDsetsid() setsid() -#define HDsetuid(U) setuid(U) +#define HDsetbuf(F, S) setbuf(F, S) +#define HDsetgid(G) setgid(G) +#define HDsetjmp(J) setjmp(J) +#define HDsetlocale(N, S) setlocale(N, S) +#define HDsetpgid(P, PG) setpgid(P, PG) +#define HDsetsid() setsid() +#define HDsetuid(U) setuid(U) /* Windows does not permit setting the buffer size to values less than 2. */ #ifndef H5_HAVE_WIN32_API -#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z) +#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, Z) #else -#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2)) +#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, (Z > 1 ? Z : 2)) #endif -#define HDsigaddset(S,N) sigaddset(S,N) -#define HDsigdelset(S,N) sigdelset(S,N) -#define HDsigemptyset(S) sigemptyset(S) -#define HDsigfillset(S) sigfillset(S) -#define HDsigismember(S,N) sigismember(S,N) -#define HDsiglongjmp(J,N) siglongjmp(J,N) -#define HDsignal(N,F) signal(N,F) -#define HDsigpending(S) sigpending(S) -#define HDsigprocmask(H,S,O) sigprocmask(H,S,O) -#define HDsigsetjmp(J,N) sigsetjmp(J,N) -#define HDsigsuspend(S) sigsuspend(S) -#define HDsin(X) sin(X) -#define HDsinh(X) sinh(X) -#define HDsleep(N) sleep(N) +#define HDsigaddset(S, N) sigaddset(S, N) +#define HDsigdelset(S, N) sigdelset(S, N) +#define HDsigemptyset(S) sigemptyset(S) +#define HDsigfillset(S) sigfillset(S) +#define HDsigismember(S, N) sigismember(S, N) +#define HDsiglongjmp(J, N) siglongjmp(J, N) +#define HDsignal(N, F) signal(N, F) +#define HDsigpending(S) sigpending(S) +#define HDsigprocmask(H, S, O) sigprocmask(H, S, O) +#define HDsigsetjmp(J, N) sigsetjmp(J, N) +#define HDsigsuspend(S) sigsuspend(S) +#define HDsin(X) sin(X) +#define HDsinh(X) sinh(X) +#define HDsleep(N) sleep(N) #ifdef H5_HAVE_WIN32_API -H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...); -#define HDsnprintf c99_snprintf /*varargs*/ +H5_DLL int c99_snprintf(char *str, size_t size, const char *format, ...); +#define HDsnprintf c99_snprintf /*varargs*/ #else -#define HDsnprintf snprintf /*varargs*/ +#define HDsnprintf snprintf /*varargs*/ #endif /* sprintf() variable arguments */ -#define HDsprintf sprintf /*varargs*/ -#define HDsqrt(X) sqrt(X) +#define HDsprintf sprintf /*varargs*/ +#define HDsqrt(X) sqrt(X) #ifdef H5_HAVE_RAND_R H5_DLL void HDsrand(unsigned int seed); -#define HDsrandom(S) HDsrand(S) +#define HDsrandom(S) HDsrand(S) #elif H5_HAVE_RANDOM -#define HDsrand(S) srandom(S) -#define HDsrandom(S) srandom(S) +#define HDsrand(S) srandom(S) +#define HDsrandom(S) srandom(S) #else -#define HDsrand(S) srand(S) -#define HDsrandom(S) srand(S) +#define HDsrand(S) srand(S) +#define HDsrandom(S) srand(S) #endif /* sscanf() variable arguments */ #ifdef H5_HAVE_WIN32_API -#define HDstrcasecmp(A,B) _stricmp(A,B) +#define HDstrcasecmp(A, B) _stricmp(A, B) #else -#define HDstrcasecmp(X,Y) strcasecmp(X,Y) +#define HDstrcasecmp(X, Y) strcasecmp(X, Y) #endif -#define HDstrcat(X,Y) strcat(X,Y) -#define HDstrchr(S,C) strchr(S,C) -#define HDstrcmp(X,Y) strcmp(X,Y) -#define HDstrcoll(X,Y) strcoll(X,Y) -#define HDstrcpy(X,Y) strcpy(X,Y) -#define HDstrcspn(X,Y) strcspn(X,Y) -#define HDstrerror(N) strerror(N) -#define HDstrftime(S,Z,F,T) strftime(S,Z,F,T) -#define HDstrlen(S) strlen(S) -#define HDstrncat(X,Y,Z) strncat(X,Y,Z) -#define HDstrncmp(X,Y,Z) strncmp(X,Y,Z) -#define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) -#define HDstrpbrk(X,Y) strpbrk(X,Y) -#define HDstrrchr(S,C) strrchr(S,C) -#define HDstrspn(X,Y) strspn(X,Y) -#define HDstrstr(X,Y) strstr(X,Y) -#define HDstrtod(S,R) strtod(S,R) -#define HDstrtok(X,Y) strtok(X,Y) -#define HDstrtol(S,R,N) strtol(S,R,N) -H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); -#define HDstrtoul(S,R,N) strtoul(S,R,N) +#define HDstrcat(X, Y) strcat(X, Y) +#define HDstrchr(S, C) strchr(S, C) +#define HDstrcmp(X, Y) strcmp(X, Y) +#define HDstrcoll(X, Y) strcoll(X, Y) +#define HDstrcpy(X, Y) strcpy(X, Y) +#define HDstrcspn(X, Y) strcspn(X, Y) +#define HDstrerror(N) strerror(N) +#define HDstrftime(S, Z, F, T) strftime(S, Z, F, T) +#define HDstrlen(S) strlen(S) +#define HDstrncat(X, Y, Z) strncat(X, Y, Z) +#define HDstrncmp(X, Y, Z) strncmp(X, Y, Z) +#define HDstrncpy(X, Y, Z) strncpy(X, Y, Z) +#define HDstrpbrk(X, Y) strpbrk(X, Y) +#define HDstrrchr(S, C) strrchr(S, C) +#define HDstrspn(X, Y) strspn(X, Y) +#define HDstrstr(X, Y) strstr(X, Y) +#define HDstrtod(S, R) strtod(S, R) +#define HDstrtok(X, Y) strtok(X, Y) +#define HDstrtol(S, R, N) strtol(S, R, N) +H5_DLL int64_t HDstrtoll(const char *s, const char **rest, int base); +#define HDstrtoul(S, R, N) strtoul(S, R, N) #ifdef H5_HAVE_WIN32_API -#define HDstrtoull(S,R,N) _strtoui64(S,R,N) +#define HDstrtoull(S, R, N) _strtoui64(S, R, N) #else -#define HDstrtoull(S,R,N) strtoull(S,R,N) +#define HDstrtoull(S, R, N) strtoull(S, R, N) #endif -#define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z) -#define HDsysconf(N) sysconf(N) -#define HDsystem(S) system(S) -#define HDtan(X) tan(X) -#define HDtanh(X) tanh(X) -#define HDtcdrain(F) tcdrain(F) -#define HDtcflow(F,A) tcflow(F,A) -#define HDtcflush(F,N) tcflush(F,N) -#define HDtcgetattr(F,T) tcgetattr(F,T) -#define HDtcgetpgrp(F) tcgetpgrp(F) -#define HDtcsendbreak(F,N) tcsendbreak(F,N) -#define HDtcsetattr(F,O,T) tcsetattr(F,O,T) -#define HDtcsetpgrp(F,N) tcsetpgrp(F,N) -#define HDtime(T) time(T) -#define HDtimes(T) times(T) -#define HDtmpfile() tmpfile() -#define HDtmpnam(S) tmpnam(S) -#define HDtolower(C) tolower(C) -#define HDtoupper(C) toupper(C) -#define HDttyname(F) ttyname(F) -#define HDtzset() tzset() -#define HDumask(N) umask(N) -#define HDuname(S) uname(S) -#define HDungetc(C,F) ungetc(C,F) +#define HDstrxfrm(X, Y, Z) strxfrm(X, Y, Z) +#define HDsysconf(N) sysconf(N) +#define HDsystem(S) system(S) +#define HDtan(X) tan(X) +#define HDtanh(X) tanh(X) +#define HDtcdrain(F) tcdrain(F) +#define HDtcflow(F, A) tcflow(F, A) +#define HDtcflush(F, N) tcflush(F, N) +#define HDtcgetattr(F, T) tcgetattr(F, T) +#define HDtcgetpgrp(F) tcgetpgrp(F) +#define HDtcsendbreak(F, N) tcsendbreak(F, N) +#define HDtcsetattr(F, O, T) tcsetattr(F, O, T) +#define HDtcsetpgrp(F, N) tcsetpgrp(F, N) +#define HDtime(T) time(T) +#define HDtimes(T) times(T) +#define HDtmpfile() tmpfile() +#define HDtmpnam(S) tmpnam(S) +#define HDtolower(C) tolower(C) +#define HDtoupper(C) toupper(C) +#define HDttyname(F) ttyname(F) +#define HDtzset() tzset() +#define HDumask(N) umask(N) +#define HDuname(S) uname(S) +#define HDungetc(C, F) ungetc(C, F) #ifdef H5_HAVE_WIN32_API -#define HDunlink(S) _unlink(S) +#define HDunlink(S) _unlink(S) #else -#define HDunlink(S) unlink(S) +#define HDunlink(S) unlink(S) #endif -#define HDutime(S,T) utime(S,T) -#define HDva_arg(A,T) va_arg(A,T) -#define HDva_end(A) va_end(A) -#define HDva_start(A,P) va_start(A,P) -#define HDvasprintf(RET,FMT,A) vasprintf(RET,FMT,A) -#define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A) -#define HDvprintf(FMT,A) vprintf(FMT,A) -#define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A) +#define HDutime(S, T) utime(S, T) +#define HDva_arg(A, T) va_arg(A, T) +#define HDva_end(A) va_end(A) +#define HDva_start(A, P) va_start(A, P) +#define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A) +#define HDvfprintf(F, FMT, A) vfprintf(F, FMT, A) +#define HDvprintf(FMT, A) vprintf(FMT, A) +#define HDvsprintf(S, FMT, A) vsprintf(S, FMT, A) #ifdef H5_HAVE_WIN32_API -H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap); -#define HDvsnprintf c99_vsnprintf +H5_DLL int c99_vsnprintf(char *str, size_t size, const char *format, va_list ap); +#define HDvsnprintf c99_vsnprintf #else -# define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A) +#define HDvsnprintf(S, N, FMT, A) vsnprintf(S, N, FMT, A) #endif -#define HDwait(W) wait(W) -#define HDwaitpid(P,W,O) waitpid(P,W,O) -#define HDwcstombs(S,P,Z) wcstombs(S,P,Z) -#define HDwctomb(S,C) wctomb(S,C) -#define HDwrite(F,M,Z) write(F,M,Z) +#define HDwait(W) wait(W) +#define HDwaitpid(P, W, O) waitpid(P, W, O) +#define HDwcstombs(S, P, Z) wcstombs(S, P, Z) +#define HDwctomb(S, C) wctomb(S, C) +#define HDwrite(F, M, Z) write(F, M, Z) /* * And now for a couple non-Posix functions... Watch out for systems that * define these in terms of macros. */ #ifdef H5_HAVE_WIN32_API -#define HDstrdup(S) _strdup(S) +#define HDstrdup(S) _strdup(S) #else /* H5_HAVE_WIN32_API */ #if !defined strdup && !defined H5_HAVE_STRDUP -extern char *strdup(const char *s); +extern char * strdup(const char *s); #endif -#define HDstrdup(S) strdup(S) +#define HDstrdup(S) strdup(S) #endif /* H5_HAVE_WIN32_API */ @@ -485,52 +484,47 @@ extern char *strdup(const char *s); * HDF Boolean type. */ #ifndef FALSE -# define FALSE false +#define FALSE false #endif #ifndef TRUE -# define TRUE true +#define TRUE true #endif /** From h5test.h **/ #ifdef H5_HAVE_PARALLEL -extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ +extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ #endif #ifdef H5_HAVE_PARALLEL -int h5_set_info_object(void); +int h5_set_info_object(void); void h5_dump_info_object(MPI_Info info); #endif - - /** From h5tools_utils.h **/ -extern int opt_err; /* getoption prints errors if this is on */ -extern int opt_ind; /* token pointer */ -extern const char *opt_arg; /* flag argument (or value) */ - +extern int opt_err; /* getoption prints errors if this is on */ +extern int opt_ind; /* token pointer */ +extern const char *opt_arg; /* flag argument (or value) */ enum { - no_arg = 0, /* doesn't take an argument */ - require_arg, /* requires an argument */ - optional_arg /* argument is optional */ + no_arg = 0, /* doesn't take an argument */ + require_arg, /* requires an argument */ + optional_arg /* argument is optional */ }; - typedef struct long_options { - const char *name; /* name of the long option */ - int has_arg; /* whether we should look for an arg */ - char shortval; /* the shortname equivalent of long arg - * this gets returned from get_option */ + const char *name; /* name of the long option */ + int has_arg; /* whether we should look for an arg */ + char shortval; /* the shortname equivalent of long arg + * this gets returned from get_option */ } long_options; -extern int get_option(int argc, const char **argv, const char *opt, - const struct long_options *l_opt); +extern int get_option(int argc, const char **argv, const char *opt, const struct long_options *l_opt); -extern int nCols; /*max number of columns for outputting */ +extern int nCols; /*max number of columns for outputting */ /* Definitions of useful routines */ -extern void print_version(const char *progname); +extern void print_version(const char *progname); #endif diff --git a/tools/test/perform/zip_perf.c b/tools/test/perform/zip_perf.c index 8f1f584..6bb0085 100644 --- a/tools/test/perform/zip_perf.c +++ b/tools/test/perform/zip_perf.c @@ -28,105 +28,103 @@ #include <zlib.h> -#define ONE_KB 1024 -#define ONE_MB (ONE_KB * ONE_KB) -#define ONE_GB (ONE_MB * ONE_KB) +#define ONE_KB 1024 +#define ONE_MB (ONE_KB * ONE_KB) +#define ONE_GB (ONE_MB * ONE_KB) -#define MICROSECOND 1000000.0F +#define MICROSECOND 1000000.0F /* report 0.0 in case t is zero too */ -#define MB_PER_SEC(bytes,t) ((fabs(t) < (double)0.0000000001F) ? (double)0.0F : ((((double)bytes) / (double)ONE_MB) / (t))) +#define MB_PER_SEC(bytes, t) \ + ((fabs(t) < (double)0.0000000001F) ? (double)0.0F : ((((double)bytes) / (double)ONE_MB) / (t))) #ifndef TRUE -#define TRUE 1 -#endif /* TRUE */ +#define TRUE 1 +#endif /* TRUE */ #ifndef FALSE -#define FALSE (!TRUE) -#endif /* FALSE */ +#define FALSE (!TRUE) +#endif /* FALSE */ #ifndef S_IRWXU -#define S_IRWXU (_S_IREAD|_S_IWRITE) +#define S_IRWXU (_S_IREAD | _S_IWRITE) #endif /* internal variables */ -static const char *prog=NULL; -static const char *option_prefix=NULL; -static char *filename=NULL; -static int compress_percent = 0; -static int compress_level = Z_DEFAULT_COMPRESSION; -static int output, random_test = FALSE; -static int report_once_flag; -static double compression_time; +static const char *prog = NULL; +static const char *option_prefix = NULL; +static char * filename = NULL; +static int compress_percent = 0; +static int compress_level = Z_DEFAULT_COMPRESSION; +static int output, random_test = FALSE; +static int report_once_flag; +static double compression_time; /* internal functions */ static void error(const char *fmt, ...); -static void compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, - uLong sourceLen); +static void compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); /* commandline options : long and short form */ -static const char *s_opts = "hB:b:c:p:rs:0123456789"; -static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "compressability", require_arg, 'c' }, - { "compressabilit", require_arg, 'c' }, - { "compressabili", require_arg, 'c' }, - { "compressabil", require_arg, 'c' }, - { "compressabi", require_arg, 'c' }, - { "compressab", require_arg, 'c' }, - { "compressa", require_arg, 'c' }, - { "compress", require_arg, 'c' }, - { "compres", require_arg, 'c' }, - { "compre", require_arg, 'c' }, - { "compr", require_arg, 'c' }, - { "comp", require_arg, 'c' }, - { "com", require_arg, 'c' }, - { "co", require_arg, 'c' }, - { "file-size", require_arg, 's' }, - { "file-siz", require_arg, 's' }, - { "file-si", require_arg, 's' }, - { "file-s", require_arg, 's' }, - { "file", require_arg, 's' }, - { "fil", require_arg, 's' }, - { "fi", require_arg, 's' }, - { "max-buffer-size", require_arg, 'B' }, - { "max-buffer-siz", require_arg, 'B' }, - { "max-buffer-si", require_arg, 'B' }, - { "max-buffer-s", require_arg, 'B' }, - { "max-buffer", require_arg, 'B' }, - { "max-buffe", require_arg, 'B' }, - { "max-buff", require_arg, 'B' }, - { "max-buf", require_arg, 'B' }, - { "max-bu", require_arg, 'B' }, - { "max-b", require_arg, 'B' }, - { "max", require_arg, 'B' }, - { "min-buffer-size", require_arg, 'b' }, - { "min-buffer-siz", require_arg, 'b' }, - { "min-buffer-si", require_arg, 'b' }, - { "min-buffer-s", require_arg, 'b' }, - { "min-buffer", require_arg, 'b' }, - { "min-buffe", require_arg, 'b' }, - { "min-buff", require_arg, 'b' }, - { "min-buf", require_arg, 'b' }, - { "min-bu", require_arg, 'b' }, - { "min-b", require_arg, 'b' }, - { "min", require_arg, 'b' }, - { "prefix", require_arg, 'p' }, - { "prefi", require_arg, 'p' }, - { "pref", require_arg, 'p' }, - { "pre", require_arg, 'p' }, - { "pr", require_arg, 'p' }, - { "random-test", no_arg, 'r' }, - { "random-tes", no_arg, 'r' }, - { "random-te", no_arg, 'r' }, - { "random-t", no_arg, 'r' }, - { "random", no_arg, 'r' }, - { "rando", no_arg, 'r' }, - { "rand", no_arg, 'r' }, - { "ran", no_arg, 'r' }, - { "ra", no_arg, 'r' }, - { NULL, 0, '\0' } -}; +static const char * s_opts = "hB:b:c:p:rs:0123456789"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, + {"compressability", require_arg, 'c'}, + {"compressabilit", require_arg, 'c'}, + {"compressabili", require_arg, 'c'}, + {"compressabil", require_arg, 'c'}, + {"compressabi", require_arg, 'c'}, + {"compressab", require_arg, 'c'}, + {"compressa", require_arg, 'c'}, + {"compress", require_arg, 'c'}, + {"compres", require_arg, 'c'}, + {"compre", require_arg, 'c'}, + {"compr", require_arg, 'c'}, + {"comp", require_arg, 'c'}, + {"com", require_arg, 'c'}, + {"co", require_arg, 'c'}, + {"file-size", require_arg, 's'}, + {"file-siz", require_arg, 's'}, + {"file-si", require_arg, 's'}, + {"file-s", require_arg, 's'}, + {"file", require_arg, 's'}, + {"fil", require_arg, 's'}, + {"fi", require_arg, 's'}, + {"max-buffer-size", require_arg, 'B'}, + {"max-buffer-siz", require_arg, 'B'}, + {"max-buffer-si", require_arg, 'B'}, + {"max-buffer-s", require_arg, 'B'}, + {"max-buffer", require_arg, 'B'}, + {"max-buffe", require_arg, 'B'}, + {"max-buff", require_arg, 'B'}, + {"max-buf", require_arg, 'B'}, + {"max-bu", require_arg, 'B'}, + {"max-b", require_arg, 'B'}, + {"max", require_arg, 'B'}, + {"min-buffer-size", require_arg, 'b'}, + {"min-buffer-siz", require_arg, 'b'}, + {"min-buffer-si", require_arg, 'b'}, + {"min-buffer-s", require_arg, 'b'}, + {"min-buffer", require_arg, 'b'}, + {"min-buffe", require_arg, 'b'}, + {"min-buff", require_arg, 'b'}, + {"min-buf", require_arg, 'b'}, + {"min-bu", require_arg, 'b'}, + {"min-b", require_arg, 'b'}, + {"min", require_arg, 'b'}, + {"prefix", require_arg, 'p'}, + {"prefi", require_arg, 'p'}, + {"pref", require_arg, 'p'}, + {"pre", require_arg, 'p'}, + {"pr", require_arg, 'p'}, + {"random-test", no_arg, 'r'}, + {"random-tes", no_arg, 'r'}, + {"random-te", no_arg, 'r'}, + {"random-t", no_arg, 'r'}, + {"random", no_arg, 'r'}, + {"rando", no_arg, 'r'}, + {"rand", no_arg, 'r'}, + {"ran", no_arg, 'r'}, + {"ra", no_arg, 'r'}, + {NULL, 0, '\0'}}; /* * Function: error @@ -165,14 +163,14 @@ cleanup(void) static void write_file(Bytef *source, uLongf sourceLen) { - Bytef *d_ptr, *dest; - uLongf d_len, destLen; + Bytef * d_ptr, *dest; + uLongf d_len, destLen; struct timeval timer_start, timer_stop; /* destination buffer needs to be at least 0.1% larger than sourceLen * plus 12 bytes */ destLen = (uLongf)((double)sourceLen + ((double)sourceLen * (double)0.1F)) + 12; - dest = (Bytef *)HDmalloc(destLen); + dest = (Bytef *)HDmalloc(destLen); if (!dest) error("out of memory"); @@ -181,10 +179,8 @@ write_file(Bytef *source, uLongf sourceLen) compress_buffer(dest, &destLen, source, sourceLen); HDgettimeofday(&timer_stop, NULL); - compression_time += ((double)timer_stop.tv_sec + - ((double)timer_stop.tv_usec) / (double)MICROSECOND) - - ((double)timer_start.tv_sec + - ((double)timer_start.tv_usec) / (double)MICROSECOND); + compression_time += ((double)timer_stop.tv_sec + ((double)timer_stop.tv_usec) / (double)MICROSECOND) - + ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / (double)MICROSECOND); if (report_once_flag) { HDfprintf(stdout, "\tCompression Ratio: %g\n", ((double)destLen) / (double)sourceLen); @@ -222,8 +218,7 @@ write_file(Bytef *source, uLongf sourceLen) * Modifications: */ static void -compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, - uLong sourceLen) +compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) { int rc = compress2(dest, destLen, source, sourceLen, compress_level); @@ -232,18 +227,18 @@ compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, cleanup(); switch (rc) { - case Z_MEM_ERROR: - error("not enough memory"); - break; - case Z_BUF_ERROR: - error("not enough room in the output buffer"); - break; - case Z_STREAM_ERROR: - error("level parameter (%d) is invalid", compress_level); - break; - default: - error("unknown compression error"); - break; + case Z_MEM_ERROR: + error("not enough memory"); + break; + case Z_BUF_ERROR: + error("not enough room in the output buffer"); + break; + case Z_STREAM_ERROR: + error("level parameter (%d) is invalid", compress_level); + break; + default: + error("unknown compression error"); + break; } } } @@ -260,8 +255,7 @@ compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, * Modifications: */ static int -uncompress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, - uLong sourceLen) +uncompress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) { int rc = uncompress(dest, destLen, source, sourceLen); @@ -282,7 +276,7 @@ static void get_unique_name(void) { const char *prefix = NULL; - const char *env = HDgetenv("HDF5_PREFIX"); + const char *env = HDgetenv("HDF5_PREFIX"); if (env) prefix = env; @@ -292,15 +286,15 @@ get_unique_name(void) if (prefix) /* 2 = 1 for '/' + 1 for null terminator */ - filename = (char *) HDmalloc(HDstrlen(prefix) + HDstrlen(ZIP_PERF_FILE) + 2); + filename = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(ZIP_PERF_FILE) + 2); else - filename = (char *) HDmalloc(HDstrlen(ZIP_PERF_FILE) + 1); + filename = (char *)HDmalloc(HDstrlen(ZIP_PERF_FILE) + 1); if (!filename) error("out of memory"); filename[0] = 0; - if (prefix){ + if (prefix) { HDstrcpy(filename, prefix); HDstrcat(filename, "/"); } @@ -361,7 +355,7 @@ static unsigned long parse_size_directive(const char *size) { unsigned long s; - char *endptr; + char * endptr; s = HDstrtoul(size, &endptr, 10); @@ -395,12 +389,12 @@ static void fill_with_random_data(Bytef *src, uLongf src_len) { register unsigned u; - h5_stat_t stat_buf; + h5_stat_t stat_buf; if (HDstat("/dev/urandom", &stat_buf) == 0) { uLongf len = src_len; Bytef *buf = src; - int fd = HDopen("/dev/urandom", O_RDONLY, 0); + int fd = HDopen("/dev/urandom", O_RDONLY, 0); HDfprintf(stdout, "Using /dev/urandom for random data\n"); @@ -436,19 +430,18 @@ fill_with_random_data(Bytef *src, uLongf src_len) } static void -do_write_test(unsigned long file_size, unsigned long min_buf_size, - unsigned long max_buf_size) +do_write_test(unsigned long file_size, unsigned long min_buf_size, unsigned long max_buf_size) { - uLongf src_len, total_len; + uLongf src_len, total_len; struct timeval timer_start, timer_stop; - double total_time; - Bytef *src; + double total_time; + Bytef * src; for (src_len = min_buf_size; src_len <= max_buf_size; src_len <<= 1) { register unsigned long i, iters; iters = file_size / src_len; - src = (Bytef *)HDcalloc(1, sizeof(Bytef) * src_len); + src = (Bytef *)HDcalloc(1, sizeof(Bytef) * src_len); if (!src) { cleanup(); @@ -465,10 +458,12 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, if (src_len >= ONE_KB && (src_len % ONE_KB) == 0) { if (src_len >= ONE_MB && (src_len % ONE_MB) == 0) { HDfprintf(stdout, "%ldMB", src_len / ONE_MB); - } else { + } + else { HDfprintf(stdout, "%ldKB", src_len / ONE_KB); } - } else { + } + else { HDfprintf(stdout, "%ld", src_len); } @@ -483,7 +478,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, for (i = 0; i <= iters; ++i) { Bytef *s_ptr = src; - uLong s_len = src_len; + uLong s_len = src_len; /* loop to make sure we write everything out that we want to write */ for (;;) { @@ -503,14 +498,11 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, HDclose(output); HDgettimeofday(&timer_stop, NULL); - total_time = ((double)timer_stop.tv_sec + - ((double)timer_stop.tv_usec) / (double)MICROSECOND) - - ((double)timer_start.tv_sec + - ((double)timer_start.tv_usec) / (double)MICROSECOND); + total_time = ((double)timer_stop.tv_sec + ((double)timer_stop.tv_usec) / (double)MICROSECOND) - + ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / (double)MICROSECOND); HDfprintf(stdout, "\tUncompressed Write Time: %.2fs\n", total_time); - HDfprintf(stdout, "\tUncompressed Write Throughput: %.2fMB/s\n", - MB_PER_SEC(file_size, total_time)); + HDfprintf(stdout, "\tUncompressed Write Throughput: %.2fMB/s\n", MB_PER_SEC(file_size, total_time)); HDunlink(filename); @@ -529,14 +521,11 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, HDclose(output); HDgettimeofday(&timer_stop, NULL); - total_time = ((double)timer_stop.tv_sec + - ((double)timer_stop.tv_usec) / (double)MICROSECOND) - - ((double)timer_start.tv_sec + - ((double)timer_start.tv_usec) / (double)MICROSECOND); + total_time = ((double)timer_stop.tv_sec + ((double)timer_stop.tv_usec) / (double)MICROSECOND) - + ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / (double)MICROSECOND); HDfprintf(stdout, "\tCompressed Write Time: %.2fs\n", total_time); - HDfprintf(stdout, "\tCompressed Write Throughput: %.2fMB/s\n", - MB_PER_SEC(file_size, total_time)); + HDfprintf(stdout, "\tCompressed Write Throughput: %.2fMB/s\n", MB_PER_SEC(file_size, total_time)); HDfprintf(stdout, "\tCompression Time: %gs\n", compression_time); HDunlink(filename); @@ -556,7 +545,7 @@ main(int argc, const char *argv[]) { unsigned long min_buf_size = 128 * ONE_KB, max_buf_size = ONE_MB; unsigned long file_size = 64 * ONE_MB; - int opt; + int opt; prog = argv[0]; @@ -565,51 +554,56 @@ main(int argc, const char *argv[]) while ((opt = get_option(argc, argv, s_opts, l_opts)) > 0) { switch ((char)opt) { - case '0': case '1': case '2': - case '3': case '4': case '5': - case '6': case '7': case '8': - case '9': - compress_level = opt - '0'; - break; - case 'B': - max_buf_size = parse_size_directive(opt_arg); - break; - case 'b': - min_buf_size = parse_size_directive(opt_arg); - break; - case 'c': - compress_percent = (int)HDstrtol(opt_arg, NULL, 10); + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + compress_level = opt - '0'; + break; + case 'B': + max_buf_size = parse_size_directive(opt_arg); + break; + case 'b': + min_buf_size = parse_size_directive(opt_arg); + break; + case 'c': + compress_percent = (int)HDstrtol(opt_arg, NULL, 10); - if (compress_percent < 0) - compress_percent = 0; - else if (compress_percent > 100) - compress_percent = 100; + if (compress_percent < 0) + compress_percent = 0; + else if (compress_percent > 100) + compress_percent = 100; - break; - case 'p': - option_prefix = opt_arg; - break; - case 'r': - random_test = TRUE; - break; - case 's': - file_size = parse_size_directive(opt_arg); - break; - case '?': - usage(); - exit(EXIT_FAILURE); - break; - case 'h': - default: - usage(); - exit(EXIT_SUCCESS); - break; + break; + case 'p': + option_prefix = opt_arg; + break; + case 'r': + random_test = TRUE; + break; + case 's': + file_size = parse_size_directive(opt_arg); + break; + case '?': + usage(); + exit(EXIT_FAILURE); + break; + case 'h': + default: + usage(); + exit(EXIT_SUCCESS); + break; } } if (min_buf_size > max_buf_size) - error("minmum buffer size (%d) exceeds maximum buffer size (%d)", - min_buf_size, max_buf_size); + error("minmum buffer size (%d) exceeds maximum buffer size (%d)", min_buf_size, max_buf_size); HDfprintf(stdout, "Filesize: %ld\n", file_size); @@ -641,4 +635,4 @@ main(void) return EXIT_SUCCESS; } -#endif /* !H5_HAVE_FILTER_DEFLATE */ +#endif /* !H5_HAVE_FILTER_DEFLATE */ |