Skip to content

Audio: Volume: Add HiFi5 implementation. - #9419

Merged
kv2019i merged 2 commits into
thesofproject:mainfrom
singalsu:volume_hifi5_rebase
Oct 31, 2024
Merged

kv2019i merged 2 commits into
thesofproject:mainfrom
singalsu:volume_hifi5_rebase

Conversation

@singalsu

Copy link
Copy Markdown
Collaborator

Add HiFi5 implementation of volume functions, compared with HiFi3 version, can reduce about 28% cycles.

@singalsu

singalsu commented Aug 29, 2024 •

Copy link
Copy Markdown
Collaborator Author

This is a new merge conflicts fixed version of Andrula's #8900. I've run this successfully in testbench HiFi5 environment with 48 kHz and 44.1 kHz rates with s16 and s32 formats. Though testbench is currently IPC3, so the test didn't exercise IPC4 code parts.

Comment thread src/audio/volume/volume.c Outdated
Comment on lines 651 to 654

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this come from Kconfig ?
i.e. The selection of HiFi3, HIFI4, HIFI5, AVX etc would set a generic CONFIG_FRAME_BYTE_ALIGN macro that could be used everywhere ?

@singalsu
singalsu force-pushed the volume_hifi5_rebase branch from 9e4ec96 to 394c08d Compare October 28, 2024 15:57
Comment thread src/audio/volume/volume.c Outdated

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@lgirdwood I don't remember from where this align requirement for 6ch comes from. There was no discussion that I could find for it in #5266. Is it specific to peakvolume or generic for loading/storing the format in 64 bit or 128 bit chunks. If internal to peakvolume, then this SOF_FRAME_BYTE_ALIGN_6CH in common.h would make no sense.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

6ch is 5.1 via display port.

@singalsu
singalsu force-pushed the volume_hifi5_rebase branch from 394c08d to 69e2d33 Compare October 28, 2024 16:06
Comment thread src/include/sof/common.h Outdated

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

or 1?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this is bytes we should state in the comments next to the definition. Should never be 1 if bytes.

@singalsu singalsu Oct 29, 2024 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think one is the default if it's not set to be free to provide any number of frames, but it makes no sense as align constraint. Also Above I think the #if SOF_MAX_XCHAL_HIFI == NONE could be left out as redundant. These could be before this a macros section for SSE or AVX specific definitions.

Comment thread src/include/sof/common.h Outdated

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll move this 6ch specific definition into volume, I can't see generally how 6ch alignement would be a special case. Every word length, channels count has some number of frames that is not matching align with 8 or 16 bytes / 64 or 128 bits.

Comment thread src/audio/volume/volume.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

maybe we can converge one way or another - with or without a space in "HiFi.N"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yep, changing to without space.

Comment thread src/audio/volume/volume_hifi5.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this loop can be replaced with a single memcpy() and you've found out that the loop is faster?.. Interesting, then we have a problem with our memcpy()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It was a finding by Andrula that I haven't verified.

Comment thread src/audio/volume/volume_hifi5.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

although it looks like it wouldn't be a single memcpy(), but a loop of them. So you actually mean that 4 assignments are faster than a memcpy()? That would be logical

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I can remove the comment to avoid it to confuse. It's most of use cases just two channels. Especially with recommended memcpy_s() there is more overhead.

Comment thread src/audio/volume/volume_hifi5.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is this really supposed to be a doxygen comment? More below

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in next version

Comment thread src/audio/volume/volume_hifi5.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"once?" Did you mean "per iteration?"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yep

@singalsu
singalsu force-pushed the volume_hifi5_rebase branch from 69e2d33 to 07df9a2 Compare October 29, 2024 09:25
@thesofproject thesofproject deleted a comment from lyakh Oct 29, 2024
@singalsu
singalsu force-pushed the volume_hifi5_rebase branch from 07df9a2 to 5b345b7 Compare October 29, 2024 10:13
@singalsu
singalsu marked this pull request as ready for review October 29, 2024 10:19

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Only minor notes, looks good!

Comment thread src/audio/volume/volume.h Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Comment says "PCM samples" which is a bit misleading as this is alignment in bytes (as tge define name says, FRAME_BYTE).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oops yes, it looks quite confusing.

Comment thread src/audio/volume/volume_hifi5.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

typo: adsress

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yep

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I added commit to fix same typos in HiFi3 and HiFi4 versions.

andrula-song and others added 2 commits October 29, 2024 15:47
Add HiFi5 implementation of volume functions, compared with
HiFi3 version, can reduce about 28% cycles.

Signed-off-by: Andrula Song <[email protected]>
Signed-off-by: Seppo Ingalsuo <[email protected]>
Changed adsress -> address, also the comments are edited to avoid
to be mistaken as Doxygen.

Signed-off-by: Seppo Ingalsuo <[email protected]>
@singalsu
singalsu force-pushed the volume_hifi5_rebase branch from 5b345b7 to 1050ffc Compare October 29, 2024 13:50
@singalsu
singalsu requested a review from lyakh October 30, 2024 08:45
@kv2019i

kv2019i commented Oct 31, 2024

Copy link
Copy Markdown
Collaborator

@kv2019i
kv2019i merged commit 2f4efa5 into thesofproject:main Oct 31, 2024
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