blob: ac03b23f3a750f34732ca369aaeea6e2f22b98dc (
plain)
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
|
/*
* (C) 2018 by Computer System Laboratory, IIS, Academia Sinica, Taiwan.
* See COPYRIGHT in top-level directory.
*/
#ifndef __LLVM_HARD_PERFMON_H
#define __LLVM_HARD_PERFMON_H
#include <map>
#include <thread>
#include "pmu/pmu.h"
#include "utils.h"
class PerfmonData;
class BaseTracer;
enum HPMControl {
HPM_INIT = 0,
HPM_FINALIZE,
HPM_START,
HPM_STOP,
};
/*
* Hardware Performance Monitor (HPM)
*/
class HardwarePerfmon {
std::thread MonThread; /* Monitor thread */
int MonThreadID; /* Monitor thread id */
bool MonThreadStop; /* Monitor thread is stopped or not */
hqemu::Mutex Lock;
/* Start monitor thread. */
void StartMonThread();
/* Monitor thread routine. */
void MonitorFunc();
public:
HardwarePerfmon();
~HardwarePerfmon();
/* Set up HPM with the monitor thread id */
void Init(int monitor_thread_tid);
/* Register a thread to be monitored. */
void RegisterThread(BaseTracer *Tracer);
/* Unreigster a thread from being monitored. */
void UnregisterThread(BaseTracer *Tracer);
/* Notify that the execution enters/leaves the code cache. */
void NotifyCacheEnter(BaseTracer *Tracer);
void NotifyCacheLeave(BaseTracer *Tracer);
/* Stop the monitor. */
void Pause();
/* Restart the monitor. */
void Resume();
};
class PerfmonData {
public:
PerfmonData(int tid);
~PerfmonData();
int TID;
pmu::Handle ICountHndl;
pmu::Handle BranchHndl;
pmu::Handle MemLoadHndl;
pmu::Handle MemStoreHndl;
pmu::Handle CoverSetHndl;
uint64_t LastNumBranches, LastNumLoads, LastNumStores;
void MonitorBasic(HPMControl Ctl);
void MonitorCoverSet(HPMControl Ctl);
};
extern HardwarePerfmon *HP;
#endif /* __LLVM_HARD_PERFMON_H */
/*
* vim: ts=8 sts=4 sw=4 expandtab
*/
|