From 1bba0aee762282de88ca6740aa1faa0f0e6c084f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Letz?= Date: Mon, 24 Feb 2025 16:08:08 +0100 Subject: [PATCH] DS now handle the clock == 0 case. --- compiler/parallelize/code_loop.cpp | 23 ++++++++++++----------- compiler/parallelize/code_loop.hh | 4 ++-- compiler/propagate/propagate.cpp | 5 ++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/compiler/parallelize/code_loop.cpp b/compiler/parallelize/code_loop.cpp index bbbfb4eccf..85264bd4f5 100644 --- a/compiler/parallelize/code_loop.cpp +++ b/compiler/parallelize/code_loop.cpp @@ -344,19 +344,19 @@ void CodeLoop::closeODblock() CodeODblock* b = dynamic_cast(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); @@ -367,7 +367,7 @@ void CodeLoop::closeUSblock() CodeUSblock* b = dynamic_cast(fCodeStack.top()); faustassert(b); fCodeStack.pop(); - + BlockInst* us_block = new BlockInst(); us_block->pushBackInst(b->fPreInst); us_block->pushBackInst(b->fComputeInst); @@ -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); } diff --git a/compiler/parallelize/code_loop.hh b/compiler/parallelize/code_loop.hh index faba8e9636..a2aee0f3fe 100644 --- a/compiler/parallelize/code_loop.hh +++ b/compiler/parallelize/code_loop.hh @@ -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) @@ -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 diff --git a/compiler/propagate/propagate.cpp b/compiler/propagate/propagate.cpp index d75be75736..9f06e78a1d 100644 --- a/compiler/propagate/propagate.cpp +++ b/compiler/propagate/propagate.cpp @@ -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")) {