1 | /* |
---|
2 | * $Id: Parameters.cpp 146 2011-02-01 20:57:54Z rosiere $ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | */ |
---|
7 | |
---|
8 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/include/Parameters.h" |
---|
9 | #include "Behavioural/include/Allocation.h" |
---|
10 | |
---|
11 | namespace morpheo { |
---|
12 | namespace behavioural { |
---|
13 | namespace core { |
---|
14 | namespace multi_front_end { |
---|
15 | namespace front_end { |
---|
16 | namespace prediction_unit { |
---|
17 | namespace direction { |
---|
18 | namespace meta_predictor { |
---|
19 | |
---|
20 | |
---|
21 | #undef FUNCTION |
---|
22 | #define FUNCTION "Meta_Predictor::Parameters" |
---|
23 | Parameters::Parameters (uint32_t nb_inst_predict , |
---|
24 | uint32_t nb_inst_update , |
---|
25 | uint32_t size_address , |
---|
26 | bool have_bht [3], |
---|
27 | uint32_t bht_size_shifter [3], |
---|
28 | uint32_t bht_nb_shifter [3], |
---|
29 | bool have_pht [3], |
---|
30 | uint32_t pht_size_counter [3], |
---|
31 | uint32_t pht_nb_counter [3], |
---|
32 | uint32_t pht_size_address_share [3], |
---|
33 | Tpht_scheme_t pht_scheme [3], |
---|
34 | bool is_toplevel) |
---|
35 | { |
---|
36 | log_begin(Meta_Predictor,FUNCTION); |
---|
37 | |
---|
38 | _nb_inst_predict = nb_inst_predict ; |
---|
39 | _nb_inst_update = nb_inst_update ; |
---|
40 | _size_address = size_address ; |
---|
41 | for (uint32_t i=0; i<3; ++i) |
---|
42 | { |
---|
43 | _have_bht [i] = have_bht [i]; |
---|
44 | _bht_size_shifter [i] = (_have_bht [i])?bht_size_shifter [i]:0; |
---|
45 | _bht_nb_shifter [i] = (_have_bht [i])?bht_nb_shifter [i]:0; |
---|
46 | _have_pht [i] = have_pht [i]; |
---|
47 | _pht_size_counter [i] = (_have_pht [i])?pht_size_counter [i]:0; |
---|
48 | _pht_nb_counter [i] = (_have_pht [i])?pht_nb_counter [i]:0; |
---|
49 | _pht_size_address_share [i] = (_have_bht[i] and _have_pht [i])?pht_size_address_share [i]:0; |
---|
50 | _pht_scheme [i] = (_have_pht [i])?pht_scheme [i]:PHT_SCHEME_COUNTER; |
---|
51 | } |
---|
52 | |
---|
53 | test(); |
---|
54 | |
---|
55 | _have_meta_predictor = (_have_bht [2] or _have_pht [2]); |
---|
56 | _nb_predictor = (_have_meta_predictor)?3:1; |
---|
57 | |
---|
58 | ALLOC1(_predictor_update_on_prediction,bool , _nb_predictor); |
---|
59 | ALLOC1(_predictor_size_history ,uint32_t, _nb_predictor); |
---|
60 | |
---|
61 | // All predictor can update on prediction .... |
---|
62 | for (uint32_t i=0; i<_nb_predictor; ++i) |
---|
63 | _predictor_update_on_prediction [i] = true; |
---|
64 | |
---|
65 | // ... But the selector prediction can't |
---|
66 | if (_have_meta_predictor) |
---|
67 | _predictor_update_on_prediction [_nb_predictor-1] = false; |
---|
68 | |
---|
69 | // // All predictor can't update on prediction .... |
---|
70 | // for (uint32_t i=0; i<_nb_predictor; ++i) |
---|
71 | // _predictor_update_on_prediction [i] = false; |
---|
72 | |
---|
73 | _param_two_level_branch_predictor = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::two_level_branch_predictor::Parameters * [_nb_predictor]; |
---|
74 | for (uint32_t i=0; i<_nb_predictor; ++i) |
---|
75 | { |
---|
76 | _param_two_level_branch_predictor [i] = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::two_level_branch_predictor::Parameters |
---|
77 | (_nb_inst_predict , |
---|
78 | _nb_inst_update , |
---|
79 | _size_address , |
---|
80 | _have_bht [i], |
---|
81 | _bht_size_shifter [i], |
---|
82 | _bht_nb_shifter [i], |
---|
83 | _have_pht [i], |
---|
84 | _pht_size_counter [i], |
---|
85 | _pht_nb_counter [i], |
---|
86 | _pht_size_address_share [i], |
---|
87 | _pht_scheme [i], |
---|
88 | _predictor_update_on_prediction [i] |
---|
89 | ); |
---|
90 | |
---|
91 | _predictor_size_history [i] = _param_two_level_branch_predictor [i]->_size_history; |
---|
92 | } |
---|
93 | |
---|
94 | _param_glue = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::meta_predictor_glue::Parameters |
---|
95 | ( |
---|
96 | _nb_inst_predict , |
---|
97 | _nb_inst_update , |
---|
98 | _nb_predictor , |
---|
99 | _predictor_size_history , |
---|
100 | _predictor_update_on_prediction |
---|
101 | ); |
---|
102 | _size_history = _param_glue->_size_history; |
---|
103 | |
---|
104 | if (is_toplevel) |
---|
105 | { |
---|
106 | copy(); |
---|
107 | } |
---|
108 | |
---|
109 | log_end(Meta_Predictor,FUNCTION); |
---|
110 | }; |
---|
111 | |
---|
112 | // #undef FUNCTION |
---|
113 | // #define FUNCTION "Meta_Predictor::Parameters (copy)" |
---|
114 | // Parameters::Parameters (Parameters & param) |
---|
115 | // { |
---|
116 | // log_begin(Meta_Predictor,FUNCTION); |
---|
117 | // test(); |
---|
118 | // log_end(Meta_Predictor,FUNCTION); |
---|
119 | // }; |
---|
120 | |
---|
121 | #undef FUNCTION |
---|
122 | #define FUNCTION "Meta_Predictor::~Parameters" |
---|
123 | Parameters::~Parameters (void) |
---|
124 | { |
---|
125 | log_begin(Meta_Predictor,FUNCTION); |
---|
126 | |
---|
127 | delete _param_glue; |
---|
128 | for (uint32_t i=0; i<_nb_predictor; ++i) |
---|
129 | delete _param_two_level_branch_predictor [i]; |
---|
130 | delete [] _param_two_level_branch_predictor; |
---|
131 | |
---|
132 | DELETE1(_predictor_size_history , _nb_predictor); |
---|
133 | DELETE1(_predictor_update_on_prediction , _nb_predictor); |
---|
134 | |
---|
135 | log_end(Meta_Predictor,FUNCTION); |
---|
136 | }; |
---|
137 | |
---|
138 | #undef FUNCTION |
---|
139 | #define FUNCTION "Meta_Predictor::copy" |
---|
140 | void Parameters::copy (void) |
---|
141 | { |
---|
142 | log_begin(Meta_Predictor,FUNCTION); |
---|
143 | |
---|
144 | COPY(_param_glue); |
---|
145 | for (uint32_t i=0; i<_nb_predictor; ++i) |
---|
146 | COPY(_param_two_level_branch_predictor [i]); |
---|
147 | |
---|
148 | log_end(Meta_Predictor,FUNCTION); |
---|
149 | }; |
---|
150 | |
---|
151 | }; // end namespace meta_predictor |
---|
152 | }; // end namespace direction |
---|
153 | }; // end namespace prediction_unit |
---|
154 | }; // end namespace front_end |
---|
155 | }; // end namespace multi_front_end |
---|
156 | }; // end namespace core |
---|
157 | |
---|
158 | }; // end namespace behavioural |
---|
159 | }; // end namespace morpheo |
---|