RecoSim  1.0
 All Classes Files Functions Variables Enumerations
user_monitoring.h
Go to the documentation of this file.
1 
22 #ifndef USER_MONITORING_H
23 #define USER_MONITORING_H
24 
25 #include <systemc.h>
26 #include "monitoring.h"
27 
28 /*
29 * NOTE:
30 * Change the name of :
31 * - user_monitoring_module_name : this is the monitoring module name declared in FoRTReSS preferences
32 * - user_sig : example of a tracing variable
33 * - trace_update_thread : you can modify and add several threads
34 *
35 * - Follow the steps below
36 */
37 
38 
39 MONITORING_MODULE(Power_Monitoring_old) {
40 
41  /***** STEP 1 *********************************************/
42  /* Declaration */
43  /* */
44  /* Types : */
45  /* double : MONITORING_VAR_DOUBLE */
46  /* integer : MONITORING_VAR_INT */
47  /* unsigned integer : MONITORING_VAR_UINT */
48  /* string : MONITORING_VAR_STRING */
49 
50  TRACE_VAR_DOUBLE(previous_hyper_energy);
51  TRACE_VAR_DOUBLE(hyper_instant_energy);
52  TRACE_VAR_DOUBLE(total_current_power);
53 
54  TRACE_VAR_DOUBLE(rz_reconf_current_power);
55  TRACE_VAR_DOUBLE(rz_hard_current_static_power);
56  TRACE_VAR_DOUBLE(rz_soft_current_idle_power);
57  TRACE_VAR_DOUBLE(rz_soft_current_static_power);
58  TRACE_VAR_DOUBLE(rz_hard_current_idle_power);
59  TRACE_VAR_DOUBLE(rz_hard_current_run_power);
60  TRACE_VAR_DOUBLE(rz_soft_current_run_power);
61 
62  double hyper_energy;
63 
64 
65  /***** STEP 2 *********************************************/
66  /* Init Variable(s) and Thread(s) */
67 
68  MONITORING_INIT(Power_Monitoring_old) {
69 
70  // Init Variable(s)
71  hyper_energy = 0;
72  total_current_power = 0;
73  previous_hyper_energy =0;
74 
75  // Init Thread(s) for Trace
76  MONITORING_ADD_THREAD(Power_Monitoring_old, trace_update_thread);
77  }
78 
79  /***** STEP 3 *********************************************/
80  /* Record Variable(s) */
81 
82  MONITORING_ACTIVATE {
83 
84  /* 2 Methods :
85  * - MONITORING_ANALOG_TRACE(declaration_name, "name_of_signal", min value, max value, height in pixel)
86  * height : in pixel, less than value 50 is not right. About 80 is a right value.
87  *
88  * - MONITORING_TRACE(declaration_name, "name_of_signal", format)
89  * format value: hexadecimal, ascii, unsigned, decimal
90  *
91  * Note: The declaration order will be the wave declaration order in the trace file
92  */
93 
94  MONITORING_ANALOG_TRACE(previous_hyper_energy, "Previous_Hyper_Energy", 0, 100, 75);
95  MONITORING_ANALOG_TRACE(hyper_instant_energy, "Hyper_Instant_Energy", 0, 100, 75);
96  MONITORING_ANALOG_TRACE(total_current_power, "Instant_current", 0, 2000, 75);
97 
98  MONITORING_ANALOG_TRACE(rz_reconf_current_power, "Reconf_current", 0, 1000, 75);
99  MONITORING_ANALOG_TRACE(rz_hard_current_static_power, "RZ_static_current", 0, 1000, 75);
100  MONITORING_ANALOG_TRACE(rz_hard_current_idle_power, "RZ_idle_current", 0, 1000, 75);
101  MONITORING_ANALOG_TRACE(rz_hard_current_run_power, "RZ_run_current", 0, 1000, 75);
102  MONITORING_ANALOG_TRACE(rz_soft_current_static_power, "Cores_static_current", 0, 1000, 75);
103  MONITORING_ANALOG_TRACE(rz_soft_current_idle_power, "Cores_idle_current", 0, 1000, 75);
104  MONITORING_ANALOG_TRACE(rz_soft_current_run_power, "Cores_run_current", 0, 1000, 75);
105 
106 
107  }
108 
109  /***** STEP 4 *********************************************/
110  /* Define the Thread behavior(s) */
111 
112  MONITORING_THREAD(trace_update_thread) {
113 
114  //double total_current_power=0;
115  sc_time current_time(SC_ZERO_TIME);
116  sc_time previous_time(SC_ZERO_TIME);
117  bool new_period=0;
118 
119  total_current_power=0;
120  double rz_current_power=0;
121  rz_reconf_current_power=0;
122  rz_hard_current_static_power=0;
123  rz_soft_current_static_power=0;
124  rz_hard_current_idle_power=0;
125  rz_soft_current_idle_power=0;
126  rz_hard_current_run_power=0;
127  rz_soft_current_run_power=0;
128  hyper_energy=0;
129 
130  // Example of behavior
131  Scheduler_interface& scheduler = services.getShedulerInterface();
132 
133  while(true) {
134 
135  /* Sampling Period */
136  //wait(monitoring_if.endOfSchedulingEvent());
137 
138 
139  /* Modify Value of the Signal */
140  vector<RZ *> all_RZs = scheduler.Scheduler_get_all_rz_vector();
141  int i = 0;
142  double Pstatic, Pidle, Prun;
143 
144  total_current_power=0;
145  rz_current_power=0;
146  rz_reconf_current_power=0;
147  rz_hard_current_static_power=0;
148  rz_soft_current_static_power=0;
149  rz_hard_current_idle_power=0;
150  rz_soft_current_idle_power=0;
151  rz_hard_current_run_power=0;
152  rz_soft_current_run_power=0;
153 
154 
155  while(i < (int) all_RZs.size()) {
156 
157  //get powers for HW or SW RZ.
158  if (all_RZs.at(i)->get_implementation_type()==HARD)
159  {
160  Pstatic=P_STATIC_1CELL*all_RZs.at(i)->get_resources_ptr()->getResourceCount("Slice")*40; //*40 à expliquer!!
161  Pidle=all_RZs.at(i)->getCurrentImplementation().getPidle();
162  Prun= all_RZs.at(i)->getCurrentImplementation().getPrun();
163  }
164  else //SOFT
165  {
166  /*if (all_RZs.at(i)->getName()=="Core_2") //handle foo CPU for power trace.
167  {
168  Pstatic=0;
169  Pidle=0;
170  Prun=0;
171  //scheduler.Scheduler_get_output_stream() << "FooCPU found" << endl;
172  }
173  else*/
174  {
175  Pstatic=CPU_PSTATIC;
176  Pidle=CPU_PIDLE;
177  Prun=CPU_PRUN;
178  }
179 
180  //scheduler.Scheduler_get_output_stream() << "RZname : " << << " get fooCPU : " << all_RZs.at(i)->get_resources_ptr()->getResourceCount("FooCPU")<< endl;
181 
182  }
183 
184  //computer RZ total power following each state
185  if( scheduler.Scheduler_is_RZ_blank(all_RZs.at(i)) )
186  {
187  rz_current_power = Pstatic;
188  if (all_RZs.at(i)->get_implementation_type()==HARD)
189  {
190  rz_hard_current_static_power += rz_current_power;
191  }
192  else
193  rz_soft_current_static_power += rz_current_power;
194  }
195  else if ( scheduler.Scheduler_get_task_state(all_RZs.at(i)) == MAPPED ||
196  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == PREEMPTED_MAPPED ||
197  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == QUEUED || //if not, is it free?
198  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == INACTIVE||
199  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == PREEMPTED_INACTIVE || //if not, is it free?
200  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == WAITING||
201  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == IDLE || //if not, is it free?
202  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == STATIC)
203  {
204  //scheduler.Scheduler_get_current_module_ID(all_RZs.at(i));;
205  if (all_RZs.at(i)->get_implementation_type()==HARD)
206  {
207 
208  rz_hard_current_static_power += Pstatic;
209  rz_hard_current_idle_power += Pidle;
210  rz_current_power = Pstatic + Pidle;
211  }
212  else
213  {
214  //rz_soft_current_static_power += Pstatic;
215  rz_soft_current_idle_power += Pidle;
216  rz_current_power = Pidle;
217  }
218  }
219  else if ( scheduler.Scheduler_get_task_state(all_RZs.at(i)) == RUNNING)
220  {
221 
222  if (all_RZs.at(i)->get_implementation_type()==HARD)
223  {
224 
225  rz_hard_current_static_power += Pstatic;
226  rz_hard_current_idle_power += Pidle;
227  rz_hard_current_run_power += Prun;
228  rz_current_power = Pstatic + Pidle+ Prun;
229  }
230  else
231  {
232  //rz_soft_current_static_power += Pstatic;
233  //rz_soft_current_idle_power += Pidle;
234  rz_soft_current_run_power += Prun;
235  rz_current_power = Prun;
236  }
237  }
238  else if ( scheduler.Scheduler_get_task_state(all_RZs.at(i)) == CONFIG)
239  {
240  rz_current_power = Pstatic + P_RECONF; //maybe to refine with Pidle model during reconf?
241  if (all_RZs.at(i)->get_implementation_type()==HARD)
242  {
243  rz_hard_current_static_power += Pstatic;
244 
245  }
246  else
247  {
248  rz_soft_current_static_power += Pstatic;
249  }
250 
251  rz_reconf_current_power += P_RECONF;
252  }
253 
254 
255  //scheduler.Scheduler_get_output_stream() << "ALL_RZ RZname: " << all_RZs.at(i)->getName()<< " - RZSlices: " << all_RZs.at(i)->get_resources_ptr()->getResourceCount("Slice") << " - RZclbm: " << all_RZs.at(i)->get_resources_ptr()->getResourceCount("CLBm")<< " - RZclbl: " << all_RZs.at(i)->get_resources_ptr()->getResourceCount("CLBl")<< endl;
256  //scheduler.Scheduler_get_output_stream() << "RZname: " << all_RZs.at(i)->getName()<< " power : " << rz_current_power << " mW " << endl;
257  total_current_power+=rz_current_power;
258  i++;
259  }
260 
261 
262 
263  double hyper_period_step = (sc_time_stamp()-Application::getGlobalOffset())/Application::getGlobalHypeperiod();
264 
265  if (hyper_period_step == (long)hyper_period_step && new_period==1)
266  {
267  if (sc_time_stamp()>=Application::getGlobalOffset ())
268  current_time=sc_time_stamp()-Application::getGlobalOffset()-((long)hyper_period_step)*Application::getGlobalHypeperiod();
269  else
270  current_time=sc_time_stamp();
271  previous_time=current_time;
272  }
273  else
274  {
275  if (sc_time_stamp()>Application::getGlobalOffset ())
276  current_time=sc_time_stamp()-Application::getGlobalOffset()-(long)hyper_period_step*Application::getGlobalHypeperiod();
277  else
278  current_time=sc_time_stamp();
279  }
280 
281  if ((current_time-previous_time).to_seconds()>5) //patch ...
282  previous_time=current_time;
283 
284  if (new_period==1 && previous_time!=current_time)
285  new_period=0;
286 
287  hyper_energy+=total_current_power*(current_time-previous_time).to_seconds();
288 
289 
290 
291 /* scheduler.Scheduler_get_output_stream() << "Current power : total : " << total_current_power<< " mW" ;
292  scheduler.Scheduler_get_output_stream() << " soft_static: " << rz_soft_current_static_power<< " mW" ;
293  scheduler.Scheduler_get_output_stream() << " soft_idle: " << rz_soft_current_idle_power<< " mW" ;
294  scheduler.Scheduler_get_output_stream() << " soft_run: " << rz_soft_current_run_power<< " mW" ;
295  scheduler.Scheduler_get_output_stream() << " hard_static: " << rz_hard_current_static_power<< " mW" ;
296  scheduler.Scheduler_get_output_stream() << " hard_idle: " << rz_hard_current_idle_power<< " mW" ;
297  scheduler.Scheduler_get_output_stream() << " hard_run: " << rz_hard_current_run_power<< " mW" ;
298  scheduler.Scheduler_get_output_stream() << " reconf: " << rz_reconf_current_power<< " mW" ;
299  scheduler.Scheduler_get_output_stream() << " during: " << (current_time-previous_time).to_seconds()*1000 << " ms at "<< current_time.to_seconds()*1000 << " ms at global " << sc_time_stamp().to_seconds()*1000 << " ms" << endl;
300 */
301  if (hyper_period_step == (long)hyper_period_step && new_period==0)
302  {
303 /* scheduler.Scheduler_get_output_stream() << "!!NEW HYPER!!" << endl;
304  scheduler.Scheduler_get_output_stream() << "Energy : " << hyper_energy << " mJ" << endl;
305 */ previous_hyper_energy=hyper_energy;
306  hyper_energy=0;
307 
308  if (sc_time_stamp()>Application::getGlobalOffset ())
309  current_time=sc_time_stamp()-Application::getGlobalOffset()-(long)hyper_period_step*Application::getGlobalHypeperiod();
310  else
311  current_time=sc_time_stamp();
312  new_period=1;
313 
314 
315  }
316 
317 
318  hyper_instant_energy = hyper_energy;
319  //scheduler.Scheduler_get_output_stream() << "scheduler_period : " << current_time-previous_time << endl;
320  previous_time=current_time;
321 
322  wait(sc_time(100, SC_US));
323  }
324  }
325 
326 };
327 
328 MONITORING_MODULE(Power_Monitoring) {
329 
330  /***** STEP 1 *********************************************/
331  /* Declaration */
332  /* */
333  /* Types : */
334  /* double : MONITORING_VAR_DOUBLE */
335  /* integer : MONITORING_VAR_INT */
336  /* unsigned integer : MONITORING_VAR_UINT */
337  /* string : MONITORING_VAR_STRING */
338 
339  TRACE_VAR_DOUBLE(previous_hyper_energy);
340  TRACE_VAR_DOUBLE(app_energy);
341  TRACE_VAR_DOUBLE(previous_app_energy);
342  TRACE_VAR_DOUBLE(hyper_instant_energy);
343  TRACE_VAR_DOUBLE(total_current_power);
344  TRACE_VAR_DOUBLE(previous_app_time);
345 
346  TRACE_VAR_DOUBLE(rz_reconf_current_power);
347  TRACE_VAR_DOUBLE(rz_hard_current_static_power);
348  TRACE_VAR_DOUBLE(rz_soft_current_idle_power);
349  TRACE_VAR_DOUBLE(rz_soft_current_static_power);
350  TRACE_VAR_DOUBLE(rz_hard_current_idle_power);
351  TRACE_VAR_DOUBLE(rz_hard_current_run_power);
352  TRACE_VAR_DOUBLE(rz_soft_current_run_power);
353  TRACE_VAR_DOUBLE(cpu_operating_point);
354 
355  //char operatingpoint_RZ1[100],operatingpoint_RZ2[100], operatingpoint_RZ3[100], operatingpoint_RZ4[100];
356 
357  TRACE_VAR_DOUBLE(RZ1_v);
358  TRACE_VAR_DOUBLE(RZ1_f);
359  TRACE_VAR_DOUBLE(RZ2_v);
360  TRACE_VAR_DOUBLE(RZ2_f);
361  TRACE_VAR_DOUBLE(RZ3_v);
362  TRACE_VAR_DOUBLE(RZ3_f);
363  TRACE_VAR_DOUBLE(RZ4_v);
364  TRACE_VAR_DOUBLE(RZ4_f);
365  TRACE_VAR_DOUBLE(RZ5_v);
366  TRACE_VAR_DOUBLE(RZ5_f);
367  //TRACE_VAR_STRING(operatingpoint_RZ2);
368  //TRACE_VAR_STRING(operatingpoint_RZ3);
369  //TRACE_VAR_STRING(operatingpoint_RZ4);
370 
371 
372  double hyper_energy;
373 
374 
375  /***** STEP 2 *********************************************/
376  /* Init Variable(s) and Thread(s) */
377 
378  MONITORING_INIT(Power_Monitoring) {
379 
380  // Init Variable(s)
381  hyper_energy = 0;
382  total_current_power = 0;
383  previous_hyper_energy =0;
384 
385  // Init Thread(s) for Trace
386  MONITORING_ADD_THREAD(Power_Monitoring, trace_update_thread_cpu);
387  }
388 
389  /***** STEP 3 *********************************************/
390  /* Record Variable(s) */
391 
392  MONITORING_ACTIVATE {
393 
394  /* 2 Methods :
395  * - MONITORING_ANALOG_TRACE(declaration_name, "name_of_signal", min value, max value, height in pixel)
396  * height : in pixel, less than value 50 is not right. About 80 is a right value.
397  *
398  * - MONITORING_TRACE(declaration_name, "name_of_signal", format)
399  * format value: hexadecimal, ascii, unsigned, decimal
400  *
401  * Note: The declaration order will be the wave declaration order in the trace file
402  */
403 
404  MONITORING_ANALOG_TRACE(previous_hyper_energy, "Previous_Hyper_Energy", 0, 100, 75);
405  MONITORING_ANALOG_TRACE(app_energy, "App_instant_Energy", 0, 100, 75);
406  MONITORING_ANALOG_TRACE(previous_app_energy, "Previous_App_Energy", 0, 100, 75);
407  MONITORING_ANALOG_TRACE(hyper_instant_energy, "Hyper_Instant_Energy", 0, 100, 75);
408  MONITORING_ANALOG_TRACE(total_current_power, "Instant_current", 0, 2000, 75);
409  MONITORING_TRACE(previous_app_time, "Previous_App_Time", "decimal")
410 
411  MONITORING_ANALOG_TRACE(rz_reconf_current_power, "Reconf_current", 0, 1000, 75);
412  MONITORING_ANALOG_TRACE(rz_hard_current_static_power, "RZ_static_current", 0, 1000, 75);
413  MONITORING_ANALOG_TRACE(rz_hard_current_idle_power, "RZ_idle_current", 0, 1000, 75);
414  MONITORING_ANALOG_TRACE(rz_hard_current_run_power, "RZ_run_current", 0, 1000, 75);
415  MONITORING_ANALOG_TRACE(rz_soft_current_static_power, "Cores_static_current", 0, 1000, 75);
416  MONITORING_ANALOG_TRACE(rz_soft_current_idle_power, "Cores_idle_current", 0, 1000, 75);
417  MONITORING_ANALOG_TRACE(rz_soft_current_run_power, "Cores_run_current", 0, 1000, 75);
418  MONITORING_ANALOG_TRACE(cpu_operating_point, "CPU_operating_point", 0, 2, 75);
419 
420 
421  MONITORING_TRACE(RZ1_v, "OP_RZ1.V", "decimal");
422  MONITORING_TRACE(RZ1_f, "OP_RZ1.F", "decimal");
423  MONITORING_TRACE(RZ2_v, "OP_RZ2.V", "decimal");
424  MONITORING_TRACE(RZ2_f, "OP_RZ2.F", "decimal");
425  MONITORING_TRACE(RZ3_v, "OP_RZ3.V", "decimal");
426  MONITORING_TRACE(RZ3_f, "OP_RZ3.F", "decimal");
427  MONITORING_TRACE(RZ4_v, "OP_RZ4.V", "decimal");
428  MONITORING_TRACE(RZ4_f, "OP_RZ4.F", "decimal");
429  MONITORING_TRACE(RZ5_v, "OP_RZ5.V", "decimal");
430  MONITORING_TRACE(RZ5_f, "OP_RZ5.F", "decimal");
431  //MONITORING_TRACE(operatingpoint_RZ2, "OP_RZ2.F", "ascii");
432  //MONITORING_TRACE(operatingpoint_RZ3, "OP_RZ3", "ascii");
433  //MONITORING_TRACE(operatingpoint_RZ4, "OP_RZ4", "ascii");
434 
435 
436  }
437 
438  /***** STEP 4 *********************************************/
439  /* Define the Thread behavior(s) */
440 
441  MONITORING_THREAD(trace_update_thread_cpu) {
442 
443  //double total_current_power=0;
444  sc_time current_time(SC_ZERO_TIME);
445  sc_time previous_time(SC_ZERO_TIME);
446  sc_time app_time(SC_ZERO_TIME);
447  bool new_period=0;
448 
449  total_current_power=0;
450  double rz_current_power=0;
451  rz_reconf_current_power=0;
452  rz_hard_current_static_power=0;
453  rz_soft_current_static_power=0;
454  rz_hard_current_idle_power=0;
455  rz_soft_current_idle_power=0;
456  rz_hard_current_run_power=0;
457  rz_soft_current_run_power=0;
458  hyper_energy=0;
459  previous_app_energy=0;
460 
461  int nb_CPU =0;
462  int nb_Running_CPU=0;
463 
464  //for future use :
465  double max_CPU_freq=PM_CPU_FREQUENCY;
466  double max_CPU_V=PM_CPU_VOLTAGE;
467 
468  // Example of behavior
469  Scheduler_interface& scheduler = services.getShedulerInterface();
470 
471  while(true) {
472 
473  /* Sampling Period */
474  //wait(monitoring_if.endOfSchedulingEvent());
475 
476 
477  /* Modify Value of the Signal */
478  vector<RZ *> all_RZs = scheduler.Scheduler_get_all_rz_vector();
479  int i = 0;
480  double Pstatic, Pidle, Prun;
481 
482  total_current_power=0;
483  rz_current_power=0;
484  rz_reconf_current_power=0;
485  rz_hard_current_static_power=0;
486  rz_soft_current_static_power=0;
487  rz_hard_current_idle_power=0;
488  rz_soft_current_idle_power=0;
489  rz_hard_current_run_power=0;
490  rz_soft_current_run_power=0;
491 
492  nb_CPU=0;
493  nb_Running_CPU=0;
494 
495  while(i < (int) all_RZs.size()) {
496 
497  //get powers for HW or SW RZ.
498  if (all_RZs.at(i)->get_implementation_type()==HARD)
499  {
500  Pstatic=P_STATIC_1CELL*all_RZs.at(i)->get_resources_ptr()->getResourceCount("Slice")*40; //*40 à expliquer!!
501  Pidle=all_RZs.at(i)->getCurrentImplementation().getPidle();
502  Prun= all_RZs.at(i)->getCurrentImplementation().getPrun();
503  }
504  else //SOFT
505  {
506  Pstatic=0;//CPU_PSTATIC;
507  Pidle=0;//CPU_PIDLE;
508  Prun=0;//CPU_PRUN; //will be computed later with CPU power model (l.
509  //nb_CPU++;
510  double voltage = all_RZs.at(i)->getConfigFctPoint().getVoltage();
511  double frequency = all_RZs.at(i)->getConfigFctPoint().getFrequency();
512 
513  float static_coeff = services.getRZProperties(all_RZs.at(i)->getName())->getConfigProcessor()->getType()->getStaticPowerCoeff();
514  float idle_coeff = services.getRZProperties(all_RZs.at(i)->getName())->getConfigProcessor()->getType()->getIdlePowerCoeff ();
515 
516  rz_soft_current_static_power+= static_coeff*voltage;
517  rz_soft_current_idle_power += idle_coeff*voltage*voltage*frequency;
518 
519 
520 
521 
522  }
523 
524  //computer RZ total power following each state
525  if(scheduler.Scheduler_is_RZ_blank(all_RZs.at(i)) )
526  {
527  //rz_current_power = Pstatic;
528  rz_current_power = 0;
529  if (all_RZs.at(i)->get_implementation_type()==HARD)
530  {
531  rz_hard_current_static_power += Pstatic;
532  rz_current_power+=Pstatic;
533  }
534  else
535  {
536  //rz_soft_current_static_power += rz_current_power;
537  }
538  }
539  else if ( scheduler.Scheduler_get_task_state(all_RZs.at(i)) == MAPPED ||
540  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == PREEMPTED_MAPPED ||
541  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == QUEUED ||
542  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == INACTIVE||
543  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == PREEMPTED_INACTIVE ||
544  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == WAITING||
545  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == IDLE ||
546  scheduler.Scheduler_get_task_state(all_RZs.at(i)) == STATIC)
547  {
548  //scheduler.Scheduler_get_current_module_ID(all_RZs.at(i));;
549  if (all_RZs.at(i)->get_implementation_type()==HARD)
550  {
551 
552  rz_hard_current_static_power += Pstatic;
553  rz_hard_current_idle_power += Pidle;
554  rz_current_power = Pstatic + Pidle;
555  }
556  else
557  {
558  //rz_soft_current_static_power += Pstatic;
559  //rz_soft_current_idle_power += Pidle;
560  //rz_current_power = Pidle;
561  }
562  }
563  else if ( scheduler.Scheduler_get_task_state(all_RZs.at(i)) == RUNNING)
564  {
565 
566  if (all_RZs.at(i)->get_implementation_type()==HARD)
567  {
568 
569  rz_hard_current_static_power += Pstatic;
570  rz_hard_current_idle_power += Pidle;
571  rz_hard_current_run_power += Prun;
572  rz_current_power = Pstatic + Pidle+ Prun;
573  }
574  else
575  {
576  //rz_soft_current_static_power += Pstatic;
577  //rz_soft_current_idle_power += Pidle;
578 
579  //rz_soft_current_run_power += Prun;
580  //rz_current_power = Prun;
581  //nb_Running_CPU++;
582 
583  double voltage = all_RZs.at(i)->getConfigFctPoint().getVoltage();
584  double frequency = all_RZs.at(i)->getConfigFctPoint().getFrequency();
585 
586  float run_coeff = services.getRZProperties(all_RZs.at(i)->getName())->getConfigProcessor()->getType()->getRunPowerCoeff ();
587 
588  rz_soft_current_run_power +=run_coeff*voltage*voltage*frequency;
589  }
590  }
591  else if ( scheduler.Scheduler_get_task_state(all_RZs.at(i)) == CONFIG)
592  {
593  rz_current_power = Pstatic + P_RECONF; //maybe to refine with Pidle model during reconf?
594  if (all_RZs.at(i)->get_implementation_type()==HARD)
595  {
596  rz_hard_current_static_power += Pstatic;
597 
598  }
599  else
600  {
601  //rz_soft_current_static_power += Pstatic;
602  }
603 
604  rz_reconf_current_power += P_RECONF;
605  }
606 
607 
608  //total_current_power+=rz_current_power;
609  i++;
610 
611  }
612  //operatingpoint_RZ1=all_RZs.at(0)->getCurrentImplementation().getName();
613  if (all_RZs.size()>0)
614  {
615  RZ1_v=all_RZs.at(0)->getConfigFctPoint().getVoltage();
616  RZ1_f=all_RZs.at(0)->getConfigFctPoint().getFrequency();
617  }
618 
619  if (all_RZs.size()>1)
620  {
621  RZ2_v=all_RZs.at(1)->getConfigFctPoint().getVoltage();
622  RZ2_f=all_RZs.at(1)->getConfigFctPoint().getFrequency();
623  }
624 
625  if (all_RZs.size()>2)
626  {
627  RZ3_v=all_RZs.at(2)->getConfigFctPoint().getVoltage();
628  RZ3_f=all_RZs.at(2)->getConfigFctPoint().getFrequency();
629  }
630 
631  if (all_RZs.size()>3)
632  {
633  RZ4_v=all_RZs.at(3)->getConfigFctPoint().getVoltage();
634  RZ4_f=all_RZs.at(3)->getConfigFctPoint().getFrequency();
635  }
636 
637  if (all_RZs.size()>4)
638  {
639  RZ5_v=all_RZs.at(4)->getConfigFctPoint().getVoltage();
640  RZ5_f=all_RZs.at(4)->getConfigFctPoint().getFrequency();
641  }
642 
643  //operatingpoint_RZ2=all_RZs.at(0)->getConfigFctPoint()->toString();
644  /*
645  i=0;
646  while(i < (int) all_RZs.size()) {
647  scheduler.Scheduler_get_output_stream() << "RZ"<<i<<" "<< all_RZs.at(i)->getName() << " point de fonctionnement " << all_RZs.at(i)->getConfigFctPoint()->toString() << " T: " << all_RZs.at(i)->getConfigFctPoint()->getVoltage() << " F: " << all_RZs.at(i)->getConfigFctPoint()->getFrequency()<< endl;
648  i++;
649  }*/
650 
651  //now we have browsed all RZ, computer CPU power depending on CPUs USAGE
652  //P=Pstatic*Vcore*Ncores+alpha*Vcore*Vcore*Ncores*Freq+beta*Vcore*Vcore*Ncoresrunning*Freq
653 
654  //max_CPU_V=CPU_VOLTAGES_STEPS[global_operating_point];
655  //max_CPU_freq=CPU_FREQUENCIES_STEPS[global_operating_point];
656  cpu_operating_point=global_operating_point;
657 
658  //rz_soft_current_static_power=PM_CPU_STATIC*max_CPU_V*nb_CPU;
659  //rz_soft_current_idle_power=PM_CPU_ALPHA*max_CPU_V*max_CPU_V*nb_CPU*max_CPU_freq;
660  //rz_soft_current_run_power=PM_CPU_BETA*max_CPU_V*max_CPU_V*nb_Running_CPU*max_CPU_freq;
661 
662  total_current_power=rz_reconf_current_power+rz_hard_current_static_power+rz_hard_current_idle_power+rz_hard_current_run_power+rz_soft_current_static_power+rz_soft_current_idle_power+rz_soft_current_run_power;
663 
664 
665  double hyper_period_step = (sc_time_stamp()-Application::getGlobalOffset())/Application::getGlobalHypeperiod();
666 
667  if (hyper_period_step == (long)hyper_period_step && new_period==1)
668  {
669  if (sc_time_stamp()>=Application::getGlobalOffset ())
670  current_time=sc_time_stamp()-Application::getGlobalOffset()-((long)hyper_period_step)*Application::getGlobalHypeperiod();
671  else
672  current_time=sc_time_stamp();
673  previous_time=current_time;
674  }
675  else
676  {
677  if (sc_time_stamp()>Application::getGlobalOffset ())
678  current_time=sc_time_stamp()-Application::getGlobalOffset()-(long)hyper_period_step*Application::getGlobalHypeperiod();
679  else
680  current_time=sc_time_stamp();
681  }
682 
683  if ((current_time-previous_time).to_seconds()>5) //patch ... de démarrage?
684  previous_time=current_time;
685 
686  if (new_period==1 && previous_time!=current_time)
687  new_period=0;
688 
689  hyper_energy+=total_current_power*(current_time-previous_time).to_seconds();
690 
691 
692  if (hyper_period_step == (long)hyper_period_step && new_period==0)
693  {
694 /* scheduler.Scheduler_get_output_stream() << "!!NEW HYPER!!" << endl;
695  scheduler.Scheduler_get_output_stream() << "Energy : " << hyper_energy << " mJ" << endl;
696 */ previous_hyper_energy=hyper_energy;
697  hyper_energy=0;
698 
699  previous_app_energy=app_energy;
700  previous_app_time=app_time.to_seconds()*1000*1000; //in us
701 
702  if (sc_time_stamp()>Application::getGlobalOffset ())
703  current_time=sc_time_stamp()-Application::getGlobalOffset()-(long)hyper_period_step*Application::getGlobalHypeperiod();
704  else
705  current_time=sc_time_stamp();
706  new_period=1;
707 
708 
709  }
710 
711 
712  if (app_is_running)
713  app_energy=hyper_energy;
714  if (app_is_running)
715 
716  app_time=current_time;
717 
718  hyper_instant_energy = hyper_energy;
719  //scheduler.Scheduler_get_output_stream() << "scheduler_period : " << current_time-previous_time << endl;
720  previous_time=current_time;
721 
722  wait(sc_time(5, SC_US));
723  }
724  }
725 
726 };
727 
728 
729 #endif
virtual Task_state Scheduler_get_task_state(int task_id)=0
Get task state.
virtual bool Scheduler_is_RZ_blank(RZ *rz)=0
Check if RZ is blank or used by a task.
virtual vector< RZ * > Scheduler_get_all_rz_vector(void)=0
Get the list of all reconfigurable zones used in the architecture.
Definition: scheduler_interface.h:138