Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio: Module adapter: Add a new simple copy function #7792

Merged

Conversation

singalsu
Copy link
Collaborator

This patch adds a simplified version of simple copy for module adapter clients with one source and one sink. The overhead of discovering multiple source and sink buffers is avoided.

The module_adapter_bind() and module_adapter_unbind() functions are changed to detect multiple sources or sinks condition to control the used simple copy function.

@singalsu singalsu force-pushed the main_module_adapter_very_simple_copy branch from 92020c5 to 6ab77b6 Compare June 13, 2023 09:19
src/audio/module_adapter/module_adapter.c Outdated Show resolved Hide resolved
src/audio/module_adapter/module_adapter.c Outdated Show resolved Hide resolved
src/audio/module_adapter/module_adapter.c Outdated Show resolved Hide resolved
src/audio/module_adapter/module_adapter.c Outdated Show resolved Hide resolved
src/audio/module_adapter/module_adapter.c Outdated Show resolved Hide resolved
src/audio/module_adapter/module_adapter.c Outdated Show resolved Hide resolved
src/audio/module_adapter/module_adapter.c Outdated Show resolved Hide resolved
@singalsu singalsu requested review from abonislawski and removed request for abonislawski June 14, 2023 15:35
@singalsu singalsu force-pushed the main_module_adapter_very_simple_copy branch from 6ab77b6 to 571e207 Compare June 14, 2023 16:02
@singalsu singalsu requested a review from lyakh June 14, 2023 16:09
src/audio/module_adapter/module_adapter.c Outdated Show resolved Hide resolved
src/audio/module_adapter/module_adapter.c Outdated Show resolved Hide resolved
src/audio/module_adapter/module_adapter.c Outdated Show resolved Hide resolved
@singalsu singalsu force-pushed the main_module_adapter_very_simple_copy branch 2 times, most recently from da4ef1f to 510d4a7 Compare June 15, 2023 11:31
@ranj063
Copy link
Collaborator

ranj063 commented Jun 15, 2023

SOFCI TEST

@singalsu singalsu force-pushed the main_module_adapter_very_simple_copy branch from 510d4a7 to 5193101 Compare June 20, 2023 10:57
@singalsu
Copy link
Collaborator Author

The saving with this rebased pipeline2.0 adapted patch is 3.4 MCPS from sum of 10s playback average numbers

                            Name,        Mtrace id, avg MCPS, max MCPS
            host-copier.0.playback,   comp:0 0x40000,     3.39,    11.42
                          gain.1.1,   comp:0 0x60000,     3.28,     9.11
                         mixin.1.1,   comp:0 0x20000,     3.27,     3.45
                        mixout.2.1,   comp:1 0x30000,     2.59,     3.31
                          gain.2.1,   comp:1 0x60001,     3.37,    16.81
    dai-copier.HDA.Analog.playback,   comp:1 0x40001,     4.04,     4.28
                                  ,                 ,    19.95,    48.39

                              Name,        Mtrace id, avg MCPS, max MCPS
            host-copier.0.playback,   comp:0 0x40000,     3.40,     6.89
                          gain.1.1,   comp:0 0x60000,     2.34,     8.22
                         mixin.1.1,   comp:0 0x20000,     2.54,     2.64
                        mixout.2.1,   comp:1 0x30000,     1.74,     2.33
                          gain.2.1,   comp:1 0x60001,     2.44,     8.48
    dai-copier.HDA.Analog.playback,   comp:1 0x40001,     4.13,     4.51
                                  ,                 ,    16.60,    33.06

Copy link
Contributor

@marcinszkudlinski marcinszkudlinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather minor - just propositions for new names, no pushing. Just please don't use sink/source :)

