Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove sharing property and make use of occurrences #1096

Draft
wants to merge 1 commit into
base: master-dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions compiler/documentator/doc_compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Tree DocCompiler::annotate(Tree LS)
{
recursivnessAnnotation(LS); // Annotate LS with recursivness information
typeAnnotation(LS, gGlobal->gLocalCausalityCheck); // Annotate LS with type information
sharingAnalysis(LS); // annotate LS with sharing count
// sharingAnalysis(LS); // annotate LS with sharing count
fOccMarkup.mark(LS); // annotate LS with occurences analysis

return LS;
Expand Down Expand Up @@ -569,7 +569,6 @@ string DocCompiler::generateCacheCode(Tree sig, const string& exp)

string vname, ctype, code, vectorname;

int sharing = getSharingCount(sig);
Occurrences* o = fOccMarkup.retrieve(sig);

// check reentrance
Expand All @@ -587,7 +586,7 @@ string DocCompiler::generateCacheCode(Tree sig, const string& exp)
gGlobal->gDocNoticeFlagMap["recursigs"] = true;
// cerr << "- r : generateCacheCode : vame=\"" << vname << "\", for sig=\"" << ppsig(sig) <<
// "\"" << endl;
if (sharing > 1) {
if (o->hasMultiOccurrences()) {
// cerr << " generateCacheCode calls generateDelayVec(generateVariableStore) on
// vame=\"" << vname <<
// "\"" << endl;
Expand All @@ -598,15 +597,15 @@ string DocCompiler::generateCacheCode(Tree sig, const string& exp)
// "\"" << endl;
return generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
}
} else if (sharing == 1 || getVectorNameProperty(sig, vectorname) || isVerySimpleFormula(sig)) {
} else if (!o->hasMultiOccurrences() || getVectorNameProperty(sig, vectorname) || isVerySimpleFormula(sig)) {
// cerr << "! generateCacheCode : sharing == 1 : return \"" << exp << "\"" << endl;
return exp;
} else if (sharing > 1) {
} else if (o->hasMultiOccurrences()) {
// cerr << "! generateCacheCode : sharing > 1 : return \"" << exp << "\"" << endl;
return generateVariableStore(sig, exp);
} else {
stringstream error;
error << "ERROR in sharing count (" << sharing << ") for " << *sig << endl;
error << "ERROR in sharing count (" << o->getOccurrencesSum() << ") for " << *sig << endl;
throw faustexception(error.str());
}

Expand Down
8 changes: 4 additions & 4 deletions compiler/documentator/doc_compile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ class DocCompiler : public virtual Garbageable {
void setVectorNameProperty(Tree sig, const std::string& vecname);
bool getVectorNameProperty(Tree sig, std::string& vecname);

int getSharingCount(Tree t);
void setSharingCount(Tree t, int count);
void sharingAnalysis(Tree t);
void sharingAnnotation(int vctxt, Tree t);
// int getSharingCount(Tree t);
// void setSharingCount(Tree t, int count);
// void sharingAnalysis(Tree t);
// void sharingAnnotation(int vctxt, Tree t);

bool isShortEnough(std::string& s, unsigned int max);

Expand Down
125 changes: 0 additions & 125 deletions compiler/documentator/doc_sharing.cpp

This file was deleted.

24 changes: 12 additions & 12 deletions compiler/generator/compile_scal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ Tree ScalarCompiler::prepare(Tree LS)
typeAnnotation(L2, true); // Annotate L2 with type information and check causality
endTiming("L2 typeAnnotation");

startTiming("sharingAnalysis");
sharingAnalysis(L2, fSharingKey); // Annotate L2 with sharing count
endTiming("sharingAnalysis");
// startTiming("sharingAnalysis");
// sharingAnalysis(L2, fSharingKey); // Annotate L2 with sharing count
// endTiming("sharingAnalysis");

startTiming("occurrences analysis");
delete fOccMarkup;
Expand Down Expand Up @@ -164,7 +164,7 @@ Tree ScalarCompiler::prepare2(Tree L0)

recursivnessAnnotation(L0); // Annotate L0 with recursivness information
typeAnnotation(L0, true); // Annotate L0 with type information
sharingAnalysis(L0, fSharingKey); // annotate L0 with sharing count
// sharingAnalysis(L0, fSharingKey); // annotate L0 with sharing count

delete fOccMarkup;
fOccMarkup = new OccMarkup();
Expand Down Expand Up @@ -866,30 +866,30 @@ string ScalarCompiler::generateCacheCode(Tree sig, const string& exp)
}

string vname, ctype;
int sharing = getSharingCount(sig, fSharingKey);
// int sharing = getSharingCount(sig, fSharingKey);
Occurrences* o = fOccMarkup->retrieve(sig);
faustassert(o);

// check for expression occuring in delays
if (o->getMaxDelay() > 0) {
getTypedNames(getCertifiedSigType(sig), "Vec", ctype, vname);
if (sharing > 1) {
if (o->hasMultiOccurrences()) {
return generateDelayVec(sig, generateVariableStore(sig, exp), ctype, vname,
o->getMaxDelay(), o->getDelayCount());
} else {
return generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay(), o->getDelayCount());
}

} else if ((sharing > 1) || (o->hasMultiOccurrences())) {
} else if (o->hasMultiOccurrences()) {
return generateVariableStore(sig, exp);

} else if (sharing == 1) {
return exp;

} else {
cerr << "ASSERT : sharing count (" << sharing << ") for " << *sig << endl;
} else if (o->getOccurrencesSum() == 0){
cerr << "ASSERT : sharing count (" << o->getOccurrencesSum() << ") for " << *sig << endl;
faustassert(false);
return {};

} else {
return exp;
}
}

