00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _KLASS_H
00025 #define _KLASS_H
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 using namespace std;
00039
00040 #include <string>
00041 #include <list>
00042 #include <set>
00043 #include <map>
00044 #include "sigtype.hh"
00045 #include "smartpointer.hh"
00046 #include "tlib.hh"
00047 #include "uitree.hh"
00048 #include "property.hh"
00049
00050 #define kMaxCategory 32
00051
00052 #include "loop.hh"
00053 #include "graphSorting.hh"
00054
00055 class Klass
00056 {
00057
00058 protected:
00059
00060
00061 static bool fNeedPowerDef;
00062
00063
00064 protected:
00065
00066 string fKlassName;
00067 string fSuperKlassName;
00068 int fNumInputs;
00069 int fNumOutputs;
00070 int fNumActives;
00071 int fNumPassives;
00072
00073 set<string> fIncludeFileSet;
00074 set<string> fLibrarySet;
00075
00076 list<Klass* > fSubClassList;
00077
00078 list<string> fDeclCode;
00079 list<string> fStaticInitCode;
00080 list<string> fStaticFields;
00081 list<string> fInitCode;
00082 list<string> fUICode;
00083 list<string> fUIMacro;
00084
00085 #if 0
00086 list<string> fSlowDecl;
00087 list<string> fSharedDecl;
00088 list<string> fCommonCode;
00089 list<string> fSlowCode;
00090 list<string> fEndCode;
00091 #endif
00092 list<string> fSharedDecl;
00093 list<string> fFirstPrivateDecl;
00094
00095 list<string> fZone1Code;
00096 list<string> fZone2Code;
00097 list<string> fZone2bCode;
00098 list<string> fZone2cCode;
00099 list<string> fZone3Code;
00100
00101 Loop* fTopLoop;
00102 property<Loop*> fLoopProperty;
00103
00104 bool fVec;
00105
00106 public:
00107
00108 Klass (const string& name, const string& super, int numInputs, int numOutputs, bool __vec = false)
00109 : fKlassName(name), fSuperKlassName(super), fNumInputs(numInputs), fNumOutputs(numOutputs),
00110 fNumActives(0), fNumPassives(0),
00111 fTopLoop(new Loop(0, "count")), fVec(__vec)
00112 {}
00113
00114 virtual ~Klass() {}
00115
00116 void openLoop(const string& size);
00117 void openLoop(Tree recsymbol, const string& size);
00118 void closeLoop(Tree sig=0);
00119
00120 void setLoopProperty(Tree sig, Loop* l);
00121 bool getLoopProperty(Tree sig, Loop*& l);
00122
00123 Loop* topLoop() { return fTopLoop; }
00124
00125 void buildTasksList();
00126
00127 void addIncludeFile (const string& str) { fIncludeFileSet.insert(str); }
00128
00129 void addLibrary (const string& str) { fLibrarySet.insert(str); }
00130
00131 void rememberNeedPowerDef () { fNeedPowerDef = true; }
00132
00133 void collectIncludeFile(set<string>& S);
00134
00135 void collectLibrary(set<string>& S);
00136
00137 void addSubKlass (Klass* son) { fSubClassList.push_back(son); }
00138
00139 void addDeclCode (const string& str) { fDeclCode.push_back(str); }
00140
00141 void addInitCode (const string& str) { fInitCode.push_back(str); }
00142
00143 void addStaticInitCode (const string& str) { fStaticInitCode.push_back(str); }
00144
00145 void addStaticFields (const string& str) { fStaticFields.push_back(str); }
00146
00147 void addUICode (const string& str) { fUICode.push_back(str); }
00148
00149 void addUIMacro (const string& str) { fUIMacro.push_back(str); }
00150
00151 void incUIActiveCount () { fNumActives++; }
00152 void incUIPassiveCount () { fNumPassives++; }
00153
00154
00155 void addSharedDecl (const string& str) { fSharedDecl.push_back(str); }
00156 void addFirstPrivateDecl (const string& str) { fFirstPrivateDecl.push_back(str); }
00157
00158 void addZone1 (const string& str) { fZone1Code.push_back(str); }
00159 void addZone2 (const string& str) { fZone2Code.push_back(str); }
00160 void addZone2b (const string& str) { fZone2bCode.push_back(str); }
00161 void addZone2c (const string& str) { fZone2cCode.push_back(str); }
00162 void addZone3 (const string& str) { fZone3Code.push_back(str); }
00163
00164 void addPreCode ( const string& str) { fTopLoop->addPreCode(str); }
00165 void addExecCode ( const string& str) { fTopLoop->addExecCode(str); }
00166 void addPostCode (const string& str) { fTopLoop->addPostCode(str); }
00167
00168 virtual void println(int n, ostream& fout);
00169
00170 virtual void printComputeMethod (int n, ostream& fout);
00171 virtual void printComputeMethodScalar (int n, ostream& fout);
00172 virtual void printComputeMethodVectorFaster (int n, ostream& fout);
00173 virtual void printComputeMethodVectorSimple (int n, ostream& fout);
00174 virtual void printComputeMethodOpenMP (int n, ostream& fout);
00175 virtual void printComputeMethodScheduler (int n, ostream& fout);
00176
00177 virtual void printLoopGraphScalar(int n, ostream& fout);
00178 virtual void printLoopGraphVector(int n, ostream& fout);
00179 virtual void printLoopGraphOpenMP(int n, ostream& fout);
00180 virtual void printLoopGraphScheduler(int n, ostream& fout);
00181 virtual void printLoopGraphInternal(int n, ostream& fout);
00182 virtual void printGraphDotFormat(ostream& fout);
00183
00184
00185 virtual void printLoopDeepFirst(int n, ostream& fout, Loop* l, set<Loop*>& visited);
00186
00187 virtual void printLastLoopLevelScheduler(int n, int lnum, const lset& L, ostream& fout);
00188 virtual void printLoopLevelScheduler(int n, int lnum, const lset& L, ostream& fout);
00189 virtual void printOneLoopScheduler(lset::const_iterator p, int n, ostream& fout);
00190 virtual void printLoopLevelOpenMP(int n, int lnum, const lset& L, ostream& fout);
00191
00192 virtual void printMetadata(int n, const map<Tree, set<Tree> >& S, ostream& fout);
00193
00194 virtual void printIncludeFile(ostream& fout);
00195
00196 virtual void printLibrary(ostream& fout);
00197 virtual void printAdditionalCode(ostream& fout);
00198
00199 int inputs() { return fNumInputs; }
00200 int outputs() { return fNumOutputs; }
00201 };
00202
00203 class SigIntGenKlass : public Klass {
00204
00205 public:
00206
00207 SigIntGenKlass (const string& name) : Klass(name, "", 0, 1, false) {}
00208
00209 virtual void println(int n, ostream& fout);
00210 };
00211
00212 class SigFloatGenKlass : public Klass {
00213
00214 public:
00215
00216 SigFloatGenKlass (const string& name) : Klass(name, "", 0, 1, false) {}
00217
00218 virtual void println(int n, ostream& fout);
00219 };
00220
00221
00222 #endif