summaryrefslogtreecommitdiffstats
path: root/tools/lib/io_timer.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2022-04-13 21:17:29 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2022-04-13 21:17:29 (GMT)
commitcabc39c3e197e2591449d2604bfee26465fb60e1 (patch)
treed5f39f5f5965584bf9bf49646a2af617adfd3e4e /tools/lib/io_timer.c
parent7355f4c505092a7a85474b47f18d5206028e2c95 (diff)
parentab69f5df770ee3cc6cd6c81d905a5317b894a002 (diff)
downloadhdf5-feature/coding_standards.zip
hdf5-feature/coding_standards.tar.gz
hdf5-feature/coding_standards.tar.bz2
Merge branch 'develop' into feature/coding_standardsfeature/coding_standards
Diffstat (limited to 'tools/lib/io_timer.c')
-rw-r--r--tools/lib/io_timer.c128
1 files changed, 62 insertions, 66 deletions
diff --git a/tools/lib/io_timer.c b/tools/lib/io_timer.c
index cb89019..ce21b3e 100644
--- a/tools/lib/io_timer.c
+++ b/tools/lib/io_timer.c
@@ -5,13 +5,13 @@
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* changes:
* rename pio_timer.c as io_timer.c;
- * Removed pio_perf.h so that it is not dependant on it;
+ * Removed pio_perf.h so that it is not dependent on it;
* Removed set_timer_type() and get_timer_type() since no one calls them;
* Merged sio_timer.c into io_timer.c;
*/
@@ -23,7 +23,6 @@
*/
#include "H5private.h"
-#include "hdf5.h"
#include "io_timer.h"
@@ -31,10 +30,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 +42,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.
@@ -135,67 +132,73 @@ io_time_set(io_time_t *pt, timer_type t, int start_stop)
/* sanity check */
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;
+ 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
@@ -221,10 +224,3 @@ io_time_get(io_time_t *pt, timer_type t)
return pt->total_time[t];
}
-
-#if 0
-/* standalone is not working yet. Need fix later. -AKC- */
-#ifdef STANDALONE
-#include "pio_standalone.c"
-#endif
-#endif