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: volume: disable HIFI4 optimizations #9208

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

gbernatxintel
Copy link
Contributor

@gbernatxintel gbernatxintel commented Jun 7, 2024

HIFI4 has been disabled. HIFI3 is being used for
the volume component with peakVol.

There was a problem with test
test_01_09_peakvol_quality[44100Hz_16in16bit_1ch-0].
The main problem was with frequencies: 11025,
22050, 44100, 88200, 176400 Hz.
Because frame is different for these frequencies. For f=44100Hz
frame is equal 44 or 45. Some of the samples were simply not processed.

Changes to HIFI4 are not-trivial and failed to fix the problem.
However, HIFI3 is fully compatible and works properly.
Performance is worse by 1-2,5% in CPU cycle usage
but no glitches appear and all samples are processed correctly.

Signed-off-by: Grzegorz Bernat grzegorzx.bernat@intel.com

@gbernatxintel
Copy link
Contributor Author

Below are the performance test logs. In the situation where we are using HIFI4 and HIFI3. The 5 tests were conducted for each module.

HIFI4
component: comp_copy: comp:0 0x5 perf comp_copy samples 48 period 1000 cpu avg 4032 peak 4790 9
component: comp_copy: comp:0 0x5 perf comp_copy samples 48 period 1000 cpu avg 4067 peak 5882 11
component: comp_copy: comp:0 0x5 perf comp_copy samples 48 period 1000 cpu avg 4008 peak 4888 0
component: comp_copy: comp:0 0x5 perf comp_copy samples 48 period 1000 cpu avg 4070 peak 9284 2
component: comp_copy: comp:0 0x5 perf comp_copy samples 48 period 1000 cpu avg 4052 peak 4696 1

HIFI3
component: comp_copy: comp:0 0x5 perf comp_copy samples 48 period 1000 cpu avg 4139 peak 4614 789
component: comp_copy: comp:0 0x5 perf comp_copy samples 48 period 1000 cpu avg 4133 peak 4830 0
component: comp_copy: comp:0 0x5 perf comp_copy samples 48 period 1000 cpu avg 4138 peak 4678 1
component: comp_copy: comp:0 0x5 perf comp_copy samples 48 period 1000 cpu avg 4194 peak 4832 0
component: comp_copy: comp:0 0x5 perf comp_copy samples 48 period 1000 cpu avg 4159 peak 4594 0

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

@gbernatxintel can you also log a bug for HiFi4. @singalsu fyi.

@gbernatxintel
Copy link
Contributor Author

@gbernatxintel can you also log a bug for HiFi4. @singalsu fyi.

@lgirdwood Added bug, #9213

@lgirdwood lgirdwood added this to the v2.10 milestone Jun 10, 2024
@singalsu
Copy link
Collaborator

@gbernatxintel This needs a patch for stable-v2.10 too

@lgirdwood
Copy link
Member

@gbernatxintel any idea why the build for MTL would fail with a missing hifi3 header ? LNL builds fine

