00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #include "defs.h"
00056 #include "resource.h"
00057 #include "timing.h"
00058 #include "tracing.h"
00059 #include "resource.h"
00060
00061
00062 static BOOL Enabled = FALSE;
00063
00064
00065 static RSTATE *timers[T_LAST+1];
00066 #define Timer(i) timers[i]
00067
00068
00069
00070
00071 static INT CU_Count = 0;
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 void
00083 Reset_Timers (void)
00084 {
00085 INT i;
00086
00087 if ( Enabled ) {
00088 for ( i=0; i <= T_LAST; i++ ) Resource_Accum (Timer(i), RR_Clear);
00089 }
00090 }
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 void
00104 Initialize_Timing ( BOOL enable )
00105 {
00106
00107 if ( Enabled = enable ) {
00108
00109
00110 Resource_Init ();
00111
00112
00113 Timer ( T_BE_Comp ) =
00114 Resource_Alloc ( "Total Back End", NULL );
00115 Timer ( T_BE_PU_Comp ) =
00116 Resource_Alloc ( "Back End on PU", NULL );
00117 Timer ( T_BE_PU_CU ) =
00118 Resource_Alloc ( "Back End on PU", Timer(T_BE_PU_Comp) );
00119 Timer ( T_ReadIR_Comp ) =
00120 Resource_Alloc ( " Reading IR", NULL );
00121 Timer ( T_ReadIR_CU ) =
00122 Resource_Alloc ( " Reading IR", Timer(T_ReadIR_Comp) );
00123 Timer ( T_Lower_Comp ) =
00124 Resource_Alloc ( " Lowering WHIRL", NULL );
00125 Timer ( T_Lower_CU ) =
00126 Resource_Alloc ( " Lowering WHIRL", Timer(T_Lower_Comp) );
00127 Timer ( T_ORI_Comp ) =
00128 Resource_Alloc ( " Olimit Region Insertion", NULL );
00129 Timer ( T_ORI_CU ) =
00130 Resource_Alloc ( " Olimit Region Insertion", Timer(T_ORI_Comp) );
00131
00132 Timer ( T_Preopt_Comp ) =
00133 Resource_Alloc ( "Pre-optimize", NULL );
00134 Timer ( T_Preopt_CU ) =
00135 Resource_Alloc ( "Pre-optimize", Timer(T_Preopt_Comp) );
00136 Timer ( T_Wopt_Comp ) =
00137 Resource_Alloc ( "Global optimize", NULL );
00138 Timer ( T_Wopt_CU ) =
00139 Resource_Alloc ( "Global optimize", Timer(T_Wopt_Comp) );
00140 Timer ( T_LNO_Comp ) =
00141 Resource_Alloc ( "Loop Nest Optimization", NULL );
00142 Timer ( T_LNO_CU ) =
00143 Resource_Alloc ( "Loop Nest Optimization", Timer(T_LNO_Comp) );
00144
00145 Timer ( T_W2C_Comp ) =
00146 Resource_Alloc ( "WHIRL To C", NULL );
00147 Timer ( T_W2C_CU ) =
00148 Resource_Alloc ( "WHIRL To C", Timer(T_W2C_Comp) );
00149 Timer ( T_W2F_Comp ) =
00150 Resource_Alloc ( "WHIRL To Fortran", NULL );
00151 Timer ( T_W2F_CU ) =
00152 Resource_Alloc ( "WHIRL To Fortran", Timer(T_W2F_Comp) );
00153
00154 Timer ( T_CodeGen_Comp ) =
00155 Resource_Alloc ( "Total Code Generator", NULL );
00156 Timer ( T_CodeGen_CU ) =
00157 Resource_Alloc ( "Total Code Generator", Timer(T_CodeGen_Comp) );
00158
00159 Timer ( T_GLRA_Comp ) =
00160 Resource_Alloc ( " Global Live Range Analysis", NULL );
00161 Timer ( T_GLRA_CU ) =
00162 Resource_Alloc ( " Global Live Range Analysis", Timer(T_GLRA_Comp) );
00163 Timer ( T_Localize_Comp ) =
00164 Resource_Alloc ( " Localize", NULL );
00165 Timer ( T_Localize_CU ) =
00166 Resource_Alloc ( " Localize", Timer(T_Localize_Comp) );
00167 Timer ( T_Expand_Comp ) =
00168 Resource_Alloc ( " Code Expansion", NULL );
00169 Timer ( T_Expand_CU ) =
00170 Resource_Alloc ( " Code Expansion", Timer(T_Expand_Comp) );
00171 Timer ( T_SWpipe_Comp ) =
00172 Resource_Alloc ( " Software pipelining", NULL );
00173 Timer ( T_SWpipe_CU ) =
00174 Resource_Alloc ( " Software pipelining", Timer(T_SWpipe_Comp) );
00175 Timer ( T_GCM_Comp ) =
00176 Resource_Alloc ( " Global Code Motion", NULL );
00177 Timer ( T_GCM_CU ) =
00178 Resource_Alloc ( " Global Code Motion", Timer(T_GCM_Comp) );
00179 Timer ( T_EBO_Comp ) =
00180 Resource_Alloc ( " Extended Block Optimization", NULL );
00181 Timer ( T_EBO_CU ) =
00182 Resource_Alloc ( " Extended BLock Optimization", Timer(T_EBO_Comp) );
00183 Timer ( T_CFLOW_Comp ) =
00184 Resource_Alloc ( " Control Flow Optimization", NULL );
00185 Timer ( T_CFLOW_CU ) =
00186 Resource_Alloc ( " Control Flow Optimization", Timer(T_CFLOW_Comp) );
00187 Timer ( T_Loop_Comp ) =
00188 Resource_Alloc ( " CG Loop", NULL );
00189 Timer ( T_Loop_CU ) =
00190 Resource_Alloc ( " CG Loop", Timer(T_Loop_Comp) );
00191 Timer ( T_Freq_Comp ) =
00192 Resource_Alloc ( " Compute Frequency", NULL );
00193 Timer ( T_Freq_CU ) =
00194 Resource_Alloc ( " Compute Frequency", Timer(T_Freq_Comp) );
00195 Timer ( T_HBF_Comp ) =
00196 Resource_Alloc ( " HyperBlock Formation", NULL );
00197 Timer ( T_HBF_CU ) =
00198 Resource_Alloc ( " HyperBlock Formation", Timer(T_HBF_Comp) );
00199 Timer ( T_Sched_Comp ) =
00200 Resource_Alloc ( " HyperBlock Scheduling", NULL );
00201 Timer ( T_Sched_CU ) =
00202 Resource_Alloc ( " HyperBlock Scheduling", Timer(T_Sched_Comp) );
00203 Timer ( T_THR_Comp ) =
00204 Resource_Alloc ( " Tree-Height Reduction", NULL );
00205 Timer ( T_THR_CU ) =
00206 Resource_Alloc ( " Tree-Height Reduction", Timer(T_THR_Comp) );
00207 Timer ( T_LRA_Comp ) =
00208 Resource_Alloc ( " Local Register Allocation", NULL );
00209 Timer ( T_LRA_CU ) =
00210 Resource_Alloc ( " Local Register Allocation", Timer(T_LRA_Comp));
00211 Timer ( T_GRA_Comp ) =
00212 Resource_Alloc ( " Global Register Allocation", NULL );
00213 Timer ( T_GRA_CU ) =
00214 Resource_Alloc ( " Global Register Allocation", Timer(T_GRA_Comp));
00215 Timer ( T_Emit_Comp ) =
00216 Resource_Alloc ( " Assembly Code Emission", NULL );
00217 Timer ( T_Emit_CU ) =
00218 Resource_Alloc ( " Assembly Code Emission", Timer(T_Emit_Comp) );
00219 Timer ( T_Region_Finalize_Comp ) =
00220 Resource_Alloc ( " Region Finalize", NULL );
00221 Timer ( T_Region_Finalize_CU ) =
00222 Resource_Alloc ( " Region Finalize", Timer(T_Region_Finalize_Comp));
00223 Timer ( T_CalcDom_Comp) =
00224 Resource_Alloc ( " Calculate_Dominators", NULL );
00225 Timer ( T_CalcDom_CU) =
00226 Resource_Alloc ( " Calculate_Dominators", Timer(T_CalcDom_Comp));
00227
00228 }
00229 }
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240 #ifndef MONGOOSE_BE
00241 void
00242 Clear_Timer ( INT Timer_ID )
00243 {
00244 if ( Enabled ) {
00245 Resource_Accum ( Timer(Timer_ID), RR_Clear );
00246 }
00247 }
00248 #endif
00249
00250 void
00251 Start_Timer ( INT Timer_ID )
00252 {
00253 if ( Enabled ) {
00254 Resource_Accum ( Timer(Timer_ID), RR_Start );
00255 }
00256 }
00257
00258 void
00259 Stop_Timer ( INT Timer_ID )
00260 {
00261 if ( Enabled ) {
00262 Resource_Accum ( Timer(Timer_ID), RR_Stop );
00263 }
00264 }
00265
00266 double Get_User_Time(INT Timer_ID)
00267 {
00268 if (Enabled) {
00269 RSTATE *r;
00270
00271 Resource_Accum ( Timer(Timer_ID), RR_Stop );
00272 Resource_Accum ( Timer(Timer_ID), RR_Start );
00273 r = Timer(Timer_ID);
00274 TIME_INFO *utime = Get_Time ( r, RR_Delta_User );
00275 return utime->secs + 0.000001 * utime->usecs;
00276 }
00277 return 0.0;
00278 }
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289 static void
00290 Add_Timer_To_Parent ( INT Timer_ID )
00291 {
00292 if ( Enabled ) {
00293 Resource_Accum ( Timer(Timer_ID), RR_End );
00294 }
00295 }
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308 void
00309 Report_Delta_Time (
00310 FILE *file,
00311 INT Timer_ID )
00312 {
00313 char *name;
00314 TIME_INFO *utime, *stime, *etime;
00315 RSTATE *r = Timer(Timer_ID);
00316 INT mem;
00317
00318 if ( Enabled ) {
00319 name = Get_Timer_Name (r);
00320 utime = Get_Time ( r, RR_Delta_User );
00321 stime = Get_Time ( r, RR_Delta_System );
00322 etime = Get_Time ( r, RR_Delta_Elapsed );
00323 mem = Get_Memory ( r, RR_Delta_Memory );
00324
00325 #if (1)
00326 fprintf ( file, "%-32s %4d.%06du %4d.%06ds %4d.%06de",
00327 name,
00328 utime->secs, utime->usecs,
00329 stime->secs, stime->usecs,
00330 etime->secs, etime->usecs );
00331 #else
00332 fprintf ( file, "%-32s %4d.%03du %4d.%03ds %4d.%02de",
00333 name,
00334 utime->secs, utime->usecs/1000,
00335 stime->secs, stime->usecs/1000,
00336 etime->secs, etime->usecs/10000 );
00337 #endif
00338 if ( mem ) fprintf ( file, " %7dm", mem );
00339 fprintf ( file, "\n" );
00340 }
00341 }
00342
00343 void
00344 Report_CG_Region_Timing (FILE *file, char *name)
00345 {
00346 if ( ! Enabled ) return;
00347 if ( file == NULL || Get_Trace ( TKIND_INFO, TINFO_CTIME ) ) return;
00348
00349 fprintf ( file, "%s%s: CG Timing Report:\n\n", DBar, name);
00350 Report_Delta_Time ( file, T_CodeGen_CU );
00351 Report_Delta_Time ( file, T_Expand_CU );
00352 Report_Delta_Time ( file, T_Localize_CU );
00353 Report_Delta_Time ( file, T_GLRA_CU );
00354 Report_Delta_Time ( file, T_EBO_CU );
00355 Report_Delta_Time ( file, T_CFLOW_CU );
00356 Report_Delta_Time ( file, T_Loop_CU );
00357 Report_Delta_Time ( file, T_CalcDom_CU );
00358 Report_Delta_Time ( file, T_SWpipe_CU );
00359 Report_Delta_Time ( file, T_Freq_CU );
00360 Report_Delta_Time ( file, T_GRA_CU );
00361 Report_Delta_Time ( file, T_LRA_CU );
00362 Report_Delta_Time ( file, T_HBF_CU );
00363 Report_Delta_Time ( file, T_Sched_CU );
00364 Report_Delta_Time ( file, T_THR_CU );
00365 Report_Delta_Time ( file, T_GCM_CU );
00366 Report_Delta_Time ( file, T_Region_Finalize_CU );
00367 fprintf ( file, "%s\n", DBar );
00368 }
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379 void
00380 Finish_BE_Timing (
00381 FILE *file,
00382 char *name )
00383 {
00384 if ( Enabled ) {
00385
00386 ++CU_Count;
00387
00388
00389 if ( file != NULL && ! Get_Trace ( TKIND_INFO, TINFO_CTIME ) ) {
00390 fprintf ( file,
00391 "%s%s (#%d): Back End Timing Report:\n\n",
00392 DBar, name, CU_Count );
00393
00394 Report_Delta_Time ( file, T_BE_PU_CU );
00395 Report_Delta_Time ( file, T_ReadIR_CU );
00396 Report_Delta_Time ( file, T_Lower_CU );
00397 Report_Delta_Time ( file, T_ORI_CU );
00398
00399 fprintf(file, "\n");
00400 Report_Delta_Time ( file, T_Preopt_CU );
00401 Report_Delta_Time ( file, T_LNO_CU );
00402 Report_Delta_Time ( file, T_Wopt_CU );
00403 Report_Delta_Time ( file, T_W2C_CU );
00404 Report_Delta_Time ( file, T_W2F_CU );
00405
00406 fprintf(file, "\n");
00407 Report_Delta_Time ( file, T_CodeGen_CU );
00408 Report_Delta_Time ( file, T_Expand_CU );
00409 Report_Delta_Time ( file, T_Localize_CU );
00410 Report_Delta_Time ( file, T_GLRA_CU );
00411 Report_Delta_Time ( file, T_EBO_CU );
00412 Report_Delta_Time ( file, T_CFLOW_CU );
00413 Report_Delta_Time ( file, T_Loop_CU );
00414 Report_Delta_Time ( file, T_CalcDom_CU);
00415 Report_Delta_Time ( file, T_SWpipe_CU );
00416 Report_Delta_Time ( file, T_Freq_CU );
00417 Report_Delta_Time ( file, T_GRA_CU );
00418 Report_Delta_Time ( file, T_LRA_CU );
00419 Report_Delta_Time ( file, T_HBF_CU );
00420 Report_Delta_Time ( file, T_Sched_CU );
00421 Report_Delta_Time ( file, T_THR_CU );
00422 Report_Delta_Time ( file, T_GCM_CU );
00423 Report_Delta_Time ( file, T_Emit_CU );
00424 Report_Delta_Time ( file, T_Region_Finalize_CU );
00425 fprintf ( file, "%s\n", DBar );
00426 }
00427
00428
00429 Add_Timer_To_Parent ( T_BE_PU_CU );
00430 Add_Timer_To_Parent ( T_ReadIR_CU );
00431 Add_Timer_To_Parent ( T_Lower_CU );
00432 Add_Timer_To_Parent ( T_ORI_CU );
00433
00434 Add_Timer_To_Parent ( T_Preopt_CU );
00435 Add_Timer_To_Parent ( T_LNO_CU );
00436 Add_Timer_To_Parent ( T_Wopt_CU );
00437
00438 Add_Timer_To_Parent ( T_W2C_CU );
00439 Add_Timer_To_Parent ( T_W2F_CU );
00440
00441 Add_Timer_To_Parent ( T_CodeGen_CU );
00442 Add_Timer_To_Parent ( T_Expand_CU );
00443 Add_Timer_To_Parent ( T_Localize_CU );
00444 Add_Timer_To_Parent ( T_GLRA_CU );
00445 Add_Timer_To_Parent ( T_EBO_CU );
00446 Add_Timer_To_Parent ( T_CFLOW_CU );
00447 Add_Timer_To_Parent ( T_Loop_CU );
00448 Add_Timer_To_Parent ( T_CalcDom_CU );
00449 Add_Timer_To_Parent ( T_SWpipe_CU );
00450 Add_Timer_To_Parent ( T_Freq_CU );
00451 Add_Timer_To_Parent ( T_GRA_CU );
00452 Add_Timer_To_Parent ( T_LRA_CU );
00453 Add_Timer_To_Parent ( T_HBF_CU );
00454 Add_Timer_To_Parent ( T_Sched_CU );
00455 Add_Timer_To_Parent ( T_THR_CU );
00456 Add_Timer_To_Parent ( T_GCM_CU );
00457 Add_Timer_To_Parent ( T_Emit_CU );
00458 Add_Timer_To_Parent ( T_Region_Finalize_CU );
00459 }
00460 }
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471 void
00472 Finish_Compilation_Timing (
00473 FILE *file,
00474 char *source )
00475 {
00476 if ( Enabled ) {
00477
00478 if ( file != NULL ) {
00479 fprintf ( file, "%s\n%s: Compilation Timing Report\n",
00480 DBar, source );
00481
00482 fprintf ( file, "\n" );
00483 Report_Delta_Time ( file, T_BE_Comp );
00484 fprintf ( file, "\n" );
00485 Report_Delta_Time ( file, T_BE_PU_Comp );
00486 Report_Delta_Time ( file, T_ReadIR_Comp );
00487 Report_Delta_Time ( file, T_Lower_Comp );
00488 Report_Delta_Time ( file, T_ORI_Comp );
00489
00490 fprintf ( file, "\n" );
00491 Report_Delta_Time ( file, T_Preopt_Comp );
00492 Report_Delta_Time ( file, T_LNO_Comp );
00493 Report_Delta_Time ( file, T_Wopt_Comp );
00494 Report_Delta_Time ( file, T_W2C_Comp );
00495 Report_Delta_Time ( file, T_W2F_Comp );
00496
00497 fprintf ( file, "\n" );
00498 Report_Delta_Time ( file, T_CodeGen_Comp );
00499 Report_Delta_Time ( file, T_Expand_Comp );
00500 Report_Delta_Time ( file, T_Localize_Comp );
00501 Report_Delta_Time ( file, T_GLRA_Comp );
00502 Report_Delta_Time ( file, T_EBO_Comp );
00503 Report_Delta_Time ( file, T_CFLOW_Comp );
00504 Report_Delta_Time ( file, T_Loop_Comp );
00505 Report_Delta_Time ( file, T_CalcDom_Comp );
00506 Report_Delta_Time ( file, T_SWpipe_Comp );
00507 Report_Delta_Time ( file, T_Freq_Comp );
00508 Report_Delta_Time ( file, T_GRA_Comp );
00509 Report_Delta_Time ( file, T_LRA_Comp );
00510 Report_Delta_Time ( file, T_HBF_Comp );
00511 Report_Delta_Time ( file, T_Sched_Comp );
00512 Report_Delta_Time ( file, T_THR_Comp );
00513 Report_Delta_Time ( file, T_GCM_Comp );
00514 Report_Delta_Time ( file, T_Emit_Comp );
00515 Report_Delta_Time ( file, T_Region_Finalize_Comp );
00516 fprintf ( file, "%s\n", DBar );
00517 }
00518 }
00519 }