Expand Down
12 changes: 6 additions & 6 deletions compiler/generator/compile_vect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ string VectorCompiler::generateLoopCode(Tree sig)
string VectorCompiler::generateCacheCode(Tree sig, const string& exp)
{
string vname, ctype;
int sharing = getSharingCount(sig, fSharingKey);
// int sharing = getSharingCount(sig, fSharingKey);
Type t = getCertifiedSigType(sig);
Occurrences* o = fOccMarkup->retrieve(sig);
int d = o->getMaxDelay();
Expand All @@ -234,7 +234,7 @@ string VectorCompiler::generateCacheCode(Tree sig, const string& exp)
// it is a non-sample expressions but used delayed
// we need a delay line
getTypedNames(getCertifiedSigType(sig), "Vec", ctype, vname);
if ((sharing > 1) && !verySimple(sig)) {
if (o->hasMultiOccurrences() && !verySimple(sig)) {
// first cache this expression because it
// it is shared and complex
string cachedexp = generateVariableStore(sig, exp);
Expand Down Expand Up @@ -279,10 +279,10 @@ string VectorCompiler::generateCacheCode(Tree sig, const string& exp)
} else {
// not delayed
Tree x, y;
if (sharing > 1 && isSigDelay(sig, x, y) && verySimple(y)) {
if (o->hasMultiOccurrences() && isSigDelay(sig, x, y) && verySimple(y)) {
// cerr << "SPECIAL CASE NO CACHE NEEDED : " << ppsig(sig) << endl;
return exp;
} else if (sharing > 1 && !verySimple(sig)) {
} else if (o->hasMultiOccurrences() && !verySimple(sig)) {
// shared and not simple : we need a vector
// cerr << "ZEC : " << ppsig(sig) << endl;
getTypedNames(getCertifiedSigType(sig), "Zec", ctype, vname);
Expand All @@ -306,7 +306,7 @@ bool VectorCompiler::needSeparateLoop(Tree sig)
{
Occurrences* o = fOccMarkup->retrieve(sig);
Type t = getCertifiedSigType(sig);
int c = getSharingCount(sig, fSharingKey);
// int c = getSharingCount(sig, fSharingKey);
bool b;

int i;
Expand All @@ -322,7 +322,7 @@ bool VectorCompiler::needSeparateLoop(Tree sig)
} else if (isProj(sig, &i, x)) {
// cerr << "REC "; // recursive expressions require a separate loop
b = true;
} else if (c > 1) {
} else if (o->hasMultiOccurrences()) {
// cerr << "SHA(" << c << ") "; // expressions used several times required a separate loop
b = true;
} else {
Expand Down
12 changes: 6 additions & 6 deletions compiler/generator/dag_instructions_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ ValueInst* DAGInstructionsCompiler::generateCacheCode(Tree sig, ValueInst* exp)
{
string vname;
BasicTyped* ctype;
int sharing = getSharingCount(sig, fSharingKey);
// int sharing = getSharingCount(sig, fSharingKey);
::Type t = getCertifiedSigType(sig);
Occurrences* o = fOccMarkup->retrieve(sig);
int d = o->getMaxDelay();
Expand All @@ -299,7 +299,7 @@ ValueInst* DAGInstructionsCompiler::generateCacheCode(Tree sig, ValueInst* exp)
getTypedNames(getCertifiedSigType(sig), "Vec", ctype, vname);
Address::AccessType access;

if ((sharing > 1) && !verySimple(sig)) {
if (o->hasMultiOccurrences() && !verySimple(sig)) {
// first cache this expression because it
// it is shared and complex
ValueInst* cachedexp = generateVariableStore(sig, exp);
Expand Down Expand Up @@ -342,10 +342,10 @@ ValueInst* DAGInstructionsCompiler::generateCacheCode(Tree sig, ValueInst* exp)
} else {
// not delayed
Tree x, y;
if (sharing > 1 && isSigDelay(sig, x, y) && verySimple(y)) {
if (o->hasMultiOccurrences() && isSigDelay(sig, x, y) && verySimple(y)) {
// cerr << "SPECIAL CASE NO CACHE NEEDED : " << ppsig(sig) << endl;
return exp;
} else if (sharing > 1 && !verySimple(sig)) {
} else if (o->hasMultiOccurrences() && !verySimple(sig)) {
// shared and not simple : we need a vector
// cerr << "Zec : " << ppsig(sig) << endl;
getTypedNames(getCertifiedSigType(sig), "Zec", ctype, vname);
Expand Down Expand Up @@ -373,7 +373,7 @@ bool DAGInstructionsCompiler::needSeparateLoop(Tree sig)
{
Occurrences* o = fOccMarkup->retrieve(sig);
::Type t = getCertifiedSigType(sig);
int c = getSharingCount(sig, fSharingKey);
// int c = getSharingCount(sig, fSharingKey);
bool b;

int i;
Expand All @@ -387,7 +387,7 @@ bool DAGInstructionsCompiler::needSeparateLoop(Tree sig)
b = false;
} else if (isProj(sig, &i, x)) {
b = true;
} else if (c > 1) {
} else if (o->hasMultiOccurrences()) {
b = true;
} else {
// sample expressions that are not recursive, not delayed
Expand Down
Loading
Loading