ccache /home/cwd_user/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/xtensa-intel_ace15_mtpm_zephyr-elf-gcc -DCC_OPTIMIZE_FLAGS=\"-O2\" -DKERNEL -DK_HEAP_MEM_POOL_SIZE=8192 -DXCC_TOOLS_VERSION=\"zephyr\" -D__ZEPHYR__=1 -DRELATIVE_FILE=\"../sof/src/audio/volume/volume_hifi3_with_peakvol.c\" -I/zep_workspace/build-mtl/zephyr/include/generated/zephyr -I/zep_workspace/zephyr/include -I/zep_workspace/build-mtl/zephyr/include/generated -I/zep_workspace/zephyr/soc/intel/intel_adsp -I/zep_workspace/zephyr/soc/intel/intel_adsp/common -I/zep_workspace/zephyr/soc/intel/intel_adsp/common/include -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace/include -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace/include/ace15_mtpm -I/zep_workspace/zephyr/drivers -I/zep_workspace/sof/zephyr/include -I/zep_workspace/sof/src/platform/intel/ace/include -I/zep_workspace/sof/src/platform/meteorlake/include -I/zep_workspace/sof/src/include/sof/audio/module_adapter/iadk -I/zep_workspace/sof/src/include/sof/audio/module_adapter/library -I/zep_workspace/modules/hal/xtensa/include -I/zep_workspace/modules/hal/xtensa/XTENSA_HAL -I/zep_workspace/modules/hal/xtensa/zephyr/soc/intel_ace15_mtpm -I/zep_workspace/sof/tools/rimage/src/include -I/zep_workspace/sof/src/include -I/zep_workspace/sof/src/arch/xtensa/include -I/zep_workspace/sof/third_party/include -I/zep_workspace/sof/xtos/include -isystem /zep_workspace/zephyr/lib/libc/minimal/include -isystem /zep_workspace/zephyr/lib/libc/common/include -isystem /opt/toolchains/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/../lib/gcc/xtensa-intel_ace15_mtpm_zephyr-elf/12.2.0/include -isystem /opt/toolchains/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/../lib/gcc/xtensa-intel_ace15_mtpm_zephyr-elf/12.2.0/include-fixed -fno-strict-aliasing -O2 -imacros /zep_workspace/build-mtl/zephyr/include/generated/zephyr/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always --sysroot=/home/cwd_user/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/xtensa-intel_ace15_mtpm_zephyr-elf -imacros /zep_workspace/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -Werror -fno-asynchronous-unwind-tables -fstrict-overflow -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/zep_workspace/sof/app=CMAKE_SOURCE_DIR -fmacro-prefix-map=/zep_workspace/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/zep_workspace=WEST_TOPDIR -ffunction-sections -fdata-sections -mlongcalls -DXTENSA_TOOLCHAIN_VARIANT=1 -std=c99 -nostdinc -std=gnu99 -MD -MT modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj -MF modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj.d -o modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj -c /zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c
/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c:28:10: fatal error: xtensa/tie/xt_hifi3.h: No such file or directory
   28 | #include <xtensa/tie/xt_hifi3.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[271/429] Building C object modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_generic_with_peakvol.c.obj

@gbernatxintel
Copy link
Contributor Author

@gbernatxintel any idea why the build for MTL would fail with a missing hifi3 header ? LNL builds fine

ccache /home/cwd_user/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/xtensa-intel_ace15_mtpm_zephyr-elf-gcc -DCC_OPTIMIZE_FLAGS=\"-O2\" -DKERNEL -DK_HEAP_MEM_POOL_SIZE=8192 -DXCC_TOOLS_VERSION=\"zephyr\" -D__ZEPHYR__=1 -DRELATIVE_FILE=\"../sof/src/audio/volume/volume_hifi3_with_peakvol.c\" -I/zep_workspace/build-mtl/zephyr/include/generated/zephyr -I/zep_workspace/zephyr/include -I/zep_workspace/build-mtl/zephyr/include/generated -I/zep_workspace/zephyr/soc/intel/intel_adsp -I/zep_workspace/zephyr/soc/intel/intel_adsp/common -I/zep_workspace/zephyr/soc/intel/intel_adsp/common/include -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace/include -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace/include/ace15_mtpm -I/zep_workspace/zephyr/drivers -I/zep_workspace/sof/zephyr/include -I/zep_workspace/sof/src/platform/intel/ace/include -I/zep_workspace/sof/src/platform/meteorlake/include -I/zep_workspace/sof/src/include/sof/audio/module_adapter/iadk -I/zep_workspace/sof/src/include/sof/audio/module_adapter/library -I/zep_workspace/modules/hal/xtensa/include -I/zep_workspace/modules/hal/xtensa/XTENSA_HAL -I/zep_workspace/modules/hal/xtensa/zephyr/soc/intel_ace15_mtpm -I/zep_workspace/sof/tools/rimage/src/include -I/zep_workspace/sof/src/include -I/zep_workspace/sof/src/arch/xtensa/include -I/zep_workspace/sof/third_party/include -I/zep_workspace/sof/xtos/include -isystem /zep_workspace/zephyr/lib/libc/minimal/include -isystem /zep_workspace/zephyr/lib/libc/common/include -isystem /opt/toolchains/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/../lib/gcc/xtensa-intel_ace15_mtpm_zephyr-elf/12.2.0/include -isystem /opt/toolchains/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/../lib/gcc/xtensa-intel_ace15_mtpm_zephyr-elf/12.2.0/include-fixed -fno-strict-aliasing -O2 -imacros /zep_workspace/build-mtl/zephyr/include/generated/zephyr/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always --sysroot=/home/cwd_user/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/xtensa-intel_ace15_mtpm_zephyr-elf -imacros /zep_workspace/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -Werror -fno-asynchronous-unwind-tables -fstrict-overflow -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/zep_workspace/sof/app=CMAKE_SOURCE_DIR -fmacro-prefix-map=/zep_workspace/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/zep_workspace=WEST_TOPDIR -ffunction-sections -fdata-sections -mlongcalls -DXTENSA_TOOLCHAIN_VARIANT=1 -std=c99 -nostdinc -std=gnu99 -MD -MT modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj -MF modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj.d -o modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj -c /zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c
/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c:28:10: fatal error: xtensa/tie/xt_hifi3.h: No such file or directory
   28 | #include <xtensa/tie/xt_hifi3.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[271/429] Building C object modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_generic_with_peakvol.c.obj

