On 04/30, Stéphane Letz wrote: > > I’ve just fixed some missing optimisation here, even If I don’t think they > can happen so much in practice: > > https://github.com/grame-cncm/faust/commit/4a8459d8faca12509c5a32bd597b9cb6d7c82a91
Let me repeat, I didn't even think about optimizing sigBinOp's. I used atan2 only for illustration and as a trivial test-case. > But then, what is the point of exposing those internal compiler concepts ? > > - I mean "serial" Well, I want this primitive for https://github.com/oleg-nesterov/fpp ;) It can have many applications, but again I don't have a simple example without too much details of fpp internals... Well... Say I have a foreign function ffunc(sig) which should initialize some state variables for the signal 'sig' at init time (in instanceConstants), this state and the signal 'sig' will be used later in compute(). However, process = _,_ <: ffunc,_, ffunc,_ : more, more; won't work, ffunc() will be called in compute(). While process = _,_ <: ffunc(meta.serial),_, ffunc(meta.serial),_ : more, more; does the trick for me. > - and what use-case for "order" Again, it can be used in fpp. But perhaps it can be used in the pure .dsp faust code as well. Consider tf1s(b1,b0,a0,w1) = tf1(b0d,b1d,a1d) with { c = 1/tan(w1*0.5/ma.SR); d = a0 + c; b1d = (b0 - b1*c) / d; b0d = (b0 + b1*c) / d; a1d = (a0 - c) / d; }; from filters.lib. 1/tan(...) is not cheap, so for the case when 'w1' changes at every tick we can create a faster but not so accurate approximation, let's name this function fast_approx(w1), and change the code above to use it instead of 1/tan(w1*0.5/ma.SR). But this is "suboptimal" in the case when 'w' is known at compile/init time. So we can use 'serial' and do tf1s(b1,b0,a0,w1) = tf1(b0d,b1d,a1d) with { c = select2(meta.order(w1)==3, 1/tan(w1*0.5/ma.SR), // kComp or kInit fast_approx(w1)); // kExec d = a0 + c; b1d = (b0 - b1*c) / d; b0d = (b0 + b1*c) / d; a1d = (a0 - c) / d; }; Yes, agreed, this example is not very convincing too. And actually I want more ;) Say, meta.type which returns kInt or kReal, fpp can use it to detect the type of the input signal(s) and generate the code accordingly. Please not that with this patch it is very easy, we just need to add 'defs = add_meta_def(defs, 2, "meta");' into mkMetaEnv() and 'case 2:' into computeSigOutput(). Oleg. _______________________________________________ Faudiostream-devel mailing list Faudiostream-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-devel