forked from tud-zih-energy/libadapt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvt_5.14.4_patch_api_hooks
297 lines (276 loc) · 9.01 KB
/
vt_5.14.4_patch_api_hooks
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
diff -crB --new-file VampirTrace-5.14.4/acinclude.m4 VampirTrace-5.14.4-apihooks/acinclude.m4
*** VampirTrace-5.14.4/acinclude.m4 2013-06-14 09:44:19.000000000 +0200
--- VampirTrace-5.14.4-apihooks/acinclude.m4 2016-03-12 09:35:42.863077841 +0100
***************
*** 1,3 ****
--- 1,4 ----
+ m4_include(config/m4/acinclude.apihook.m4)
m4_include(config/m4/acinclude.clapack.m4)
m4_include(config/m4/acinclude.compinst.m4)
m4_include(config/m4/acinclude.compwrap.m4)
diff -crB --new-file VampirTrace-5.14.4/config/m4/acinclude.apihook.m4 VampirTrace-5.14.4-apihooks/config/m4/acinclude.apihook.m4
*** VampirTrace-5.14.4/config/m4/acinclude.apihook.m4 1970-01-01 01:00:00.000000000 +0100
--- VampirTrace-5.14.4-apihooks/config/m4/acinclude.apihook.m4 2013-03-21 14:15:54.000000000 +0100
***************
*** 0 ****
--- 1,54 ----
+ AC_DEFUN([ACVT_APIHOOKS],
+ [
+ have_apihooks="no"
+ apihooks_error="no"
+
+ APIHOOKSLIBDIR=
+ APIHOOKSLIB="-lvtapihooks"
+ APIHOOKSPREFIX="vt_api_hooks"
+
+
+ AC_MSG_CHECKING([whether API hooks should be included])
+
+ AC_ARG_ENABLE(
+ apihooks,
+ AC_HELP_STRING(
+ [--enable-apihooks],
+ [enable support for API hooks, default: disabled]),
+ [
+ have_apihooks="yes";
+ AC_MSG_RESULT([yes])
+ ],
+ [
+ AC_MSG_RESULT([no])
+ ]
+
+ )
+
+ AS_IF([test x"$have_apihooks" = "xyes"],
+ [
+ AC_ARG_WITH(apihooks-lib-dir,
+ AC_HELP_STRING([--with-apihooks-lib-dir=APIHOOKSLIBDIR],
+ [give the path for API-hooks-library, default: /usr/lib]),
+ [APIHOOKSLIBDIR="-L$withval/"])
+
+ AC_ARG_WITH(apihooks-lib,
+ AC_HELP_STRING([--with-apihooks-lib=APIHOOKSLIB], [use given API hooks lib, default: -lvtapihooks]),
+ [APIHOOKSLIB="$withval"])
+
+ AC_ARG_WITH(apihooks-prefix,
+ AC_HELP_STRING([--with-apihooks-prefix=APIHOOKSPREFIX], [use given API hooks prefix, default: vt_api_hooks]),
+ [APIHOOKSPREFIX="$withval"])
+
+ sav_LIBS=$LIBS
+ LIBS="$LIBS $APIHOOKSLIBDIR $APIHOOKSLIB"
+
+ AC_MSG_CHECKING([whether API hooks library can be found/linked (flags: $LIBS)])
+ AC_TRY_LINK([],[],
+ [AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no]);apihooks_error=yes])
+ LIBS=$sav_LIBS
+ ])
+ AC_SUBST(APIHOOKSLIBDIR)
+ AC_SUBST(APIHOOKSLIB)
+ AC_SUBST(APIHOOKSPREFIX)
+ ])
diff -crB --new-file VampirTrace-5.14.4/config/m4/acinclude.conf.m4 VampirTrace-5.14.4-apihooks/config/m4/acinclude.conf.m4
*** VampirTrace-5.14.4/config/m4/acinclude.conf.m4 2013-02-18 09:45:40.000000000 +0100
--- VampirTrace-5.14.4-apihooks/config/m4/acinclude.conf.m4 2016-03-12 09:33:39.519695578 +0100
***************
*** 284,289 ****
--- 284,299 ----
[answer="yes"], [answer="no"])
echo " Build Plugin Counter support: $answer"
+ AS_IF([test x"$have_apihooks" = "xyes"],
+ [answer="yes"], [answer="no"])
+ echo " Build API hook support: $answer"
+
+ AS_IF([test x"$have_apihooks" = "xyes"],
+ [
+ echo " API hooks library: $APIHOOKSLIB"
+ echo " API hooks prefix : $APIHOOKSPREFIX"
+ ])
+
AS_IF([test x"$have_rusage" = "xyes"],
[answer="yes"], [answer="no"])
echo " Build Resource usage trace support: $answer"
diff -crB --new-file VampirTrace-5.14.4/configure.ac VampirTrace-5.14.4-apihooks/configure.ac
*** VampirTrace-5.14.4/configure.ac 2013-06-14 09:45:34.000000000 +0200
--- VampirTrace-5.14.4-apihooks/configure.ac 2016-03-12 09:37:05.114666702 +0100
***************
*** 341,346 ****
--- 341,353 ----
AM_CONDITIONAL(AMBUILDJAVA, test x"$have_java" = "xyes")
AM_CONDITIONAL(AMBUILDVTJAVA, test x"$have_java" = "xyes" -a x"$JAVA" != x)
+ # Check for support for API hooks
+ ACVT_CONF_TITLE([API hooks])
+ ACVT_APIHOOKS
+ #these only occur if api hooks are enforced but the linking failed
+ AS_IF([test x"$apihooks_error" = "xyes"], [AC_MSG_NOTICE([Error: Linking failed]); exit 1])
+ AM_CONDITIONAL(AMHAVEAPIHOOKS, test x"$have_apihooks" = "xyes")
+
# Check for hardware performace counter support
ACVT_CONF_TITLE([Hardware performance counter])
ACVT_METRICS
diff -crB --new-file VampirTrace-5.14.4/vtlib/Makefile.am VampirTrace-5.14.4-apihooks/vtlib/Makefile.am
*** VampirTrace-5.14.4/vtlib/Makefile.am 2013-03-27 10:41:00.000000000 +0100
--- VampirTrace-5.14.4-apihooks/vtlib/Makefile.am 2016-03-12 09:34:36.155411716 +0100
***************
*** 256,261 ****
--- 256,269 ----
PLUGINCNTRCFLAGS =
endif
+ if AMHAVEAPIHOOKS
+ APIHOOKSCFLAGS = -DVT_API_HOOKS_CLASS=$(APIHOOKSPREFIX)
+ APIHOOKSLIBRARY = $(APIHOOKSLIBDIR) $(APIHOOKSLIB)
+ else
+ APIHOOKSCFLAGS =
+ APIHOOKSLIBRARY =
+ endif
+
if AMHAVEMETRICS
if AMHAVEPAPI
METRSOURCES = vt_metric_papi.c
diff -crB --new-file VampirTrace-5.14.4/vtlib/vt_api_hook.h VampirTrace-5.14.4-apihooks/vtlib/vt_api_hook.h
*** VampirTrace-5.14.4/vtlib/vt_api_hook.h 1970-01-01 01:00:00.000000000 +0100
--- VampirTrace-5.14.4-apihooks/vtlib/vt_api_hook.h 2013-08-05 16:26:11.000000000 +0200
***************
*** 0 ****
--- 1,47 ----
+ /**
+ * VampirTrace
+ * http://www.tu-dresden.de/zih/vampirtrace
+ *
+ * Copyright (c) 2005-2013, ZIH, TU Dresden, Federal Republic of Germany
+ *
+ * Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
+ * Centre, Federal Republic of Germany
+ *
+ * See the file COPYING in the package base directory for details
+ **/
+
+
+ #if defined(VT_API_HOOKS_CLASS)
+
+ /* This double dereferencing has to be used. Otherwise A might
+ * not be resolved correctly */
+
+ #define CONCAT_(A,B) A ## _ ## B
+ #define CONCAT(A,B) CONCAT_(A,B)
+
+ /* Use this to define functions */
+
+ #define VT_API_HOOK_DEFINE(function_name, signature) \
+ extern void CONCAT(VT_API_HOOKS_CLASS,function_name signature);
+
+ /* Use this to call functions */
+
+ #define VT_API_HOOK(function_name, params) \
+ CONCAT(VT_API_HOOKS_CLASS,function_name) params;
+
+ /* function definitions */
+ VT_API_HOOK_DEFINE(enter,(uint32_t, uint64_t *, uint32_t))
+ VT_API_HOOK_DEFINE(exit,(uint32_t, uint64_t *))
+ VT_API_HOOK_DEFINE(open,(void))
+ VT_API_HOOK_DEFINE(close,(void))
+ VT_API_HOOK_DEFINE(close_on_signal,(void))
+ VT_API_HOOK_DEFINE(vt_trace_on,(uint32_t,uint8_t))
+ VT_API_HOOK_DEFINE(vt_trace_off,(uint32_t,uint8_t,uint8_t))
+ VT_API_HOOK_DEFINE(reset,(void))
+ VT_API_HOOK_DEFINE(def_region,(uint32_t, const char *, uint32_t, uint32_t,
+ uint32_t, const char *, uint8_t, uint32_t))
+
+ #else
+ #define VT_API_HOOK(function_name, params)
+ #endif
+
diff -crB --new-file VampirTrace-5.14.4/vtlib/vt_trc.c VampirTrace-5.14.4-apihooks/vtlib/vt_trc.c
*** VampirTrace-5.14.4/vtlib/vt_trc.c 2013-06-14 14:54:54.000000000 +0200
--- VampirTrace-5.14.4-apihooks/vtlib/vt_trc.c 2016-03-12 09:43:07.612858555 +0100
***************
*** 89,94 ****
--- 89,95 ----
# include "vt_plugin_cntr_int.h"
#endif /* VT_PLUGIN_CNTR */
+ #include "vt_api_hook.h"
#define GET_THREAD_ID(tid) \
if ( (tid) == VT_CURRENT_THREAD ) { \
***************
*** 1153,1158 ****
--- 1154,1161 ----
if ( vt_open_called )
return;
+ VT_API_HOOK(open,());
+
/* do initialization only once */
#if (defined(VT_MT) || defined(VT_HYB))
VTThrd_lock(&init_mutex);
***************
*** 1477,1482 ****
--- 1480,1487 ----
int extra_enters;
uint64_t time;
+ VT_API_HOOK(reset,());
+
vt_is_alive = 0;
/* notice current call stack level */
***************
*** 1601,1606 ****
--- 1606,1613 ----
void vt_close_by_signal(int signum)
{
+ VT_API_HOOK(close_by_signal,());
+
vt_cntl_msg(2, "Received signal %i on pid %i", signum, getpid());
/* restore original signal handler */
***************
*** 1625,1630 ****
--- 1632,1639 ----
/* catch vt_close called from child processes through atexit */
if ( init_pid != getpid() ) return;
+ VT_API_HOOK(close,());
+
/* do finalization only once */
#if (defined(VT_MT) || defined(VT_HYB))
VTThrd_lock(&init_mutex);
***************
*** 1862,1867 ****
--- 1871,1878 ----
{
GET_THREAD_ID(tid);
+ VT_API_HOOK(vt_trace_on,(tid,mark));
+
if ( vt_is_alive &&
VTTHRD_TRACE_STATUS(VTThrdv[tid]) == VT_TRACE_OFF )
{
***************
*** 1900,1905 ****
--- 1911,1918 ----
{
GET_THREAD_ID(tid);
+ VT_API_HOOK(vt_trace_off,(tid,mark,permanent));
+
if ( vt_is_alive &&
VTTHRD_TRACE_STATUS(VTThrdv[tid]) != VT_TRACE_OFF_PERMANENT )
{
***************
*** 2489,2494 ****
--- 2502,2510 ----
rdid,
sid);
+ VT_API_HOOK(def_region, (tid, rname, fid, begln, endln, rgroup,
+ rtype, rid));
+
return rid;
}
***************
*** 2737,2742 ****
--- 2753,2760 ----
GET_THREAD_ID(tid);
+ VT_API_HOOK(enter,(tid,time,rid));
+
/* immediately return, if tracing is disabled permanently */
if (VTTHRD_TRACE_STATUS(VTThrdv[tid]) == VT_TRACE_OFF_PERMANENT) return 0;
***************
*** 2870,2875 ****
--- 2888,2895 ----
GET_THREAD_ID(tid);
+ VT_API_HOOK(exit,(tid,time));
+
/* immediately return, if tracing is disabled permanently */
if (VTTHRD_TRACE_STATUS(VTThrdv[tid]) == VT_TRACE_OFF_PERMANENT) return;