You're right, overall it can't be set up that way. I am just analyzing how it should be changed, because there was already a discussion once if we wanted to do a HIFI downgrade for the platform

#8682

@singalsu
Copy link
Collaborator

@gbernatxintel any idea why the build for MTL would fail with a missing hifi3 header ? LNL builds fine

ccache /home/cwd_user/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/xtensa-intel_ace15_mtpm_zephyr-elf-gcc -DCC_OPTIMIZE_FLAGS=\"-O2\" -DKERNEL -DK_HEAP_MEM_POOL_SIZE=8192 -DXCC_TOOLS_VERSION=\"zephyr\" -D__ZEPHYR__=1 -DRELATIVE_FILE=\"../sof/src/audio/volume/volume_hifi3_with_peakvol.c\" -I/zep_workspace/build-mtl/zephyr/include/generated/zephyr -I/zep_workspace/zephyr/include -I/zep_workspace/build-mtl/zephyr/include/generated -I/zep_workspace/zephyr/soc/intel/intel_adsp -I/zep_workspace/zephyr/soc/intel/intel_adsp/common -I/zep_workspace/zephyr/soc/intel/intel_adsp/common/include -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace/include -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace/include/ace15_mtpm -I/zep_workspace/zephyr/drivers -I/zep_workspace/sof/zephyr/include -I/zep_workspace/sof/src/platform/intel/ace/include -I/zep_workspace/sof/src/platform/meteorlake/include -I/zep_workspace/sof/src/include/sof/audio/module_adapter/iadk -I/zep_workspace/sof/src/include/sof/audio/module_adapter/library -I/zep_workspace/modules/hal/xtensa/include -I/zep_workspace/modules/hal/xtensa/XTENSA_HAL -I/zep_workspace/modules/hal/xtensa/zephyr/soc/intel_ace15_mtpm -I/zep_workspace/sof/tools/rimage/src/include -I/zep_workspace/sof/src/include -I/zep_workspace/sof/src/arch/xtensa/include -I/zep_workspace/sof/third_party/include -I/zep_workspace/sof/xtos/include -isystem /zep_workspace/zephyr/lib/libc/minimal/include -isystem /zep_workspace/zephyr/lib/libc/common/include -isystem /opt/toolchains/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/../lib/gcc/xtensa-intel_ace15_mtpm_zephyr-elf/12.2.0/include -isystem /opt/toolchains/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/../lib/gcc/xtensa-intel_ace15_mtpm_zephyr-elf/12.2.0/include-fixed -fno-strict-aliasing -O2 -imacros /zep_workspace/build-mtl/zephyr/include/generated/zephyr/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always --sysroot=/home/cwd_user/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/xtensa-intel_ace15_mtpm_zephyr-elf -imacros /zep_workspace/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -Werror -fno-asynchronous-unwind-tables -fstrict-overflow -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/zep_workspace/sof/app=CMAKE_SOURCE_DIR -fmacro-prefix-map=/zep_workspace/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/zep_workspace=WEST_TOPDIR -ffunction-sections -fdata-sections -mlongcalls -DXTENSA_TOOLCHAIN_VARIANT=1 -std=c99 -nostdinc -std=gnu99 -MD -MT modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj -MF modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj.d -o modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj -c /zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c
/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c:28:10: fatal error: xtensa/tie/xt_hifi3.h: No such file or directory
   28 | #include <xtensa/tie/xt_hifi3.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[271/429] Building C object modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_generic_with_peakvol.c.obj

