[88] | 1 | /* |
---|
| 2 | * $Id: Parameters.cpp 136 2009-10-20 18:52:15Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/Core/Multi_Front_end/Front_end/include/Parameters.h" |
---|
[128] | 9 | #include "Behavioural/include/Allocation.h" |
---|
[88] | 10 | #include "Common/include/Max.h" |
---|
| 11 | |
---|
| 12 | namespace morpheo { |
---|
| 13 | namespace behavioural { |
---|
| 14 | namespace core { |
---|
| 15 | namespace multi_front_end { |
---|
| 16 | namespace front_end { |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | #undef FUNCTION |
---|
| 20 | #define FUNCTION "Front_end::Parameters" |
---|
| 21 | Parameters::Parameters (uint32_t nb_context , |
---|
| 22 | uint32_t nb_decod_unit , |
---|
| 23 | uint32_t size_general_data , |
---|
| 24 | morpheo::behavioural::custom::custom_information_t (*get_custom_information) (void), |
---|
| 25 | // ifetch_unit |
---|
[136] | 26 | uint32_t * size_ifetch_queue ,//[nb_context] |
---|
| 27 | ifetch_unit::ifetch_queue::Tifetch_queue_scheme_t |
---|
| 28 | * ifetch_queue_scheme ,//[nb_context] |
---|
| 29 | uint32_t * nb_inst_fetch ,//[nb_context] |
---|
| 30 | bool ** instruction_implemeted ,//[nb_context] |
---|
| 31 | uint32_t * link_context_to_decod_unit ,//[nb_context] |
---|
[88] | 32 | // decod_unit |
---|
[111] | 33 | uint32_t * size_decod_queue ,//[nb_decod_unit] |
---|
| 34 | decod_unit::decod_queue::Tdecod_queue_scheme_t |
---|
| 35 | * decod_queue_scheme ,//[nb_decod_unit] |
---|
| 36 | uint32_t * nb_inst_decod ,//[nb_decod_unit] |
---|
| 37 | uint32_t * nb_context_select ,//[nb_decod_unit] |
---|
| 38 | Tpriority_t * context_select_priority ,//[nb_decod_unit] |
---|
| 39 | Tload_balancing_t * context_select_load_balancing ,//[nb_decod_unit] |
---|
[88] | 40 | // prediction_unit |
---|
| 41 | uint32_t nb_inst_branch_predict , |
---|
| 42 | uint32_t nb_inst_branch_decod , |
---|
| 43 | uint32_t nb_inst_branch_update , |
---|
| 44 | uint32_t nb_inst_branch_complete , |
---|
| 45 | uint32_t btb_size_queue , |
---|
| 46 | uint32_t btb_associativity , |
---|
| 47 | uint32_t btb_size_counter , |
---|
| 48 | Tvictim_t btb_victim_scheme , |
---|
| 49 | Tpredictor_t dir_predictor_scheme , |
---|
| 50 | bool * dir_have_bht ,//[3] |
---|
| 51 | uint32_t * dir_bht_size_shifter ,//[3] |
---|
| 52 | uint32_t * dir_bht_nb_shifter ,//[3] |
---|
| 53 | bool * dir_have_pht ,//[3] |
---|
| 54 | uint32_t * dir_pht_size_counter ,//[3] |
---|
| 55 | uint32_t * dir_pht_nb_counter ,//[3] |
---|
| 56 | uint32_t * dir_pht_size_address_share ,//[3] |
---|
| 57 | uint32_t * ras_size_queue , |
---|
| 58 | uint32_t * upt_size_queue , |
---|
[95] | 59 | uint32_t * ufpt_size_queue , |
---|
[88] | 60 | // context_state |
---|
| 61 | uint32_t size_nb_inst_commit , |
---|
[111] | 62 | |
---|
| 63 | uint32_t nb_thread , |
---|
| 64 | uint32_t * translate_num_context_to_num_thread ,//[nb_context] |
---|
| 65 | |
---|
[88] | 66 | bool is_toplevel): |
---|
| 67 | morpheo::behavioural::Parameters() |
---|
| 68 | { |
---|
| 69 | log_begin(Front_end,FUNCTION); |
---|
| 70 | |
---|
| 71 | _nb_context = nb_context ; |
---|
| 72 | _nb_decod_unit = nb_decod_unit ; |
---|
| 73 | // _size_general_data = size_general_data ; |
---|
| 74 | _get_custom_information = get_custom_information ; |
---|
[111] | 75 | _nb_thread = nb_thread ; |
---|
| 76 | _translate_num_context_to_num_thread = translate_num_context_to_num_thread ; |
---|
[88] | 77 | _size_ifetch_queue = size_ifetch_queue ; |
---|
[136] | 78 | _ifetch_queue_scheme = ifetch_queue_scheme ; |
---|
[88] | 79 | _nb_inst_fetch = nb_inst_fetch ; |
---|
| 80 | _instruction_implemeted = instruction_implemeted ; |
---|
| 81 | _link_context_to_decod_unit = link_context_to_decod_unit ; |
---|
| 82 | _size_decod_queue = size_decod_queue ; |
---|
[111] | 83 | _decod_queue_scheme = decod_queue_scheme ; |
---|
[88] | 84 | _nb_inst_decod = nb_inst_decod ; |
---|
| 85 | _nb_context_select = nb_context_select ; |
---|
| 86 | _context_select_priority = context_select_priority ; |
---|
| 87 | _context_select_load_balancing = context_select_load_balancing ; |
---|
| 88 | _nb_inst_branch_predict = nb_inst_branch_predict ; |
---|
| 89 | _nb_inst_branch_decod = nb_inst_branch_decod ; |
---|
| 90 | _nb_inst_branch_update = nb_inst_branch_update ; |
---|
| 91 | _nb_inst_branch_complete = nb_inst_branch_complete ; |
---|
| 92 | _btb_size_queue = btb_size_queue ; |
---|
| 93 | _btb_associativity = btb_associativity ; |
---|
| 94 | _btb_size_counter = btb_size_counter ; |
---|
| 95 | _btb_victim_scheme = btb_victim_scheme ; |
---|
| 96 | _dir_predictor_scheme = dir_predictor_scheme ; |
---|
| 97 | for (uint32_t i=0; i<3; i++) |
---|
| 98 | { |
---|
| 99 | _dir_have_bht [i] = dir_have_bht [i]; |
---|
| 100 | _dir_bht_size_shifter [i] = dir_bht_size_shifter [i]; |
---|
| 101 | _dir_bht_nb_shifter [i] = dir_bht_nb_shifter [i]; |
---|
| 102 | _dir_have_pht [i] = dir_have_pht [i]; |
---|
| 103 | _dir_pht_size_counter [i] = dir_pht_size_counter [i]; |
---|
| 104 | _dir_pht_nb_counter [i] = dir_pht_nb_counter [i]; |
---|
| 105 | _dir_pht_size_address_share [i] = dir_pht_size_address_share [i]; |
---|
| 106 | } |
---|
| 107 | _ras_size_queue = ras_size_queue ; |
---|
| 108 | _upt_size_queue = upt_size_queue ; |
---|
[95] | 109 | _ufpt_size_queue = ufpt_size_queue ; |
---|
[88] | 110 | |
---|
| 111 | test(); |
---|
| 112 | |
---|
| 113 | // _size_context_id = log2(_nb_context); |
---|
| 114 | uint32_t size_instruction_address = size_general_data - 2; |
---|
[106] | 115 | |
---|
[128] | 116 | ALLOC1(_array_size_depth ,uint32_t,_nb_context); |
---|
[88] | 117 | for (uint32_t i=0; i<_nb_context; i++) |
---|
| 118 | _array_size_depth [i] = log2(_upt_size_queue[i]); |
---|
[106] | 119 | |
---|
[128] | 120 | ALLOC1(_array_size_nb_inst_decod ,uint32_t,_nb_decod_unit); |
---|
[88] | 121 | for (uint32_t i=0; i<_nb_decod_unit; i++) |
---|
| 122 | _array_size_nb_inst_decod [i] = log2(_size_decod_queue[i]+1); |
---|
| 123 | |
---|
[108] | 124 | uint32_t size_nb_inst_decod = max<uint32_t>(_array_size_nb_inst_decod,_nb_decod_unit); |
---|
| 125 | |
---|
[88] | 126 | _param_ifetch_unit = new behavioural::core::multi_front_end::front_end::ifetch_unit::Parameters * [_nb_context]; |
---|
| 127 | for (uint32_t i=0; i<_nb_context; ++i) |
---|
| 128 | { |
---|
| 129 | _param_ifetch_unit [i] = new behavioural::core::multi_front_end::front_end::ifetch_unit::Parameters |
---|
[136] | 130 | (_size_ifetch_queue [i] , |
---|
| 131 | _ifetch_queue_scheme[i] , |
---|
| 132 | _nb_inst_fetch [i] , |
---|
| 133 | log2(_upt_size_queue[i]) , |
---|
[95] | 134 | size_instruction_address ); |
---|
[88] | 135 | } |
---|
| 136 | |
---|
| 137 | _param_prediction_unit = new behavioural::core::multi_front_end::front_end::prediction_unit::Parameters |
---|
[111] | 138 | (_nb_context , |
---|
| 139 | _nb_decod_unit , |
---|
| 140 | size_instruction_address , |
---|
| 141 | _nb_inst_fetch , |
---|
| 142 | _nb_inst_decod , |
---|
| 143 | _nb_inst_branch_predict , |
---|
| 144 | _nb_inst_branch_decod , |
---|
| 145 | _nb_inst_branch_update , |
---|
| 146 | _nb_inst_branch_complete , |
---|
| 147 | _btb_size_queue , |
---|
| 148 | _btb_associativity , |
---|
| 149 | _btb_size_counter , |
---|
| 150 | _btb_victim_scheme , |
---|
| 151 | _dir_predictor_scheme , |
---|
| 152 | _dir_have_bht , |
---|
| 153 | _dir_bht_size_shifter , |
---|
| 154 | _dir_bht_nb_shifter , |
---|
| 155 | _dir_have_pht , |
---|
| 156 | _dir_pht_size_counter , |
---|
| 157 | _dir_pht_nb_counter , |
---|
| 158 | _dir_pht_size_address_share , |
---|
| 159 | _ras_size_queue , |
---|
| 160 | _upt_size_queue , |
---|
| 161 | _ufpt_size_queue , |
---|
| 162 | _nb_thread , |
---|
| 163 | _translate_num_context_to_num_thread |
---|
| 164 | ); |
---|
[88] | 165 | |
---|
[128] | 166 | ALLOC1(_translate_context_id_from_decod_unit,std::vector<uint32_t>,_nb_decod_unit); |
---|
[88] | 167 | |
---|
| 168 | for (uint32_t i=0; i<_nb_context; ++i) |
---|
| 169 | _translate_context_id_from_decod_unit [_link_context_to_decod_unit[i]].push_back(i); |
---|
| 170 | |
---|
[128] | 171 | ALLOC1(_decod_unit_nb_context ,uint32_t,_nb_decod_unit); |
---|
| 172 | ALLOC2(_decod_unit_nb_inst_fetch ,uint32_t,_nb_decod_unit,_translate_context_id_from_decod_unit [it1].size()); |
---|
| 173 | ALLOC2(_decod_unit_nb_branch_speculated ,uint32_t,_nb_decod_unit,_translate_context_id_from_decod_unit [it1].size()); |
---|
| 174 | // ALLOC2(_decod_unit_depth ,uint32_t,_nb_decod_unit,_translate_context_id_from_decod_unit [it1].size()); |
---|
| 175 | ALLOC3(_decod_unit_instruction_implemeted,bool ,_nb_decod_unit,_translate_context_id_from_decod_unit [it1].size(),NB_INSTRUCTION); |
---|
| 176 | // ALLOC2(_have_port_decod_unit_context_id ,bool ,_nb_decod_unit); |
---|
[88] | 177 | _sum_inst_decod = 0; |
---|
| 178 | |
---|
| 179 | for (uint32_t i=0; i<_nb_decod_unit; ++i) |
---|
| 180 | { |
---|
| 181 | _sum_inst_decod += _nb_inst_decod [i]; |
---|
| 182 | |
---|
| 183 | uint32_t size = _translate_context_id_from_decod_unit [i].size(); |
---|
| 184 | |
---|
| 185 | _decod_unit_nb_context [i] = size; |
---|
[128] | 186 | // _have_port_decod_unit_context_id [i] = size > 0; |
---|
[88] | 187 | |
---|
| 188 | for (uint32_t j=0; j<size; ++j) |
---|
| 189 | { |
---|
| 190 | uint32_t x = _translate_context_id_from_decod_unit[i][j]; |
---|
| 191 | |
---|
| 192 | _decod_unit_nb_inst_fetch [i][j] = _nb_inst_fetch [x]; |
---|
| 193 | _decod_unit_nb_branch_speculated [i][j] = _upt_size_queue [x]; |
---|
[128] | 194 | // _decod_unit_depth [i][j] = log2(_upt_size_queue[x]); |
---|
[88] | 195 | |
---|
| 196 | for (uint32_t k=0; k<NB_INSTRUCTION; ++k) |
---|
| 197 | _decod_unit_instruction_implemeted [i][j][k] = _instruction_implemeted [x][k]; |
---|
| 198 | } |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | log_printf(TRACE,Front_end,FUNCTION,_("Translate")); |
---|
| 202 | for (uint32_t i=0; i<_nb_decod_unit; ++i) |
---|
| 203 | { |
---|
| 204 | uint32_t size = _decod_unit_nb_context [i]; |
---|
| 205 | log_printf(TRACE,Front_end,FUNCTION,_("Decod_unit [%d], nb_decod_unit_context : %d"),i,size); |
---|
| 206 | |
---|
| 207 | for (uint32_t j=0; j<size; ++j) |
---|
| 208 | { |
---|
| 209 | log_printf(TRACE,Front_end,FUNCTION,_(" Context [%d] -> Decod_unit_Context [%d]"),j,(_translate_context_id_from_decod_unit [i])[j]); |
---|
| 210 | log_printf(TRACE,Front_end,FUNCTION,_(" * decod_unit_nb_inst_fetch : %d"),_decod_unit_nb_inst_fetch [i][j]); |
---|
| 211 | log_printf(TRACE,Front_end,FUNCTION,_(" * decod_unit_nb_branch_speculated : %d"),_decod_unit_nb_branch_speculated[i][j]); |
---|
| 212 | } |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | _param_decod_unit = new behavioural::core::multi_front_end::front_end::decod_unit::Parameters * [_nb_decod_unit]; |
---|
| 216 | for (uint32_t i=0; i<_nb_decod_unit; ++i) |
---|
| 217 | { |
---|
| 218 | _param_decod_unit [i] = new behavioural::core::multi_front_end::front_end::decod_unit::Parameters |
---|
| 219 | (_decod_unit_nb_context [i], |
---|
| 220 | _decod_unit_nb_inst_fetch [i], |
---|
| 221 | _nb_inst_decod [i], |
---|
| 222 | _size_decod_queue [i], |
---|
[111] | 223 | _decod_queue_scheme [i], |
---|
[88] | 224 | size_general_data , |
---|
| 225 | _decod_unit_nb_branch_speculated [i], |
---|
| 226 | // _decod_unit_depth [i], |
---|
| 227 | _nb_context_select [i], |
---|
| 228 | _context_select_priority [i], |
---|
| 229 | _context_select_load_balancing [i], |
---|
| 230 | _decod_unit_instruction_implemeted [i], |
---|
| 231 | _get_custom_information ); |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | _param_context_state = new behavioural::core::multi_front_end::front_end::context_state::Parameters |
---|
| 235 | (_nb_context, |
---|
| 236 | _nb_decod_unit, |
---|
| 237 | _nb_inst_branch_complete, |
---|
[106] | 238 | _upt_size_queue, |
---|
[88] | 239 | size_instruction_address, |
---|
| 240 | _array_size_nb_inst_decod, |
---|
| 241 | size_nb_inst_commit, |
---|
| 242 | _link_context_to_decod_unit); |
---|
| 243 | |
---|
| 244 | _param_glue = new behavioural::core::multi_front_end::front_end::front_end_glue::Parameters |
---|
| 245 | (_nb_context , |
---|
| 246 | _nb_decod_unit , |
---|
| 247 | _nb_inst_decod , |
---|
| 248 | _nb_inst_branch_complete , |
---|
| 249 | _link_context_to_decod_unit , |
---|
| 250 | _translate_context_id_from_decod_unit , |
---|
| 251 | size_instruction_address , |
---|
| 252 | _array_size_depth , |
---|
[108] | 253 | _upt_size_queue ,//_nb_branch_speculated |
---|
| 254 | size_nb_inst_decod |
---|
[88] | 255 | ); |
---|
| 256 | |
---|
| 257 | if (is_toplevel) |
---|
| 258 | { |
---|
| 259 | _size_context_id = log2(_nb_context); |
---|
| 260 | _size_instruction_address = size_instruction_address; |
---|
| 261 | _size_general_data = size_general_data; |
---|
[108] | 262 | _size_nb_inst_decod = size_nb_inst_decod; |
---|
[88] | 263 | _size_nb_inst_commit = size_nb_inst_commit; |
---|
| 264 | _size_depth = max<uint32_t>(_array_size_depth,_nb_context); |
---|
| 265 | _size_ifetch_queue_ptr = log2(max<uint32_t>(_size_ifetch_queue,_nb_context)); |
---|
| 266 | _size_inst_ifetch_ptr = log2(max<uint32_t>(_nb_inst_fetch ,_nb_context)); |
---|
| 267 | |
---|
| 268 | _have_port_context_id = _size_context_id > 0; |
---|
| 269 | _have_port_depth = _size_depth > 0; |
---|
| 270 | _have_port_ifetch_queue_ptr = _size_ifetch_queue_ptr> 0; |
---|
| 271 | _have_port_inst_ifetch_ptr = _size_inst_ifetch_ptr > 0; |
---|
| 272 | |
---|
| 273 | copy (); |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | log_end(Front_end,FUNCTION); |
---|
| 277 | }; |
---|
| 278 | |
---|
| 279 | // #undef FUNCTION |
---|
| 280 | // #define FUNCTION "Front_end::Parameters (copy)" |
---|
| 281 | // Parameters::Parameters (Parameters & param) |
---|
| 282 | // { |
---|
| 283 | // log_begin(Front_end,FUNCTION); |
---|
| 284 | // test(); |
---|
| 285 | // log_end(Front_end,FUNCTION); |
---|
| 286 | // }; |
---|
| 287 | |
---|
| 288 | #undef FUNCTION |
---|
| 289 | #define FUNCTION "Front_end::~Parameters" |
---|
| 290 | Parameters::~Parameters () |
---|
| 291 | { |
---|
| 292 | log_begin(Front_end,FUNCTION); |
---|
| 293 | |
---|
[122] | 294 | delete _param_glue ; |
---|
| 295 | delete _param_context_state ; |
---|
[88] | 296 | for (uint32_t i=0; i<_nb_decod_unit; i++) |
---|
[122] | 297 | delete _param_decod_unit [i]; |
---|
[88] | 298 | delete [] _param_decod_unit ; |
---|
[122] | 299 | delete _param_prediction_unit; |
---|
[88] | 300 | for (uint32_t i=0; i<_nb_context; i++) |
---|
[122] | 301 | delete _param_ifetch_unit [i]; |
---|
[88] | 302 | delete [] _param_ifetch_unit ; |
---|
| 303 | |
---|
[128] | 304 | // DELETE2(_have_port_decod_unit_context_id ,_nb_decod_unit); |
---|
| 305 | DELETE3(_decod_unit_instruction_implemeted ,_nb_decod_unit,_translate_context_id_from_decod_unit [it1].size(),NB_INSTRUCTION); |
---|
| 306 | // DELETE2(_decod_unit_depth ,_nb_decod_unit,_translate_context_id_from_decod_unit [it1].size()); |
---|
| 307 | DELETE2(_decod_unit_nb_branch_speculated ,_nb_decod_unit,_translate_context_id_from_decod_unit [it1].size()); |
---|
| 308 | DELETE2(_decod_unit_nb_inst_fetch ,_nb_decod_unit,_translate_context_id_from_decod_unit [it1].size()); |
---|
| 309 | DELETE1(_decod_unit_nb_context ,_nb_decod_unit); |
---|
[88] | 310 | |
---|
[128] | 311 | DELETE1(_translate_context_id_from_decod_unit,_nb_decod_unit); |
---|
| 312 | DELETE1(_array_size_nb_inst_decod ,_nb_decod_unit); |
---|
| 313 | DELETE1(_array_size_depth ,_nb_context); |
---|
[88] | 314 | |
---|
| 315 | log_end(Front_end,FUNCTION); |
---|
| 316 | }; |
---|
| 317 | |
---|
| 318 | |
---|
| 319 | #undef FUNCTION |
---|
| 320 | #define FUNCTION "Front_end::copy" |
---|
| 321 | void Parameters::copy (void) |
---|
| 322 | { |
---|
| 323 | log_begin(Front_end,FUNCTION); |
---|
| 324 | |
---|
| 325 | COPY(_param_glue ); |
---|
| 326 | COPY(_param_context_state ); |
---|
| 327 | for (uint32_t i=0; i<_nb_decod_unit; i++) |
---|
| 328 | { |
---|
| 329 | COPY(_param_decod_unit [i]); |
---|
| 330 | } |
---|
| 331 | COPY(_param_prediction_unit); |
---|
| 332 | for (uint32_t i=0; i<_nb_context; i++) |
---|
| 333 | COPY(_param_ifetch_unit [i]); |
---|
| 334 | |
---|
| 335 | log_end(Front_end,FUNCTION); |
---|
| 336 | }; |
---|
| 337 | |
---|
| 338 | }; // end namespace front_end |
---|
| 339 | }; // end namespace multi_front_end |
---|
| 340 | }; // end namespace core |
---|
| 341 | |
---|
| 342 | }; // end namespace behavioural |
---|
| 343 | }; // end namespace morpheo |
---|