GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
instr.h
Go to the documentation of this file.
1 
6 #ifndef GHOST_INSTR_H
7 #define GHOST_INSTR_H
8 
9 #include "config.h"
10 #include <ghost/log.h>
11 #include <ghost/error.h>
12 #include <pthread.h>
13 
14 #ifdef GHOST_INSTR_TIMING
15 
16 #include <ghost/timing.h>
17 
18 #endif
19 
20 #ifdef GHOST_INSTR_LIKWID
21 
22 #include <likwid.h>
23 
24 #endif
25 
26 extern pthread_key_t ghost_instr_enable_key;
27 
28 #ifdef GHOST_INSTR_TIMING
29 
30 #ifdef GHOST_INSTR_LIKWID
31 
32 #define GHOST_INSTR_START(tag) {\
33  if (pthread_getspecific(ghost_instr_enable_key)) {\
34  if (GHOST_VERBOSITY > 1) {\
35  GHOST_DEBUG_LOG(1,"Enter instrumented region %s",tag);\
36  }\
37  char region[256] = "";\
38  snprintf(region,256,"%s%s%s",ghost_instr_prefix_get(), tag, ghost_instr_suffix_get());\
39  ghost_timing_tick(region);\
40  _Pragma("omp parallel")\
41  likwid_markerStartRegion(region);\
42  }\
43 }\
44 
45 #define GHOST_INSTR_STOP(tag) {\
46  if (pthread_getspecific(ghost_instr_enable_key)) {\
47  if (GHOST_VERBOSITY > 1) {\
48  GHOST_DEBUG_LOG(1,"Exit instrumented region %s",tag);\
49  }\
50  char region[256] = "";\
51  snprintf(region,256,"%s%s%s",ghost_instr_prefix_get(), tag, ghost_instr_suffix_get());\
52  ghost_timing_tock(region);\
53  _Pragma("omp parallel")\
54  likwid_markerStopRegion(region);\
55  }\
56 }\
57 
58 #else
59 
60 #define GHOST_INSTR_START(tag) {\
61  if (pthread_getspecific(ghost_instr_enable_key)) {\
62  if (GHOST_VERBOSITY > 1) {\
63  GHOST_DEBUG_LOG(1,"Enter instrumented region %s",tag);\
64  }\
65  char region[256] = "";\
66  snprintf(region,256,"%s%s%s",ghost_instr_prefix_get(), tag, ghost_instr_suffix_get());\
67  ghost_timing_tick(region);\
68  }\
69 }\
70 
71 #define GHOST_INSTR_STOP(tag) {\
72  if (pthread_getspecific(ghost_instr_enable_key)) {\
73  if (GHOST_VERBOSITY > 1) {\
74  GHOST_DEBUG_LOG(1,"Exit instrumented region %s",tag);\
75  }\
76  char region[256] = "";\
77  snprintf(region,256,"%s%s%s",ghost_instr_prefix_get(), tag, ghost_instr_suffix_get());\
78  ghost_timing_tock(region);\
79  }\
80 }\
81 
82 #endif
83 
84 #else //GHOST_INSTR_TIMING
85 
86 #ifdef GHOST_INSTR_LIKWID
87 
93 #define GHOST_INSTR_START(tag) {\
94  if (pthread_getspecific(ghost_instr_enable_key)) {\
95  if (GHOST_VERBOSITY > 1) {\
96  GHOST_DEBUG_LOG(1,"Enter instrumented region %s",tag);\
97  }\
98  char region[256] = "";\
99  snprintf(region,256,"%s%s%s",ghost_instr_prefix_get(), tag, ghost_instr_suffix_get());\
100  _Pragma("omp parallel")\
101  likwid_markerStartRegion(region);\
102  }\
103 }\
104 
105 
110 #define GHOST_INSTR_STOP(tag) {\
111  if (pthread_getspecific(ghost_instr_enable_key)) {\
112  if (GHOST_VERBOSITY > 1) {\
113  GHOST_DEBUG_LOG(1,"Exit instrumented region %s",tag);\
114  }\
115  char region[256] = "";\
116  snprintf(region,256,"%s%s%s",ghost_instr_prefix_get(), tag, ghost_instr_suffix_get());\
117  _Pragma("omp parallel")\
118  likwid_markerStopRegion(region);\
119  }\
120 }\
121 
122 #else
123 
127 #define GHOST_INSTR_START(tag)\
128  if (GHOST_VERBOSITY > 1) {\
129  GHOST_DEBUG_LOG(1,"Enter instrumented region %s",tag);\
130  }\
131 
132 
135 #define GHOST_INSTR_STOP(tag) \
136  if (GHOST_VERBOSITY > 1) {\
137  GHOST_DEBUG_LOG(1,"Exit instrumented region %s",tag);\
138  }\
139 
140 #endif
141 
142 #endif
143 
144 
145 #ifdef __cplusplus
146 extern "C" {
147 #endif
148 
156  void ghost_instr_prefix_set(const char *prefix);
157 
158  char *ghost_instr_prefix_get();
166  void ghost_instr_suffix_set(const char *suffix);
167 
168  char *ghost_instr_suffix_get();
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 
176 #endif
ghost_error ghost_instr_destroy()
Definition: instr.c:27
Types, functions and macros for error handling.
void ghost_instr_prefix_set(const char *prefix)
Set the instrumentation prefix.
Definition: instr.c:42
ghost_error
Error return type.
Definition: error.h:23
pthread_key_t ghost_instr_enable_key
Definition: instr.c:10
void ghost_instr_suffix_set(const char *suffix)
Set the instrumentation suffix.
Definition: instr.c:58
char * ghost_instr_prefix_get()
Definition: instr.c:48
char * ghost_instr_suffix_get()
Definition: instr.c:63
Macros for logging.
ghost_error ghost_instr_create()
Definition: instr.c:12
Functions and types related to time measurement.