-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathgettime.h
76 lines (65 loc) · 2.63 KB
/
gettime.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/***********************************************************************
* Copyright (C) 2002,2003,2004,2005,2006,2007,2008 Carsten Urbach
* Copyright (C) 2012 Bartosz Kostrzewa (gettime.[c,h])
*
* This file is part of tmLQCD.
*
* tmLQCD is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* tmLQCD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with tmLQCD. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/
#ifndef _GETTIME_H
#define _GETTIME_H
#define TM_TIMING_MAX_LEVELS 15
#define TM_TIMING_STACK_PATH_LENGTH 500
#define TM_TIMING_NAME_LENGTH 50
/* gettime provides a time measurement with the BGL real time ticker,
MPI_Wtime, clock_gettime and clock in decreasing order of preference
depending on availability. Except for clock(), all these measurements
are good representations of walltime */
#ifdef __cplusplus
extern "C" {
#endif
double gettime(void);
typedef struct tm_timers_s {
int lvl;
double t[TM_TIMING_MAX_LEVELS];
char callstack[TM_TIMING_MAX_LEVELS][TM_TIMING_STACK_PATH_LENGTH];
char name[TM_TIMING_MAX_LEVELS][TM_TIMING_NAME_LENGTH];
} tm_timers_t;
// tm_stopwatch_push will increase the timing level and perform a gettime()
// measurement
// the 'name' and context arguments are used to build a hierarchical tree
// where 'name' must always be specified and 'group' can be used
// for disambiguiation
// internally, if not at level 0, the context of the level below
// is prepended:
//
// callstack[lvl-1]/[group:]name
//
void tm_stopwatch_push(tm_timers_t * const timers, const char * const name,
const char * const group);
// tm_stopwatch_pop will output and decrease the timing level
//
// # %s: Time for %s : %e s level: %d g_proc_id: %d %s \n
//
// with the prefix, the name and gettime()-startime inserted if the g_proc_id
// matches proc_id and the g_debug_level is equal or higher than
// dbg_level_threshold
// The call stack is given by the last field.
void tm_stopwatch_pop(tm_timers_t * const timers,
const int proc_id, const int dbg_level_threshold,
const char * const prefix);
#ifdef __cplusplus
}
#endif
#endif /* _GETTIME_H */