You're right, overall it can't be set up that way. I am just analyzing how it should be changed, because there was already a discussion once if we wanted to do a HIFI downgrade for the platform

#8682

But the build for lnl worked. Is it a problem in the CI host xcc install?

@lgirdwood
Copy link
Member

But the build for lnl worked. Is it a problem in the CI host xcc install?

@marc-hb @fredoh9 @ssavati can someone check the tooling here ? Looks like we may have an incomplete xtensa compiler installation. Thanks !

@gbernatxintel
Copy link
Contributor Author

@gbernatxintel any idea why the build for MTL would fail with a missing hifi3 header ? LNL builds fine

ccache /home/cwd_user/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/xtensa-intel_ace15_mtpm_zephyr-elf-gcc -DCC_OPTIMIZE_FLAGS=\"-O2\" -DKERNEL -DK_HEAP_MEM_POOL_SIZE=8192 -DXCC_TOOLS_VERSION=\"zephyr\" -D__ZEPHYR__=1 -DRELATIVE_FILE=\"../sof/src/audio/volume/volume_hifi3_with_peakvol.c\" -I/zep_workspace/build-mtl/zephyr/include/generated/zephyr -I/zep_workspace/zephyr/include -I/zep_workspace/build-mtl/zephyr/include/generated -I/zep_workspace/zephyr/soc/intel/intel_adsp -I/zep_workspace/zephyr/soc/intel/intel_adsp/common -I/zep_workspace/zephyr/soc/intel/intel_adsp/common/include -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace/include -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace/include/ace15_mtpm -I/zep_workspace/zephyr/drivers -I/zep_workspace/sof/zephyr/include -I/zep_workspace/sof/src/platform/intel/ace/include -I/zep_workspace/sof/src/platform/meteorlake/include -I/zep_workspace/sof/src/include/sof/audio/module_adapter/iadk -I/zep_workspace/sof/src/include/sof/audio/module_adapter/library -I/zep_workspace/modules/hal/xtensa/include -I/zep_workspace/modules/hal/xtensa/XTENSA_HAL -I/zep_workspace/modules/hal/xtensa/zephyr/soc/intel_ace15_mtpm -I/zep_workspace/sof/tools/rimage/src/include -I/zep_workspace/sof/src/include -I/zep_workspace/sof/src/arch/xtensa/include -I/zep_workspace/sof/third_party/include -I/zep_workspace/sof/xtos/include -isystem /zep_workspace/zephyr/lib/libc/minimal/include -isystem /zep_workspace/zephyr/lib/libc/common/include -isystem /opt/toolchains/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/../lib/gcc/xtensa-intel_ace15_mtpm_zephyr-elf/12.2.0/include -isystem /opt/toolchains/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/../lib/gcc/xtensa-intel_ace15_mtpm_zephyr-elf/12.2.0/include-fixed -fno-strict-aliasing -O2 -imacros /zep_workspace/build-mtl/zephyr/include/generated/zephyr/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always --sysroot=/home/cwd_user/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/xtensa-intel_ace15_mtpm_zephyr-elf -imacros /zep_workspace/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -Werror -fno-asynchronous-unwind-tables -fstrict-overflow -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/zep_workspace/sof/app=CMAKE_SOURCE_DIR -fmacro-prefix-map=/zep_workspace/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/zep_workspace=WEST_TOPDIR -ffunction-sections -fdata-sections -mlongcalls -DXTENSA_TOOLCHAIN_VARIANT=1 -std=c99 -nostdinc -std=gnu99 -MD -MT modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj -MF modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj.d -o modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj -c /zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c
/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c:28:10: fatal error: xtensa/tie/xt_hifi3.h: No such file or directory
   28 | #include <xtensa/tie/xt_hifi3.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[271/429] Building C object modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_generic_with_peakvol.c.obj

