File: papi_debug.h

package info (click to toggle)
papi 5.7.0+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 9,856 kB
  • sloc: ansic: 93,265; fortran: 3,338; xml: 2,460; makefile: 815; sh: 290
file content (289 lines) | stat: -rw-r--r-- 6,641 bytes parent folder | download | duplicates (4)
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
/****************************/
/* THIS IS OPEN SOURCE CODE */
/****************************/
/** 
* @file    papi_debug.h
* @author  Philip Mucci
*          mucci@cs.utk.edu
* @author  Dan Terpstra
*          terpstra.utk.edu
* @author  Kevin London
*	       london@cs.utk.edu
* @author  Haihang You
*          you@cs.utk.edu
*/

#ifndef _PAPI_DEBUG_H
#define _PAPI_DEBUG_H

#ifdef NO_VARARG_MACRO
#include <stdarg.h>
#endif

#include <stdio.h>

/* Debug Levels */

#define DEBUG_SUBSTRATE         0x002
#define DEBUG_API               0x004
#define DEBUG_INTERNAL          0x008
#define DEBUG_THREADS           0x010
#define DEBUG_MULTIPLEX         0x020
#define DEBUG_OVERFLOW          0x040
#define DEBUG_PROFILE           0x080
#define DEBUG_MEMORY            0x100
#define DEBUG_LEAK              0x200
#define DEBUG_ALL               (DEBUG_SUBSTRATE|DEBUG_API|DEBUG_INTERNAL|DEBUG_THREADS|DEBUG_MULTIPLEX|DEBUG_OVERFLOW|DEBUG_PROFILE|DEBUG_MEMORY|DEBUG_LEAK)

/* Please get rid of the DBG macro from your code */

extern int _papi_hwi_debug;
extern unsigned long int ( *_papi_hwi_thread_id_fn ) ( void );

#ifdef DEBUG

#ifdef __GNUC__
#define FUNC __FUNCTION__
#elif defined(__func__)
#define FUNC __func__
#else
#define FUNC "?"
#endif

#define DEBUGLABEL(a) if (_papi_hwi_thread_id_fn) fprintf(stderr, "%s:%s:%s:%d:%d:%#lx ",a,__FILE__, FUNC, __LINE__,(int)getpid(),_papi_hwi_thread_id_fn()); else fprintf(stderr, "%s:%s:%s:%d:%d ",a,__FILE__, FUNC, __LINE__, (int)getpid())
#define ISLEVEL(a) (_papi_hwi_debug&a)

#define DEBUGLEVEL(a) ((a&DEBUG_SUBSTRATE)?"SUBSTRATE":(a&DEBUG_API)?"API":(a&DEBUG_INTERNAL)?"INTERNAL":(a&DEBUG_THREADS)?"THREADS":(a&DEBUG_MULTIPLEX)?"MULTIPLEX":(a&DEBUG_OVERFLOW)?"OVERFLOW":(a&DEBUG_PROFILE)?"PROFILE":(a&DEBUG_MEMORY)?"MEMORY":(a&DEBUG_LEAK)?"LEAK":"UNKNOWN")

#ifndef NO_VARARG_MACRO		 /* Has variable arg macro support */
#define PAPIDEBUG(level,format, args...) { if(_papi_hwi_debug&level){DEBUGLABEL(DEBUGLEVEL(level));fprintf(stderr,format, ## args);}}

 /* Macros */

#define SUBDBG(format, args...) (PAPIDEBUG(DEBUG_SUBSTRATE,format, ## args))
#define APIDBG(format, args...) (PAPIDEBUG(DEBUG_API,format, ## args))
#define INTDBG(format, args...) (PAPIDEBUG(DEBUG_INTERNAL,format, ## args))
#define THRDBG(format, args...) (PAPIDEBUG(DEBUG_THREADS,format, ## args))
#define MPXDBG(format, args...) (PAPIDEBUG(DEBUG_MULTIPLEX,format, ## args))
#define OVFDBG(format, args...) (PAPIDEBUG(DEBUG_OVERFLOW,format, ## args))
#define PRFDBG(format, args...) (PAPIDEBUG(DEBUG_PROFILE,format, ## args))
#define MEMDBG(format, args...) (PAPIDEBUG(DEBUG_MEMORY,format, ## args))
#define LEAKDBG(format, args...) (PAPIDEBUG(DEBUG_LEAK,format, ## args))
#endif

#else
#ifndef NO_VARARG_MACRO		 /* Has variable arg macro support */
#define SUBDBG(format, args...) { ; }
#define APIDBG(format, args...) { ; }
#define INTDBG(format, args...) { ; }
#define THRDBG(format, args...) { ; }
#define MPXDBG(format, args...) { ; }
#define OVFDBG(format, args...) { ; }
#define PRFDBG(format, args...) { ; }
#define MEMDBG(format, args...) { ; }
#define LEAKDBG(format, args...) { ; }
#define PAPIDEBUG(level, format, args...) { ; }
#endif
#endif

