sof icon indicating copy to clipboard operation
sof copied to clipboard

[FEATURE] Optimize audio processing components' source/sink buffer access, deprecate read/write frag

Open singalsu opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe. Yes, audio_stream_read_frag_sXX() and audio_stream_write_frag_sXX() cause high processing load due to their check for circular buffer wrap for every PCM sample. E.g. in stereo mixer case the overhead from those functions was 30 MCPS in CML cAVS platform.

Describe the solution you'd like Access buffers in max. size blocks before buffers circular wrap, check wrap, and continue with next blob. The function audio_stream_bytes_without_wrap() has only a small overhead and typically is needed only a couple of times per copy() period.

Describe alternatives you've considered Implement processing access to buffers with Xtensa circular buffers. This is an alternative that is already used in several components. However block processing could be still more efficient in algorithms with a straightforward buffer copy data traffic. It is due to only single HW circular buffer access at time. There's need to set the begin and end registers every time the buffer to access changes. There are also align requirements for data in HW circular buffers to take care about.

Additional context Components those use read/write frag are here initially assumed some optimize priority. I assumed priority is high if topologies contain several instances of the component. Medium priority for single instance, low priority for test or demo components. All components in key phrase detection are high priority due low xtal oscillator use as DSP clock and low MCPS available.

  • Crossover (medium)
  • DC blocker (medium, fix in PR #5871)
  • DRC (medium, fix in PR #5489)
  • EQ FIR (medium, fix in PR #5339)
  • EQ IIR (high, fix in PR #4940)
  • EQ IIR pass-through (medium, fix in PR #5333)
  • IGO NR (medium)
  • KBP (high, fix in PR #5049)
  • Mixer (high, fix in PR #4944)
  • Multi-band DRC (medium, fix in PR #5511)
  • PCM converter generic (high, fix in PR #5019)
  • Selector (high, fix in PR #5053)
  • Smart amp generic (medium)
  • Smart amp Maxim DSM (medium)
  • TDFB (medium, PR in #5351)
  • Volume zero-crossings detect mode (medium, PR in #5328)
  • Volume generic (low, fix in PR #5300)
  • Google RTC audio processing (medium, fix in PR #5579)

Other

  • Components in samples, detect test, smart amp test, kwd nn test (low)
  • Testbench (low)
  • Cmocka (low)

singalsu avatar Nov 05 '21 10:11 singalsu

Changed IGO optimize priority to high (see issue #4970).

singalsu avatar Nov 09 '21 08:11 singalsu

PCM converter generic (high) - pls do this next.

lgirdwood avatar Nov 18 '21 16:11 lgirdwood

Next ones to optimize are KBP and Selector, unless other requested.

singalsu avatar Dec 01 '21 17:12 singalsu

This issue can be closed. All components are now updated.

singalsu avatar Apr 25 '24 07:04 singalsu