pio_timer.h

00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00002  * Copyright by The HDF Group.                                               *
00003  * Copyright by the Board of Trustees of the University of Illinois.         *
00004  * All rights reserved.                                                      *
00005  *                                                                           *
00006  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00007  * terms governing use, modification, and redistribution, is contained in    *
00008  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00009  * of the source code distribution tree; Copyright.html can be found at the  *
00010  * root level of an installed copy of the electronic HDF5 document set and   *
00011  * is linked from the top-level documents page.  It can also be found at     *
00012  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00013  * access to either file, you may request a copy from help@hdfgroup.org.     *
00014  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00015 
00016 #ifndef PIO_TIMER__
00017 #define PIO_TIMER__
00018 
00019 #include "hdf5.h"
00020 
00021 #if defined(H5_TIME_WITH_SYS_TIME)
00022 #   include <sys/time.h>
00023 #   include <time.h>
00024 #elif defined(H5_HAVE_SYS_TIME_H)
00025 #   include <sys/time.h>
00026 #else
00027 #   include <time.h>
00028 #endif
00029 
00030 /* The different types of timers we can have */
00031 typedef enum timer_type_ {
00032     HDF5_FILE_OPENCLOSE,
00033     HDF5_DATASET_CREATE,
00034     HDF5_MPI_WRITE,
00035     HDF5_MPI_READ,
00036     HDF5_FILE_READ_OPEN,
00037     HDF5_FILE_READ_CLOSE,
00038     HDF5_FILE_WRITE_OPEN,
00039     HDF5_FILE_WRITE_CLOSE,
00040     HDF5_FINE_WRITE_FIXED_DIMS,
00041     HDF5_FINE_READ_FIXED_DIMS,
00042     HDF5_GROSS_WRITE_FIXED_DIMS,
00043     HDF5_GROSS_READ_FIXED_DIMS,
00044     HDF5_RAW_WRITE_FIXED_DIMS,
00045     HDF5_RAW_READ_FIXED_DIMS,
00046     NUM_TIMERS
00047 } timer_type;
00048 
00049 typedef enum clock_type_ {
00050     MPI_TIMER = 0,  /* Use MPI timer to measure time        */
00051     SYS_TIMER = 1   /* Use system clock to measure time     */
00052 } clock_type;
00053 
00054 /* Miscellaneous identifiers */
00055 enum {
00056     START,          /* Start a specified timer              */
00057     STOP            /* Stop a specified timer               */
00058 };
00059 
00060 /* The performance time structure */
00061 typedef struct pio_time_ {
00062     clock_type type;
00063     double total_time[NUM_TIMERS];
00064     double mpi_timer[NUM_TIMERS];
00065     struct timeval sys_timer[NUM_TIMERS];
00066 } pio_time;
00067 
00068 /* External function declarations */
00069 #ifdef __cplusplus
00070 extern "C" {
00071 #endif  /* __cplusplus */
00072 extern pio_time    *pio_time_new(clock_type t);
00073 extern void         pio_time_destroy(pio_time *pt);
00074 extern void         set_timer_type(pio_time *pt, clock_type type);
00075 extern clock_type   get_timer_type(pio_time *pt);
00076 extern pio_time    *set_time(pio_time *pt, timer_type t, int start_stop);
00077 extern double       get_time(pio_time *pt, timer_type t);
00078 #ifdef __cplusplus
00079 }
00080 #endif  /* __cplusplus */
00081 
00082 #endif  /* PIO_TIMER__ */