You're right, overall it can't be set up that way. I am just analyzing how it should be changed, because there was already a discussion once if we wanted to do a HIFI downgrade for the platform
#8682

But the build for lnl worked. Is it a problem in the CI host xcc install?

someone check the tooling here ? Looks like we may have an incomplete xtensa compiler installation. Thanks !

Precisely according to me it is not a problem of the compiler.
The problem is that in the platform config VOLUME_HIFI3 is rigidly enabled. Well, and the same config takes to build the project using gcc. Generally it needs to be changed so that MAX_HIFI indicates for VOLUME_HIFI -> 3 when HIFI is available and HIFI_NONE when not.

@lgirdwood
Copy link
Member

@gbernatxintel any idea why the build for MTL would fail with a missing hifi3 header ? LNL builds fine

ccache /home/cwd_user/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/xtensa-intel_ace15_mtpm_zephyr-elf-gcc -DCC_OPTIMIZE_FLAGS=\"-O2\" -DKERNEL -DK_HEAP_MEM_POOL_SIZE=8192 -DXCC_TOOLS_VERSION=\"zephyr\" -D__ZEPHYR__=1 -DRELATIVE_FILE=\"../sof/src/audio/volume/volume_hifi3_with_peakvol.c\" -I/zep_workspace/build-mtl/zephyr/include/generated/zephyr -I/zep_workspace/zephyr/include -I/zep_workspace/build-mtl/zephyr/include/generated -I/zep_workspace/zephyr/soc/intel/intel_adsp -I/zep_workspace/zephyr/soc/intel/intel_adsp/common -I/zep_workspace/zephyr/soc/intel/intel_adsp/common/include -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace/include -I/zep_workspace/zephyr/soc/intel/intel_adsp/ace/include/ace15_mtpm -I/zep_workspace/zephyr/drivers -I/zep_workspace/sof/zephyr/include -I/zep_workspace/sof/src/platform/intel/ace/include -I/zep_workspace/sof/src/platform/meteorlake/include -I/zep_workspace/sof/src/include/sof/audio/module_adapter/iadk -I/zep_workspace/sof/src/include/sof/audio/module_adapter/library -I/zep_workspace/modules/hal/xtensa/include -I/zep_workspace/modules/hal/xtensa/XTENSA_HAL -I/zep_workspace/modules/hal/xtensa/zephyr/soc/intel_ace15_mtpm -I/zep_workspace/sof/tools/rimage/src/include -I/zep_workspace/sof/src/include -I/zep_workspace/sof/src/arch/xtensa/include -I/zep_workspace/sof/third_party/include -I/zep_workspace/sof/xtos/include -isystem /zep_workspace/zephyr/lib/libc/minimal/include -isystem /zep_workspace/zephyr/lib/libc/common/include -isystem /opt/toolchains/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/../lib/gcc/xtensa-intel_ace15_mtpm_zephyr-elf/12.2.0/include -isystem /opt/toolchains/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/bin/../lib/gcc/xtensa-intel_ace15_mtpm_zephyr-elf/12.2.0/include-fixed -fno-strict-aliasing -O2 -imacros /zep_workspace/build-mtl/zephyr/include/generated/zephyr/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always --sysroot=/home/cwd_user/zephyr-sdk-0.16.4/xtensa-intel_ace15_mtpm_zephyr-elf/xtensa-intel_ace15_mtpm_zephyr-elf -imacros /zep_workspace/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -Werror -fno-asynchronous-unwind-tables -fstrict-overflow -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/zep_workspace/sof/app=CMAKE_SOURCE_DIR -fmacro-prefix-map=/zep_workspace/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/zep_workspace=WEST_TOPDIR -ffunction-sections -fdata-sections -mlongcalls -DXTENSA_TOOLCHAIN_VARIANT=1 -std=c99 -nostdinc -std=gnu99 -MD -MT modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj -MF modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj.d -o modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c.obj -c /zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c
/zep_workspace/sof/src/audio/volume/volume_hifi3_with_peakvol.c:28:10: fatal error: xtensa/tie/xt_hifi3.h: No such file or directory
   28 | #include <xtensa/tie/xt_hifi3.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[271/429] Building C object modules/sof/CMakeFiles/modules_sof.dir/zep_workspace/sof/src/audio/volume/volume_generic_with_peakvol.c.obj

