#include <stdio.h>
#include <assert.h>
#include "defines.h"
#include "perf.h"
#include "util.h"
#include "expr.h"
Functions | |
static perf_stat * | perf_gen_stats (func_unit *funit) |
static void | perf_output_mod_stats (FILE *ofile, func_unit *funit) |
static void | perf_output_inst_report_helper (FILE *ofile, funit_inst *root) |
void | perf_output_inst_report (FILE *ofile) |
Variables | |
db ** | db_list |
unsigned int | curr_db |
Allocates and initializes the contents of a performance structure to display the total number of expressions in the given functional unit and the number of times these expressions that were executed during simulation.
funit | Pointer to functional unit to generate performance statistics for |
References expression_s::exec_num, exp_link_s::exp, func_unit_s::exp_head, EXP_OP_NUM, malloc_safe, exp_link_s::next, expression_s::op, perf_stat_s::op_cnt, perf_stat_s::op_exec_cnt, PROFILE, and PROFILE_END.
Referenced by perf_output_mod_stats().
00045 { PROFILE(PERF_GEN_STATS); 00046 00047 exp_link* expl; /* Pointer to current expression link */ 00048 perf_stat* pstat; /* Pointer to newly created performance stat structure */ 00049 int i; /* Loop iterator */ 00050 00051 /* Create and initialize new perf_stat structure */ 00052 pstat = (perf_stat*)malloc_safe( sizeof( perf_stat ) ); 00053 for( i=0; i<EXP_OP_NUM; i++ ) { 00054 pstat->op_exec_cnt[i] = 0; 00055 pstat->op_cnt[i] = 0; 00056 } 00057 00058 /* Populate performance structure */ 00059 expl = funit->exp_head; 00060 while( expl != NULL ) { 00061 pstat->op_cnt[expl->exp->op] += 1; 00062 pstat->op_exec_cnt[expl->exp->op] += expl->exp->exec_num; 00063 expl = expl->next; 00064 } 00065 00066 PROFILE_END; 00067 00068 return( pstat ); 00069 00070 }
void perf_output_inst_report | ( | FILE * | ofile | ) |
Generates a performance report on an instance basis to the specified output file.
ofile | File to output report information to |
References curr_db, inst_link_s::inst, db_s::inst_head, inst_link_s::next, perf_output_inst_report_helper(), PROFILE, and PROFILE_END.
Referenced by command_score().
00137 { PROFILE(PERF_OUTPUT_INST_REPORT); 00138 00139 inst_link* instl; /* Pointer to current instance link */ 00140 00141 fprintf( ofile, "\nSIMULATION PERFORMANCE STATISTICS:\n\n" ); 00142 00143 instl = db_list[curr_db]->inst_head; 00144 while( instl != NULL ) { 00145 perf_output_inst_report_helper( ofile, instl->inst ); 00146 instl = instl->next; 00147 } 00148 00149 PROFILE_END; 00150 00151 }
static void perf_output_inst_report_helper | ( | FILE * | ofile, | |
funit_inst * | root | |||
) | [static] |
Called by the perf_output_inst_report function to output a performance report on an instance basis.
ofile | File to output report information to | |
root | Pointer to current functional unit instance to output performance stats for |
References funit_inst_s::child_head, funit_inst_s::funit, funit_inst_s::next, perf_output_mod_stats(), PROFILE, and PROFILE_END.
Referenced by perf_output_inst_report().
00112 { PROFILE(PERF_OUTPUT_INST_REPORT_HELPER); 00113 00114 funit_inst* curr; /* Pointer to current child instance to output */ 00115 00116 if( root != NULL ) { 00117 00118 perf_output_mod_stats( ofile, root->funit ); 00119 00120 curr = root->child_head; 00121 while( curr != NULL ) { 00122 perf_output_inst_report_helper( ofile, curr ); 00123 curr = curr->next; 00124 } 00125 00126 } 00127 00128 PROFILE_END; 00129 00130 }
static void perf_output_mod_stats | ( | FILE * | ofile, | |
func_unit * | funit | |||
) | [static] |
Outputs the expression performance statistics to the given output stream.
ofile | Pointer to file to output performance results to | |
funit | Pointer to functional unit to output performance metrics for |
References EXP_OP_NUM, expression_string_op(), get_funit_type(), func_unit_s::name, perf_stat_s::op_cnt, perf_stat_s::op_exec_cnt, perf_gen_stats(), PROFILE, PROFILE_END, and func_unit_s::type.
Referenced by perf_output_inst_report_helper().
00078 { PROFILE(PERF_OUTPUT_MOD_STATS); 00079 00080 perf_stat* pstat; /* Pointer to performance statistic structure for this funit */ 00081 int i; /* Loop iterator */ 00082 float avg_exec; /* Calculated average execution count for the current expression op */ 00083 00084 /* Get performance structure */ 00085 pstat = perf_gen_stats( funit ); 00086 00087 /* Output the structure */ 00088 fprintf( ofile, " %s: %s\n", get_funit_type( funit->type ), funit->name ); 00089 fprintf( ofile, " ExpOp Cnt / Executed / Avg. Executed\n" ); 00090 00091 for( i=0; i<EXP_OP_NUM; i++ ) { 00092 if( pstat->op_exec_cnt[i] > 0 ) { 00093 avg_exec = pstat->op_exec_cnt[i] / pstat->op_cnt[i]; 00094 fprintf( ofile, " %-10.10s %-8.0f %-8u %-8.1f\n", 00095 expression_string_op( i ), pstat->op_cnt[i], pstat->op_exec_cnt[i], avg_exec ); 00096 } 00097 } 00098 00099 fprintf( ofile, "\n" ); 00100 00101 PROFILE_END; 00102 00103 }
unsigned int curr_db |
Index of current database in db_list array that is being handled.