SCOREC core
Parallel unstructured mesh tools
phiotimer.h
Go to the documentation of this file.
1 #ifndef PHIOTIMER_H
2 #define PHIOTIMER_H
3 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 typedef struct PCU_t PCU_t;
14 
15 #define PHASTAIO_READTIME(cmd,bytes) {\
16  phastaioTime t0,t1;\
17  phastaio_time(&t0);\
18  cmd\
19  phastaio_time(&t1);\
20  const size_t time = phastaio_time_diff(&t0,&t1);\
21  phastaio_addReadTime(time);\
22  phastaio_addReadBytes(bytes);\
23 }
24 
25 #define PHASTAIO_WRITETIME(cmd,bytes) {\
26  phastaioTime t0,t1;\
27  phastaio_time(&t0);\
28  cmd\
29  phastaio_time(&t1);\
30  const size_t time = phastaio_time_diff(&t0,&t1);\
31  phastaio_addWriteTime(time);\
32  phastaio_addWriteBytes(bytes);\
33 }
34 
35 #define PHASTAIO_OPENTIME(cmd) {\
36  phastaioTime t0,t1;\
37  phastaio_time(&t0);\
38  cmd\
39  phastaio_time(&t1);\
40  const size_t time = phastaio_time_diff(&t0,&t1);\
41  phastaio_addOpenTime(time);\
42 }
43 
44 #define PHASTAIO_CLOSETIME(cmd) {\
45  phastaioTime t0,t1;\
46  phastaio_time(&t0);\
47  cmd\
48  phastaio_time(&t1);\
49  const size_t time = phastaio_time_diff(&t0,&t1);\
50  phastaio_addCloseTime(time);\
51 }
52 
53 /* \brief constants to identify the different phasta and chef files */
54 enum phastaio_file {
55  GEOMBC_READ,
56  GEOMBC_WRITE,
57  RESTART_READ,
58  RESTART_WRITE,
59  NUM_PHASTAIO_MODES
60 };
61 
62 #if defined(HAVE_INTEL_RDTSC)
63 typedef size_t phastaioTime;
64 #elif defined(USE_PCU_TIME)
65 typedef double phastaioTime;
66 #elif defined(HAVE_CLOCK_GETTIME)
67 #include <time.h>
68 typedef struct timespec phastaioTime;
69 #endif
70 /* \brief get the current time */
71 void phastaio_time(phastaioTime* t);
72 /* \brief compute the time difference end-start */
73 size_t phastaio_time_diff(phastaioTime* start, phastaioTime* end);
74 /* \brief accumulate bytes read */
75 void phastaio_addReadBytes(size_t b);
76 /* \brief accumulate bytes written */
77 void phastaio_addWriteBytes(size_t b);
78 /* \brief accumulate time reading */
79 void phastaio_addReadTime(size_t t);
80 /* \brief accumulate time writing */
81 void phastaio_addWriteTime(size_t t);
82 /* \brief accumulate time opening */
83 void phastaio_addOpenTime(size_t t);
84 /* \brief accumulate time closing */
85 void phastaio_addCloseTime(size_t t);
86 /* \brief initialize the counters and timers */
87 void phastaio_initStats(PCU_t h);
88 /* \brief print io information */
89 void phastaio_printStats(PCU_t h);
90 /* \brief set the current file to record counters and timers for
91  * \detail see phastaio_file enum */
92 void phastaio_setfile(int f);
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif