diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2016-10-21 21:48:36 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2016-10-21 21:48:36 (GMT) |
commit | 1b28a865ca0cc356c0d9581e09da8228b717da11 (patch) | |
tree | c2a3762e6e0d304311ea5965d6dd080b2a4136f9 | |
parent | a33fcdfb6bc7917e42ac4e7dcebd9a94afafc650 (diff) | |
download | hdf5-1b28a865ca0cc356c0d9581e09da8228b717da11.zip hdf5-1b28a865ca0cc356c0d9581e09da8228b717da11.tar.gz hdf5-1b28a865ca0cc356c0d9581e09da8228b717da11.tar.bz2 |
HDFFV-9942: Update perform tool code to align with develop
-rw-r--r-- | tools/perform/chunk.c | 24 | ||||
-rw-r--r-- | tools/perform/iopipe.c | 27 | ||||
-rw-r--r-- | tools/perform/overhead.c | 25 | ||||
-rw-r--r-- | tools/perform/perf.c | 18 | ||||
-rw-r--r-- | tools/perform/pio_engine.c | 17 | ||||
-rw-r--r-- | tools/perform/pio_perf.c | 80 | ||||
-rw-r--r-- | tools/perform/pio_perf.h | 3 | ||||
-rw-r--r-- | tools/perform/pio_standalone.c | 1 | ||||
-rw-r--r-- | tools/perform/pio_standalone.h | 445 | ||||
-rw-r--r-- | tools/perform/sio_engine.c | 127 | ||||
-rw-r--r-- | tools/perform/sio_perf.c | 35 | ||||
-rw-r--r-- | tools/perform/sio_standalone.h | 42 | ||||
-rw-r--r-- | tools/perform/zip_perf.c | 24 |
13 files changed, 618 insertions, 250 deletions
diff --git a/tools/perform/chunk.c b/tools/perform/chunk.c index 74bcc46..b1419ee 100644 --- a/tools/perform/chunk.c +++ b/tools/perform/chunk.c @@ -57,9 +57,9 @@ #define RM_CACHE_STRT 25 #define RM_CACHE_END 25 #define RM_CACHE_DELT 5 -#define RM_START 0.50F -#define RM_END 5.00F -#define RM_DELTA 0.50F +#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 @@ -67,9 +67,9 @@ #define DIAG_CACHE_STRT 25 #define DIAG_CACHE_END 25 #define DIAG_CACHE_DELT 5 -#define DIAG_START 0.50F -#define DIAG_END 5.00F -#define DIAG_DELTA 0.50F +#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 */ @@ -163,7 +163,7 @@ create_dataset (void) assert(dset>=0); /* The data */ - buf = 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); @@ -194,7 +194,7 @@ static double test_rowmaj (int op, size_t cache_size, size_t io_size) { hid_t file, dset, mem_space, file_space; - signed char *buf = calloc (1, (size_t)(SQUARE(io_size))); + 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; @@ -273,7 +273,7 @@ test_diag (int op, size_t cache_size, size_t io_size, size_t offset) hsize_t i, hs_size[2]; hsize_t nio = 0; hsize_t hs_offset[2]; - signed char *buf = calloc (1, (size_t)(SQUARE (io_size))); + signed char *buf = (signed char *)calloc(1, (size_t)(SQUARE (io_size))); int mdc_nelmts; size_t rdcc_nelmts; double w0; @@ -320,7 +320,7 @@ test_diag (int op, size_t cache_size, size_t io_size, size_t offset) * Win32 version 5.0 compiler. * 1998-11-06 ptl */ - return (double)(hssize_t)nio/(hssize_t)nio_g; + return (double)nio/(double)nio_g; } @@ -479,9 +479,7 @@ main (void) 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) { + 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); diff --git a/tools/perform/iopipe.c b/tools/perform/iopipe.c index a04ef82..fd62d37 100644 --- a/tools/perform/iopipe.c +++ b/tools/perform/iopipe.c @@ -81,25 +81,25 @@ print_stats (const char *prefix, double u_time, s_time; u_time = ((double)(r_stop->ru_utime.tv_sec)+ - (double)(r_stop->ru_utime.tv_usec)/1000000.0F) - + (double)(r_stop->ru_utime.tv_usec)/(double)1000000.0F) - ((double)(r_start->ru_utime.tv_sec)+ - (double)(r_start->ru_utime.tv_usec)/1000000.0F); + (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)/1000000.0F) - + (double)(r_stop->ru_stime.tv_usec)/(double)1000000.0F) - ((double)(r_start->ru_stime.tv_sec)+ - (double)(r_start->ru_stime.tv_usec)/1000000.0F); + (double)(r_start->ru_stime.tv_usec)/(double)1000000.0F); #endif #ifndef H5_HAVE_SYS_TIMEB e_time = ((double)(t_stop->tv_sec)+ - (double)(t_stop->tv_usec)/1000000.0F) - + (double)(t_stop->tv_usec)/(double)1000000.0F) - ((double)(t_start->tv_sec)+ - (double)(t_start->tv_usec)/1000000.0F); + (double)(t_start->tv_usec)/(double)1000000.0F); #else e_time = ((double)(t_stop->tv_sec)+ - (double)(t_stop->tv_usec)/1000.0F) - + (double)(t_stop->tv_usec)/(double)1000.0F) - ((double)(t_start->tv_sec)+ - (double)(t_start->tv_usec)/1000.0F); + (double)(t_start->tv_usec)/(double)1000.0F); #endif bw = (double)nbytes / e_time; @@ -135,8 +135,13 @@ synchronize (void) #if defined(H5_HAVE_WIN32_API) && ! defined(__CYGWIN__) _flushall(); #else - HDsystem("sync"); - HDsystem("df >/dev/null"); + int status; + + status = HDsystem("sync"); + HDassert(status >= 0); + + status = HDsystem("df >/dev/null"); + HDassert(status >= 0); #endif #endif } @@ -191,7 +196,7 @@ main (void) * 1998-11-06 ptl */ printf ("I/O request size is %1.1fMB\n", - (double)(hssize_t)(size[0]*size[1])/1024.0F*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); diff --git a/tools/perform/overhead.c b/tools/perform/overhead.c index 0288ffa..98093c7 100644 --- a/tools/perform/overhead.c +++ b/tools/perform/overhead.c @@ -42,10 +42,6 @@ # include <unistd.h> #endif -#ifdef H5_HAVE_IO_H -# include <io.h> -#endif - /* Solaris Studio defines attribute, but for the attributes we need */ #if !defined(H5_HAVE_ATTRIBUTE) || defined __cplusplus || defined(__SUNPRO_C) # undef __attribute__ @@ -203,7 +199,7 @@ test(fill_t fill_style, const double splits[], int *had = NULL; /*for random filling */ const char *sname=NULL; /*fill style nam */ int mdc_nelmts; /*num meta objs to cache*/ - hsize_t i; + hsize_t i, k; int j; h5_stat_t sb; @@ -224,7 +220,7 @@ test(fill_t fill_style, const double splits[], if ((fd=HDopen(FILE_NAME_1, O_RDONLY, 0666)) < 0) goto error; if(FILL_RANDOM==fill_style) - had = calloc((size_t)cur_size[0], sizeof(int)); + had = (int *)calloc((size_t)cur_size[0], sizeof(int)); for (i=1; i<=cur_size[0]; i++) { @@ -240,13 +236,13 @@ test(fill_t fill_style, const double splits[], hs_start[0] = i%2 ? i/2 : cur_size[0]-i/2; break; case FILL_OUTWARD: - j = (int)(cur_size[0]-i)+1; - hs_start[0] = j%2 ? j/2 : (hssize_t)cur_size[0]-j/2; + 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] = j; + hs_start[0] = (hsize_t)j; had[j] = 1; break; case FILL_ALL: @@ -269,14 +265,9 @@ test(fill_t fill_style, const double splits[], if (verbose) { if (H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; if (HDfstat(fd, &sb) < 0) goto error; - /* - * The extra cast in the following statement is a bug workaround - * for the Win32 version 5.0 compiler. - * 1998-11-06 ptl - */ printf("%4lu %8.3f ***\n", (unsigned long)i, - (double)(hssize_t)(sb.st_size-i*sizeof(int))/(hssize_t)i); + (double)(sb.st_size - (HDoff_t)(i * sizeof(int))) / (double)i); } } @@ -320,8 +311,8 @@ test(fill_t fill_style, const double splits[], if (HDfstat(fd, &sb) < 0) goto error; printf("%-7s %8.3f\n", sname, - (double)(hssize_t)(sb.st_size-cur_size[0]*sizeof(int))/ - (hssize_t)cur_size[0]); + (double)(sb.st_size - (HDoff_t)(cur_size[0] * sizeof(int))) / + (double)cur_size[0]); } HDclose(fd); diff --git a/tools/perform/perf.c b/tools/perform/perf.c index afd13c0..7b9590c 100644 --- a/tools/perform/perf.c +++ b/tools/perform/perf.c @@ -24,15 +24,26 @@ #include "hdf5.h" #include "H5private.h" + #ifdef H5_HAVE_PARALLEL + +#ifdef H5_STDC_HEADERS +#include <errno.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> -#include <fcntl.h> +#include <string.h> +#endif + #ifdef H5_HAVE_UNISTD_H +#include <sys/types.h> #include <unistd.h> #endif -#include <errno.h> -#include <string.h> + +#ifdef H5_HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + #if defined(H5_TIME_WITH_SYS_TIME) # include <sys/time.h> # include <time.h> @@ -41,6 +52,7 @@ #else # include <time.h> #endif + #include <mpi.h> #ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ # include <mpio.h> diff --git a/tools/perform/pio_engine.c b/tools/perform/pio_engine.c index 96cfcc2..ab11efd 100644 --- a/tools/perform/pio_engine.c +++ b/tools/perform/pio_engine.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * @@ -17,17 +16,23 @@ * Author: Albert Cheng of NCSA, Oct 24, 2001. */ -#include <sys/types.h> -#include <sys/stat.h> +#include "hdf5.h" + +#ifdef H5_STDC_HEADERS +#include <errno.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> -#include <fcntl.h> +#endif + #ifdef H5_HAVE_UNISTD_H +#include <sys/types.h> #include <unistd.h> #endif -#include <errno.h> -#include "hdf5.h" +#ifdef H5_HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif #ifdef H5_HAVE_PARALLEL diff --git a/tools/perform/pio_perf.c b/tools/perform/pio_perf.c index 4db2249..c1bfadb 100644 --- a/tools/perform/pio_perf.c +++ b/tools/perform/pio_perf.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * @@ -378,7 +377,7 @@ main(int argc, char **argv) } if (opts->output_file) { - if ((output = fopen(opts->output_file, "w")) == NULL) { + if ((output = HDfopen(opts->output_file, "w")) == NULL) { fprintf(stderr, "%s: cannot open output file\n", progname); perror(opts->output_file); goto finish; @@ -461,28 +460,28 @@ run_test_loop(struct options *opts) if (parms.dim2d){ parms.num_bytes = (off_t)pow((double)(opts->num_bpp*parms.num_procs),2); if (parms.interleaved) - output_report("Transfer Buffer Size: %ldx%ld bytes, File size: %.2f MBs\n", + 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 MBs\n", + 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 KBs\n", + 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 MBs\n", + 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 MBs\n", + 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); } @@ -1228,7 +1227,7 @@ report_parameters(struct options *opts) HDfprintf(output, "Contiguous\n"); { - char *prefix = getenv("HDF5_PARAPREFIX"); + char *prefix = HDgetenv("HDF5_PARAPREFIX"); HDfprintf(output, "rank %d: Env HDF5_PARAPREFIX=%s\n", rank, (prefix ? prefix : "not set")); @@ -1293,7 +1292,7 @@ parse_command_line(int argc, char *argv[]) char buf[10]; int i; - memset(buf, '\0', sizeof(buf)); + HDmemset(buf, '\0', sizeof(buf)); for (i = 0; *end != '\0' && *end != ','; ++end) if (isalnum(*end) && i < 10) @@ -1345,7 +1344,7 @@ parse_command_line(int argc, char *argv[]) char buf[10]; int i; - memset(buf, '\0', sizeof(buf)); + HDmemset(buf, '\0', sizeof(buf)); for (i = 0; *end != '\0' && *end != ','; ++end) if (isalnum(*end) && i < 10) @@ -1509,7 +1508,7 @@ parse_size_directive(const char *size) off_t s; char *endptr; - s = strtol(size, &endptr, 10); + s = HDstrtol(size, &endptr, 10); if (endptr && *endptr) { while (*endptr != '\0' && (*endptr == ' ' || *endptr == '\t')) @@ -1673,60 +1672,8 @@ usage(const char *prog) printf(" HDF5_MPI_INFO MPI INFO object key=value separated by ;\n"); printf(" HDF5_PARAPREFIX Paralllel data files prefix\n"); fflush(stdout); - } -} - -void debug_start_stop_time(io_time_t *pt, timer_type t, int start_stop) -{ -#if 1 - if (pio_debug_level >= 4) { - const char *msg; - int myrank; - - MPI_Comm_rank(pio_comm_g, &myrank); - - switch (t) { - case HDF5_FILE_OPENCLOSE: - msg = "File Open/Close"; - break; - case HDF5_DATASET_CREATE: - msg = "Dataset Create"; - break; - case HDF5_MPI_WRITE: - msg = "MPI Write"; - break; - case HDF5_MPI_READ: - msg = "MPI Read"; - break; - case HDF5_FINE_WRITE_FIXED_DIMS: - msg = "Fine Write"; - break; - case HDF5_FINE_READ_FIXED_DIMS: - msg = "Fine Read"; - break; - case HDF5_GROSS_WRITE_FIXED_DIMS: - msg = "Gross Write"; - break; - case HDF5_GROSS_READ_FIXED_DIMS: - msg = "Gross Read"; - break; - case HDF5_RAW_WRITE_FIXED_DIMS: - msg = "Raw Write"; - break; - case HDF5_RAW_READ_FIXED_DIMS: - msg = "Raw Read"; - break; - default: - msg = "Unknown Timer"; - break; - } - - fprintf(output, " Proc %d: %s %s: %.2f\n", myrank, msg, - (start_stop == TSTART ? "Start" : "Stop"), - pt->total_time[t]); - } -#endif -} /* debug_start_stop_time */ + } /* end if */ +} /* end usage() */ #else /* H5_HAVE_PARALLEL */ @@ -1736,13 +1683,12 @@ void debug_start_stop_time(io_time_t *pt, timer_type t, int start_stop) * parallel stuff. * Return: EXIT_SUCCESS * Programmer: Bill Wendling, 14. November 2001 - * Modifications: */ int main(void) { printf("No parallel IO performance because parallel is not configured\n"); return EXIT_SUCCESS; -} +} /* end main */ #endif /* !H5_HAVE_PARALLEL */ diff --git a/tools/perform/pio_perf.h b/tools/perform/pio_perf.h index 0fff7a3..89cf3a8 100644 --- a/tools/perform/pio_perf.h +++ b/tools/perform/pio_perf.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * @@ -16,6 +15,7 @@ #ifndef PIO_PERF_H__ #define PIO_PERF_H__ +#include "io_timer.h" #ifndef STANDALONE #include "H5private.h" #include "h5test.h" @@ -24,7 +24,6 @@ #else #include "pio_standalone.h" #endif -#include "io_timer.h" /* setup the dataset no fill option if this is v1.5 or more */ #if H5_VERS_MAJOR > 1 || H5_VERS_MINOR > 4 diff --git a/tools/perform/pio_standalone.c b/tools/perform/pio_standalone.c index e404274..475c678 100644 --- a/tools/perform/pio_standalone.c +++ b/tools/perform/pio_standalone.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * diff --git a/tools/perform/pio_standalone.h b/tools/perform/pio_standalone.h index 584a057..ee523ed 100644 --- a/tools/perform/pio_standalone.h +++ b/tools/perform/pio_standalone.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * @@ -44,62 +43,437 @@ #endif /* - * And now for a couple non-Posix functions... Watch out for systems that - * define these in terms of macros. + * 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) #ifdef H5_HAVE_WIN32_API -#define HDstrdup(S) _strdup(S) +#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 */ - -#if !defined strdup && !defined H5_HAVE_STRDUP -extern char *strdup(const char *s); +#define HDaccess(F,M) access(F, M) +#ifndef F_OK +#define F_OK 00 +#define W_OK 02 +#define R_OK 04 #endif - -#define HDstrdup(S) strdup(S) - #endif /* H5_HAVE_WIN32_API */ - +#define HDacos(X) acos(X) +#ifdef H5_HAVE_ALARM +#define HDalarm(N) alarm(N) +#else /* H5_HAVE_ALARM */ +#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) +#ifdef H5_HAVE_DIFFTIME +#define HDdifftime(X,Y) difftime(X,Y) +#else +#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) +/* 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) +/* use ABS() because fabsf() fabsl() are not common yet. */ +#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) +#ifdef H5_HAVE_WIN32_API +#define HDfileno(F) _fileno(F) +#else /* H5_HAVE_WIN32_API */ +#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) H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); -#define HDstrcmp(S,T) strcmp(S,T) -#define HDstrlen(S) strlen(S) -#define HDstrncmp(S,T,L) strncmp(S,T,L) -#define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) -#define HDstrchr(S,C) strchr(S,C) -#define HDfree(M) free(M) +#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) +#else /* H5_HAVE_FREXPF */ +#define HDfrexpf(X,N) frexp(X,N) +#endif /* H5_HAVE_FREXPF */ +#ifdef H5_HAVE_FREXPL +#define HDfrexpl(X,N) frexpl(X,N) +#else /* H5_HAVE_FREXPL */ +#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) +#else + #define HDfseek(F,O,W) fseek(F,O,W) +#endif +#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 +#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 +#endif +#ifndef H5_HAVE_WIN32_API +/* These definitions differ in Windows and are defined in + * H5win32defs for that platform. + */ +typedef struct stat h5_stat_t; +typedef off_t h5_stat_size_t; +#define HDoff_t off_t +#endif /* H5_HAVE_WIN32_API */ +#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() +#else /* H5_HAVE_WIN32_API */ +#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 HDgets(S) gets(S) +#ifdef H5_HAVE_WIN32_API + 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) +#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) +#ifdef H5_HAVE_WIN32_API + #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 +#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) +/* + * 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) +/* + * 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) +#else /* H5_HAVE_VISUAL_STUDIO */ +#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) +#else /* H5_HAVE_WIN32_API */ +#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) #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) +#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) +/* printf() variable arguments */ +#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() +H5_DLL int HDrand(void); +#elif H5_HAVE_RANDOM +#define HDrand() random() +#define HDrandom() random() #else -#define HDopen(S,F,M) open(S,F,M) +#define HDrand() rand() +#define HDrandom() rand() #endif -#define HDclose(F) close(F) +#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) +/* 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) +#else +#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) #ifdef H5_HAVE_WIN32_API -#define HDlseek(F,O,W) _lseeki64(F,O,W) +H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...); +#define HDsnprintf c99_snprintf /*varargs*/ #else -#define HDlseek(F,O,W) lseek(F,O,W) +#define HDsnprintf snprintf /*varargs*/ #endif - -#define HDwrite(F,M,Z) write(F,M,Z) - -#define HDread(F,M,Z) read(F,M,Z) +/* sprintf() variable arguments */ +#define HDsqrt(X) sqrt(X) +#ifdef H5_HAVE_RAND_R +H5_DLL void HDsrand(unsigned int seed); +#define HDsrandom(S) HDsrand(S) +#elif H5_HAVE_RANDOM +#define HDsrand(S) srandom(S) +#define HDsrandom(S) srandom(S) +#else +#define HDsrand(S) srand(S) +#define HDsrandom(S) srand(S) +#endif +/* sscanf() variable arguments */ #ifdef H5_HAVE_WIN32_API - #define HDstat(S,B) _stati64(S,B) +#define HDstrcasecmp(A,B) _stricmp(A,B) #else -#define HDstat(S,B) stat(S,B) +#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) +#ifdef H5_HAVE_WIN32_API +#define HDstrtoull(S,R,N) _strtoui64(S,R,N) +#else +#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) #ifdef H5_HAVE_WIN32_API -#define HDfstat(F,B) _fstati64(F,B) -typedef struct _stati64 h5_stat_t; -typedef __int64 h5_stat_size_t; +#define HDunlink(S) _unlink(S) #else -#define HDfstat(F,B) fstat(F,B) -typedef struct stat h5_stat_t; -typedef off_t h5_stat_size_t; +#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) +#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 +#else +# 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) + +/* + * 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) +#else /* H5_HAVE_WIN32_API */ + +#if !defined strdup && !defined H5_HAVE_STRDUP +extern char *strdup(const char *s); +#endif + +#define HDstrdup(S) strdup(S) + +#endif /* H5_HAVE_WIN32_API */ /* * HDF Boolean type. @@ -111,7 +485,6 @@ typedef off_t h5_stat_size_t; # define TRUE 1 #endif - /** From h5test.h **/ #ifdef H5_HAVE_PARALLEL diff --git a/tools/perform/sio_engine.c b/tools/perform/sio_engine.c index 3b28ea7..7ae79b3 100644 --- a/tools/perform/sio_engine.c +++ b/tools/perform/sio_engine.c @@ -16,17 +16,23 @@ * Author: Christian Chilan, April 2008 */ -#include <sys/types.h> -#include <sys/stat.h> +#include "hdf5.h" + +#ifdef H5_STDC_HEADERS +#include <errno.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> -#include <fcntl.h> +#endif + #ifdef H5_HAVE_UNISTD_H -# include <unistd.h> +#include <sys/types.h> +#include <unistd.h> #endif -#include <errno.h> -#include "hdf5.h" +#ifdef H5_HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif #include "sio_perf.h" @@ -90,7 +96,7 @@ static herr_t do_fclose(iotype iot, file_descr *fd); static void do_cleanupfile(iotype iot, char *fname); /* global variables */ -static off_t offset[MAX_DIMS]; /* dataset size in bytes */ +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 */ @@ -181,7 +187,7 @@ do_sio(parameters param) } /* Allocate transfer buffer */ - if ((buffer = 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); } @@ -402,7 +408,8 @@ do_write(results *res, file_descr *fd, parameters *parms, void *buffer) { int ret_code = SUCCESS; char dname[64]; - long i; + int i; + size_t u; /* HDF5 variables */ herr_t hrc; /*HDF5 return code */ hsize_t h5dims[MAX_DIMS]; /*dataset dim sizes */ @@ -412,20 +419,20 @@ do_write(results *res, file_descr *fd, parameters *parms, void *buffer) hsize_t h5start[MAX_DIMS]; /*selection start */ hsize_t h5maxdims[MAX_DIMS]; int rank; /*rank of dataset */ - /* Prepare buffer for verifying data */ + + /* Prepare buffer for verifying data */ /* if (parms->verify) memset(buffer,1,linear_buf_size); */ buf_p=(unsigned char *)buffer; - for (i=0; i < linear_buf_size; i++) - buf_p[i]=i%128; + 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) { @@ -612,20 +619,22 @@ done: * Programmer: Christian Chilan, April, 2008 * Modifications: */ - -static herr_t dset_write(int local_dim, file_descr *fd, parameters *parms, void *buffer) +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]; - long i,j; + hsize_t i; + 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]){ - h5offset[cur_dim] = offset[cur_dim] = i; + h5offset[cur_dim] = (hssize_t)i; + offset[cur_dim] = (HDoff_t)i; if (local_dim > 0){ @@ -637,17 +646,15 @@ static herr_t dset_write(int local_dim, file_descr *fd, parameters *parms, void case POSIXIO: /* initialize POSIX offset in the buffer */ - for (j=0; j < parms->rank; j++) { - buf_offset[j]=0; - } + 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 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); @@ -655,7 +662,8 @@ static herr_t dset_write(int local_dim, file_descr *fd, parameters *parms, void for (k=0; k < parms->rank; k++){ - if (dims[k] <= h5offset[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"); @@ -696,20 +704,17 @@ done: * Modifications: */ -static herr_t posix_buffer_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) { - int dtype_size = 1; int ret_code = SUCCESS; - long i; - size_t d_offset; - size_t linear_dset_offset = 0; - int j, rc; /* if dimension is not contiguous, call recursively */ if (local_dim < parms->rank-1 && local_dim != cont_dim) { + size_t u; - for (i=0; i < parms->buf_size[local_dim]; i += dtype_size) { - buf_offset[local_dim] = i; + for(u = 0; u < parms->buf_size[local_dim]; u ++) { + buf_offset[local_dim] = u; posix_buffer_write(local_dim+1, fd, parms, buffer); /* if next dimension is cont_dim, it will fill out the buffer @@ -720,17 +725,20 @@ static herr_t posix_buffer_write(int local_dim, file_descr *fd, parameters *parm } /* otherwise, perform contiguous POSIX access */ } else { + HDoff_t d_offset; + HDoff_t linear_dset_offset = 0; + int i, j, rc; buf_offset[local_dim] = 0; /* determine offset in the 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++) - d_offset *= parms->dset_size[j]; + for(j = i + 1; j < parms->rank; j++) + d_offset *= (HDoff_t)parms->dset_size[j]; - linear_dset_offset += (offset[i]+buf_offset[i])*d_offset; + linear_dset_offset += (offset[i] + (HDoff_t)buf_offset[i]) * d_offset; } /* only care if seek returns error */ @@ -745,6 +753,7 @@ static herr_t posix_buffer_write(int local_dim, file_descr *fd, parameters *parm buf_p += cont_size; } + done: return ret_code; } @@ -762,7 +771,8 @@ 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]; - long i; + int i; + size_t u; /* HDF5 variables */ herr_t hrc; /*HDF5 return code */ hsize_t h5dims[MAX_DIMS]; /*dataset dim sizes */ @@ -778,8 +788,8 @@ do_read(results *res, file_descr *fd, parameters *parms, void *buffer) } /* end if */ /* Prepare buffer for verifying data */ - for(i = 0; i < linear_buf_size; i++) - buffer2[i] = i % 128; + for(u = 0; u < linear_buf_size; u++) + buffer2[u] = (char)(u % 128); rank = parms->rank; for(i = 0; i < rank; i++) @@ -937,14 +947,16 @@ static herr_t dset_read(int local_dim, file_descr *fd, parameters *parms, void *buffer, const char *buffer2) { int cur_dim = order[local_dim]-1; - int ret_code = SUCCESS; - long i,j; + hsize_t i; + 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]){ - h5offset[cur_dim] = offset[cur_dim] = i; + h5offset[cur_dim] = (hssize_t)i; + offset[cur_dim] = (HDoff_t)i; /* if traverse in order array is incomplete, recurse */ if (local_dim > 0){ @@ -971,13 +983,6 @@ static herr_t dset_read(int local_dim, file_descr *fd, parameters *parms, hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, h5dset_space_id, h5dxpl, buffer); VRFY((hrc >= 0), "H5Dread"); -#if 0 - for (j=0; j<linear_buf_size; j++) { - buf_p = (unsigned char*)buffer; - if (buf_p[j]!=buffer2[j]) - printf("Inconsistent data in %d\n", j); - } -#endif break; default: @@ -1000,26 +1005,26 @@ done: * Modifications: */ -static herr_t posix_buffer_read(int local_dim, file_descr *fd, parameters *parms, void *buffer) +static herr_t +posix_buffer_read(int local_dim, file_descr *fd, parameters *parms, void *buffer) { - int dtype_size = 1; int ret_code = SUCCESS; - long i; - size_t d_offset; - size_t linear_dset_offset = 0; - int j, rc; /* if local dimension is not contiguous, recurse */ if (local_dim < parms->rank-1 && local_dim != cont_dim) { + size_t u; - for (i=0; i < parms->buf_size[local_dim]; i += dtype_size) { - buf_offset[local_dim] = i; + 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) break; } /* otherwise, perform contiguous POSIX access */ } else { + HDoff_t d_offset; + HDoff_t linear_dset_offset = 0; + int i, j, rc; buf_offset[local_dim] = 0; /* determine offset in buffer */ @@ -1027,9 +1032,9 @@ static herr_t posix_buffer_read(int local_dim, file_descr *fd, parameters *parms d_offset=1; for (j=i+1; j<parms->rank; j++) - d_offset *= parms->dset_size[j]; + d_offset *= (HDoff_t)parms->dset_size[j]; - linear_dset_offset += (offset[i]+buf_offset[i])*d_offset; + linear_dset_offset += (offset[i] + (HDoff_t)buf_offset[i]) * d_offset; } /* only care if seek returns error */ @@ -1161,7 +1166,7 @@ set_vfd(parameters *param) memb_fapl[mt] = H5P_DEFAULT; sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; - memb_addr[mt] = 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, diff --git a/tools/perform/sio_perf.c b/tools/perform/sio_perf.c index 7d75a2d..01ecf2b 100644 --- a/tools/perform/sio_perf.c +++ b/tools/perform/sio_perf.c @@ -68,7 +68,7 @@ #define SIO_HDF5 0x4 /* report 0.0 in case t is zero too */ -#define MB_PER_SEC(bytes,t) (((t)==0.0F) ? 0.0F : ((((double)bytes) / 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 @@ -392,6 +392,7 @@ run_test_loop(struct options *opts) parameters parms; int i; size_t buf_bytes; + /* load options into parameter structure */ parms.num_files = opts->num_files; parms.num_dsets = opts->num_dsets; @@ -943,7 +944,8 @@ parse_command_line(int argc, char *argv[]) register int opt; struct options *cl_opts; int i, default_rank, actual_rank, ranks[4]; - cl_opts = (struct options *)malloc(sizeof(struct options)); + + cl_opts = (struct options *)HDmalloc(sizeof(struct options)); cl_opts->output_file = NULL; cl_opts->io_types = 0; /* will set default after parsing options */ @@ -956,11 +958,11 @@ parse_command_line(int argc, char *argv[]) cl_opts->chk_rank = 0; cl_opts->order_rank = 0; - for (i=0; i<MAX_DIMS; i++){ - cl_opts->buf_size[i]=(i+1)*10; - cl_opts->dset_size[i]=(i+1)*100; - cl_opts->chk_size[i]=(i+1)*10; - cl_opts->order[i]=i+1; + 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->vfd = sec2; @@ -985,7 +987,7 @@ parse_command_line(int argc, char *argv[]) while (end && *end != '\0') { char buf[10]; - memset(buf, '\0', sizeof(buf)); + HDmemset(buf, '\0', sizeof(buf)); for (i = 0; *end != '\0' && *end != ','; ++end) if (isalnum(*end) && i < 10) @@ -1024,7 +1026,7 @@ parse_command_line(int argc, char *argv[]) while (end && *end != '\0') { char buf[10]; - memset(buf, '\0', sizeof(buf)); + HDmemset(buf, '\0', sizeof(buf)); for (i = 0; *end != '\0' && *end != ','; ++end) if (isalnum(*end) && i < 10) @@ -1052,7 +1054,7 @@ parse_command_line(int argc, char *argv[]) while (end && *end != '\0') { char buf[10]; - memset(buf, '\0', sizeof(buf)); + HDmemset(buf, '\0', sizeof(buf)); for (i = 0; *end != '\0' && *end != ','; ++end) if (isalnum(*end) && i < 10) @@ -1110,7 +1112,7 @@ parse_command_line(int argc, char *argv[]) while (end && *end != '\0') { char buf[10]; - memset(buf, '\0', sizeof(buf)); + HDmemset(buf, '\0', sizeof(buf)); for (i = 0; *end != '\0' && *end != ','; ++end) if (isalnum(*end) && i < 10) @@ -1174,7 +1176,7 @@ parse_command_line(int argc, char *argv[]) while (end && *end != '\0') { char buf[10]; - memset(buf, '\0', sizeof(buf)); + HDmemset(buf, '\0', sizeof(buf)); for (i = 0; *end != '\0' && *end != ','; ++end) if (isalnum(*end) && i < 10) @@ -1202,13 +1204,13 @@ parse_command_line(int argc, char *argv[]) while (end && *end != '\0') { char buf[10]; - memset(buf, '\0', sizeof(buf)); + HDmemset(buf, '\0', sizeof(buf)); for (i = 0; *end != '\0' && *end != ','; ++end) if (isalnum(*end) && i < 10) buf[i++] = *end; - cl_opts->order[j] = parse_size_directive(buf); + cl_opts->order[j] = (int)parse_size_directive(buf); j++; @@ -1300,7 +1302,7 @@ parse_size_directive(const char *size) off_t s; char *endptr; - s = strtol(size, &endptr, 10); + s = HDstrtoull(size, &endptr, 10); if (endptr && *endptr) { while (*endptr != '\0' && (*endptr == ' ' || *endptr == '\t')) @@ -1311,14 +1313,17 @@ parse_size_directive(const char *size) case 'k': s *= ONE_KB; break; + case 'M': case 'm': s *= ONE_MB; break; + case 'G': case 'g': s *= ONE_GB; break; + default: fprintf(stderr, "Illegal size specifier '%c'\n", *endptr); exit(EXIT_FAILURE); diff --git a/tools/perform/sio_standalone.h b/tools/perform/sio_standalone.h index 8f52eba..6d6afe9 100644 --- a/tools/perform/sio_standalone.h +++ b/tools/perform/sio_standalone.h @@ -56,6 +56,14 @@ # define H5_INC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)+1)) #endif +#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)) + /* * Redefine all the POSIX functions. We should never see a POSIX * function (or any other non-HDF5 function) in the source! @@ -70,6 +78,11 @@ #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 W_OK 02 +#define R_OK 04 +#endif #endif /* H5_HAVE_WIN32_API */ #define HDacos(X) acos(X) #ifdef H5_HAVE_ALARM @@ -183,20 +196,32 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #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 #endif +#ifndef H5_HAVE_WIN32_API +/* These definitions differ in Windows and are defined in + * H5win32defs for that platform. + */ +typedef struct stat h5_stat_t; +typedef off_t h5_stat_size_t; +#define HDoff_t off_t +#endif /* H5_HAVE_WIN32_API */ + #define HDftell(F) ftell(F) #define HDftruncate(F,L) ftruncate(F,L) #define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F) @@ -210,11 +235,11 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDgetgrgid(G) getgrgid(G) #define HDgetgrnam(S) getgrnam(S) #define HDgetgroups(Z,G) getgroups(Z,G) -#ifdef H5_HAVE_VISUAL_STUDIO +#ifdef H5_HAVE_WIN32_API #define HDgetlogin() Wgetlogin() -#else /* H5_HAVE_VISUAL_STUDIO */ +#else /* H5_HAVE_WIN32_API */ #define HDgetlogin() getlogin() -#endif /* H5_HAVE_VISUAL_STUDIO */ +#endif /* H5_HAVE_WIN32_API */ #define HDgetpgrp() getpgrp() #define HDgetpid() getpid() #define HDgetppid() getppid() @@ -222,12 +247,12 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDgetpwuid(U) getpwuid(U) #define HDgetrusage(X,S) getrusage(X,S) #define HDgets(S) gets(S) -#ifdef H5_HAVE_VISUAL_STUDIO +#ifdef H5_HAVE_WIN32_API H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); #define HDgettimeofday(V,Z) Wgettimeofday(V,Z) -#else /* H5_HAVE_VISUAL_STUDIO */ +#else /* H5_HAVE_WIN32_API */ #define HDgettimeofday(S,P) gettimeofday(S,P) -#endif /* H5_HAVE_VISUAL_STUDIO */ +#endif /* H5_HAVE_WIN32_API */ #define HDgetuid() getuid() #define HDgmtime(T) gmtime(T) #define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ @@ -402,6 +427,11 @@ H5_DLL void HDsrand(unsigned int seed); #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) +#else +#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) diff --git a/tools/perform/zip_perf.c b/tools/perform/zip_perf.c index d025602..d9b1fa2 100644 --- a/tools/perform/zip_perf.c +++ b/tools/perform/zip_perf.c @@ -37,7 +37,7 @@ #define MICROSECOND 1000000.0F /* report 0.0 in case t is zero too */ -#define MB_PER_SEC(bytes,t) ((fabs(t)<0.0000000001F) ? 0.0F : ((((double)bytes) / 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 @@ -173,7 +173,7 @@ write_file(Bytef *source, uLongf sourceLen) /* destination buffer needs to be at least 0.1% larger than sourceLen * plus 12 bytes */ - destLen = (uLongf)((double)sourceLen + ((double)sourceLen * 0.1F)) + 12; + destLen = (uLongf)((double)sourceLen + ((double)sourceLen * (double)0.1F)) + 12; dest = (Bytef *)HDmalloc(destLen); if (!dest) @@ -184,9 +184,9 @@ write_file(Bytef *source, uLongf sourceLen) HDgettimeofday(&timer_stop, NULL); compression_time += ((double)timer_stop.tv_sec + - ((double)timer_stop.tv_usec) / MICROSECOND) - + ((double)timer_stop.tv_usec) / (double)MICROSECOND) - ((double)timer_start.tv_sec + - ((double)timer_start.tv_usec) / MICROSECOND); + ((double)timer_start.tv_usec) / (double)MICROSECOND); if (report_once_flag) { HDfprintf(stdout, "\tCompression Ratio: %g\n", ((double)destLen) / (double)sourceLen); @@ -206,7 +206,7 @@ write_file(Bytef *source, uLongf sourceLen) if (rc == (int)d_len) break; - d_len -= rc; + d_len -= (size_t)rc; d_ptr += rc; } @@ -419,7 +419,7 @@ fill_with_random_data(Bytef *src, uLongf src_len) break; buf += rc; - len -= rc; + len -= (size_t)rc; } } else { HDfprintf(stdout, "Using random() for random data\n"); @@ -429,7 +429,7 @@ fill_with_random_data(Bytef *src, uLongf src_len) } if (compress_percent) { - unsigned long s = src_len * compress_percent / 100; + size_t s = (size_t)((src_len * (uLongf)compress_percent) / 100); HDmemset(src, '\0', s); } @@ -495,7 +495,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, if (rc == (ssize_t)s_len) break; - s_len -= rc; + s_len -= (size_t)rc; s_ptr += rc; } } @@ -504,9 +504,9 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, HDgettimeofday(&timer_stop, NULL); total_time = ((double)timer_stop.tv_sec + - ((double)timer_stop.tv_usec) / MICROSECOND) - + ((double)timer_stop.tv_usec) / (double)MICROSECOND) - ((double)timer_start.tv_sec + - ((double)timer_start.tv_usec) / MICROSECOND); + ((double)timer_start.tv_usec) / (double)MICROSECOND); HDfprintf(stdout, "\tUncompressed Write Time: %.2fs\n", total_time); HDfprintf(stdout, "\tUncompressed Write Throughput: %.2fMB/s\n", @@ -530,9 +530,9 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, HDgettimeofday(&timer_stop, NULL); total_time = ((double)timer_stop.tv_sec + - ((double)timer_stop.tv_usec) / MICROSECOND) - + ((double)timer_stop.tv_usec) / (double)MICROSECOND) - ((double)timer_start.tv_sec + - ((double)timer_start.tv_usec) / MICROSECOND); + ((double)timer_start.tv_usec) / (double)MICROSECOND); HDfprintf(stdout, "\tCompressed Write Time: %.2fs\n", total_time); HDfprintf(stdout, "\tCompressed Write Throughput: %.2fMB/s\n", |