Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

loopdetect.H

Go to the documentation of this file.
00001 // loopdetect.H
00002 
00003 /*
00004  * 4/25/97 WAH: Created.
00005  * 7/23/97 WAH: Fixed #define of WTSIZE.
00006  * 7/31/97 WAH: Added loopunroll_stats class.
00007  * 9/17/97 WAH: Name changes.
00008  * 1/22/98 WAH: Changed FindCommonNaturalLoop so marking is optional.
00009  * 4/3/98 WAH:  Added missing #include of lego.H.
00010  */
00011 
00012 #ifndef LEGOAN_LOOPDETECT_HEADER
00013 #define LEGOAN_LOOPDETECT_HEADER
00014 
00015 #include "lego.H"
00016 
00017 /*
00018  * class loopdetect_stats
00019  *
00020  * Statistics structure for loop detection.
00021  */
00022 class loopdetect_stats
00023 {
00024 
00025 #ifndef WTSIZE
00026 #define WTSIZE (10000)
00027 #endif
00028 
00029 struct idpair
00030 {
00031   int i;  // amount of treegions with given block/op count
00032   double d;  // total weight of these treegions
00033 }; // end struct idpair
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   // add more stats later
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       } // end for
00057     total_weight = 0.0;
00058   } // end loopunroll_stats
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       } // end if
00081     fprintf (out, "\n");
00082     return;
00083   } // end dump
00084 }; // end class loopdetect_stats
00085 
00086 /*
00087  * class loopunroll_stats
00088  *
00089  * Statistics structure for loop unrolling.
00090  */
00091 class loopunroll_stats
00092 {
00093 
00094 struct idpair
00095 {
00096   int i;  // number of loops with given unrolling factor
00097   double d;  // total weight of these loops
00098 }; // end struct idpair
00099 
00100 public:
00101   char *filename;
00102   long loop_count;
00103   struct idpair unroll_stats[WTSIZE];
00104   double total_weight;
00105   // add more stats later
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       } // end for
00119     total_weight = 0.0;
00120   } // end loopunroll_stats
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     //    fprintf (out, "%lf\t",
00127     //       ((double) block_count) / ((double) loop_count));
00128     //    fprintf (out, "%lf\n",
00129     //       ((double) op_count) / ((double) loop_count));
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         //      fprintf (out, "\n");
00138         //      for (i = 0; i < WTSIZE; i++)
00139         //        if (op_stats[i].i != 0)
00140         //          fprintf (out, "\t%d\t%d\t%lf\n", i, op_stats[i].i,
00141         //                   op_stats[i].d / total_weight);
00142       } // end if
00143     fprintf (out, "\n");
00144     return;
00145   } // end dump
00146 }; // end class loopunroll_stats
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 

Generated on Mon Jul 21 20:27:56 2003 for TINKER LEGO DOC by doxygen 1.3.2