#include <klass.hh>
Inherited by SigFloatGenKlass, and SigIntGenKlass.
Public Member Functions | |
Klass (const string &name, const string &super, int numInputs, int numOutputs, bool __vec=false) | |
virtual | ~Klass () |
void | openLoop (const string &size) |
Open a non-recursive loop on top of the stack of open loops. | |
void | openLoop (Tree recsymbol, const string &size) |
Open a recursive loop on top of the stack of open loops. | |
void | closeLoop (Tree sig=0) |
Close the top loop and either keep it or absorb it within its enclosing loop. | |
void | setLoopProperty (Tree sig, Loop *l) |
Store the loop used to compute a signal. | |
bool | getLoopProperty (Tree sig, Loop *&l) |
Returns the loop used to compute a signal. | |
Loop * | topLoop () |
void | buildTasksList () |
void | addIncludeFile (const string &str) |
void | addLibrary (const string &str) |
void | rememberNeedPowerDef () |
void | collectIncludeFile (set< string > &S) |
void | collectLibrary (set< string > &S) |
void | addSubKlass (Klass *son) |
void | addDeclCode (const string &str) |
void | addInitCode (const string &str) |
void | addStaticInitCode (const string &str) |
void | addStaticFields (const string &str) |
void | addUICode (const string &str) |
void | addUIMacro (const string &str) |
void | incUIActiveCount () |
void | incUIPassiveCount () |
void | addSharedDecl (const string &str) |
void | addFirstPrivateDecl (const string &str) |
void | addZone1 (const string &str) |
void | addZone2 (const string &str) |
void | addZone2b (const string &str) |
void | addZone2c (const string &str) |
void | addZone3 (const string &str) |
void | addPreCode (const string &str) |
void | addExecCode (const string &str) |
void | addPostCode (const string &str) |
virtual void | println (int n, ostream &fout) |
Print a full C++ class corresponding to a Faust dsp. | |
virtual void | printComputeMethod (int n, ostream &fout) |
Print Compute() method according to the various switch. | |
virtual void | printComputeMethodScalar (int n, ostream &fout) |
virtual void | printComputeMethodVectorFaster (int n, ostream &fout) |
Uses loops of constant gVecSize boundary in order to provide the C compiler with more optimisation opportunities. | |
virtual void | printComputeMethodVectorSimple (int n, ostream &fout) |
Simple loop layout, generally less efficient than printComputeMethodVectorFaster. | |
virtual void | printComputeMethodOpenMP (int n, ostream &fout) |
virtual void | printComputeMethodScheduler (int n, ostream &fout) |
virtual void | printLoopGraphScalar (int n, ostream &fout) |
Print the loop graph (scalar mode). | |
virtual void | printLoopGraphVector (int n, ostream &fout) |
Print the loop graph (used for vector code). | |
virtual void | printLoopGraphOpenMP (int n, ostream &fout) |
Print the loop graph as a serie of parallel loops. | |
virtual void | printLoopGraphScheduler (int n, ostream &fout) |
Print the loop graph as a serie of parallel loops. | |
virtual void | printLoopGraphInternal (int n, ostream &fout) |
Print the loop graph (used for internals classes). | |
virtual void | printGraphDotFormat (ostream &fout) |
Print the loop graph in dot format. | |
virtual void | printLoopDeepFirst (int n, ostream &fout, Loop *l, set< Loop * > &visited) |
Print a loop graph deep first. | |
virtual void | printLastLoopLevelScheduler (int n, int lnum, const lset &L, ostream &fout) |
Print the 'level' of the loop graph as a set of parallel loops. | |
virtual void | printLoopLevelScheduler (int n, int lnum, const lset &L, ostream &fout) |
Print the 'level' of the loop graph as a set of parallel loops. | |
virtual void | printOneLoopScheduler (lset::const_iterator p, int n, ostream &fout) |
virtual void | printLoopLevelOpenMP (int n, int lnum, const lset &L, ostream &fout) |
Print the 'level' of the loop graph as a set of parallel loops. | |
virtual void | printMetadata (int n, const map< Tree, set< Tree > > &S, ostream &fout) |
Print metadata declaration. | |
virtual void | printIncludeFile (ostream &fout) |
Print the required include files. | |
virtual void | printLibrary (ostream &fout) |
Print the required C++ libraries as comments in source code. | |
virtual void | printAdditionalCode (ostream &fout) |
Print additional functions required by the generated code. | |
int | inputs () |
int | outputs () |
Protected Attributes | |
string | fKlassName |
string | fSuperKlassName |
int | fNumInputs |
int | fNumOutputs |
int | fNumActives |
number of active controls in the UI (sliders, buttons, etc.) | |
int | fNumPassives |
number of passive widgets in the UI (bargraphs, etc.) | |
set< string > | fIncludeFileSet |
set< string > | fLibrarySet |
list< Klass * > | fSubClassList |
list< string > | fDeclCode |
list< string > | fStaticInitCode |
static init code for class constant tables | |
list< string > | fStaticFields |
static fields after class | |
list< string > | fInitCode |
list< string > | fUICode |
list< string > | fUIMacro |
list< string > | fSharedDecl |
shared declarations | |
list< string > | fFirstPrivateDecl |
first private declarations | |
list< string > | fZone1Code |
shared vectors | |
list< string > | fZone2Code |
first private | |
list< string > | fZone2bCode |
single once per block | |
list< string > | fZone2cCode |
single once per block | |
list< string > | fZone3Code |
private every sub block | |
Loop * | fTopLoop |
active loops currently open | |
property< Loop * > | fLoopProperty |
loops used to compute some signals | |
bool | fVec |
Static Protected Attributes | |
static bool | fNeedPowerDef = false |
true when faustpower definition is needed |
Definition at line 55 of file klass.hh.
Klass::Klass | ( | const string & | name, | |
const string & | super, | |||
int | numInputs, | |||
int | numOutputs, | |||
bool | __vec = false | |||
) | [inline] |
Definition at line 108 of file klass.hh.
00109 : fKlassName(name), fSuperKlassName(super), fNumInputs(numInputs), fNumOutputs(numOutputs), 00110 fNumActives(0), fNumPassives(0), 00111 fTopLoop(new Loop(0, "count")), fVec(__vec) 00112 {}
void Klass::addDeclCode | ( | const string & | str | ) | [inline] |
Definition at line 139 of file klass.hh.
References fDeclCode.
Referenced by buildTasksList(), VectorCompiler::dlineLoop(), SchedulerCompiler::dlineLoop(), ScalarCompiler::ensureIotaCode(), ScalarCompiler::generateButton(), ScalarCompiler::generateCheckbox(), ScalarCompiler::generateDelayLine(), ScalarCompiler::generateDelayVecNoTemp(), ScalarCompiler::generateHBargraph(), ScalarCompiler::generateHSlider(), ScalarCompiler::generateIota(), ScalarCompiler::generateNumEntry(), ScalarCompiler::generatePrefix(), ScalarCompiler::generateStaticTable(), ScalarCompiler::generateTable(), ScalarCompiler::generateVariableStore(), ScalarCompiler::generateVBargraph(), ScalarCompiler::generateVSlider(), and SchedulerCompiler::vectorLoop().
00139 { fDeclCode.push_back(str); }
void Klass::addExecCode | ( | const string & | str | ) | [inline] |
Definition at line 165 of file klass.hh.
References Loop::addExecCode(), and fTopLoop.
Referenced by VectorCompiler::compileMultiSignal(), SchedulerCompiler::compileMultiSignal(), ScalarCompiler::compileMultiSignal(), ScalarCompiler::compileSingleSignal(), VectorCompiler::dlineLoop(), SchedulerCompiler::dlineLoop(), ScalarCompiler::generateDelayLine(), ScalarCompiler::generateDelayVecNoTemp(), ScalarCompiler::generateHBargraph(), ScalarCompiler::generateIota(), ScalarCompiler::generateOutput(), ScalarCompiler::generatePrefix(), ScalarCompiler::generateVariableStore(), ScalarCompiler::generateVBargraph(), ScalarCompiler::generateWRTbl(), VectorCompiler::vectorLoop(), and SchedulerCompiler::vectorLoop().
00165 { fTopLoop->addExecCode(str); }
void Klass::addFirstPrivateDecl | ( | const string & | str | ) | [inline] |
Definition at line 156 of file klass.hh.
References fFirstPrivateDecl.
Referenced by VectorCompiler::dlineLoop(), SchedulerCompiler::dlineLoop(), and ScalarCompiler::generateVariableStore().
00156 { fFirstPrivateDecl.push_back(str); }
void Klass::addIncludeFile | ( | const string & | str | ) | [inline] |
Definition at line 127 of file klass.hh.
References fIncludeFileSet.
Referenced by Compiler::addIncludeFile().
00127 { fIncludeFileSet.insert(str); }
void Klass::addInitCode | ( | const string & | str | ) | [inline] |
Definition at line 141 of file klass.hh.
References fInitCode.
Referenced by buildTasksList(), VectorCompiler::dlineLoop(), SchedulerCompiler::dlineLoop(), ScalarCompiler::ensureIotaCode(), ScalarCompiler::generateButton(), ScalarCompiler::generateCheckbox(), ScalarCompiler::generateDelayLine(), ScalarCompiler::generateDelayVecNoTemp(), ScalarCompiler::generateHBargraph(), ScalarCompiler::generateHSlider(), ScalarCompiler::generateIota(), ScalarCompiler::generateNumEntry(), ScalarCompiler::generatePrefix(), ScalarCompiler::generateSigGen(), ScalarCompiler::generateTable(), ScalarCompiler::generateVariableStore(), ScalarCompiler::generateVBargraph(), and ScalarCompiler::generateVSlider().
00141 { fInitCode.push_back(str); }
void Klass::addLibrary | ( | const string & | str | ) | [inline] |
Definition at line 129 of file klass.hh.
References fLibrarySet.
Referenced by Compiler::addLibrary().
00129 { fLibrarySet.insert(str); }
void Klass::addPostCode | ( | const string & | str | ) | [inline] |
Definition at line 166 of file klass.hh.
References Loop::addPostCode(), and fTopLoop.
Referenced by VectorCompiler::dlineLoop(), SchedulerCompiler::dlineLoop(), ScalarCompiler::ensureIotaCode(), ScalarCompiler::generateDelayLine(), and ScalarCompiler::generateDelayVecNoTemp().
00166 { fTopLoop->addPostCode(str); }
void Klass::addPreCode | ( | const string & | str | ) | [inline] |
Definition at line 164 of file klass.hh.
References Loop::addPreCode(), and fTopLoop.
Referenced by VectorCompiler::dlineLoop(), and SchedulerCompiler::dlineLoop().
00164 { fTopLoop->addPreCode(str); }
void Klass::addSharedDecl | ( | const string & | str | ) | [inline] |
Definition at line 155 of file klass.hh.
References fSharedDecl.
Referenced by VectorCompiler::compileMultiSignal(), SchedulerCompiler::compileMultiSignal(), VectorCompiler::dlineLoop(), SchedulerCompiler::dlineLoop(), VectorCompiler::vectorLoop(), and SchedulerCompiler::vectorLoop().
00155 { fSharedDecl.push_back(str); }
void Klass::addStaticFields | ( | const string & | str | ) | [inline] |
Definition at line 145 of file klass.hh.
References fStaticFields.
Referenced by ScalarCompiler::generateStaticTable().
00145 { fStaticFields.push_back(str); }
void Klass::addStaticInitCode | ( | const string & | str | ) | [inline] |
Definition at line 143 of file klass.hh.
References fStaticInitCode.
Referenced by ScalarCompiler::generateStaticSigGen(), and ScalarCompiler::generateStaticTable().
00143 { fStaticInitCode.push_back(str); }
void Klass::addSubKlass | ( | Klass * | son | ) | [inline] |
Definition at line 137 of file klass.hh.
References fSubClassList.
Referenced by ScalarCompiler::generateSigGen(), and ScalarCompiler::generateStaticSigGen().
00137 { fSubClassList.push_back(son); }
void Klass::addUICode | ( | const string & | str | ) | [inline] |
Definition at line 147 of file klass.hh.
References fUICode.
Referenced by Compiler::generateUserInterfaceTree(), and Compiler::generateWidgetCode().
00147 { fUICode.push_back(str); }
void Klass::addUIMacro | ( | const string & | str | ) | [inline] |
Definition at line 149 of file klass.hh.
References fUIMacro.
Referenced by Compiler::generateWidgetMacro().
00149 { fUIMacro.push_back(str); }
void Klass::addZone1 | ( | const string & | str | ) | [inline] |
Definition at line 158 of file klass.hh.
References fZone1Code.
Referenced by VectorCompiler::dlineLoop(), and VectorCompiler::vectorLoop().
00158 { fZone1Code.push_back(str); }
void Klass::addZone2 | ( | const string & | str | ) | [inline] |
Definition at line 159 of file klass.hh.
References fZone2Code.
Referenced by VectorCompiler::dlineLoop(), SchedulerCompiler::dlineLoop(), ScalarCompiler::generateHBargraph(), ScalarCompiler::generateVariableStore(), and ScalarCompiler::generateVBargraph().
00159 { fZone2Code.push_back(str); }
void Klass::addZone2b | ( | const string & | str | ) | [inline] |
Definition at line 160 of file klass.hh.
References fZone2bCode.
00160 { fZone2bCode.push_back(str); }
void Klass::addZone2c | ( | const string & | str | ) | [inline] |
Definition at line 161 of file klass.hh.
References fZone2cCode.
Referenced by buildTasksList().
00161 { fZone2cCode.push_back(str); }
void Klass::addZone3 | ( | const string & | str | ) | [inline] |
Definition at line 162 of file klass.hh.
References fZone3Code.
Referenced by buildTasksList(), VectorCompiler::compileMultiSignal(), SchedulerCompiler::compileMultiSignal(), and ScalarCompiler::compileMultiSignal().
00162 { fZone3Code.push_back(str); }
void Klass::buildTasksList | ( | ) |
Definition at line 313 of file klass.cpp.
References addDeclCode(), addInitCode(), addZone2c(), addZone3(), computeUseCount(), Loop::fIndex, fTopLoop, gGroupTaskSwitch, groupSeqLoops(), gTaskCount, LAST_TASK_INDEX, sortGraph(), START_TASK_INDEX, START_TASK_MAX, subst(), and T().
Referenced by SchedulerCompiler::compileMultiSignal().
00314 { 00315 lgraph G; 00316 00317 if (gGroupTaskSwitch) { 00318 computeUseCount(fTopLoop); 00319 groupSeqLoops(fTopLoop); 00320 } 00321 00322 sortGraph(fTopLoop, G); 00323 int index_task = START_TASK_INDEX; 00324 00325 addDeclCode("TaskGraph fGraph;"); 00326 addDeclCode("FAUSTFLOAT** input;"); 00327 addDeclCode("FAUSTFLOAT** output;"); 00328 addDeclCode("volatile bool fIsFinished;"); 00329 addDeclCode("int fFullCount;"); 00330 addDeclCode("int fIndex;"); 00331 addDeclCode("DSPThreadPool* fThreadPool;"); 00332 addDeclCode("int fStaticNumThreads;"); 00333 addDeclCode("int fDynamicNumThreads;"); 00334 00335 // Compute forward dependencies 00336 for (int l=G.size()-1; l>=0; l--) { 00337 for (lset::const_iterator p =G[l].begin(); p!=G[l].end(); p++) { 00338 for (lset::const_iterator p1 = (*p)->fBackwardLoopDependencies.begin(); p1!=(*p)->fBackwardLoopDependencies.end(); p1++) { 00339 (*p1)->fForwardLoopDependencies.insert((*p)); 00340 } 00341 (*p)->fIndex = index_task; 00342 index_task++; 00343 } 00344 } 00345 00346 // Compute ready tasks list 00347 vector<int> task_num; 00348 for (int l=G.size()-1; l>=0; l--) { 00349 lset::const_iterator next; 00350 for (lset::const_iterator p =G[l].begin(); p!=G[l].end(); p++) { 00351 if ((*p)->fBackwardLoopDependencies.size() == 0) { 00352 task_num.push_back((*p)->fIndex); 00353 } 00354 } 00355 } 00356 00357 if (task_num.size() < START_TASK_MAX) { 00358 00359 // Push ready tasks thread 0, execute one task directly 00360 00361 addZone3("if (cur_thread == 0) {"); 00362 00363 Loop* keep = NULL; 00364 for (int l=G.size()-1; l>=0; l--) { 00365 lset::const_iterator next; 00366 for (lset::const_iterator p =G[l].begin(); p!=G[l].end(); p++) { 00367 if ((*p)->fBackwardLoopDependencies.size() == 0) { 00368 if (keep == NULL) { 00369 keep = *p; 00370 } else { 00371 addZone3(subst(" taskqueue.PushHead($0);", T((*p)->fIndex))); 00372 } 00373 } 00374 } 00375 } 00376 00377 if (keep != NULL) { 00378 addZone3(subst(" tasknum = $0;", T(keep->fIndex))); 00379 } 00380 00381 addZone3("} else {"); 00382 addZone3(" tasknum = TaskQueue::GetNextTask(cur_thread, fDynamicNumThreads);"); 00383 addZone3("}"); 00384 00385 } else { 00386 00387 // Cut ready tasks list and have each thread (dynamically) use a subpart 00388 addZone3(subst("int task_list_size = $0;", T((int)task_num.size()))); 00389 stringstream buf; 00390 buf << "int task_list[" << task_num.size() << "] = {"; 00391 for(size_t i = 0; i < task_num.size(); i++) { 00392 buf << task_num[i]; 00393 if (i != (task_num.size() - 1)) 00394 buf << ","; 00395 } 00396 buf << "};"; 00397 00398 addZone3(buf.str()); 00399 addZone3("taskqueue.InitTaskList(task_list_size, task_list, fDynamicNumThreads, cur_thread, tasknum);"); 00400 } 00401 00402 // Last stage connected to end task 00403 if (G[0].size() > 1) { 00404 addZone2c("// Initialize end task, if more than one input"); 00405 addZone2c(subst("fGraph.InitTask($0,$1);", T(LAST_TASK_INDEX), T((int)G[0].size()))); 00406 } else { 00407 addZone2c("// End task has only one input, so will be directly activated"); 00408 } 00409 00410 // Compute init section 00411 addZone2c("// Only initialize taks with more than one input"); 00412 for (int l=G.size()-1; l>=0; l--) { 00413 for (lset::const_iterator p =G[l].begin(); p!=G[l].end(); p++) { 00414 if ((*p)->fBackwardLoopDependencies.size() > 1) { // Only initialize taks with more than 1 input, since taks with one input are "directly" activated. 00415 addZone2c(subst("fGraph.InitTask($0,$1);", T(START_TASK_INDEX + gTaskCount++), T((int)(*p)->fBackwardLoopDependencies.size()))); 00416 } else { 00417 gTaskCount++; 00418 } 00419 } 00420 } 00421 00422 addInitCode("fStaticNumThreads = get_max_cpu();"); 00423 addInitCode("fDynamicNumThreads = getenv(\"OMP_NUM_THREADS\") ? atoi(getenv(\"OMP_NUM_THREADS\")) : fStaticNumThreads;"); 00424 addInitCode("fThreadPool = DSPThreadPool::Init();"); 00425 addInitCode("fThreadPool->StartAll(fStaticNumThreads - 1, false);"); 00426 00427 gTaskCount = 0; 00428 }
void Klass::closeLoop | ( | Tree | sig = 0 |
) |
Close the top loop and either keep it or absorb it within its enclosing loop.
Definition at line 113 of file klass.cpp.
References Loop::absorb(), Loop::fBackwardLoopDependencies, Loop::fEnclosingLoop, fTopLoop, Loop::hasRecDependencies(), Loop::isEmpty(), and setLoopProperty().
Referenced by VectorCompiler::compileMultiSignal(), SchedulerCompiler::compileMultiSignal(), and VectorCompiler::generateCode().
00114 { 00115 assert(fTopLoop); 00116 Loop* l = fTopLoop; 00117 fTopLoop = l->fEnclosingLoop; 00118 assert(fTopLoop); 00119 //cerr << "close loop :" << l << endl; 00120 00121 if (l->isEmpty() || l->hasRecDependencies()) { 00122 // empty or dependent loop -> absorbed by enclosing one 00123 //cerr << "absorbtion : " << fTopLoop << "----absorb----> " << l << endl; 00124 fTopLoop->absorb(l); 00125 delete l; 00126 } else { 00127 // we have an independent loop 00128 if (sig) { 00129 setLoopProperty(sig,l); // associate the signal 00130 //cerr << "setLoopProperty : "<< ppsig(sig) << "----loop prop---> "<< l << endl; 00131 } else { 00132 //cerr << "***ETRANGE**** no signal for loop "<< l << endl; 00133 } 00134 //cerr << "backward dependency added : " << fTopLoop << "----depends on----> " << l << endl; 00135 fTopLoop->fBackwardLoopDependencies.insert(l); 00136 } 00137 }
void Klass::collectIncludeFile | ( | set< string > & | S | ) |
Definition at line 1185 of file klass.cpp.
References fIncludeFileSet, fSubClassList, and merge().
Referenced by printIncludeFile().
01186 { 01187 list<Klass* >::iterator k; 01188 01189 for (k = fSubClassList.begin(); k != fSubClassList.end(); k++) (*k)->collectIncludeFile(S); 01190 merge(S, fIncludeFileSet); 01191 }
void Klass::collectLibrary | ( | set< string > & | S | ) |
Definition at line 1193 of file klass.cpp.
References fLibrarySet, fSubClassList, and merge().
Referenced by printLibrary().
01194 { 01195 list<Klass* >::iterator k; 01196 01197 for (k = fSubClassList.begin(); k != fSubClassList.end(); k++) (*k)->collectLibrary(S); 01198 merge(S, fLibrarySet); 01199 }
Returns the loop used to compute a signal.
Definition at line 83 of file klass.cpp.
References fLoopProperty.
Referenced by VectorCompiler::CS().
00084 { 00085 return fLoopProperty.get(sig, l); 00086 }
void Klass::incUIActiveCount | ( | ) | [inline] |
Definition at line 151 of file klass.hh.
References fNumActives.
Referenced by Compiler::generateWidgetCode().
00151 { fNumActives++; }
void Klass::incUIPassiveCount | ( | ) | [inline] |
Definition at line 152 of file klass.hh.
References fNumPassives.
Referenced by Compiler::generateWidgetCode().
00152 { fNumPassives++; }
int Klass::inputs | ( | ) | [inline] |
Definition at line 199 of file klass.hh.
References fNumInputs.
Referenced by VectorCompiler::compileMultiSignal(), SchedulerCompiler::compileMultiSignal(), ScalarCompiler::compileMultiSignal(), and main().
00199 { return fNumInputs; }
void Klass::openLoop | ( | Tree | recsymbol, | |
const string & | size | |||
) |
void Klass::openLoop | ( | const string & | size | ) |
Open a non-recursive loop on top of the stack of open loops.
size | the number of iterations of the loop |
Definition at line 92 of file klass.cpp.
References fTopLoop.
Referenced by VectorCompiler::compileMultiSignal(), SchedulerCompiler::compileMultiSignal(), and VectorCompiler::generateCode().
00093 { 00094 fTopLoop = new Loop(fTopLoop, size); 00095 //cerr << "openLoop(" << size << ") ----> " << fTopLoop << endl; 00096 }
int Klass::outputs | ( | ) | [inline] |
Definition at line 200 of file klass.hh.
References fNumOutputs.
Referenced by VectorCompiler::compileMultiSignal(), SchedulerCompiler::compileMultiSignal(), ScalarCompiler::compileMultiSignal(), and main().
00200 { return fNumOutputs; }
void Klass::printAdditionalCode | ( | ostream & | fout | ) | [virtual] |
Print additional functions required by the generated code.
Definition at line 206 of file klass.cpp.
References fNeedPowerDef.
Referenced by main().
00207 { 00208 if (fNeedPowerDef) { 00209 // Add faustpower definition to C++ code 00210 fout << "#include <cmath>" << endl; 00211 fout << "template <int N> inline float faustpower(float x) { return powf(x,N); } " << endl; 00212 fout << "template <int N> inline double faustpower(double x) { return pow(x,N); }" << endl; 00213 fout << "template <int N> inline int faustpower(int x) { return faustpower<N/2>(x) * faustpower<N-N/2>(x); } " << endl; 00214 fout << "template <> inline int faustpower<0>(int x) { return 1; }" << endl; 00215 fout << "template <> inline int faustpower<1>(int x) { return x; }" << endl; 00216 } 00217 00218 }
void Klass::printComputeMethod | ( | int | n, | |
ostream & | fout | |||
) | [virtual] |
Print Compute() method according to the various switch.
Definition at line 797 of file klass.cpp.
References gOpenMPSwitch, gSchedulerSwitch, gVectorLoopVariant, gVectorSwitch, printComputeMethodOpenMP(), printComputeMethodScalar(), printComputeMethodScheduler(), printComputeMethodVectorFaster(), and printComputeMethodVectorSimple().
Referenced by println().
00798 { 00799 if (gSchedulerSwitch) { 00800 printComputeMethodScheduler (n, fout); 00801 } else if (gOpenMPSwitch) { 00802 printComputeMethodOpenMP (n, fout); 00803 } else if (gVectorSwitch) { 00804 switch (gVectorLoopVariant) { 00805 case 0 : printComputeMethodVectorFaster(n, fout); break; 00806 case 1 : printComputeMethodVectorSimple(n, fout); break; 00807 default : cerr << "unknown loop variant " << gVectorLoopVariant << endl; exit(1); 00808 } 00809 } else { 00810 printComputeMethodScalar(n, fout); 00811 } 00812 }
void Klass::printComputeMethodOpenMP | ( | int | n, | |
ostream & | fout | |||
) | [virtual] |
Definition at line 930 of file klass.cpp.
References fFirstPrivateDecl, fZone1Code, fZone2bCode, fZone2Code, fZone3Code, gVecSize, printdecllist(), printlines(), printLoopGraphOpenMP(), subst(), tab(), and xfloat().
Referenced by printComputeMethod().
00931 { 00932 // in openMP mode we need to split loops in smaller pieces not larger 00933 // than gVecSize and add OpenMP pragmas 00934 tab(n+1,fout); fout << subst("virtual void compute (int fullcount, $0** input, $0** output) {", xfloat()); 00935 printlines(n+2, fZone1Code, fout); 00936 printlines(n+2, fZone2Code, fout); 00937 tab(n+2,fout); fout << "#pragma omp parallel"; 00938 printdecllist(n+3, "firstprivate", fFirstPrivateDecl, fout); 00939 00940 tab(n+2,fout); fout << "{"; 00941 if (!fZone2bCode.empty()) { 00942 tab(n+3,fout); fout << "#pragma omp single"; 00943 tab(n+3,fout); fout << "{"; 00944 printlines(n+4, fZone2bCode, fout); 00945 tab(n+3,fout); fout << "}"; 00946 } 00947 00948 tab(n+3,fout); fout << "for (int index = 0; index < fullcount; index += " << gVecSize << ") {"; 00949 tab(n+4,fout); fout << "int count = min ("<< gVecSize << ", fullcount-index);"; 00950 00951 printlines (n+4, fZone3Code, fout); 00952 printLoopGraphOpenMP (n+4,fout); 00953 00954 tab(n+3,fout); fout << "}"; 00955 00956 tab(n+2,fout); fout << "}"; 00957 tab(n+1,fout); fout << "}"; 00958 }
void Klass::printComputeMethodScalar | ( | int | n, | |
ostream & | fout | |||
) | [virtual] |
Definition at line 814 of file klass.cpp.
References fZone1Code, fZone2bCode, fZone2Code, fZone3Code, printlines(), printLoopGraphScalar(), subst(), tab(), and xfloat().
Referenced by printComputeMethod().
00815 { 00816 tab(n+1,fout); fout << subst("virtual void compute (int count, $0** input, $0** output) {", xfloat()); 00817 printlines (n+2, fZone1Code, fout); 00818 printlines (n+2, fZone2Code, fout); 00819 printlines (n+2, fZone2bCode, fout); 00820 printlines (n+2, fZone3Code, fout); 00821 printLoopGraphScalar (n+2,fout); 00822 tab(n+1,fout); fout << "}"; 00823 }
void Klass::printComputeMethodScheduler | ( | int | n, | |
ostream & | fout | |||
) | [virtual] |
Definition at line 1029 of file klass.cpp.
References fZone1Code, fZone2cCode, fZone2Code, fZone3Code, gTaskCount, gVecSize, printlines(), printLoopGraphScheduler(), START_TASK_INDEX, subst(), tab(), and xfloat().
Referenced by printComputeMethod().
01030 { 01031 tab(n+1,fout); fout << "void display() {"; 01032 tab(n+2,fout); fout << "fGraph.Display();"; 01033 tab(n+1,fout); fout << "}"; 01034 01035 tab(n+1,fout); fout << subst("virtual void compute (int fullcount, $0** input, $0** output) {", xfloat()); 01036 01037 tab(n+2,fout); fout << "GetRealTime();"; 01038 01039 tab(n+2,fout); fout << "this->input = input;"; 01040 tab(n+2,fout); fout << "this->output = output;"; 01041 01042 tab(n+2,fout); fout << "StartMeasure();"; 01043 01044 tab(n+2,fout); fout << "for (fIndex = 0; fIndex < fullcount; fIndex += " << gVecSize << ") {"; 01045 01046 tab(n+3,fout); fout << "fFullCount = min ("<< gVecSize << ", fullcount-fIndex);"; 01047 tab(n+3,fout); fout << "TaskQueue::Init();"; 01048 printlines (n+3, fZone2cCode, fout); 01049 01050 tab(n+3,fout); fout << "fIsFinished = false;"; 01051 tab(n+3,fout); fout << "fThreadPool->SignalAll(fDynamicNumThreads - 1, this);"; 01052 tab(n+3,fout); fout << "computeThread(0);"; 01053 tab(n+3,fout); fout << "while (!fThreadPool->IsFinished()) {}"; 01054 01055 tab(n+2,fout); fout << "}"; 01056 01057 tab(n+2,fout); fout << "StopMeasure(fStaticNumThreads, fDynamicNumThreads);"; 01058 01059 tab(n+1,fout); fout << "}"; 01060 01061 tab(n+1,fout); fout << "void computeThread(int cur_thread) {"; 01062 printlines (n+2, fZone1Code, fout); 01063 printlines (n+2, fZone2Code, fout); 01064 01065 tab(n+2,fout); fout << "// Init graph state"; 01066 01067 tab(n+2,fout); fout << "{"; 01068 tab(n+3,fout); fout << "TaskQueue taskqueue(cur_thread);"; 01069 tab(n+3,fout); fout << "int tasknum = -1;"; 01070 tab(n+3,fout); fout << "int count = fFullCount;"; 01071 01072 // Init input and output 01073 tab(n+3,fout); fout << "// Init input and output"; 01074 printlines (n+3, fZone3Code, fout); 01075 01076 tab(n+3,fout); fout << "while (!fIsFinished) {"; 01077 tab(n+4,fout); fout << "switch (tasknum) {"; 01078 01079 // Work stealing task 01080 tab(n+5, fout); fout << "case WORK_STEALING_INDEX: { "; 01081 tab(n+6, fout); fout << "tasknum = TaskQueue::GetNextTask(cur_thread, fDynamicNumThreads);"; 01082 tab(n+6, fout); fout << "break;"; 01083 tab(n+5, fout); fout << "} "; 01084 01085 // End task 01086 tab(n+5, fout); fout << "case LAST_TASK_INDEX: { "; 01087 tab(n+6, fout); fout << "fIsFinished = true;"; 01088 tab(n+6, fout); fout << "break;"; 01089 tab(n+5, fout); fout << "} "; 01090 01091 gTaskCount = START_TASK_INDEX ; 01092 01093 // DSP tasks 01094 printLoopGraphScheduler (n+5,fout); 01095 01096 tab(n+4,fout); fout << "}"; 01097 tab(n+3,fout); fout << "}"; 01098 tab(n+2,fout); fout << "}"; 01099 tab(n+1,fout); fout << "}"; 01100 }
void Klass::printComputeMethodVectorFaster | ( | int | n, | |
ostream & | fout | |||
) | [virtual] |
Uses loops of constant gVecSize boundary in order to provide the C compiler with more optimisation opportunities.
Improves performances in general, but not always
Definition at line 830 of file klass.cpp.
References fZone1Code, fZone2bCode, fZone2Code, fZone3Code, gVecSize, printlines(), printLoopGraphVector(), subst(), tab(), and xfloat().
Referenced by printComputeMethod().
00831 { 00832 // in vector mode we need to split loops in smaller pieces not larger 00833 // than gVecSize 00834 tab(n+1,fout); fout << subst("virtual void compute (int fullcount, $0** input, $0** output) {", xfloat()); 00835 printlines(n+2, fZone1Code, fout); 00836 printlines(n+2, fZone2Code, fout); 00837 printlines(n+2, fZone2bCode, fout); 00838 00839 tab(n+2,fout); fout << "int index;"; 00840 tab(n+2,fout); fout << "for (index = 0; index <= fullcount - " << gVecSize << "; index += " << gVecSize << ") {"; 00841 tab(n+3,fout); fout << "// compute by blocks of " << gVecSize << " samples"; 00842 tab(n+3,fout); fout << "const int count = " << gVecSize << ";"; 00843 printlines (n+3, fZone3Code, fout); 00844 printLoopGraphVector(n+3,fout); 00845 tab(n+2,fout); fout << "}"; 00846 00847 tab(n+2,fout); fout << "if (index < fullcount) {"; 00848 tab(n+3,fout); fout << "// compute the remaining samples if any"; 00849 tab(n+3,fout); fout << "int count = fullcount-index;"; 00850 printlines (n+3, fZone3Code, fout); 00851 printLoopGraphVector(n+3,fout); 00852 tab(n+2,fout); fout << "}"; 00853 tab(n+1,fout); fout << "}"; 00854 }
void Klass::printComputeMethodVectorSimple | ( | int | n, | |
ostream & | fout | |||
) | [virtual] |
Simple loop layout, generally less efficient than printComputeMethodVectorFaster.
Definition at line 859 of file klass.cpp.
References fZone1Code, fZone2bCode, fZone2Code, fZone3Code, gVecSize, printlines(), printLoopGraphVector(), subst(), tab(), and xfloat().
Referenced by printComputeMethod().
00860 { 00861 // in vector mode we need to split loops in smaller pieces not larger 00862 // than gVecSize 00863 tab(n+1,fout); fout << subst("virtual void compute (int fullcount, $0** input, $0** output) {", xfloat()); 00864 printlines(n+2, fZone1Code, fout); 00865 printlines(n+2, fZone2Code, fout); 00866 printlines(n+2, fZone2bCode, fout); 00867 tab(n+2,fout); fout << "for (int index = 0; index < fullcount; index += " << gVecSize << ") {"; 00868 tab(n+3,fout); fout << "int count = min("<< gVecSize << ", fullcount-index);"; 00869 printlines (n+3, fZone3Code, fout); 00870 printLoopGraphVector(n+3,fout); 00871 tab(n+2,fout); fout << "}"; 00872 tab(n+1,fout); fout << "}"; 00873 }
void Klass::printGraphDotFormat | ( | ostream & | fout | ) | [virtual] |
Print the loop graph in dot format.
Definition at line 507 of file klass.cpp.
References fTopLoop, and sortGraph().
Referenced by main().
00508 { 00509 lgraph G; 00510 sortGraph(fTopLoop, G); 00511 00512 fout << "strict digraph loopgraph {" << endl; 00513 fout << '\t' << "rankdir=LR;" << endl; 00514 fout << '\t' << "node[color=blue, fillcolor=lightblue, style=filled, fontsize=9];" << endl; 00515 00516 int lnum = 0; // used for loop numbers 00517 // for each level of the graph 00518 for (int l=G.size()-1; l>=0; l--) { 00519 // for each task in the level 00520 for (lset::const_iterator t =G[l].begin(); t!=G[l].end(); t++) { 00521 // print task label "Lxxx : 0xffffff" 00522 fout << '\t' << 'L'<<(*t)<<"[label=<<font face=\"verdana,bold\">L"<<lnum++<<"</font> : "<<(*t)<<">];"<<endl; 00523 // for each source of the task 00524 for (lset::const_iterator src = (*t)->fBackwardLoopDependencies.begin(); src!=(*t)->fBackwardLoopDependencies.end(); src++) { 00525 // print the connection Lxxx -> Lyyy; 00526 fout << '\t' << 'L'<<(*src)<<"->"<<'L'<<(*t)<<';'<<endl; 00527 } 00528 } 00529 } 00530 fout << "}" << endl; 00531 }
void Klass::printIncludeFile | ( | ostream & | fout | ) | [virtual] |
Print the required include files.
Definition at line 188 of file klass.cpp.
References collectIncludeFile(), and gOpenMPSwitch.
Referenced by main().
00189 { 00190 set<string> S; 00191 set<string>::iterator f; 00192 00193 if (gOpenMPSwitch) { 00194 fout << "#include <omp.h>" << "\n"; 00195 } 00196 00197 collectIncludeFile(S); 00198 for (f = S.begin(); f != S.end(); f++) { 00199 fout << "#include " << *f << "\n"; 00200 } 00201 }
void Klass::printLastLoopLevelScheduler | ( | int | n, | |
int | lnum, | |||
const lset & | L, | |||
ostream & | fout | |||
) | [virtual] |
Print the 'level' of the loop graph as a set of parallel loops.
Definition at line 609 of file klass.cpp.
References gTaskCount, nonRecursiveLevel(), and tab().
Referenced by printLoopGraphScheduler().
00610 { 00611 if (nonRecursiveLevel(L) && L.size() == 1 && !(*L.begin())->isEmpty()) { 00612 00613 lset::const_iterator p =L.begin(); 00614 tab(n, fout); fout << "case " << gTaskCount++ << ": { "; 00615 (*p)->println(n+1, fout); 00616 tab(n+1, fout); fout << "tasknum = LAST_TASK_INDEX;"; 00617 tab(n+1, fout); fout << "break;"; 00618 tab(n, fout); fout << "} "; 00619 00620 } else if (L.size() > 1) { 00621 00622 for (lset::const_iterator p =L.begin(); p!=L.end(); p++) { 00623 tab(n, fout); fout << "case " << gTaskCount++ << ": { "; 00624 (*p)->println(n+1, fout); 00625 tab(n+1, fout); fout << "fGraph.ActivateOneOutputTask(taskqueue, LAST_TASK_INDEX, tasknum);"; 00626 tab(n+1, fout); fout << "break;"; 00627 tab(n, fout); fout << "} "; 00628 } 00629 00630 } else if (L.size() == 1 && !(*L.begin())->isEmpty()) { 00631 00632 lset::const_iterator p =L.begin(); 00633 tab(n, fout); fout << "case " << gTaskCount++ << ": { "; 00634 (*p)->println(n+1, fout); 00635 tab(n+1, fout); fout << "tasknum = LAST_TASK_INDEX;"; 00636 tab(n+1, fout); fout << "break;"; 00637 tab(n, fout); fout << "} "; 00638 00639 } 00640 }
void Klass::printLibrary | ( | ostream & | fout | ) | [virtual] |
Print the required C++ libraries as comments in source code.
Definition at line 171 of file klass.cpp.
References collectLibrary().
Referenced by main().
00172 { 00173 set<string> S; 00174 set<string>::iterator f; 00175 00176 string sep; 00177 collectLibrary(S); 00178 fout << "/* link with "; 00179 for (f = S.begin(), sep =": "; f != S.end(); f++, sep = ", ") { 00180 fout << sep << *f; 00181 } 00182 fout << " */\n"; 00183 }
void Klass::println | ( | int | n, | |
ostream & | fout | |||
) | [virtual] |
Print a full C++ class corresponding to a Faust dsp.
Reimplemented in SigIntGenKlass, and SigFloatGenKlass.
Definition at line 718 of file klass.cpp.
References fDeclCode, fInitCode, fKlassName, fNumActives, fNumInputs, fNumOutputs, fNumPassives, fStaticFields, fStaticInitCode, fSubClassList, fSuperKlassName, fUICode, fUIMacro, gMetaDataSet, gSchedulerSwitch, gUIMacroSwitch, printComputeMethod(), printlines(), printMetadata(), and tab().
Referenced by main().
00719 { 00720 list<Klass* >::iterator k; 00721 00722 if (gSchedulerSwitch) { 00723 tab(n,fout); fout << "class " << fKlassName << " : public " << fSuperKlassName << ", public Runnable {"; 00724 } else { 00725 tab(n,fout); fout << "class " << fKlassName << " : public " << fSuperKlassName << "{"; 00726 } 00727 00728 if (gUIMacroSwitch) { 00729 tab(n,fout); fout << " public:"; 00730 } else { 00731 tab(n,fout); fout << " private:"; 00732 } 00733 00734 for (k = fSubClassList.begin(); k != fSubClassList.end(); k++) (*k)->println(n+1, fout); 00735 00736 printlines(n+1, fDeclCode, fout); 00737 00738 tab(n,fout); fout << " public:"; 00739 00740 printMetadata(n+1, gMetaDataSet, fout); 00741 00742 if (gSchedulerSwitch) { 00743 tab(n+1,fout); fout << "virtual ~mydsp() \t{ " 00744 << "DSPThreadPool::Destroy()" 00745 << "; }"; 00746 } 00747 00748 tab(n+1,fout); fout << "virtual int getNumInputs() \t{ " 00749 << "return " << fNumInputs 00750 << "; }"; 00751 tab(n+1,fout); fout << "virtual int getNumOutputs() \t{ " 00752 << "return " << fNumOutputs 00753 << "; }"; 00754 00755 tab(n+1,fout); fout << "static void classInit(int samplingFreq) {"; 00756 printlines (n+2, fStaticInitCode, fout); 00757 tab(n+1,fout); fout << "}"; 00758 00759 tab(n+1,fout); fout << "virtual void instanceInit(int samplingFreq) {"; 00760 tab(n+2,fout); fout << "fSamplingFreq = samplingFreq;"; 00761 printlines (n+2, fInitCode, fout); 00762 tab(n+1,fout); fout << "}"; 00763 00764 tab(n+1,fout); fout << "virtual void init(int samplingFreq) {"; 00765 tab(n+2,fout); fout << "classInit(samplingFreq);"; 00766 tab(n+2,fout); fout << "instanceInit(samplingFreq);"; 00767 tab(n+1,fout); fout << "}"; 00768 00769 00770 tab(n+1,fout); fout << "virtual void buildUserInterface(UI* interface) {"; 00771 printlines (n+2, fUICode, fout); 00772 tab(n+1,fout); fout << "}"; 00773 00774 printComputeMethod(n, fout); 00775 00776 tab(n,fout); fout << "};\n" << endl; 00777 00778 printlines(n, fStaticFields, fout); 00779 00780 // generate user interface macros if needed 00781 if (gUIMacroSwitch) { 00782 tab(n, fout); fout << "#ifdef FAUST_UIMACROS"; 00783 tab(n+1,fout); fout << "#define FAUST_INPUTS " << fNumInputs; 00784 tab(n+1,fout); fout << "#define FAUST_OUTPUTS " << fNumOutputs; 00785 tab(n+1,fout); fout << "#define FAUST_ACTIVES " << fNumActives; 00786 tab(n+1,fout); fout << "#define FAUST_PASSIVES " << fNumPassives; 00787 printlines(n+1, fUIMacro, fout); 00788 tab(n, fout); fout << "#endif"; 00789 } 00790 00791 fout << endl; 00792 }
void Klass::printLoopDeepFirst | ( | int | n, | |
ostream & | fout, | |||
Loop * | l, | |||
set< Loop * > & | visited | |||
) | [virtual] |
Print a loop graph deep first.
Definition at line 252 of file klass.cpp.
References Loop::fBackwardLoopDependencies, Loop::fOrder, isElement(), Loop::println(), and tab().
Referenced by printLoopGraphVector().
00253 { 00254 // avoid printing already printed loops 00255 if (isElement(visited, l)) return; 00256 00257 // remember we have printed this loop 00258 visited.insert(l); 00259 00260 // print the dependencies loops (that need to be computed before this one) 00261 for (lset::const_iterator p =l->fBackwardLoopDependencies.begin(); p!=l->fBackwardLoopDependencies.end(); p++) { 00262 printLoopDeepFirst(n, fout, *p, visited); 00263 } 00264 // the print the loop itself 00265 tab(n, fout); 00266 tab(n, fout); fout << "// LOOP " << l << ", ORDER " << l->fOrder << endl; 00267 l->println(n+1, fout); 00268 }
void Klass::printLoopGraphInternal | ( | int | n, | |
ostream & | fout | |||
) | [virtual] |
Print the loop graph (used for internals classes).
Definition at line 536 of file klass.cpp.
References fTopLoop, gVectorSwitch, sortGraph(), and tab().
Referenced by SigFloatGenKlass::println(), and SigIntGenKlass::println().
00537 { 00538 lgraph G; 00539 sortGraph(fTopLoop, G); 00540 00541 // normal mode 00542 for (int l=G.size()-1; l>=0; l--) { 00543 if (gVectorSwitch) { tab(n, fout); fout << "// SECTION : " << G.size() - l; } 00544 for (lset::const_iterator p =G[l].begin(); p!=G[l].end(); p++) { 00545 (*p)->printoneln(n, fout); 00546 } 00547 } 00548 }
void Klass::printLoopGraphOpenMP | ( | int | n, | |
ostream & | fout | |||
) | [virtual] |
Print the loop graph as a serie of parallel loops.
Definition at line 464 of file klass.cpp.
References computeUseCount(), fTopLoop, gGroupTaskSwitch, groupSeqLoops(), printLoopLevelOpenMP(), sortGraph(), and tab().
Referenced by printComputeMethodOpenMP().
00465 { 00466 if (gGroupTaskSwitch) { 00467 computeUseCount(fTopLoop); 00468 groupSeqLoops(fTopLoop); 00469 } 00470 00471 lgraph G; 00472 sortGraph(fTopLoop, G); 00473 00474 // OpenMP mode : add OpenMP directives 00475 for (int l=G.size()-1; l>=0; l--) { 00476 tab(n, fout); fout << "// SECTION : " << G.size() - l; 00477 printLoopLevelOpenMP(n, G.size() - l, G[l], fout); 00478 } 00479 }
void Klass::printLoopGraphScalar | ( | int | n, | |
ostream & | fout | |||
) | [virtual] |
Print the loop graph (scalar mode).
Definition at line 553 of file klass.cpp.
References fTopLoop, and Loop::printoneln().
Referenced by printComputeMethodScalar().
00554 { 00555 fTopLoop->printoneln(n, fout); 00556 }
void Klass::printLoopGraphScheduler | ( | int | n, | |
ostream & | fout | |||
) | [virtual] |
Print the loop graph as a serie of parallel loops.
Definition at line 484 of file klass.cpp.
References computeUseCount(), fTopLoop, gGroupTaskSwitch, groupSeqLoops(), printLastLoopLevelScheduler(), printLoopLevelScheduler(), sortGraph(), and tab().
Referenced by printComputeMethodScheduler().
00485 { 00486 if (gGroupTaskSwitch) { 00487 computeUseCount(fTopLoop); 00488 groupSeqLoops(fTopLoop); 00489 } 00490 00491 lgraph G; 00492 sortGraph(fTopLoop, G); 00493 00494 // OpenMP mode : add OpenMP directives 00495 for (int l=G.size()-1; l>0; l--) { 00496 tab(n, fout); fout << "// SECTION : " << G.size() - l; 00497 printLoopLevelScheduler(n, G.size() - l, G[l], fout); 00498 } 00499 00500 printLastLoopLevelScheduler(n, G.size(), G[0], fout); 00501 }
void Klass::printLoopGraphVector | ( | int | n, | |
ostream & | fout | |||
) | [virtual] |
Print the loop graph (used for vector code).
Definition at line 433 of file klass.cpp.
References computeUseCount(), fTopLoop, gDeepFirstSwitch, gGroupTaskSwitch, groupSeqLoops(), gVectorSwitch, printLoopDeepFirst(), sortGraph(), and tab().
Referenced by printComputeMethodVectorFaster(), and printComputeMethodVectorSimple().
00434 { 00435 if (gGroupTaskSwitch) { 00436 computeUseCount(fTopLoop); 00437 groupSeqLoops(fTopLoop); 00438 } 00439 00440 lgraph G; 00441 sortGraph(fTopLoop, G); 00442 00443 #if 1 00444 // EXPERIMENTAL 00445 if (gVectorSwitch && gDeepFirstSwitch) { 00446 set<Loop*> visited; 00447 printLoopDeepFirst(n, fout, fTopLoop, visited); 00448 return; 00449 } 00450 #endif 00451 00452 // normal mode 00453 for (int l=G.size()-1; l>=0; l--) { 00454 if (gVectorSwitch) { tab(n, fout); fout << "// SECTION : " << G.size() - l; } 00455 for (lset::const_iterator p =G[l].begin(); p!=G[l].end(); p++) { 00456 (*p)->println(n, fout); 00457 } 00458 } 00459 }
void Klass::printLoopLevelOpenMP | ( | int | n, | |
int | lnum, | |||
const lset & | L, | |||
ostream & | fout | |||
) | [virtual] |
Print the 'level' of the loop graph as a set of parallel loops.
Definition at line 573 of file klass.cpp.
References nonRecursiveLevel(), and tab().
Referenced by printLoopGraphOpenMP().
00574 { 00575 if (nonRecursiveLevel(L) && L.size()==1) { 00576 for (lset::const_iterator p =L.begin(); p!=L.end(); p++) { 00577 if ((*p)->isEmpty() == false) { 00578 tab(n, fout); fout << "#pragma omp single "; 00579 tab(n, fout); fout << "{ "; 00580 (*p)->println(n+1, fout); 00581 tab(n, fout); fout << "} "; 00582 } 00583 } 00584 00585 } else if (L.size() > 1) { 00586 tab(n, fout); fout << "#pragma omp sections "; 00587 tab(n, fout); fout << "{ "; 00588 for (lset::const_iterator p =L.begin(); p!=L.end(); p++) { 00589 tab(n+1, fout); fout << "#pragma omp section "; 00590 tab(n+1, fout); fout << "{"; 00591 (*p)->println(n+2, fout); 00592 tab(n+1, fout); fout << "} "; 00593 } 00594 tab(n, fout); fout << "} "; 00595 } else if (L.size() == 1 && !(*L.begin())->isEmpty()) { 00596 tab(n, fout); fout << "#pragma omp single "; 00597 tab(n, fout); fout << "{ "; 00598 for (lset::const_iterator p =L.begin(); p!=L.end(); p++) { 00599 (*p)->println(n+1, fout); 00600 } 00601 tab(n, fout); fout << "} "; 00602 } 00603 }
void Klass::printLoopLevelScheduler | ( | int | n, | |
int | lnum, | |||
const lset & | L, | |||
ostream & | fout | |||
) | [virtual] |
Print the 'level' of the loop graph as a set of parallel loops.
Definition at line 702 of file klass.cpp.
References nonRecursiveLevel(), and printOneLoopScheduler().
Referenced by printLoopGraphScheduler().
00703 { 00704 if (nonRecursiveLevel(L) && L.size() == 1 && !(*L.begin())->isEmpty()) { 00705 printOneLoopScheduler(L.begin(), n, fout); 00706 } else if (L.size() > 1) { 00707 for (lset::const_iterator p = L.begin(); p != L.end(); p++) { 00708 printOneLoopScheduler(p, n, fout); 00709 } 00710 } else if (L.size() == 1 && !(*L.begin())->isEmpty()) { 00711 printOneLoopScheduler(L.begin(), n, fout); 00712 } 00713 }
Print metadata declaration.
Definition at line 223 of file klass.cpp.
References gMetaDataSet, tab(), and tree().
Referenced by println().
00224 { 00225 tab(n,fout); fout << "static void metadata(Meta* m) \t{ "; 00226 00227 for (map<Tree, set<Tree> >::iterator i = gMetaDataSet.begin(); i != gMetaDataSet.end(); i++) { 00228 if (i->first != tree("author")) { 00229 tab(n+1,fout); fout << "m->declare(\"" << *(i->first) << "\", " << **(i->second.begin()) << ");"; 00230 } else { 00231 for (set<Tree>::iterator j = i->second.begin(); j != i->second.end(); j++) { 00232 if (j == i->second.begin()) { 00233 tab(n+1,fout); fout << "m->declare(\"" << *(i->first) << "\", " << **j << ");" ; 00234 } else { 00235 tab(n+1,fout); fout << "m->declare(\"" << "contributor" << "\", " << **j << ");"; 00236 } 00237 } 00238 } 00239 } 00240 00241 tab(n,fout); fout << "}" << endl; 00242 }
void Klass::printOneLoopScheduler | ( | lset::const_iterator | p, | |
int | n, | |||
ostream & | fout | |||
) | [virtual] |
Definition at line 642 of file klass.cpp.
References Loop::fIndex, gTaskCount, subst(), T(), and tab().
Referenced by printLoopLevelScheduler().
00643 { 00644 tab(n, fout); fout << "case " << gTaskCount++ << ": { "; 00645 (*p)->println(n+1, fout); 00646 00647 // One output only 00648 if ((*p)->fForwardLoopDependencies.size() == 1) { 00649 00650 lset::const_iterator p1 = (*p)->fForwardLoopDependencies.begin(); 00651 if ((*p1)->fBackwardLoopDependencies.size () == 1) { 00652 tab(n+1, fout); fout << subst("tasknum = $0;", T((*p1)->fIndex)); 00653 } else { 00654 tab(n+1, fout); fout << subst("fGraph.ActivateOneOutputTask(taskqueue, $0, tasknum);", T((*p1)->fIndex)); 00655 } 00656 00657 } else { 00658 00659 Loop* keep = NULL; 00660 // Find one output with only one backward dependencies 00661 for (lset::const_iterator p1 = (*p)->fForwardLoopDependencies.begin(); p1!=(*p)->fForwardLoopDependencies.end(); p1++) { 00662 if ((*p1)->fBackwardLoopDependencies.size () == 1) { 00663 keep = *p1; 00664 break; 00665 } 00666 } 00667 00668 if (keep == NULL) { 00669 tab(n+1, fout); fout << "tasknum = WORK_STEALING_INDEX;"; 00670 } 00671 00672 for (lset::const_iterator p1 = (*p)->fForwardLoopDependencies.begin(); p1!=(*p)->fForwardLoopDependencies.end(); p1++) { 00673 if ((*p1)->fBackwardLoopDependencies.size () == 1) { // Task is the only input 00674 if (*p1 != keep) { 00675 tab(n+1, fout); fout << subst("taskqueue.PushHead($0);", T((*p1)->fIndex)); 00676 } 00677 } else { 00678 if (keep == NULL) { 00679 tab(n+1, fout); fout << subst("fGraph.ActivateOutputTask(taskqueue, $0, tasknum);", T((*p1)->fIndex)); 00680 } else { 00681 tab(n+1, fout); fout << subst("fGraph.ActivateOutputTask(taskqueue, $0);", T((*p1)->fIndex)); 00682 } 00683 } 00684 } 00685 00686 if (keep != NULL) { 00687 tab(n+1, fout); fout << subst("tasknum = $0;", T(keep->fIndex)); // Last one 00688 } else { 00689 tab(n+1, fout); fout << "fGraph.GetReadyTask(taskqueue, tasknum);"; // Last one 00690 } 00691 } 00692 00693 tab(n+1, fout); fout << "break;"; 00694 tab(n, fout); fout << "} "; 00695 }
void Klass::rememberNeedPowerDef | ( | ) | [inline] |
Definition at line 131 of file klass.hh.
References fNeedPowerDef.
Referenced by PowPrim::generateCode().
00131 { fNeedPowerDef = true; }
Store the loop used to compute a signal.
Definition at line 75 of file klass.cpp.
References fLoopProperty.
Referenced by closeLoop().
00076 { 00077 fLoopProperty.set(sig,l); 00078 }
Loop* Klass::topLoop | ( | ) | [inline] |
Definition at line 123 of file klass.hh.
References fTopLoop.
Referenced by VectorCompiler::CS(), and VectorCompiler::generateCode().
00123 { return fTopLoop; }
list<string> Klass::fDeclCode [protected] |
Definition at line 78 of file klass.hh.
Referenced by addDeclCode(), SigFloatGenKlass::println(), SigIntGenKlass::println(), and println().
list<string> Klass::fFirstPrivateDecl [protected] |
first private declarations
Definition at line 93 of file klass.hh.
Referenced by addFirstPrivateDecl(), and printComputeMethodOpenMP().
set<string> Klass::fIncludeFileSet [protected] |
Definition at line 73 of file klass.hh.
Referenced by addIncludeFile(), and collectIncludeFile().
list<string> Klass::fInitCode [protected] |
Definition at line 81 of file klass.hh.
Referenced by addInitCode(), SigFloatGenKlass::println(), and println().
string Klass::fKlassName [protected] |
Definition at line 66 of file klass.hh.
Referenced by SigFloatGenKlass::println(), SigIntGenKlass::println(), and println().
set<string> Klass::fLibrarySet [protected] |
Definition at line 74 of file klass.hh.
Referenced by addLibrary(), and collectLibrary().
property<Loop*> Klass::fLoopProperty [protected] |
loops used to compute some signals
Definition at line 102 of file klass.hh.
Referenced by getLoopProperty(), and setLoopProperty().
bool Klass::fNeedPowerDef = false [static, protected] |
true when faustpower definition is needed
Definition at line 61 of file klass.hh.
Referenced by printAdditionalCode(), and rememberNeedPowerDef().
int Klass::fNumActives [protected] |
number of active controls in the UI (sliders, buttons, etc.)
Definition at line 70 of file klass.hh.
Referenced by incUIActiveCount(), and println().
int Klass::fNumInputs [protected] |
Definition at line 68 of file klass.hh.
Referenced by inputs(), SigFloatGenKlass::println(), SigIntGenKlass::println(), and println().
int Klass::fNumOutputs [protected] |
Definition at line 69 of file klass.hh.
Referenced by outputs(), SigFloatGenKlass::println(), SigIntGenKlass::println(), and println().
int Klass::fNumPassives [protected] |
number of passive widgets in the UI (bargraphs, etc.)
Definition at line 71 of file klass.hh.
Referenced by incUIPassiveCount(), and println().
list<string> Klass::fSharedDecl [protected] |
list<string> Klass::fStaticFields [protected] |
static fields after class
Definition at line 80 of file klass.hh.
Referenced by addStaticFields(), and println().
list<string> Klass::fStaticInitCode [protected] |
static init code for class constant tables
Definition at line 79 of file klass.hh.
Referenced by addStaticInitCode(), and println().
list<Klass* > Klass::fSubClassList [protected] |
Definition at line 76 of file klass.hh.
Referenced by addSubKlass(), collectIncludeFile(), collectLibrary(), SigFloatGenKlass::println(), SigIntGenKlass::println(), and println().
string Klass::fSuperKlassName [protected] |
Loop* Klass::fTopLoop [protected] |
active loops currently open
Definition at line 101 of file klass.hh.
Referenced by addExecCode(), addPostCode(), addPreCode(), buildTasksList(), closeLoop(), openLoop(), printGraphDotFormat(), printLoopGraphInternal(), printLoopGraphOpenMP(), printLoopGraphScalar(), printLoopGraphScheduler(), printLoopGraphVector(), and topLoop().
list<string> Klass::fUICode [protected] |
Definition at line 82 of file klass.hh.
Referenced by addUICode(), and println().
list<string> Klass::fUIMacro [protected] |
Definition at line 83 of file klass.hh.
Referenced by addUIMacro(), and println().
bool Klass::fVec [protected] |
list<string> Klass::fZone1Code [protected] |
shared vectors
Definition at line 95 of file klass.hh.
Referenced by addZone1(), printComputeMethodOpenMP(), printComputeMethodScalar(), printComputeMethodScheduler(), printComputeMethodVectorFaster(), printComputeMethodVectorSimple(), SigFloatGenKlass::println(), and SigIntGenKlass::println().
list<string> Klass::fZone2bCode [protected] |
single once per block
Definition at line 97 of file klass.hh.
Referenced by addZone2b(), printComputeMethodOpenMP(), printComputeMethodScalar(), printComputeMethodVectorFaster(), printComputeMethodVectorSimple(), SigFloatGenKlass::println(), and SigIntGenKlass::println().
list<string> Klass::fZone2cCode [protected] |
single once per block
Definition at line 98 of file klass.hh.
Referenced by addZone2c(), and printComputeMethodScheduler().
list<string> Klass::fZone2Code [protected] |
first private
Definition at line 96 of file klass.hh.
Referenced by addZone2(), printComputeMethodOpenMP(), printComputeMethodScalar(), printComputeMethodScheduler(), printComputeMethodVectorFaster(), printComputeMethodVectorSimple(), SigFloatGenKlass::println(), and SigIntGenKlass::println().
list<string> Klass::fZone3Code [protected] |
private every sub block
Definition at line 99 of file klass.hh.
Referenced by addZone3(), printComputeMethodOpenMP(), printComputeMethodScalar(), printComputeMethodScheduler(), printComputeMethodVectorFaster(), printComputeMethodVectorSimple(), SigFloatGenKlass::println(), and SigIntGenKlass::println().