@@ -184,6 +184,8 @@ struct processing_module {
struct output_stream_buffer *output_buffers;
uint32_t num_input_buffers; /**< number of input buffers */
uint32_t num_output_buffers; /**< number of output buffers */
struct comp_buffer *source; /**< single source buffer for multi_source_or_sink = false */
Copy link
Contributor

@marcinszkudlinski marcinszkudlinski Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't call it sink/source - may be confusions with struct sof_source / struct sof_sink interface

struct comp_buffer *source_comp_buffer;

or simiar

/* False for module with one sink and one source to reduce module processing
* overhead. True if multiple source or sink buffers.
*/
bool multi_source_or_sink;
Copy link
Contributor

@marcinszkudlinski marcinszkudlinski Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool simple_1_1_copy ?
to be consistent with module_adapter_audio_stream_copy_1to1 that is called when true

@singalsu singalsu force-pushed the main_module_adapter_very_simple_copy branch from 5193101 to e5bf8ca Compare June 21, 2023 11:07
@singalsu
Copy link
Collaborator Author

The PR is updated according to @marcinszkudlinski 's proposals. The boolean is inverted with new name mod->stream_copy_single_to_single .

Copy link
Collaborator

@lyakh lyakh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a couple of very minor comments

} else {
mod->source_comp_buffer = NULL;
mod->sink_comp_buffer = NULL;
mod->stream_copy_single_to_single = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.stream_copy_1to1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking 1to1 looks too much like 1:1 that would give wrong impression about doing just memcpy() from buffer to buffer.

if (mod->input_buffers[0].consumed)
audio_stream_consume(&source_c->stream, mod->input_buffers[0].consumed);

/* produce data into all active output buffers */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's just one output buffer, right?

@singalsu singalsu force-pushed the main_module_adapter_very_simple_copy branch from e5bf8ca to 7b1ed0a Compare June 22, 2023 09:50
@singalsu
Copy link
Collaborator Author

Previous CI round 43 successful and 2 failing checks, failed Internal Intel CI System/merge/build with West, failed
sof-ci/jenkins/pr-device-test/main-cavs2.5 with multiple suspend resume. New try...

@singalsu singalsu force-pushed the main_module_adapter_very_simple_copy branch 2 times, most recently from 2f88a2f to c23b13b Compare June 22, 2023 16:56
Copy link
Contributor

@btian1 btian1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems Ranjani trying other method with your PR for #7850 #7858
This one should be fine for merge.

Just one concern, all our optimization is trying to figure out special case and use specific function to handle it, this have benefit for this special case, however, it does increase performance for worst case and code size, I am not clear why COE team must get those module performance low for this, if there is no low power(38.4mhz)mode, it is not must for handle module with multiple routines.

@singalsu singalsu force-pushed the main_module_adapter_very_simple_copy branch from c23b13b to 97ad7fd Compare June 26, 2023 08:21
@singalsu
Copy link
Collaborator Author

seems Ranjani trying other method with your PR for #7850 #7858 This one should be fine for merge.

Just one concern, all our optimization is trying to figure out special case and use specific function to handle it, this have benefit for this special case, however, it does increase performance for worst case and code size, I am not clear why COE team must get those module performance low for this, if there is no low power(38.4mhz)mode, it is not must for handle module with multiple routines.

The previous version did not not enable the optimization, now it's using fix by @ranj063 to get the bind/unbind code to work correctly.

Yes, this is a best case optimization. But it's quite common that components have only one source and and one sink so I think this is worth it. It will be even better when pipeline 2.x let's components have linear shared buffers. Since this is small add there is not much code size overhead and it can be cleaned up when the shared buffers work is ready.

@singalsu singalsu force-pushed the main_module_adapter_very_simple_copy branch from 97ad7fd to fd7c5ad Compare June 26, 2023 13:09
This patch adds a simplified version of audio stream copy for
module adapter clients with one source and one sink. The overhead
of discovering multiple source and sink buffers is avoided.

The module_adapter_bind() and module_adapter_unbind() functions
are changed to detect multiple sources or sinks condition
to control the used simple copy function. The mod->source and
mod->sink pointers to buffers are updated when there's only
one source and sink.

Signed-off-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Seppo Ingalsuo <[email protected]>
@singalsu singalsu force-pushed the main_module_adapter_very_simple_copy branch from fd7c5ad to d9a6491 Compare June 26, 2023 15:26
@singalsu
Copy link
Collaborator Author

42 successful and 3 failing checks

  • Zephyr / build-linux (zmain, imx8 imx8x imx8m) (pull_request)
  • sof-ci/jenkins/pr-device-test/main-ace --> verify-kernel-boot-log.sh, check-pause-resume-capture-100.sh
  • sof-ci/jenkins/pr-device-test/main-cavs2.5 --> check-suspend-resume-5.sh

@singalsu
Copy link
Collaborator Author

SOFCI TEST

@singalsu
Copy link
Collaborator Author

Now 43 successful and 2 failing checks

  • Zephyr / build-linux (zmain, imx8 imx8x imx8m)
  • sof-ci/jenkins/pr-device-test/main-cavs2.5 --> check-suspend-resume-with-playback.sh timeout

@singalsu
Copy link
Collaborator Author

SOFCI TEST

2 similar comments
@ranj063
Copy link
Collaborator

ranj063 commented Jun 27, 2023

SOFCI TEST

@singalsu
Copy link
Collaborator Author

SOFCI TEST

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @singalsu , looks good now!

@kv2019i kv2019i dismissed marcinszkudlinski’s stale review June 28, 2023 10:42

Marcin's comments have been addressed and he's not available for re-review this week

@kv2019i
Copy link
Collaborator

kv2019i commented Jun 28, 2023

https://sof-ci.01.org/sofpr/PR7792/build10174/devicetest/index.html looks a bit worrisome. I went though all the failures (verify-kernel-bootlog, check-runtime-pm-status , multiple-pipeline-capture ) and all are failures of #7482 , IOW with MOD_SET_DX failing. I'm going to proceed and merge this, but we need to raise attention to #7482 .

@kv2019i kv2019i merged commit ee6eb1b into thesofproject:main Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants