00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef LEGOAN_LOOPDETECT_HEADER
00013 #define LEGOAN_LOOPDETECT_HEADER
00014
00015 #include "lego.H"
00016
00017
00018
00019
00020
00021
00022 class loopdetect_stats
00023 {
00024
00025 #ifndef WTSIZE
00026 #define WTSIZE (10000)
00027 #endif
00028
00029 struct idpair
00030 {
00031 int i;
00032 double d;
00033 };
00034
00035 public:
00036 char *filename;
00037 long loop_count;
00038 long block_count;
00039 struct idpair block_stats[WTSIZE];
00040 long op_count;
00041 struct idpair op_stats[WTSIZE];
00042 double total_weight;
00043
00044
00045 loopdetect_stats (char *fn)
00046 {
00047 int i;
00048
00049 filename = new char [strlen (fn) + 1];
00050 strcpy (filename, fn);
00051 loop_count = block_count = op_count = 0;
00052 for (i = 0; i < WTSIZE; i++)
00053 {
00054 block_stats[i].i = op_stats[i].i = 0;
00055 block_stats[i].d = op_stats[i].d = 0.0;
00056 }
00057 total_weight = 0.0;
00058 }
00059 void dump (FILE *out)
00060 {
00061 int i;
00062
00063 fprintf (out, "%s\t%ld\t", filename, loop_count);
00064 fprintf (out, "%lf\t",
00065 ((double) block_count) / ((double) loop_count));
00066 fprintf (out, "%lf\n",
00067 ((double) op_count) / ((double) loop_count));
00068
00069 if (loop_count > 0 && block_count != 0)
00070 {
00071 for (i = 0; i < WTSIZE; i++)
00072 if (block_stats[i].i != 0)
00073 fprintf (out, "\t%d\t%d\t%lf\n", i, block_stats[i].i,
00074 block_stats[i].d / total_weight);
00075 fprintf (out, "\n");
00076 for (i = 0; i < WTSIZE; i++)
00077 if (op_stats[i].i != 0)
00078 fprintf (out, "\t%d\t%d\t%lf\n", i, op_stats[i].i,
00079 op_stats[i].d / total_weight);
00080 }
00081 fprintf (out, "\n");
00082 return;
00083 }
00084 };
00085
00086
00087
00088
00089
00090
00091 class loopunroll_stats
00092 {
00093
00094 struct idpair
00095 {
00096 int i;
00097 double d;
00098 };
00099
00100 public:
00101 char *filename;
00102 long loop_count;
00103 struct idpair unroll_stats[WTSIZE];
00104 double total_weight;
00105
00106
00107 loopunroll_stats (char *fn)
00108 {
00109 int i;
00110
00111 filename = new char [strlen (fn) + 1];
00112 strcpy (filename, fn);
00113 loop_count = 0;
00114 for (i = 0; i < WTSIZE; i++)
00115 {
00116 unroll_stats[i].i = 0;
00117 unroll_stats[i].d = 0.0;
00118 }
00119 total_weight = 0.0;
00120 }
00121 void dump (FILE *out)
00122 {
00123 int i;
00124
00125 fprintf (out, "%s\t%ld\t%lf\n", filename, loop_count, total_weight);
00126
00127
00128
00129
00130
00131 if (loop_count > 0)
00132 {
00133 for (i = 0; i < WTSIZE; i++)
00134 if (unroll_stats[i].i != 0)
00135 fprintf (out, "\t%d\t%d\t%lf\n", i, unroll_stats[i].i,
00136 unroll_stats[i].d / total_weight);
00137
00138
00139
00140
00141
00142 }
00143 fprintf (out, "\n");
00144 return;
00145 }
00146 };
00147
00148 regionList *FindNaturalLoop (opEdges *, legoProc *);
00149 regionList *FindCommonNaturalLoop (opEdges *, legoProc *, int = 0);
00150 void CreateLcLoopAttributes (legoProc *);
00151 void LoopDetect (legoProc *, loopdetect_stats * = NULL);
00152 legoRegion *FindLoopHeader (regionList *);
00153 void GatherUnrollInfo (legoProc *, loopunroll_stats *);
00154 void markbackedgesandloopheaders (legoProc *proc);
00155
00156 #endif // LEGOAN_LOOPDETECT_HEADER
00157