You're right, overall it can't be set up that way. I am just analyzing how it should be changed, because there was already a discussion once if we wanted to do a HIFI downgrade for the platform
#8682

But the build for lnl worked. Is it a problem in the CI host xcc install?

someone check the tooling here ? Looks like we may have an incomplete xtensa compiler installation. Thanks !

Precisely according to me it is not a problem of the compiler. The problem is that in the platform config VOLUME_HIFI3 is rigidly enabled. Well, and the same config takes to build the project using gcc. Generally it needs to be changed so that MAX_HIFI indicates for VOLUME_HIFI -> 3 when HIFI is available and HIFI_NONE when not.

Yeah, this file should not be built with GCC, this change must be overriding the default for GCC.

@marc-hb
Copy link
Collaborator

marc-hb commented Jun 11, 2024

this change must be overriding the default for GCC.

Yes that's what it does. If tell KConfig CONFIG_VOLUME_HIFI3 then it unconditionally compiles volume HIFI3

The system is quite flexible but it was not designed to override the toolchain maximum for only one component and only one toolchain. If you override the level, then you override it for all toolchains.

Alternative that I think disables only what you want to disable:

Other possibilities:

  • turn off HIFI4 entirely in MTL. Not desirable I guess?

  • xtensa-build-zephyr.py knows which toolchain it is using (that's one of its main purposes). So it could easily look for a toolchain-specific overlay.

  • Some if toolchain magic in Kconfig? I think Zephyr has some somewhere. Very obscure.

@marc-hb
Copy link
Collaborator

marc-hb commented Jun 11, 2024

Here's yet another way to do it. Spoilt with choice!

--- a/src/audio/volume/volume_hifi3_with_peakvol.c
+++ b/src/audio/volume/volume_hifi3_with_peakvol.c
@@ -21,12 +21,15 @@ LOG_MODULE_DECLARE(volume_hifi3, CONFIG_SOF_LOG_LEVEL);

 #include "volume.h"

-#if SOF_USE_HIFI(3, VOLUME)
+// Hifi4 is disabled, see bug XXXX.
+// Hifi5 is not there yet.
+#if SOF_USE_HIFI(3, VOLUME) || SOF_USE_HIFI(4, VOLUME) || SOF_USE_HIFI(5, VOLUME)

 #if CONFIG_COMP_PEAK_VOL

 #include <xtensa/tie/xt_hifi3.h>

+#warning VOLUME 3 is on 
+
 #if CONFIG_FORMAT_S24LE
 /**
  * \brief HiFi3 enabled volume processing from 24/32 bit to 24/32 or 32 bit.
diff --git a/src/audio/volume/volume_hifi4_with_peakvol.c b/src/audio/volume/volume_hifi4_with_peakvol.c
index 56e86d13b07b..ca4ba23e05c6 100644
--- a/src/audio/volume/volume_hifi4_with_peakvol.c
+++ b/src/audio/volume/volume_hifi4_with_peakvol.c
@@ -21,11 +21,14 @@ LOG_MODULE_DECLARE(volume_hifi4, CONFIG_SOF_LOG_LEVEL);

 #include "volume.h"

-#if SOF_USE_HIFI(4, VOLUME) || SOF_USE_HIFI(5, VOLUME)
+// disabled and replaced by HIFI3, see issue XXXX
+#if 0 // SOF_USE_HIFI(4, VOLUME) || SOF_USE_HIFI(5, VOLUME)

 #if CONFIG_COMP_PEAK_VOL
 #include <xtensa/tie/xt_hifi4.h>

+#warning VOLUME 4 is on
+
 static inline void vol_store_gain(struct vol_data *cd, const int channels_count)
 {
        int32_t i;

@marc-hb
Copy link
Collaborator

marc-hb commented Jun 11, 2024

xtensa-build-zephyr.py knows which toolchain it is using (that's one of its main purposes). So it could easily look for a toolchain-specific overlay.

BTW we already have board and platform specific overlays:

https://github.com/thesofproject/sof/tree/main/app

@gbernatxintel gbernatxintel force-pushed the gb_peakVol_setHifi3 branch 7 times, most recently from 6d30359 to 9308b12 Compare June 12, 2024 11:47
@gbernatxintel
Copy link
Contributor Author

Thank you @marc-hb for your help, I corrected the code according to your recommendation. Tests on HIFI3 pass correctly and compilation on gcc does not cause errors.

Thank you

@gbernatxintel
Copy link
Contributor Author

We currently have 2 working solutions:

  1. in this PR I disable HIFI4 for volume_peakvol.
    (the problem with the code style is that #if 0 is used and the code is not removed, we do not want to remove this code, because someday when the bug is fixed it will be needed)

  2. solution that disables Hifi4 completely what Marc proposed. volume.h: disable HIFI4 for ACE1.5 #9221


#if CONFIG_COMP_PEAK_VOL

#include <xtensa/tie/xt_hifi3.h>

#warning VOLUME 3 is on
Copy link
Collaborator

Choose a reason for hiding this comment

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

doesn't this break builds since warnings are treated as errors - at least in some configurations? Maybe we need a run-time dev_warn() or similar with this instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should not spoil, in the volume HIFi component is not available comments and logs, so only this we can use

Copy link
Collaborator

@marc-hb marc-hb Jun 12, 2024

Choose a reason for hiding this comment

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

Don't put this in production. This was just sample debug code I posted in a comment to help. We're trying to always keep the build warning-free by default.

Otherwise LGTM. Other reviewers should consider all the other alternatives I listed above, they have subtly different trade-offs.

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

LGTM except for the #warning. Other reviewers should consider all the other alternatives I listed above, they have subtly different trade-offs.


#if CONFIG_COMP_PEAK_VOL

#include <xtensa/tie/xt_hifi3.h>

#warning VOLUME 3 is on
Copy link
Collaborator

@marc-hb marc-hb Jun 12, 2024

Choose a reason for hiding this comment

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

Don't put this in production. This was just sample debug code I posted in a comment to help. We're trying to always keep the build warning-free by default.

Otherwise LGTM. Other reviewers should consider all the other alternatives I listed above, they have subtly different trade-offs.

@gbernatxintel
Copy link
Contributor Author

LGTM except for the #warning. Other reviewers should consider all the other alternatives I listed above, they have subtly different trade-offs.

@marc-hb Ok, thank you. I fixed the code

@gbernatxintel
Copy link
Contributor Author

@lgirdwood @singalsu @lyakh
Hey there! Could you please take a look at this PR and let me know if you think we should go ahead with this change or consider a different approach? Thanks!

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.

I think it seems better to disable HIFI4 volume optimizatons for now so I think this PR is good, but the git commit message needs to be updated (see inline).

src/audio/volume/volume_hifi3_with_peakvol.c Show resolved Hide resolved
Copy link
Contributor

@tmleman tmleman left a comment

Choose a reason for hiding this comment

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

Pre-approval. I agree with Kai and have no other comments, so once those are addressed, it will be OK for me.

HIFI4 has been disabled. HIFI3 is being used for
the volume component with peakVol.

There was a problem with test
test_01_09_peakvol_quality[44100Hz_16in16bit_1ch-0].
The main problem was with frequencies: 11025,
22050, 44100, 88200, 176400 Hz.
Because frame is different for these frequencies. For f=44100Hz
frame is equal 44 or 45. Some of the samples were simply not processed.

Changes to HIFI4 are not-trivial and failed to fix the problem.
However, HIFI3 is fully compatible and works properly.
Performance is worse by 1-2,5% in CPU cycle usage
but no glitches appear and all samples are processed correctly.

Signed-off-by: Grzegorz Bernat <grzegorzx.bernat@intel.com>
@gbernatxintel gbernatxintel changed the title app: board: Set CONFIG_VOLUME_HIFI3=y for MTL platform audio: volume: disable HIFI4 optimizations Jun 14, 2024
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.

Excellent, thanks @gbernatxintel !

@kv2019i kv2019i merged commit 87571f3 into thesofproject:main Jun 14, 2024
42 of 46 checks passed
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.

7 participants