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
|
#ifdef GCC
#define magic_timing_begin(cycleLo, cycleHi) {\
asm volatile( "rdtsc": "=a" (cycleLo), "=d" (cycleHi)); \
}\
#define magic_timing_end(cycleLo, cycleHi) {\
unsigned tempCycleLo, tempCycleHi; \
asm volatile( "rdtsc": "=a" (tempCycleLo), "=d" (tempCycleHi)); \
cycleLo = tempCycleLo-cycleLo;\
cycleHi = tempCycleHi - cycleHi;\
}\
#define magic_timing_report(cycleLo, cycleHi) {\
printf("Timing report: %d %d\n", cycleLo, cycleHi); \
}\
#endif
#ifdef METRO
#define magic_timing_begin(cycleLo, cycleHi) {\
asm volatile( "mfsr $8, CYCLE_LO\n\t" \
"mfsr $9, CYCLE_HI\n\t" \
"addu %0, $8, $0\n\t" \
"addu %1, $9, $0\n\t" \
:"=r" (cycleLo), "=r" (cycleHi) \
: \
:"$8", "$9"\
);\
}
#define magic_timing_end(cycleLo, cycleHi) {\
asm volatile( \
"mfsr $8, CYCLE_LO\n\t" \
"mfsr $9, CYCLE_HI\n\t" \
"subu %0, $8, %0\n\t" \
"subu %1, $9, %1\n\t" \
:"=r" (cycleLo), "=r" (cycleHi) \
: \
:"$8", "$9"\
); \
}
#define magic_timing_report(cycleLo, cycleHi) {\
asm volatile( "addu $8, %0, $0\n\t" \
"mtsr PASS $8\n\t" \
"mtsr PASS $9\n\t" \
: \
:"r" (cycleLo), "r" (cycleHi) \
: "$8", "$9" \
);\
}
//#define metro_magic_timing_report(cycleLo, cycleHi) {\
// asm volatile( "nop\n\t");\
//}
#endif
#ifdef BTL
#include "/u/kvs/raw/rawlib/archlib/include/raw.h"
#define magic_timing_begin(cycleLo, cycleHi) {\
raw_magic_timing_report_begin();\
}
#define magic_timing_end(cycleLo, cycleHi) {\
raw_magic_timing_report_end(); \
}
#define magic_timing_report(cycleLo, cycleHi) {\
raw_magic_timing_report_print(); \
}
//
//void metro_magic_timing_begin(int cycleLo, int cycleHi)
//{
// raw_magic_timing_report_begin();
//}
//
//void metro_magic_timing_end(int cycleLo, int cycleHi)
//{
// raw_magic_timing_report_end();
//}
//
//void metro_magic_timing_report(int cycleLo, int cycleHi)
//{
// raw_magic_timing_report_print();
// return;
//}
#endif
|