Skip to content

Commit

Permalink
remove sharing property and make use of occurrences
Browse files Browse the repository at this point in the history
  • Loading branch information
crop2000 committed Dec 15, 2024
1 parent bfbbad9 commit 443fbeb
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 186 deletions.
15 changes: 4 additions & 11 deletions compiler/generator/compile_scal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "ppsig.hh"
#include "prim2.hh"
#include "recursivness.hh"
#include "sharing.hh"
#include "sigDependenciesGraph.hh"
#include "sigNewConstantPropagation.hh"
#include "sigPromotion.hh"
Expand Down Expand Up @@ -128,10 +127,6 @@ 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("occurrences analysis");
delete fOccMarkup;
fOccMarkup = new OccMarkup(fConditionProperty);
Expand Down Expand Up @@ -164,7 +159,6 @@ 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

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

string vname, ctype;
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) {
} else if (o->getOccurrencesSum() == 1) {
return exp;

} else {
cerr << "ASSERT : sharing count (" << sharing << ") for " << *sig << endl;
cerr << "ASSERT : getOccurrencesSum (" << o->getOccurrencesSum() << ") for " << *sig << endl;
faustassert(false);
return {};
}
Expand Down
11 changes: 4 additions & 7 deletions compiler/generator/compile_vect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "compile_vect.hh"
#include "floats.hh"
#include "ppsig.hh"
#include "sharing.hh"

using namespace std;

Expand Down Expand Up @@ -220,7 +219,6 @@ string VectorCompiler::generateLoopCode(Tree sig)
string VectorCompiler::generateCacheCode(Tree sig, const string& exp)
{
string vname, ctype;
int sharing = getSharingCount(sig, fSharingKey);
Type t = getCertifiedSigType(sig);
Occurrences* o = fOccMarkup->retrieve(sig);
int d = o->getMaxDelay();
Expand All @@ -234,7 +232,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 +277,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 +304,6 @@ bool VectorCompiler::needSeparateLoop(Tree sig)
{
Occurrences* o = fOccMarkup->retrieve(sig);
Type t = getCertifiedSigType(sig);
int c = getSharingCount(sig, fSharingKey);
bool b;

int i;
Expand All @@ -322,7 +319,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
11 changes: 4 additions & 7 deletions compiler/generator/dag_instructions_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "dag_instructions_compiler.hh"
#include "fir_to_fir.hh"
#include "ppsig.hh"
#include "sharing.hh"
#include "sigtyperules.hh"
#include "timing.hh"

Expand Down Expand Up @@ -283,7 +282,6 @@ ValueInst* DAGInstructionsCompiler::generateCacheCode(Tree sig, ValueInst* exp)
{
string vname;
BasicTyped* ctype;
int sharing = getSharingCount(sig, fSharingKey);
::Type t = getCertifiedSigType(sig);
Occurrences* o = fOccMarkup->retrieve(sig);
int d = o->getMaxDelay();
Expand All @@ -299,7 +297,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 +340,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 +371,6 @@ bool DAGInstructionsCompiler::needSeparateLoop(Tree sig)
{
Occurrences* o = fOccMarkup->retrieve(sig);
::Type t = getCertifiedSigType(sig);
int c = getSharingCount(sig, fSharingKey);
bool b;

int i;
Expand All @@ -387,7 +384,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
14 changes: 4 additions & 10 deletions compiler/generator/instructions_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "normalform.hh"
#include "prim2.hh"
#include "recursivness.hh"
#include "sharing.hh"
#include "sigPromotion.hh"
#include "sigRetiming.hh"
#include "sigToGraph.hh"
Expand Down Expand Up @@ -120,9 +119,6 @@ Tree InstructionsCompiler::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("occurrences analysis");
delete fOccMarkup;
Expand Down Expand Up @@ -156,7 +152,6 @@ Tree InstructionsCompiler::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

delete fOccMarkup;
fOccMarkup = new OccMarkup();
Expand Down Expand Up @@ -1049,28 +1044,27 @@ ValueInst* InstructionsCompiler::generateCacheCode(Tree sig, ValueInst* exp)

string vname;
BasicTyped* ctype;
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());
} else {
return generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
}

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

} else if (sharing == 1) {
} else if (o->getOccurrencesSum() == 1) {
return exp;

} else {
cerr << "ASSERT : in sharing count (" << sharing << ") for " << *sig << endl;
cerr << "ASSERT : getOccurrencesSum (" << o->getOccurrencesSum() << ") for " << *sig << endl;
faustassert(false);
return IB::genNullValueInst();
}
Expand Down
9 changes: 9 additions & 0 deletions compiler/generator/occurrences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ int Occurrences::getOccurrence(int variability) const
return fOccurrences[variability];
}

int Occurrences::getOccurrencesSum() const
{
int sum = 0;
for (int i = 0; i < 4; i++) {
sum += fOccurrences[i];
}
return sum;
}

Occurrences::Occurrences(int v, int r, Tree xc) : fXVariability(xVariability(v, r))
{
for (int i = 0; i < 4; i++) {
Expand Down
1 change: 1 addition & 0 deletions compiler/generator/occurrences.hh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Occurrences : public virtual Garbageable {
int getDelayCount() const;
Tree getExecCondition() const; ///< return the exec condition
int getOccurrence(int variability) const; ///< return the number of occurrence by variability
int getOccurrencesSum() const; ///< return the number of occurrence by variability
};

/**
Expand Down
117 changes: 0 additions & 117 deletions compiler/signals/sharing.cpp

This file was deleted.

Loading

0 comments on commit 443fbeb

Please sign in to comment.