-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiperspective.cc
72 lines (56 loc) · 1.58 KB
/
multiperspective.cc
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
///////////////////////////////////////////////////////////////////////
//// Copyright 2015 Samsung Austin Semiconductor, LLC. //
/////////////////////////////////////////////////////////////////////////
#include "multiperspective.h"
class MULTIPERSPECTIVE {
public:
void initialize()
{
cpu = 0;
std::cout << "CPU " << cpu << " Multiperspective branch predictor" << std::endl;
predictor = new PREDICTOR();
}
uint8_t predict(uint64_t ip)
{
uint8_t prediction = predictor->GetPrediction(ip);
return prediction;
}
void update(uint64_t ip, uint32_t branch_type,
uint32_t taken, uint32_t prediction,
uint64_t target)
{
//FIXME: opType has less types here, maybe need to take better care
predictor->UpdatePredictor(ip, branch_type, taken, prediction, target);
}
void cleanup_branch_predictor()
{
delete predictor;
}
private:
uint32_t cpu;
PREDICTOR* predictor;
};
extern "C"
{
MULTIPERSPECTIVE* create_MULTIPERSPECTIVE()
{
return new MULTIPERSPECTIVE;
}
void delete_MULTIPERSPECTIVE(MULTIPERSPECTIVE* tage_sc_l)
{
delete tage_sc_l;
}
void initialize_MULTIPERSPECTIVE(MULTIPERSPECTIVE* tage_sc_l)
{
tage_sc_l->initialize();
}
uint8_t predict_MULTIPERSPECTIVE(MULTIPERSPECTIVE* tage_sc_l, uint64_t ip)
{
return tage_sc_l->predict(ip);
}
void update_MULTIPERSPECTIVE(MULTIPERSPECTIVE* tage_sc_l, uint64_t ip, uint32_t branch_type, uint32_t taken,
uint32_t predictor, uint64_t target)
{
tage_sc_l->update(ip, branch_type, taken, predictor, target);
}
}