/*
 * Debug functions for platforms without vararg macro support
 */

#ifdef NO_VARARG_MACRO

static void PAPIDEBUG( int level, char *format, va_list args )
{
#ifdef DEBUG

	if ( ISLEVEL( level ) ) {
		vfprintf( stderr, format, args );
	} else
#endif
		return;
}

static void
_SUBDBG( char *format, ... )
{
#ifdef DEBUG
	va_list args;
	va_start(args, format);
	PAPIDEBUG( DEBUG_SUBSTRATE, format, args );
	va_end(args);
#endif
}
#ifdef DEBUG
#define SUBDBG do { \
 if (DEBUG_SUBSTRATE & _papi_hwi_debug) {\
   DEBUGLABEL( DEBUGLEVEL ( DEBUG_SUBSTRATE ) ); \
 } \
} while(0); _SUBDBG
#else
#define SUBDBG _SUBDBG
#endif

static void
_APIDBG( char *format, ... )
{
#ifdef DEBUG
	va_list args;
	va_start(args, format);
	PAPIDEBUG( DEBUG_API, format, args );
	va_end(args);
#endif
}
#ifdef DEBUG
#define APIDBG do { \
  if (DEBUG_API&_papi_hwi_debug) {\
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_API ) ); \
  } \
} while(0); _APIDBG
#else
#define APIDBG _APIDBG
#endif

static void
_INTDBG( char *format, ... )
{
#ifdef DEBUG
	va_list args;
	va_start(args, format);
	PAPIDEBUG( DEBUG_INTERNAL, format, args );
	va_end(args);
#endif
}
#ifdef DEBUG
#define INTDBG do { \
    if (DEBUG_INTERNAL&_papi_hwi_debug) {\
	  DEBUGLABEL( DEBUGLEVEL ( DEBUG_INTERNAL ) ); \
	} \
} while(0); _INTDBG
#else
#define INTDBG _INTDBG
#endif 

static void
_THRDBG( char *format, ... )
{
#ifdef DEBUG
	va_list args;
	va_start(args, format);
	PAPIDEBUG( DEBUG_THREADS, format, args );
	va_end(args);
#endif
}
#ifdef DEBUG
#define THRDBG do { \
  if (DEBUG_THREADS&_papi_hwi_debug) {\
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_THREADS ) ); \
  } \
} while(0); _THRDBG
#else
#define THRDBG _THRDBG
#endif

static void
_MPXDBG( char *format, ... )
{
#ifdef DEBUG
	va_list args;
	va_start(args, format);
	PAPIDEBUG( DEBUG_MULTIPLEX, format, args );
	va_end(args);
#endif
}
#ifdef DEBUG
#define MPXDBG do { \
  if (DEBUG_MULTIPLEX&_papi_hwi_debug) {\
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_MULTIPLEX ) ); \
  } \
} while(0); _MPXDBG
#else
#define MPXDBG _MPXDBG
#endif

static void
_OVFDBG( char *format, ... )
{
#ifdef DEBUG
	va_list args;
	va_start(args, format);
	PAPIDEBUG( DEBUG_OVERFLOW, format, args );
	va_end(args);
#endif
}
#ifdef DEBUG
#define OVFDBG do { \
  if (DEBUG_OVERFLOW&_papi_hwi_debug) {\
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_OVERFLOW ) ); \
  } \
} while(0); _OVFDBG
#else
#define OVFDBG _OVFDBG
#endif

static void
_PRFDBG( char *format, ... )
{
#ifdef DEBUG
	va_list args;
	va_start(args, format);
	PAPIDEBUG( DEBUG_PROFILE, format, args );
	va_end(args);
#endif
}
#ifdef DEBUG
#define PRFDBG do { \
  if (DEBUG_PROFILE&_papi_hwi_debug) {\
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_PROFILE ) ); \
  } \
} while(0); _PRFDBG
#else
#define PRFDBG _PRFDBG
#endif

static void
_MEMDBG( char *format, ... )
{
#ifdef DEBUG
	va_list args;
	va_start(args, format);
	PAPIDEBUG( DEBUG_MEMORY, format , args);
	va_end(args);
#endif
}
#ifdef DEBUG
#define MEMDBG do { \
  if (DEBUG_MEMORY&_papi_hwi_debug) {\
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_MEMORY ) ); \
  } \
} while(0); _MEMDBG
#else
#define MEMDBG _MEMDBG
#endif

static void
_LEAKDBG( char *format, ... )
{
#ifdef DEBUG
	va_list args;
	va_start(args, format);
	PAPIDEBUG( DEBUG_LEAK, format , args);
	va_end(args);
#endif
}
#ifdef DEBUG
#define LEAKDBG do { \
  if (DEBUG_LEAK&_papi_hwi_debug) {\
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_LEAK ) ); \
  } \
} while(0); _LEAKDBG
#else
#define LEAKDBG _LEAKDBG
#endif

/* ifdef NO_VARARG_MACRO */
#endif

#endif /* PAPI_DEBUG_H */