Skip to content

Commit

Permalink
DS now handle the clock == 0 case.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Feb 24, 2025
1 parent fe24c1a commit 1bba0ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
23 changes: 12 additions & 11 deletions compiler/parallelize/code_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,19 +344,19 @@ void CodeLoop::closeODblock()
CodeODblock* b = dynamic_cast<CodeODblock*>(fCodeStack.top());
faustassert(b);
fCodeStack.pop();

BlockInst* od_block = new BlockInst();
od_block->pushBackInst(b->fPreInst);
od_block->pushBackInst(b->fComputeInst);
od_block->pushBackInst(b->fPostInst);
//pushComputeDSPMethod(IB::genIfInst(b->fCond, then_block));

// pushComputeDSPMethod(IB::genIfInst(b->fCond, then_block));

DeclareVarInst* loop_decl =
IB::genDecLoopVar(b->fLoopIndex, IB::genInt32Typed(), IB::genInt32NumInst(0));
IB::genDecLoopVar(b->fLoopIndex, IB::genInt32Typed(), IB::genInt32NumInst(0));
ValueInst* loop_end = IB::genLessThan(loop_decl->load(), b->fODCond);
StoreVarInst* loop_inc = loop_decl->store(IB::genAdd(loop_decl->load(), 1));

ForLoopInst* loop = IB::genForLoopInst(loop_decl, loop_end, loop_inc);
loop->pushFrontInst(od_block);
pushComputeDSPMethod(loop);
Expand All @@ -367,7 +367,7 @@ void CodeLoop::closeUSblock()
CodeUSblock* b = dynamic_cast<CodeUSblock*>(fCodeStack.top());
faustassert(b);
fCodeStack.pop();

BlockInst* us_block = new BlockInst();
us_block->pushBackInst(b->fPreInst);
us_block->pushBackInst(b->fComputeInst);
Expand Down Expand Up @@ -395,10 +395,11 @@ void CodeLoop::closeDSblock()
ds_block1->pushBackInst(b->fPostInst);

BlockInst* ds_block2 = new BlockInst();
ds_block2->pushBackInst(
IB::genIfInst(IB::genEqual(IB::genRem(IB::genLoadStructVar(b->fDSCounter), b->fDSfactor),
IB::genInt32NumInst(0)),
ds_block1));
ds_block2->pushBackInst(IB::genIfInst(
IB::genAnd(IB::genGreaterThan(b->fDSfactor, IB::genInt32NumInst(0)),
IB::genEqual(IB::genRem(IB::genLoadStructVar(b->fDSCounter), b->fDSfactor),
IB::genInt32NumInst(0))),
ds_block1));

pushComputeDSPMethod(ds_block2);
}
4 changes: 2 additions & 2 deletions compiler/parallelize/code_loop.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct Codeblock : public virtual Garbageable {
};

struct CodeODblock : public Codeblock {
ValueInst* fODCond; ///< condition of the OD block
ValueInst* fODCond; ///< condition of the OD block
std::string fLoopIndex;

CodeODblock(ValueInst* cond) : Codeblock(), fODCond(cond)
Expand Down Expand Up @@ -263,7 +263,7 @@ class CodeLoop : public virtual Garbageable {
* Close the current/top OD block.
*/
void closeODblock();

/**
* Open a new US block.
* @param us_factor the upsampling factor of the US block
Expand Down
5 changes: 2 additions & 3 deletions compiler/propagate/propagate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,12 @@ static siglist realPropagate(Tree clockenv, Tree slotenv, Tree path, Tree box, c
string vname = string(tree2str(name));
if ((clockenv != gGlobal->nil) &&
((vname == "fSamplingFreq") || (vname == "fSamplingRate"))) {

Tree adapted_sr = sigFConst(type, name, file);
Tree clocks = clockenv;
Tree clocks = clockenv;
// Unroll the stack of all US/DS to compute the adapted SR
do {
Tree sr_factor = hd(clocks);
Tree us_ds = hd(tl(clocks));
Tree us_ds = hd(tl(clocks));
if (us_ds == tree("Upsampling")) {
adapted_sr = sigMul(adapted_sr, sr_factor);
} else if (us_ds == tree("Downsampling")) {
Expand Down

0 comments on commit 1bba0ae

Please sign in to comment.