I'm already using this template technique with dynamic dispatch for oscillators to only call code that supports specific enabled oscillator features. On the parameters side of things my oscillators have ~32 parameters, so using this template specialisation technique for optimising constant parameters isn't going to fly.mystran wrote: Tue Feb 28, 2023 10:24 amThe problem I have with a stride approach is that it complicates things unnecessarily. Now you need all the extra logic for dealing with the strides. The key thing is to realize that this extra logic is not free in terms of performance either, especially if you try to deal with all of it in a general code path.. but specializing for all kinds of different strides is a huge increase in code-size that you really don't want.JustinJ wrote: Tue Feb 28, 2023 9:44 am I haven't implemented a stride value but thinking about it, for non-mutating value buffers the stride could be 0 rather than 1.
The thing about constant vs. non-constant is that in many cases it's actually reasonable to specialize code. For example if a filter takes cutoff, resonance and some general "morph" parameter, then we'd have 2^3=8 cases of constant vs. non-constant inputs.
template <bool constantCutoff, bool constantRes, bool constantMorph> processFilter(...)
Then you can predicate things on the flags so that your filter statically skips loading new parameter values inside the per-sample loop if it's running with a constant input... and then if you had something like a trapezoidal solver where some of the system factorization stays the same when parameters don't change, the compiler can potentially hoist these out of the loop too.
Maybe we're talking cross-purposes regarding strides? I'm just seeing it as a setting that's either 0 or 1 for the control value type. If it's 0 then only the first buffer position has the control value. If it's 1 then the buffer is full of smoothing or modulating values. The stride value then is just added to the scan position as you access the value array and process the block. There isn't even a conditional here. I understand what you mean about being able to skip this loading of constants, but it should be cache friendly right?
