diff options
Diffstat (limited to 'tools/perform')
-rw-r--r-- | tools/perform/CMakeLists.txt | 8 | ||||
-rw-r--r-- | tools/perform/Makefile.am | 4 | ||||
-rw-r--r-- | tools/perform/Makefile.in | 11 | ||||
-rw-r--r-- | tools/perform/io_timer.c | 225 | ||||
-rw-r--r-- | tools/perform/io_timer.h (renamed from tools/perform/pio_timer.h) | 38 | ||||
-rw-r--r-- | tools/perform/pio_engine.c | 8 | ||||
-rw-r--r-- | tools/perform/pio_perf.c | 54 | ||||
-rw-r--r-- | tools/perform/pio_perf.h | 6 | ||||
-rw-r--r-- | tools/perform/pio_timer.c | 258 | ||||
-rw-r--r-- | tools/perform/sio_engine.c | 6 | ||||
-rw-r--r-- | tools/perform/sio_perf.c | 49 | ||||
-rw-r--r-- | tools/perform/sio_perf.h | 6 | ||||
-rw-r--r-- | tools/perform/sio_timer.c | 197 | ||||
-rw-r--r-- | tools/perform/sio_timer.h | 78 |
14 files changed, 375 insertions, 573 deletions
diff --git a/tools/perform/CMakeLists.txt b/tools/perform/CMakeLists.txt index af3121e..fe3be0a 100644 --- a/tools/perform/CMakeLists.txt +++ b/tools/perform/CMakeLists.txt @@ -17,7 +17,7 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib ) # -------------------------------------------------------------------- #-- Adding test for h5perf_serial set (h5perf_serial_SRCS - ${HDF5_PERFORM_SOURCE_DIR}/sio_timer.c + ${HDF5_PERFORM_SOURCE_DIR}/io_timer.c ${HDF5_PERFORM_SOURCE_DIR}/sio_perf.c ${HDF5_PERFORM_SOURCE_DIR}/sio_engine.c ) @@ -30,7 +30,7 @@ set_target_properties (h5perf_serial PROPERTIES FOLDER perform) if (HDF5_BUILD_PERFORM_STANDALONE) #-- Adding test for h5perf_serial_alone set (h5perf_serial_alone_SRCS - ${HDF5_PERFORM_SOURCE_DIR}/sio_timer.c + ${HDF5_PERFORM_SOURCE_DIR}/io_timer.c ${HDF5_PERFORM_SOURCE_DIR}/sio_perf.c ${HDF5_PERFORM_SOURCE_DIR}/sio_engine.c ) @@ -99,7 +99,7 @@ set_target_properties (zip_perf PROPERTIES FOLDER perform) if (H5_HAVE_PARALLEL AND BUILD_TESTING) #-- Adding test for h5perf set (h5perf_SRCS - ${HDF5_PERFORM_SOURCE_DIR}/pio_timer.c + ${HDF5_PERFORM_SOURCE_DIR}/io_timer.c ${HDF5_PERFORM_SOURCE_DIR}/pio_perf.c ${HDF5_PERFORM_SOURCE_DIR}/pio_engine.c ) @@ -112,7 +112,7 @@ if (H5_HAVE_PARALLEL AND BUILD_TESTING) if (HDF5_BUILD_PERFORM_STANDALONE) #-- Adding test for h5perf set (h5perf_alone_SRCS - ${HDF5_PERFORM_SOURCE_DIR}/pio_timer.c + ${HDF5_PERFORM_SOURCE_DIR}/io_timer.c ${HDF5_PERFORM_SOURCE_DIR}/pio_perf.c ${HDF5_PERFORM_SOURCE_DIR}/pio_engine.c ) diff --git a/tools/perform/Makefile.am b/tools/perform/Makefile.am index 59c598a..265c5cf 100644 --- a/tools/perform/Makefile.am +++ b/tools/perform/Makefile.am @@ -59,8 +59,8 @@ TEST_PROG = iopipe chunk overhead zip_perf perf_meta h5perf_serial $(BUILD_ALL_P # "make clean" and some systems, e.g., AIX, do not like it. check_PROGRAMS= iopipe chunk overhead zip_perf perf_meta $(BUILD_ALL_PROGS) perf -h5perf_SOURCES=pio_perf.c pio_engine.c pio_timer.c -h5perf_serial_SOURCES=sio_perf.c sio_engine.c sio_timer.c +h5perf_SOURCES=pio_perf.c pio_engine.c io_timer.c +h5perf_serial_SOURCES=sio_perf.c sio_engine.c io_timer.c # These are the files that `make clean' (and derivatives) will remove from # this directory. diff --git a/tools/perform/Makefile.in b/tools/perform/Makefile.in index 1244e27..7ea71a7 100644 --- a/tools/perform/Makefile.in +++ b/tools/perform/Makefile.in @@ -131,14 +131,14 @@ am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_h5perf_OBJECTS = pio_perf.$(OBJEXT) pio_engine.$(OBJEXT) \ - pio_timer.$(OBJEXT) + io_timer.$(OBJEXT) h5perf_OBJECTS = $(am_h5perf_OBJECTS) h5perf_DEPENDENCIES = $(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) h5perf_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(h5perf_LDFLAGS) $(LDFLAGS) -o $@ am_h5perf_serial_OBJECTS = sio_perf.$(OBJEXT) sio_engine.$(OBJEXT) \ - sio_timer.$(OBJEXT) + io_timer.$(OBJEXT) h5perf_serial_OBJECTS = $(am_h5perf_serial_OBJECTS) h5perf_serial_DEPENDENCIES = $(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) h5perf_serial_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ @@ -723,8 +723,8 @@ h5perf_serial_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) @BUILD_PARALLEL_CONDITIONAL_TRUE@TEST_PROG_PARA = h5perf perf # Serial test programs. TEST_PROG = iopipe chunk overhead zip_perf perf_meta h5perf_serial $(BUILD_ALL_PROGS) -h5perf_SOURCES = pio_perf.c pio_engine.c pio_timer.c -h5perf_serial_SOURCES = sio_perf.c sio_engine.c sio_timer.c +h5perf_SOURCES = pio_perf.c pio_engine.c io_timer.c +h5perf_serial_SOURCES = sio_perf.c sio_engine.c io_timer.c # These are the files that `make clean' (and derivatives) will remove from # this directory. @@ -892,16 +892,15 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chunk.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io_timer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iopipe.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/overhead.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perf_meta.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pio_engine.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pio_perf.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pio_timer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sio_engine.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sio_perf.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sio_timer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zip_perf.Po@am__quote@ .c.o: diff --git a/tools/perform/io_timer.c b/tools/perform/io_timer.c new file mode 100644 index 0000000..efe909d --- /dev/null +++ b/tools/perform/io_timer.c @@ -0,0 +1,225 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* changes: + * rename pio_timer.c as io_timer.c; + * Removed pio_perf.h so that it is not dependant on it; + * Removed set_timer_type() and get_timer_type() since no one calls them; + * Merged sio_timer.c into io_timer.c; + */ + +/* + * Purpose: + * + * This is a module of useful timing functions for performance testing. + */ + +#include <stdio.h> +#include <stdlib.h> + +#include "hdf5.h" + +#ifdef H5_HAVE_PARALLEL +#include <mpi.h> +#endif + +#include "io_timer.h" + +/* + * The number to divide the tv_usec field with to get a nice decimal to add to + * the number of seconds. + */ +#define MICROSECOND 1000000.0 + +/* global variables */ +io_time_t *timer_g; /* timer: global for stub functions */ + +/* + * Function: sub_time + * Purpose: Struct two time values, and return the difference, in microseconds + * + * Note that the function assumes that a > b + * Programmer: Leon Arber, 1/27/06 + */ +static double sub_time(struct timeval* a, struct timeval* b) +{ + return (((double)a->tv_sec + + ((double)a->tv_usec) / MICROSECOND) - + ((double)b->tv_sec + + ((double)b->tv_usec) / MICROSECOND)); +} + + +/* + * Function: io_time_new + * Purpose: Build us a brand, spankin', new performance time object. + * The object is a black box to the user. They just tell us + * what type of timer they want (MPI_CLOCK for MPI_Wtime or + * SYS_CLOCK for system time). + * Return: Pointer to io_time object + * Programmer: Bill Wendling, 01. October 2001 + * Modifications: + */ +io_time_t * +io_time_new(clock_type type) +{ + io_time_t *pt = (io_time_t *)calloc(1, sizeof(struct io_time_t)); + + /* set global timer variable */ + timer_g = pt; + + pt->type = type; + return pt; +} + +/* + * Function: io_time_destroy + * Purpose: Remove the memory allocated for the io_time object. Only + * need to call on a pointer allocated with the ``io_time_new'' + * function. + * Return: Nothing + * Programmer: Bill Wendling, 01. October 2001 + * Modifications: + */ +void +io_time_destroy(io_time_t *pt) +{ + HDfree(pt); + /* reset the global timer pointer too. */ + timer_g = NULL; +} + +#if 0 +/* no one is calling set_timer_type or get_timer_type ???*/ +/* + * Function: set_timer_type + * Purpose: Set the type of the timer to either MPI_CLOCK or SYS_CLOCK. + * This really only needs to be called if you didn't construct a + * timer with the pio_timer_new function (shame!). + * Return: Nothing + * Programmer: Bill Wendling, 04. October 2001 + * Modifications: + */ +void +set_timer_type(io_time_t *pt, clock_type type) +{ + pt->type = type; +} + +/* + * Function: get_timer_type + * Purpose: Get the type of the timer. + * Return: MPI_CLOCK or SYS_CLOCK. + * Programmer: Bill Wendling, 04. October 2001 + * Modifications: + */ +clock_type +get_timer_type(io_time_t *pt) +{ + return pt->type; +} +#endif + +/* + * Function: set_time + * Purpose: Set the time in a ``io_time_t'' object. + * Return: Pointer to the passed in ``io_time_t'' object if SUCCEED; Null otherwise. + * Programmer: Bill Wendling, 01. October 2001 + * Modifications: + */ +io_time_t * +set_time(io_time_t *pt, timer_type t, int start_stop) +{ + /* sanity check */ + assert(pt); + + switch(pt->type){ +#ifdef H5_HAVE_PARALLEL + case MPI_CLOCK: + if (start_stop == TSTART) { + pt->mpi_timer[t] = MPI_Wtime(); + + /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS + * we compute the time it took to only open the file */ + if(t == HDF5_FINE_WRITE_FIXED_DIMS) + pt->total_time[HDF5_FILE_WRITE_OPEN] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_GROSS_WRITE_FIXED_DIMS]; + else if(t == HDF5_FINE_READ_FIXED_DIMS) + pt->total_time[HDF5_FILE_READ_OPEN] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_GROSS_READ_FIXED_DIMS]; + + } else { + pt->total_time[t] += MPI_Wtime() - pt->mpi_timer[t]; + pt->mpi_timer[t] = MPI_Wtime(); + + /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS + * we compute the time it took to close the file after the last read/write finished */ + if(t == HDF5_GROSS_WRITE_FIXED_DIMS) + pt->total_time[HDF5_FILE_WRITE_CLOSE] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_FINE_WRITE_FIXED_DIMS]; + else if(t == HDF5_GROSS_READ_FIXED_DIMS) + pt->total_time[HDF5_FILE_READ_CLOSE] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_FINE_READ_FIXED_DIMS]; + } + break; +#endif /* H5_HAVE_PARALLEL */ + case SYS_CLOCK: + if (start_stop == TSTART) { + HDgettimeofday(&pt->sys_timer[t], NULL); + + /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS + * we compute the time it took to only open the file */ + if(t == HDF5_FINE_WRITE_FIXED_DIMS) + pt->total_time[HDF5_FILE_WRITE_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_WRITE_FIXED_DIMS])); + else if(t == HDF5_FINE_READ_FIXED_DIMS) + pt->total_time[HDF5_FILE_READ_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_READ_FIXED_DIMS])); + + + } else { + struct timeval sys_t; + + HDgettimeofday(&sys_t, NULL); + pt->total_time[t] += sub_time(&sys_t, &(pt->sys_timer[t])); + + /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS + * we compute the time it took to close the file after the last read/write finished */ + if(t == HDF5_GROSS_WRITE_FIXED_DIMS) + pt->total_time[HDF5_FILE_WRITE_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_WRITE_FIXED_DIMS])); + else if(t == HDF5_GROSS_READ_FIXED_DIMS) + pt->total_time[HDF5_FILE_READ_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_READ_FIXED_DIMS])); + + } + break; + default: + fprintf(stderr, "Unknown time clock type (%d)\n", pt->type); + return (NULL); + break; + } + + debug_start_stop_time(pt, t, start_stop); + + return pt; +} + +/* + * Function: get_time + * Purpose: Get the time from a ``io_time_t'' object. + * Return: The number of seconds as a DOUBLE. + * Programmer: Bill Wendling, 01. October 2001 + * Modifications: + */ +double +get_time(io_time_t *pt, timer_type t) +{ + return pt->total_time[t]; +} + +#ifdef STANDALONE +#include "pio_standalone.c" +#endif diff --git a/tools/perform/pio_timer.h b/tools/perform/io_timer.h index a5ee6d7..5480ed5 100644 --- a/tools/perform/pio_timer.h +++ b/tools/perform/io_timer.h @@ -13,10 +13,11 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef PIO_TIMER__ -#define PIO_TIMER__ +#ifndef IO_TIMER__ +#define IO_TIMER__ #include "hdf5.h" +#include "H5private.h" #if defined(H5_TIME_WITH_SYS_TIME) # include <sys/time.h> @@ -27,6 +28,9 @@ # include <time.h> #endif +#ifdef H5_HAVE_WINSOCK2_H +# include <winsock2.h> +#endif /* H5_HAVE_WINSOCK2_H */ /* The different types of timers we can have */ typedef enum timer_type_ { HDF5_FILE_OPENCLOSE, @@ -47,8 +51,8 @@ typedef enum timer_type_ { } timer_type; typedef enum clock_type_ { - MPI_TIMER = 0, /* Use MPI timer to measure time */ - SYS_TIMER = 1 /* Use system clock to measure time */ + SYS_CLOCK = 0, /* Use system clock to measure time */ + MPI_CLOCK = 1 /* Use MPI clock to measure time */ } clock_type; /* Miscellaneous identifiers */ @@ -58,25 +62,33 @@ enum { }; /* The performance time structure */ -typedef struct pio_time_ { +typedef struct io_time_t { clock_type type; double total_time[NUM_TIMERS]; double mpi_timer[NUM_TIMERS]; struct timeval sys_timer[NUM_TIMERS]; -} pio_time; +} io_time_t; /* External function declarations */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -extern pio_time *pio_time_new(clock_type t); -extern void pio_time_destroy(pio_time *pt); -extern void set_timer_type(pio_time *pt, clock_type type); -extern clock_type get_timer_type(pio_time *pt); -extern pio_time *set_time(pio_time *pt, timer_type t, int start_stop); -extern double get_time(pio_time *pt, timer_type t); +#if 1 +/* from sio_time.h */ +//extern io_time_t *sio_time_new(void); +//extern void sio_time_destroy(io_time_t *pt); +//extern void set_timer_type(io_time_t *pt); +//extern io_time_t *set_time(io_time_t *pt, timer_type t, int start_stop); +//extern double get_time(io_time_t *pt, timer_type t); +#endif +extern io_time_t *io_time_new(clock_type t); +extern void io_time_destroy(io_time_t *pt); +//extern void set_timer_type(io_time_t *pt, clock_type type); +//extern clock_type get_timer_type(io_time_t *pt); +extern io_time_t *set_time(io_time_t *pt, timer_type t, int start_stop); +extern double get_time(io_time_t *pt, timer_type t); #ifdef __cplusplus } #endif /* __cplusplus */ -#endif /* PIO_TIMER__ */ +#endif /* IO_TIMER__ */ diff --git a/tools/perform/pio_engine.c b/tools/perform/pio_engine.c index 3535fb4..8cb9138 100644 --- a/tools/perform/pio_engine.c +++ b/tools/perform/pio_engine.c @@ -38,7 +38,7 @@ #endif /* !MPI_FILE_NULL */ #include "pio_perf.h" -#include "pio_timer.h" +//#include "io_timer.h" /* Macro definitions */ @@ -174,15 +174,15 @@ do_pio(parameters param) switch (iot) { case MPIO: fd.mpifd = MPI_FILE_NULL; - res.timers = pio_time_new(MPI_TIMER); + res.timers = io_time_new(MPI_CLOCK); break; case POSIXIO: fd.posixfd = -1; - res.timers = pio_time_new(MPI_TIMER); + res.timers = io_time_new(MPI_CLOCK); break; case PHDF5: fd.h5fd = -1; - res.timers = pio_time_new(MPI_TIMER); + res.timers = io_time_new(MPI_CLOCK); break; default: /* unknown request */ diff --git a/tools/perform/pio_perf.c b/tools/perform/pio_perf.c index cf41cbe..4db2249 100644 --- a/tools/perform/pio_perf.c +++ b/tools/perform/pio_perf.c @@ -664,7 +664,7 @@ run_test(iotype iot, parameters parms, struct options *opts) } - pio_time_destroy(res.timers); + io_time_destroy(res.timers); } /* @@ -1676,6 +1676,58 @@ usage(const char *prog) } } +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 */ + #else /* H5_HAVE_PARALLEL */ /* diff --git a/tools/perform/pio_perf.h b/tools/perform/pio_perf.h index 3295e2b..0fff7a3 100644 --- a/tools/perform/pio_perf.h +++ b/tools/perform/pio_perf.h @@ -24,7 +24,7 @@ #else #include "pio_standalone.h" #endif -#include "pio_timer.h" +#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 @@ -59,7 +59,7 @@ typedef struct parameters_ { typedef struct results_ { herr_t ret_code; - pio_time *timers; + io_time_t *timers; } results; #ifndef SUCCESS @@ -71,7 +71,7 @@ typedef struct results_ { #endif /* !FAIL */ extern FILE *output; /* output file */ -extern pio_time *timer_g; /* timer: global for stub functions */ +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 */ diff --git a/tools/perform/pio_timer.c b/tools/perform/pio_timer.c deleted file mode 100644 index aba219e..0000000 --- a/tools/perform/pio_timer.c +++ /dev/null @@ -1,258 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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 * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Purpose: - * - * This is a module of useful timing functions for performance testing. - */ - -#include <stdio.h> -#include <stdlib.h> - -#include "hdf5.h" - -#ifdef H5_HAVE_PARALLEL - -#include <mpi.h> - -#include "pio_perf.h" - -/* - * The number to divide the tv_usec field with to get a nice decimal to add to - * the number of seconds. - */ -#define MICROSECOND 1000000.0 - -/* global variables */ -pio_time *timer_g; /* timer: global for stub functions */ - -/* - * Function: sub_time - * Purpose: Struct two time values, and return the difference, in microseconds - * - * Note that the function assumes that a > b - * Programmer: Leon Arber, 1/27/06 - */ -static double sub_time(struct timeval* a, struct timeval* b) -{ - return (((double)a->tv_sec + - ((double)a->tv_usec) / MICROSECOND) - - ((double)b->tv_sec + - ((double)b->tv_usec) / MICROSECOND)); -} - - -/* - * Function: pio_time_new - * Purpose: Build us a brand, spankin', new performance time object. - * The object is a black box to the user. They just tell us - * what type of timer they want (MPI_TIMER for MPI_Wtime or - * SYS_TIMER for system time). - * Return: Pointer to pio_time object - * Programmer: Bill Wendling, 01. October 2001 - * Modifications: - */ -pio_time * -pio_time_new(clock_type type) -{ - pio_time *pt = (pio_time *)calloc(1, sizeof(struct pio_time_)); - - /* set global timer variable */ - timer_g = pt; - - pt->type = type; - return pt; -} - -/* - * Function: pio_time_destroy - * Purpose: Remove the memory allocated for the pio_time object. Only - * need to call on a pointer allocated with the ``pio_time_new'' - * function. - * Return: Nothing - * Programmer: Bill Wendling, 01. October 2001 - * Modifications: - */ -void -pio_time_destroy(pio_time *pt) -{ - HDfree(pt); - /* reset the global timer pointer too. */ - timer_g = NULL; -} - -/* - * Function: set_timer_type - * Purpose: Set the type of the timer to either MPI_TIMER or SYS_TIMER. - * This really only needs to be called if you didn't construct a - * timer with the pio_timer_new function (shame!). - * Return: Nothing - * Programmer: Bill Wendling, 04. October 2001 - * Modifications: - */ -void -set_timer_type(pio_time *pt, clock_type type) -{ - pt->type = type; -} - -/* - * Function: get_timer_type - * Purpose: Get the type of the timer. - * Return: MPI_TIMER or SYS_TIMER. - * Programmer: Bill Wendling, 04. October 2001 - * Modifications: - */ -clock_type -get_timer_type(pio_time *pt) -{ - return pt->type; -} - -/* - * Function: set_time - * Purpose: Set the time in a ``pio_time'' object. - * Return: Pointer to the passed in ``pio_time'' object. - * Programmer: Bill Wendling, 01. October 2001 - * Modifications: - */ -pio_time * -set_time(pio_time *pt, timer_type t, int start_stop) -{ - if (pt) { - if (pt->type == MPI_TIMER) { - if (start_stop == TSTART) { - pt->mpi_timer[t] = MPI_Wtime(); - - /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS - * we compute the time it took to only open the file */ - if(t == HDF5_FINE_WRITE_FIXED_DIMS) - pt->total_time[HDF5_FILE_WRITE_OPEN] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_GROSS_WRITE_FIXED_DIMS]; - else if(t == HDF5_FINE_READ_FIXED_DIMS) - pt->total_time[HDF5_FILE_READ_OPEN] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_GROSS_READ_FIXED_DIMS]; - - } else { - pt->total_time[t] += MPI_Wtime() - pt->mpi_timer[t]; - pt->mpi_timer[t] = MPI_Wtime(); - - /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS - * we compute the time it took to close the file after the last read/write finished */ - if(t == HDF5_GROSS_WRITE_FIXED_DIMS) - pt->total_time[HDF5_FILE_WRITE_CLOSE] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_FINE_WRITE_FIXED_DIMS]; - else if(t == HDF5_GROSS_READ_FIXED_DIMS) - pt->total_time[HDF5_FILE_READ_CLOSE] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_FINE_READ_FIXED_DIMS]; - } - } else { - if (start_stop == TSTART) { - HDgettimeofday(&pt->sys_timer[t], NULL); - - /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS - * we compute the time it took to only open the file */ - if(t == HDF5_FINE_WRITE_FIXED_DIMS) - pt->total_time[HDF5_FILE_WRITE_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_WRITE_FIXED_DIMS])); - else if(t == HDF5_FINE_READ_FIXED_DIMS) - pt->total_time[HDF5_FILE_READ_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_READ_FIXED_DIMS])); - - - } else { - struct timeval sys_t; - - HDgettimeofday(&sys_t, NULL); - pt->total_time[t] += sub_time(&sys_t, &(pt->sys_timer[t])); - -/* ((double)sys_t.tv_sec + - ((double)sys_t.tv_usec) / MICROSECOND) - - ((double)pt->sys_timer[t].tv_sec + - ((double)pt->sys_timer[t].tv_usec) / MICROSECOND);*/ - - /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS - * we compute the time it took to close the file after the last read/write finished */ - if(t == HDF5_GROSS_WRITE_FIXED_DIMS) - pt->total_time[HDF5_FILE_WRITE_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_WRITE_FIXED_DIMS])); - else if(t == HDF5_GROSS_READ_FIXED_DIMS) - pt->total_time[HDF5_FILE_READ_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_READ_FIXED_DIMS])); - - } - } - - 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]); - } - } - - return pt; -} - -/* - * Function: get_time - * Purpose: Get the time from a ``pio_time'' object. - * Return: The number of seconds as a DOUBLE. - * Programmer: Bill Wendling, 01. October 2001 - * Modifications: - */ -double -get_time(pio_time *pt, timer_type t) -{ - return pt->total_time[t]; -} - -#endif /* H5_HAVE_PARALLEL */ -#ifdef STANDALONE -#include "pio_standalone.c" -#endif diff --git a/tools/perform/sio_engine.c b/tools/perform/sio_engine.c index 07e6b16c..dc6cbb8 100644 --- a/tools/perform/sio_engine.c +++ b/tools/perform/sio_engine.c @@ -29,7 +29,7 @@ #include "hdf5.h" #include "sio_perf.h" -#include "sio_timer.h" +//#include "io_timer.h" /* Macro definitions */ @@ -143,11 +143,11 @@ do_sio(parameters param) switch (iot) { case POSIXIO: fd.posixfd = -1; - res.timers = sio_time_new(); + res.timers = io_time_new(SYS_CLOCK); break; case HDF5: fd.h5fd = -1; - res.timers = sio_time_new(); + res.timers = io_time_new(SYS_CLOCK); break; default: /* unknown request */ diff --git a/tools/perform/sio_perf.c b/tools/perform/sio_perf.c index 26cec6d..1828d6f 100644 --- a/tools/perform/sio_perf.c +++ b/tools/perform/sio_perf.c @@ -547,7 +547,7 @@ run_test(iotype iot, parameters parms, struct options *opts) read_raw_mm_table[i] = read_gross_mm; } - sio_time_destroy(res.timers); + io_time_destroy(res.timers); } /* @@ -1407,3 +1407,50 @@ usage(const char *prog) fflush(stdout); } +void debug_start_stop_time(io_time_t *pt, timer_type t, int start_stop) +{ + if (sio_debug_level >= 4) { + const char *msg; + + 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, " %s %s: %.2f\n", msg, + (start_stop == TSTART ? "Start" : "Stop"), + pt->total_time[t]); + } +} /* debug_start_stop_time */ + diff --git a/tools/perform/sio_perf.h b/tools/perform/sio_perf.h index b40fed3..311d909 100644 --- a/tools/perform/sio_perf.h +++ b/tools/perform/sio_perf.h @@ -15,7 +15,7 @@ #ifndef SIO_PERF_H__ #define SIO_PERF_H__ -#include "sio_timer.h" +#include "io_timer.h" #ifndef STANDALONE #include "H5private.h" #include "h5test.h" @@ -71,7 +71,7 @@ typedef struct parameters_ { typedef struct results_ { herr_t ret_code; - sio_time *timers; + io_time_t *timers; } results; #ifndef SUCCESS @@ -83,7 +83,7 @@ typedef struct results_ { #endif /* !FAIL */ extern FILE *output; /* output file */ -extern sio_time *timer_g; /* timer: global for stub functions */ +extern io_time_t *timer_g; /* timer: global for stub functions */ extern int sio_debug_level; /* The debug level: * 0 - Off * 1 - Minimal diff --git a/tools/perform/sio_timer.c b/tools/perform/sio_timer.c deleted file mode 100644 index 4e42ee6..0000000 --- a/tools/perform/sio_timer.c +++ /dev/null @@ -1,197 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Purpose: - * - * This is a module of useful timing functions for performance testing. - */ - -#include <stdio.h> -#include <stdlib.h> - -#include "sio_timer.h" - - -#include "sio_perf.h" - -/* - * The number to divide the tv_usec field with to get a nice decimal to add to - * the number of seconds. - */ -#define MICROSECOND 1000000.0 - -/* global variables */ -sio_time *timer_g; /* timer: global for stub functions */ - -/* - * Function: sub_time - * Purpose: Struct two time values, and return the difference, in microseconds - * - * Note that the function assumes that a > b - * Programmer: Leon Arber, 1/27/06 - */ -static double sub_time(struct timeval* a, struct timeval* b) -{ - return (((double)a->tv_sec + - ((double)a->tv_usec) / MICROSECOND) - - ((double)b->tv_sec + - ((double)b->tv_usec) / MICROSECOND)); -} - - -/* - * Function: sio_time_new - * Purpose: Build us a brand, spankin', new performance time object. - * The object is a black box to the user. - * Return: Pointer to sio_time object - * Programmer: Bill Wendling, 01. October 2001 - * Modifications: - */ -sio_time * -sio_time_new(void) -{ - sio_time *pt = (sio_time *)calloc(1, sizeof(struct sio_time_)); - - /* set global timer variable */ - timer_g = pt; - - return pt; -} - -/* - * Function: sio_time_destroy - * Purpose: Remove the memory allocated for the sio_time object. Only - * need to call on a pointer allocated with the ``sio_time_new'' - * function. - * Return: Nothing - * Programmer: Bill Wendling, 01. October 2001 - * Modifications: - */ -void -sio_time_destroy(sio_time *pt) -{ - HDfree(pt); - /* reset the global timer pointer too. */ - timer_g = NULL; -} - - - -/* - * Function: set_time - * Purpose: Set the time in a ``sio_time'' object. - * Return: Pointer to the passed in ``sio_time'' object. - * Programmer: Bill Wendling, 01. October 2001 - * Modifications: - */ -sio_time * -set_time(sio_time *pt, timer_type t, int start_stop) -{ - if (pt) { - if (start_stop == TSTART) { - HDgettimeofday(&pt->sys_timer[t], NULL); - - /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS - * we compute the time it took to only open the file */ - if(t == HDF5_FINE_WRITE_FIXED_DIMS) - pt->total_time[HDF5_FILE_WRITE_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_WRITE_FIXED_DIMS])); - else if(t == HDF5_FINE_READ_FIXED_DIMS) - pt->total_time[HDF5_FILE_READ_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_READ_FIXED_DIMS])); - - - } else { - struct timeval sys_t; - - HDgettimeofday(&sys_t, NULL); - pt->total_time[t] += sub_time(&sys_t, &(pt->sys_timer[t])); - -/* ((double)sys_t.tv_sec + - ((double)sys_t.tv_usec) / MICROSECOND) - - ((double)pt->sys_timer[t].tv_sec + - ((double)pt->sys_timer[t].tv_usec) / MICROSECOND);*/ - - /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS - * we compute the time it took to close the file after the last read/write finished */ - if(t == HDF5_GROSS_WRITE_FIXED_DIMS) - pt->total_time[HDF5_FILE_WRITE_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_WRITE_FIXED_DIMS])); - else if(t == HDF5_GROSS_READ_FIXED_DIMS) - pt->total_time[HDF5_FILE_READ_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_READ_FIXED_DIMS])); - - } - - if (sio_debug_level >= 4) { - const char *msg; - - 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, " %s %s: %.2f\n", msg, - (start_stop == TSTART ? "Start" : "Stop"), - pt->total_time[t]); - } - } - - return pt; -} - -/* - * Function: get_time - * Purpose: Get the time from a ``sio_time'' object. - * Return: The number of seconds as a DOUBLE. - * Programmer: Bill Wendling, 01. October 2001 - * Modifications: - */ -double -get_time(sio_time *pt, timer_type t) -{ - return pt->total_time[t]; -} -#ifdef STANDALONE -#include "sio_standalone.c" -#endif - diff --git a/tools/perform/sio_timer.h b/tools/perform/sio_timer.h deleted file mode 100644 index 46702c3..0000000 --- a/tools/perform/sio_timer.h +++ /dev/null @@ -1,78 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef SIO_TIMER__ -#define SIO_TIMER__ - -#include "hdf5.h" - -#if defined(H5_TIME_WITH_SYS_TIME) -# include <sys/time.h> -# include <time.h> -#elif defined(H5_HAVE_SYS_TIME_H) -# include <sys/time.h> -#else -# include <time.h> -#endif - -#ifdef H5_HAVE_WINSOCK2_H -# include <winsock2.h> -#endif /* H5_HAVE_WINSOCK2_H */ - -/* The different types of timers we can have */ -typedef enum timer_type_ { - HDF5_FILE_OPENCLOSE, - HDF5_DATASET_CREATE, - HDF5_MPI_WRITE, - HDF5_MPI_READ, - HDF5_FILE_READ_OPEN, - HDF5_FILE_READ_CLOSE, - HDF5_FILE_WRITE_OPEN, - HDF5_FILE_WRITE_CLOSE, - HDF5_FINE_WRITE_FIXED_DIMS, - HDF5_FINE_READ_FIXED_DIMS, - HDF5_GROSS_WRITE_FIXED_DIMS, - HDF5_GROSS_READ_FIXED_DIMS, - HDF5_RAW_WRITE_FIXED_DIMS, - HDF5_RAW_READ_FIXED_DIMS, - NUM_TIMERS -} timer_type; - - -/* Miscellaneous identifiers */ -enum { - TSTART, /* Start a specified timer */ - TSTOP /* Stop a specified timer */ -}; - -/* The performance time structure */ -typedef struct sio_time_ { - double total_time[NUM_TIMERS]; - struct timeval sys_timer[NUM_TIMERS]; -} sio_time; - -/* External function declarations */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ -extern sio_time *sio_time_new(void); -extern void sio_time_destroy(sio_time *pt); -extern void set_timer_type(sio_time *pt); -extern sio_time *set_time(sio_time *pt, timer_type t, int start_stop); -extern double get_time(sio_time *pt, timer_type t); -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* SIO_TIMER__ */ |