diff options
Diffstat (limited to 'tools/lib/io_timer.c')
-rw-r--r-- | tools/lib/io_timer.c | 136 |
1 files changed, 70 insertions, 66 deletions
diff --git a/tools/lib/io_timer.c b/tools/lib/io_timer.c index ab184d3..58d3b65 100644 --- a/tools/lib/io_timer.c +++ b/tools/lib/io_timer.c @@ -5,7 +5,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -31,10 +31,10 @@ * The number to divide the tv_usec field with to get a nice decimal to add to * the number of seconds. */ -#define MICROSECOND 1000000.0F +#define MICROSECOND 1000000.0F /* global variables */ -io_time_t *timer_g; /* timer: global for stub functions */ +io_time_t *timer_g; /* timer: global for stub functions */ /* * Function: sub_time @@ -43,15 +43,13 @@ io_time_t *timer_g; /* timer: global for stub functions */ * Note that the function assumes that a > b * Programmer: Leon Arber, 1/27/06 */ -static double sub_time(struct timeval* a, struct timeval* b) +static double +sub_time(struct timeval *a, struct timeval *b) { - return (((double)a->tv_sec + - ((double)a->tv_usec) / (double)MICROSECOND) - - ((double)b->tv_sec + - ((double)b->tv_usec) / (double)MICROSECOND)); + return (((double)a->tv_sec + ((double)a->tv_usec) / (double)MICROSECOND) - + ((double)b->tv_sec + ((double)b->tv_usec) / (double)MICROSECOND)); } - /* * Function: io_time_new * Purpose: Build us a brand, spankin', new performance time object. @@ -123,75 +121,85 @@ get_timer_type(io_time_t *pt) #endif /* - * Function: set_time + * Function: io_time_set * 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) +io_time_set(io_time_t *pt, timer_type t, int start_stop) { /* sanity check */ - assert(pt); + HDassert(pt); - switch(pt->type){ + 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; + 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; +#else + case MPI_CLOCK: + HDfprintf(stderr, "MPI clock set in serial library\n"); + return NULL; #endif /* H5_HAVE_PARALLEL */ - case SYS_CLOCK: + 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 { + /* 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])); - + /* 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; + break; - default: - HDfprintf(stderr, "Unknown time clock type (%d)\n", pt->type); - return NULL; + default: + HDfprintf(stderr, "Unknown time clock type (%d)\n", pt->type); + return NULL; } /* end switch */ #if 0 @@ -203,21 +211,17 @@ set_time(io_time_t *pt, timer_type t, int start_stop) } /* - * Function: get_time + * Function: io_time_get * 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) +io_time_get(io_time_t *pt, timer_type t) { + /* sanity check */ + HDassert(pt); + return pt->total_time[t]; } - -#if 0 -/* standalone is not working yet. Need fix later. -AKC- */ -#ifdef STANDALONE -#include "pio_standalone.c" -#endif -#endif |