Kaynağa Gözat

Perf gate: the Delay glide and Atrium's build groups in fewer instructions, bit for bit (round 190kg)

The 0.1.30 rollup failed CI's performance gate on instructions per sample
against main's baseline e42789b (synth100 +6 %, automation +4.4 %; limit
+4 %). Callgrind against e42789b found two causes:

- automation: round 190ie's basic Delay glide (16 Delays under a tempo
  clip never land). Its loop took ~76 instructions per sample against
  ~40 for the steady loop: GCC paired the two sides into half-filled
  vectors, the float damp members and the write index were stored and
  reloaded every sample (the line's floats may alias them), a division
  per sample for the wrap, unsigned double <-> size_t conversions.
- synth100: round 190it's Atrium revision 1. The four build groups were
  summed through an indexed stack array (a store and a load at every one
  of 80 taps per sample) and the 4-point Hadamard was recomputed with
  ternaries inside the line loop.

Delay::process keeps every operation and its order per sample: state in
locals, compare wraps, signed conversions (the lengths are < 2^53), and
when the line is longer than a 64-sample chunk (no sample of the chunk
can read what it writes) two passes: the echoes through the feedback
low-pass (the glide in delayGlideChunk, with a no-wrap variant), then
the line's writes and the outputs (element-wise, vectorisable). Short
lines keep the per-sample loop. processLaw1 sums the groups in four
registers (each in tap order) and computes the Hadamard once per sample.

Every gate cell's render hash is unchanged (5 projects x 64/128/256);
a harness over every built-in effect (13,344 renders: settings, rates,
blocks, tempo ramps / waves / steps) is bit-identical; the new test
perf190kg_delay_renders_round_190ie_bit_for_bit compares the Delay with
round 190ie's loop verbatim (160 renders, lines down to 6 samples).

Local perfbench (g++ 15), instructions per sample vs e42789b:
synth100@128 +5.55 % -> +0.72 %, automation@128 +5.05 % -> +1.90 %;
every other cell at or below the rollup's.
Ka1-S 2 hafta önce
ebeveyn
işleme
c92bac2e7d
4 değiştirilmiş dosya ile 380 ekleme ve 43 silme
  1. 196 36
      src/core/Effects.cpp
  2. 33 7
      src/core/LynxVerbs.cpp
  3. 150 0
      tests/Perf190kgTests.inc
  4. 1 0
      tests/tests.cpp

+ 196 - 36
src/core/Effects.cpp

@@ -69,6 +69,8 @@
 #include <cmath>
 #include <complex>
 #include <cstdio>
+#include <cstdint>
+#include <type_traits>
 
 namespace lynx
 {
@@ -437,6 +439,64 @@ private:
 
 // ---------------------------------------------------------------------------
 
+// Round 190kg (perf): the basic Delay's glide over one chunk whose reads all lie before its writes — the same
+// operations per sample as Delay::process's own glide (the length steps toward the target and snaps within 0.001
+// sample; the line read between samples; the feedback low-pass), the two sides in one loop. Returns the samples it
+// glided (fewer than m when the glide lands). GCC's straight-line vectoriser paired the two sides into half-filled
+// vectors with more shuffles than work here, so it is off for this function (no effect on the results: the same
+// IEEE operations either way)
+#if defined(__GNUC__) && ! defined(__clang__)
+__attribute__ ((optimize ("no-tree-slp-vectorize")))
+#endif
+int delayGlideChunk (double& cur, double target, double glideK, const float* bufL, const float* bufR, std::size_t size,
+                     std::size_t at, int m, float dampCoeff, float& dampL, float& dampR, float* eL, float* eR) noexcept
+{
+    auto c = cur;
+    auto lpL = dampL, lpR = dampR;
+    int k = 0;
+    // flat: no position of the chunk wraps — its writes end before the line's end, and every read (≥ 1 sample after
+    // the line's start: the lengths are ≤ the larger of `c` and `target`) lies after the start; the read positions are
+    // then plain differences, the same ones the wrapping arithmetic gives
+    const auto longest = (std::size_t) (std::int64_t) std::max (c, target);
+    if (at + (std::size_t) m <= size && at >= longest + 1)
+    {
+        for (; k < m && c != target; ++k, ++at)
+        {
+            const auto diff = target - c;
+            c = std::abs (diff) < 0.001 ? target : c + diff * glideK;
+            const auto wholeSigned = (std::int64_t) c;
+            const auto frac = (float) (c - (double) wholeSigned);
+            const auto from = at - (std::size_t) wholeSigned;
+            const auto xL = bufL[from], xR = bufR[from];
+            lpL += dampCoeff * ((xL + (bufL[from - 1] - xL) * frac) - lpL);
+            lpR += dampCoeff * ((xR + (bufR[from - 1] - xR) * frac) - lpR);
+            eL[k] = lpL;
+            eR[k] = lpR;
+        }
+    }
+    else
+        for (; k < m && c != target; ++k)
+        {
+            const auto diff = target - c;
+            c = std::abs (diff) < 0.001 ? target : c + diff * glideK;
+            const auto wholeSigned = (std::int64_t) c; // (≥ 1 and < size)
+            const auto whole = (std::size_t) wholeSigned;
+            const auto frac = (float) (c - (double) wholeSigned);
+            const auto from = at >= whole ? at - whole : at + size - whole, before = from == 0 ? size - 1 : from - 1;
+            const auto xL = bufL[from], xR = bufR[from];
+            lpL += dampCoeff * ((xL + (bufL[before] - xL) * frac) - lpL);
+            lpR += dampCoeff * ((xR + (bufR[before] - xR) * frac) - lpR);
+            eL[k] = lpL;
+            eR[k] = lpR;
+            if (++at == size)
+                at = 0;
+        }
+    cur = c;
+    dampL = lpL;
+    dampR = lpR;
+    return k;
+}
+
 class Delay final : public Effect
 {
 public:
@@ -490,46 +550,146 @@ public:
         settled = true;
         lastIndex = index;
 
-        auto sample = [&] (int i, float echoL, float echoR) noexcept {
-            // 1-pole low-pass in the feedback path: repeats get darker
-            damp[0] += dampCoeff * (echoL - damp[0]);
-            damp[1] += dampCoeff * (echoR - damp[1]);
-            echoL = damp[0];
-            echoR = damp[1];
-
-            const auto inL = l[i], inR = r[i];
+        // round 190kg (perf, bit for bit): the same arithmetic in the same order per sample, arranged for fewer
+        // instructions. The state lives in locals (the buffers' floats could alias the float members: every sample
+        // stored and reloaded them); positions wrap by a compare instead of a division; the glide's conversions are
+        // signed (the length is ≥ 1 and < 2^53: the same values, without the unsigned conversions' slow paths). And
+        // when the line is longer than a chunk, no sample of the chunk can read what the chunk writes, so the chunk
+        // runs in two passes: the echoes as the line holds them through the feedback low-pass (serial), then the line's
+        // writes and the outputs (independent per sample: vectorisable, still one IEEE operation each, in the same order)
+        float* const bufL = buffer[0].data();
+        float* const bufR = buffer[1].data();
+        auto w = write;
+        auto dampL = damp[0], dampR = damp[1];
+        auto cur = current;
+        const auto steadyPos = [&] (std::size_t at) noexcept { return (at + size - delaySamples) % size; };
+        // one glide step, then the echo read between samples at write position `at`
+        const auto glideRead = [&] (std::size_t at0, float& echoL, float& echoR) noexcept {
+            const auto diff = target - cur;
+            cur = std::abs (diff) < 0.001 ? target : cur + diff * glideK;
+            const auto wholeSigned = (std::int64_t) cur; // (≥ 1 and < size)
+            const auto whole = (std::size_t) wholeSigned;
+            const auto frac = (float) (cur - (double) wholeSigned);
+            const auto at = at0 >= whole ? at0 - whole : at0 + size - whole, before = at == 0 ? size - 1 : at - 1;
+            echoL = bufL[at] + (bufL[before] - bufL[at]) * frac;
+            echoR = bufR[at] + (bufR[before] - bufR[at]) * frac;
+        };
+        const auto run = [&] (auto pingPongOn) noexcept {
+            constexpr bool pp = decltype (pingPongOn)::value;
+            // one sample as before round 190kg's passes (the chunks a short line could read back)
+            const auto sample = [&] (int i, float echoL, float echoR) noexcept {
+                // 1-pole low-pass in the feedback path: repeats get darker
+                dampL += dampCoeff * (echoL - dampL);
+                dampR += dampCoeff * (echoR - dampR);
+                echoL = dampL;
+                echoR = dampR;
+
+                const auto inL = l[i], inR = r[i];
+
+                if constexpr (pp) // mono input on the left side, repeats alternate
+                {
+                    bufL[w] = 0.5f * (inL + inR) + echoR * feedback;
+                    bufR[w] = echoL * feedback;
+                }
+                else
+                {
+                    bufL[w] = inL + echoL * feedback;
+                    bufR[w] = inR + echoR * feedback;
+                }
 
-            if (pingPong) // mono input on the left side, repeats alternate
-            {
-                buffer[0][write] = 0.5f * (inL + inR) + echoR * feedback;
-                buffer[1][write] = echoL * feedback;
-            }
-            else
+                l[i] = inL + mix * echoL;
+                r[i] = inR + mix * echoR;
+                if (++w == size)
+                    w = 0;
+            };
+            constexpr int chunk = 64;
+            float eL[chunk], eR[chunk];
+            for (int i = 0; i < n;)
             {
-                buffer[0][write] = inL + echoL * feedback;
-                buffer[1][write] = inR + echoR * feedback;
+                const int m = std::min (chunk, n - i);
+                // (the glide moves monotonically between `cur` and `target`: every length read in the chunk is ≥ the
+                // smaller one's whole part)
+                if (std::min (cur, target) <= (double) (m + 1))
+                {
+                    for (const int end = i + m; i < end; ++i)
+                    {
+                        float echoL, echoR;
+                        if (cur != target) // gliding toward the new tempo's length
+                            glideRead (w, echoL, echoR);
+                        else // the steady length: whole samples, bit for bit as before
+                        {
+                            const auto readPos = steadyPos (w);
+                            echoL = bufL[readPos];
+                            echoR = bufR[readPos];
+                        }
+                        sample (i, echoL, echoR);
+                    }
+                    continue;
+                }
+                // 1. the echoes through the feedback path's low-pass: read between samples while the glide moves
+                // (nothing the chunk writes is read: every length is > m), then whole samples at the steady length
+                const int g = cur != target ? delayGlideChunk (cur, target, glideK, bufL, bufR, size, w, m, dampCoeff, dampL, dampR, eL, eR) : 0;
+                if (g < m) // (one loop per side: no shuffles between them)
+                {
+                    auto at = w + (std::size_t) g;
+                    if (at >= size)
+                        at -= size;
+                    const auto from = steadyPos (at);
+                    const auto steady = [&] (const float* line, float& lp, float* e) noexcept {
+                        auto readPos = from;
+                        for (int k = g; k < m; ++k)
+                        {
+                            lp += dampCoeff * (line[readPos] - lp);
+                            e[k] = lp;
+                            if (++readPos == size)
+                                readPos = 0;
+                        }
+                    };
+                    steady (bufL, dampL, eL);
+                    steady (bufR, dampR, eR);
+                }
+                // 2. the line's writes and the outputs, in runs up to the line's end
+                for (int done = 0; done < m;)
+                {
+                    const int seg = (int) std::min<std::size_t> ((std::size_t) (m - done), size - w);
+                    float* const outL = l + i + done;
+                    float* const outR = r + i + done;
+                    float* const lineL = bufL + w;
+                    float* const lineR = bufR + w;
+                    const float* const echoL = eL + done;
+                    const float* const echoR = eR + done;
+                    for (int k = 0; k < seg; ++k)
+                    {
+                        const auto inL = outL[k], inR = outR[k];
+                        if constexpr (pp)
+                        {
+                            lineL[k] = 0.5f * (inL + inR) + echoR[k] * feedback;
+                            lineR[k] = echoL[k] * feedback;
+                        }
+                        else
+                        {
+                            lineL[k] = inL + echoL[k] * feedback;
+                            lineR[k] = inR + echoR[k] * feedback;
+                        }
+                        outL[k] = inL + mix * echoL[k];
+                        outR[k] = inR + mix * echoR[k];
+                    }
+                    done += seg;
+                    w += (std::size_t) seg;
+                    if (w == size)
+                        w = 0;
+                }
+                i += m;
             }
-
-            l[i] = inL + mix * echoL;
-            r[i] = inR + mix * echoR;
-            write = (write + 1) % size;
         };
-
-        int i = 0;
-        for (; i < n && current != target; ++i) // gliding toward the new tempo's length
-        {
-            const auto diff = target - current;
-            current = std::abs (diff) < 0.001 ? target : current + diff * glideK;
-            const auto whole = (std::size_t) current; // (≥ 1 and < size)
-            const auto frac = (float) (current - (double) whole);
-            const auto at = write >= whole ? write - whole : write + size - whole, before = at == 0 ? size - 1 : at - 1;
-            sample (i, buffer[0][at] + (buffer[0][before] - buffer[0][at]) * frac, buffer[1][at] + (buffer[1][before] - buffer[1][at]) * frac);
-        }
-        for (; i < n; ++i) // the steady length: whole samples, bit for bit as before
-        {
-            const auto readPos = (write + size - delaySamples) % size;
-            sample (i, buffer[0][readPos], buffer[1][readPos]);
-        }
+        if (pingPong)
+            run (std::true_type {});
+        else
+            run (std::false_type {});
+        current = cur;
+        write = w;
+        damp[0] = dampL;
+        damp[1] = dampR;
     }
 
 private:

+ 33 - 7
src/core/LynxVerbs.cpp

@@ -864,6 +864,7 @@ struct Engine::Impl
         const auto onsetLevel = (float) s.onsetLevel, onsetFeed = (float) std::clamp (s.onsetFeed, 0.0, 1.0);
         const auto onsetFront = (float) std::clamp (s.onsetFront, 0.0, 1.0);
         const auto onsetOn = onsetLevel != 0.0f || onsetFeed != 0.0f;
+        const auto splitShare = 0.5f * (1.0f - onsetFeed); // (revision 1's build groups, below)
         if (onsetOn)
             for (int k = 0; k < onsetSteps; ++k)
                 for (int j = 0; j < onsetChans; ++j)
@@ -912,9 +913,25 @@ struct Engine::Impl
                     // into every line: one fixed random-sign FIR left its ripple (±3 … 4 dB, 50 … 200 Hz wide) on the
                     // whole tail; four independent ones average it out (a steady sine meets the tail's mean gain)
                     dif[c].write (v);
+                    // (round 190kg, perf: the four groups' sums in registers, each still added in the taps' order — the
+                    // indexed array went through memory at every tap)
+                    static_assert (buildTaps % 4 == 0);
+                    const auto tap = [&] (int k) noexcept { return bW[c][k] * (bD[c][k] == 0 ? v : dif[c].read (bD[c][k])); };
                     float g4[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
-                    for (int k = 0; k < buildTaps; ++k)
-                        g4[k & 3] += bW[c][k] * (bD[c][k] == 0 ? v : dif[c].read (bD[c][k]));
+                    {
+                        float g0 = 0.0f, g1 = 0.0f, g2 = 0.0f, g3 = 0.0f;
+                        for (int k = 0; k < buildTaps; k += 4)
+                        {
+                            g0 += tap (k);
+                            g1 += tap (k + 1);
+                            g2 += tap (k + 2);
+                            g3 += tap (k + 3);
+                        }
+                        g4[0] = g0;
+                        g4[1] = g1;
+                        g4[2] = g2;
+                        g4[3] = g3;
+                    }
                     // below ~600 Hz the groups go on as one sum (the build's low band as before: there the few modes
                     // of the tank, not the taps, set the tone, and music read them as before); above, apart
                     float low = 0.0f;
@@ -936,6 +953,18 @@ struct Engine::Impl
                 }
                 d[c] = v;
             }
+            // revision 1's build groups into the lines of each half: a 4-point Hadamard (signs per line as below), × the
+            // build's share (round 190kg, perf: once per sample here instead of inside the line loop; the same operations)
+            float splitIn[2][4];
+            if (build && split)
+                for (int c = 0; c < 2; ++c)
+                {
+                    const auto* q = dg[c];
+                    splitIn[c][0] = splitShare * (q[0] + q[1] + q[2] + q[3]);
+                    splitIn[c][1] = splitShare * (q[0] + (-q[1]) + q[2] + (-q[3]));
+                    splitIn[c][2] = splitShare * (q[0] + q[1] + (-q[2]) + (-q[3]));
+                    splitIn[c][3] = splitShare * (q[0] + (-q[1]) + (-q[2]) + q[3]);
+                }
             eModPhase += eModInc;
             if (eModPhase > 2.0 * pi)
                 eModPhase -= 2.0 * pi;
@@ -1080,11 +1109,8 @@ struct Engine::Impl
                 const auto alt = (i & 1) == 0 ? 0.5f : -0.5f;
                 if (build && split)
                 {
-                    const auto hb = 0.5f * (1.0f - onsetFeed);
-                    const auto hl = dg[0][0] + (i & 1 ? -dg[0][1] : dg[0][1]) + (i & 2 ? -dg[0][2] : dg[0][2]) + ((i == 1 || i == 2) ? -dg[0][3] : dg[0][3]);
-                    const auto hr = dg[1][0] + (i & 1 ? -dg[1][1] : dg[1][1]) + (i & 2 ? -dg[1][2] : dg[1][2]) + ((i == 1 || i == 2) ? -dg[1][3] : dg[1][3]);
-                    lines[i].write (u + alt * in[0] + hb * hl);
-                    lines[i + 4].write (w + alt * in[1] + hb * hr);
+                    lines[i].write (u + alt * in[0] + splitIn[0][i]);
+                    lines[i + 4].write (w + alt * in[1] + splitIn[1][i]);
                 }
                 else
                 {

+ 150 - 0
tests/Perf190kgTests.inc

@@ -0,0 +1,150 @@
+// Round 190kg (0.1.30 performance gate): the basic Delay's loops rearranged for fewer instructions must render
+// exactly what round 190ie's loops rendered. The reference below is round 190ie's Delay::process verbatim (the glide
+// toward a new tempo's length, read between samples, then whole samples at the steady length); the effect must match
+// it bit for bit under steady tempos, ramps, waves and steps, at block sizes around the 64-sample chunks, with Time
+// knob moves, ping-pong on and off, and lines shorter than a chunk (very fast tempos: the per-sample fallback).
+
+#include <cstring>
+
+namespace perf190kg
+{
+struct Delay190ie
+{
+    static constexpr double maxSeconds = 3.0, glideSeconds = 0.5;
+    std::array<std::vector<float>, 2> buffer;
+    double sampleRate = 44100.0, glideK = 1.0, current = 0.0;
+    int lastIndex = -1;
+    bool settled = false;
+    std::size_t write = 0;
+    float damp[2] {};
+    explicit Delay190ie (double sr) : sampleRate (sr)
+    {
+        buffer[0].assign ((std::size_t) (maxSeconds * 192000.0) + 4, 0.0f);
+        buffer[1].assign ((std::size_t) (maxSeconds * 192000.0) + 4, 0.0f);
+        glideK = 1.0 - std::pow (0.01, 1.0 / (glideSeconds * sr));
+    }
+    void process (float* l, float* r, int n, const lynx::EffectParams& params, double bpm) noexcept
+    {
+        static constexpr std::array<double, 8> divisions { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 4.0 };
+        const auto index = std::clamp ((int) (params[0] * 8.0f), 0, 7);
+        const auto beats = divisions[(std::size_t) index];
+        const auto seconds = std::min (maxSeconds - 0.01, beats * 60.0 / std::max (bpm, 20.0));
+        const auto delaySamples = std::max<std::size_t> (1, (std::size_t) (seconds * sampleRate));
+        const auto feedback = params[1] * 0.95f;
+        const auto mix = params[2];
+        const auto pingPong = params[3] > 0.5f;
+        const auto dampCoeff = 1.0f - params[4] * 0.9f;
+        const auto size = buffer[0].size();
+        const auto target = (double) delaySamples;
+        if (! settled || index != lastIndex)
+            current = target;
+        settled = true;
+        lastIndex = index;
+        auto sample = [&] (int i, float echoL, float echoR) noexcept {
+            damp[0] += dampCoeff * (echoL - damp[0]);
+            damp[1] += dampCoeff * (echoR - damp[1]);
+            echoL = damp[0];
+            echoR = damp[1];
+            const auto inL = l[i], inR = r[i];
+            if (pingPong)
+            {
+                buffer[0][write] = 0.5f * (inL + inR) + echoR * feedback;
+                buffer[1][write] = echoL * feedback;
+            }
+            else
+            {
+                buffer[0][write] = inL + echoL * feedback;
+                buffer[1][write] = inR + echoR * feedback;
+            }
+            l[i] = inL + mix * echoL;
+            r[i] = inR + mix * echoR;
+            write = (write + 1) % size;
+        };
+        int i = 0;
+        for (; i < n && current != target; ++i)
+        {
+            const auto diff = target - current;
+            current = std::abs (diff) < 0.001 ? target : current + diff * glideK;
+            const auto whole = (std::size_t) current;
+            const auto frac = (float) (current - (double) whole);
+            const auto at = write >= whole ? write - whole : write + size - whole, before = at == 0 ? size - 1 : at - 1;
+            sample (i, buffer[0][at] + (buffer[0][before] - buffer[0][at]) * frac, buffer[1][at] + (buffer[1][before] - buffer[1][at]) * frac);
+        }
+        for (; i < n; ++i)
+        {
+            const auto readPos = (write + size - delaySamples) % size;
+            sample (i, buffer[0][readPos], buffer[1][readPos]);
+        }
+    }
+};
+
+inline bool sameBits (const std::vector<float>& a, const std::vector<float>& b)
+{
+    return a.size() == b.size() && std::memcmp (a.data(), b.data(), a.size() * sizeof (float)) == 0;
+}
+} // namespace perf190kg
+
+TEST (perf190kg_delay_renders_round_190ie_bit_for_bit)
+{
+    using namespace perf190kg;
+    constexpr double pi = 3.14159265358979323846;
+    // tempo laws (BPM at a block's start, of n samples): steady, ramp, the perf project's wave, a step, and a very fast
+    // wave whose 1/16 lines are shorter than a chunk (2,000 … 30,000 BPM: 88 … 6 samples at 44.1 kHz)
+    const auto tempo = [&] (int law, int at, int n) {
+        const double f = (double) at / (double) n;
+        switch (law)
+        {
+            case 1: return 120.0 + 20.0 * f;
+            case 2: return 122.0 + 4.0 * std::sin (2 * pi * 3.0 * f);
+            case 3: return f < 0.5 ? 120.0 : 97.0;
+            case 4: return 16000.0 + 14000.0 * std::sin (2 * pi * 2.0 * f);
+            default: return 120.0;
+        }
+    };
+    int cases = 0, same = 0;
+    for (const double rate : { 44100.0, 96000.0 })
+        for (const int block : { 37, 64, 128, 200 })
+            for (int law = 0; law < 5; ++law)
+                for (int variant = 0; variant < 4; ++variant)
+                {
+                    auto slot = lynx::makeEffectSlot (lynx::EffectKind::delay);
+                    slot.params[0] = variant == 1 ? 0.0f : variant == 2 ? 0.9f : 0.4f;   // 1/16, 1 bar, 1/4 dot.
+                    slot.params[1] = variant == 3 ? 0.98f : 0.6f;                        // feedback
+                    slot.params[2] = 0.5f;                                               // mix
+                    slot.params[3] = variant == 1 || variant == 3 ? 1.0f : 0.0f;         // ping-pong
+                    slot.params[4] = variant == 2 ? 0.0f : 0.45f;                        // damping
+                    auto fx = lynx::makeEffect (slot);
+                    CHECK (fx != nullptr);
+                    if (fx == nullptr)
+                        return;
+                    fx->prepare (rate);
+                    Delay190ie ref (rate);
+                    const int n = (int) (1.6 * rate);
+                    std::vector<float> l ((std::size_t) n), r ((std::size_t) n);
+                    for (int i = 0; i < n; ++i)
+                    {
+                        const auto t = i / rate;
+                        const auto gate = (i % (int) (0.4 * rate)) < (int) (0.15 * rate) ? 1.0 : 0.0;
+                        l[(std::size_t) i] = (float) (gate * 0.3 * std::sin (2 * pi * 330.0 * t));
+                        r[(std::size_t) i] = (float) (gate * 0.25 * std::sin (2 * pi * 440.0 * t + 0.3));
+                    }
+                    auto refL = l, refR = r;
+                    auto params = slot.params;
+                    for (int at = 0; at < n; at += block)
+                    {
+                        const int len = std::min (block, n - at);
+                        if (variant == 0 && at >= n / 2 && at - block < n / 2)
+                            params[0] = 0.6f; // a Time knob move: the new length at once
+                        const auto bpm = tempo (law, at, n);
+                        fx->process (l.data() + at, r.data() + at, len, params, bpm);
+                        ref.process (refL.data() + at, refR.data() + at, len, params, bpm);
+                    }
+                    ++cases;
+                    if (sameBits (l, refL) && sameBits (r, refR))
+                        ++same;
+                    else
+                        std::printf ("  Delay differs from round 190ie's loop: %.0f Hz, block %d, tempo law %d, variant %d\n", rate, block, law, variant);
+                }
+    std::printf ("  basic Delay vs round 190ie's loop: %d / %d renders bit-identical\n", same, cases);
+    CHECK (same == cases);
+}

+ 1 - 0
tests/tests.cpp

@@ -17840,6 +17840,7 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "Simple190jcTests.inc" // round 190jc: the Simple layout's BandLab / FLM look (design190ia slices 5, 14, 15, 22, 24)
 #include "Rollup030Tests.inc" // round 190il: semantic interactions of the 0.1.30 rollup (keep last)
 #include "Bug190ieTests.inc" // round 190ie (issue #185: tempo automation through the basic Delay)
+#include "Perf190kgTests.inc" // round 190kg: the basic Delay's faster loops render round 190ie's samples bit for bit
 #include "PerfGate190idTests.inc" // round perfgate190id: the performance gate's synthetic projects (community slice B12)
 #include "Details190ihTests.inc" // round 190ih: DETAILS slices R2, R3, R4, R7, R9, R12, R14
 #include "Rackmix190ioTests.inc" // round 190io: FL rack + Mixer landmarks, Mixer details, issue #154 part 2