-
Notifications
You must be signed in to change notification settings - Fork 5
/
instrumentation.h
executable file
·69 lines (54 loc) · 1.46 KB
/
instrumentation.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
#ifndef _INSTRUMENTATION_H
#define _INSTRUMENTATION_H
#include <stdio.h>
#include <stdint.h>
#include "tsc_x86.h"
#ifdef INSTRUMENTATION
#define NUM_ADDS(n) num_adds(n)
#define NUM_MULS(n) num_muls(n)
#define NUM_DIVS(n) num_divs(n)
#define NUM_SQRTS(n) num_sqrts(n)
#define NUM_EXPS(n) num_exps(n)
#define NUM_FLOPS num_flops()
#define RESET_FLOPS() reset_flops()
void num_adds(int n);
void num_muls(int n);
void num_divs(int n);
void num_sqrts(int n);
void num_exps(int n);
uint64_t num_flops(void);
void reset_flops();
#else
#define NUM_ADDS(n) ((void) 0)
#define NUM_MULS(n) ((void) 0)
#define NUM_DIVS(n) ((void) 0)
#define NUM_SQRTS(n) ((void) 0)
#define NUM_EXPS(n) ((void) 0)
#define NUM_FLOPS ((uint64_t) 0)
#define RESET_FLOPS() ((void) 0)
#endif
#ifdef PROFILING
#ifndef PROFILING_NUM_FUNCS
#define PROFILING_NUM_FUNCS 128
#endif
extern const char *__func_names[PROFILING_NUM_FUNCS];
extern uint64_t __func_times[PROFILING_NUM_FUNCS];
extern int __curr_idx;
#define ENTER_FUNC \
static int __profiler_ready = 0; \
static int __func_index; \
if (!__profiler_ready) { \
__func_index = ++__curr_idx; \
__func_names[__func_index] = __func__; \
__profiler_ready = 1; \
} \
uint64_t __func_start = start_tsc()
#define EXIT_FUNC __func_times[__func_index] += stop_tsc(__func_start)
#define PROFILER_LIST() __profiler_list()
void __profiler_list(void);
#else
#define ENTER_FUNC ((void) 0)
#define EXIT_FUNC ((void) 0)
#define PROFILER_LIST() ((void) 0)
#endif
#endif