Skip to content

Commit

Permalink
Math: add build option to math filter
Browse files Browse the repository at this point in the history
EQFIR EQIIR and TDFB are all refered from math filter, so
define option in math filter, use unified SIMD selection for
EQFIR EQIIR and TDFB.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
  • Loading branch information
btian1 authored and lgirdwood committed Feb 26, 2024
1 parent 80dd84c commit ab87904
Show file tree
Hide file tree
Showing 20 changed files with 136 additions and 119 deletions.
10 changes: 6 additions & 4 deletions src/audio/eq_fir/eq_fir.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
#include <sof/audio/audio_stream.h>
#include <sof/audio/format.h>
#include <sof/math/fir_config.h>
#if FIR_GENERIC
#include <sof/common.h>

#if SOF_USE_HIFI(NONE, FILTER)
#include <sof/math/fir_generic.h>
#endif
#if FIR_HIFIEP
#if SOF_USE_HIFI(2, FILTER)
#include <sof/math/fir_hifi2ep.h>
#endif
#if FIR_HIFI3
#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER)
#include <sof/math/fir_hifi3.h>
#endif
#include <user/fir.h>
Expand Down Expand Up @@ -75,7 +77,7 @@ int eq_fir_params(struct processing_module *mod);
* set_fir_func.
*/

#if FIR_HIFI3 || FIR_HIFIEP
#if SOF_USE_HIFI(2, FILTER) || SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER)
#if CONFIG_FORMAT_S16LE
static inline void set_s16_fir(struct comp_data *cd)
{
Expand Down
5 changes: 3 additions & 2 deletions src/audio/eq_fir/eq_fir_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
// Keyon Jie <yang.jie@linux.intel.com>

#include <sof/math/fir_config.h>
#include <sof/common.h>

#if FIR_GENERIC
#if SOF_USE_HIFI(NONE, FILTER)

#include <sof/audio/module_adapter/module/generic.h>
#include <sof/math/fir_generic.h>
Expand Down Expand Up @@ -132,4 +133,4 @@ void eq_fir_s32(struct fir_state_32x16 fir[], struct input_stream_buffer *bsourc
}
#endif /* CONFIG_FORMAT_S32LE */

#endif /* FIR_GENERIC */
#endif /* FILTER_HIFI_NONE */
3 changes: 2 additions & 1 deletion src/audio/eq_fir/eq_fir_hifi2ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
// Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>

#include <sof/math/fir_config.h>
#include <sof/common.h>

#if FIR_HIFIEP
#if SOF_USE_HIFI(2, FILTER)

#include <sof/audio/module_adapter/module/generic.h>
#include <sof/audio/buffer.h>
Expand Down
3 changes: 2 additions & 1 deletion src/audio/eq_fir/eq_fir_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
// Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>

#include <sof/math/fir_config.h>
#include <sof/common.h>

#if FIR_HIFI3
#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER)

#include <sof/audio/module_adapter/module/generic.h>
#include <sof/math/fir_hifi3.h>
Expand Down
23 changes: 7 additions & 16 deletions src/audio/tdfb/tdfb_comp.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,17 @@
#include <sof/math/fir_hifi3.h>
#include <sof/math/iir_df1.h>
#include <sof/platform.h>
#include <sof/common.h>

/* Select optimized code variant when xt-xcc compiler is used */
#if defined __XCC__
#include <xtensa/config/core-isa.h>
#if XCHAL_HAVE_HIFI2EP == 1
#define TDFB_GENERIC 0
#define TDFB_HIFIEP 1
#define TDFB_HIFI3 0
#elif XCHAL_HAVE_HIFI3 == 1 || XCHAL_HAVE_HIFI4 == 1
/* TDFB and EQFIR depend on math FIR.
* so align TDFB, math FIR, and EQFIR use same selection.
*/
#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER)
#define TDFB_HIFI3 1
#define TDFB_HIFIEP 0
#define TDFB_GENERIC 0
#else
#error "No HIFIEP or HIFI3 found. Cannot build TDFB module."
#endif
#elif SOF_USE_HIFI(2, FILTER)
#define TDFB_HIFI2 1
#else
/* GCC */
#define TDFB_GENERIC 1
#define TDFB_HIFIEP 0
#define TDFB_HIFI3 0
#endif

#define TDFB_IN_BUF_LENGTH (2 * PLATFORM_MAX_CHANNELS)
Expand Down
38 changes: 0 additions & 38 deletions src/include/sof/math/fir_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,4 @@
#endif
#endif

/* Define SOFM_FIR_FORCEARCH 0/2/3 in build command line or temporarily in
* this file to override the default auto detection.
*/
#ifdef SOFM_FIR_FORCEARCH
# if SOFM_FIR_FORCEARCH == 3
# define FIR_GENERIC 0
# define FIR_HIFIEP 0
# define FIR_HIFI3 1
# elif SOFM_FIR_FORCEARCH == 2
# define FIR_GENERIC 0
# define FIR_HIFIEP 1
# define FIR_HIFI3 0
# elif SOFM_FIR_FORCEARCH == 0
# define FIR_GENERIC 1
# define FIR_HIFIEP 0
# define FIR_HIFI3 0
# else
# error "Unsupported SOFM_FIR_FORCEARCH value."
# endif
#else
# if defined __XCC__
# include <xtensa/config/core-isa.h>
# define FIR_GENERIC 0
# if XCHAL_HAVE_HIFI2EP == 1
# define FIR_HIFIEP 1
# define FIR_HIFI3 0
# elif XCHAL_HAVE_HIFI3 == 1 || XCHAL_HAVE_HIFI4 == 1
# define FIR_HIFI3 1
# define FIR_HIFIEP 0
# else
# error "No HIFIEP or HIFI3 found. Cannot build FIR module."
# endif
# else
# define FIR_GENERIC 1
# define FIR_HIFI3 0
# endif /* __XCC__ */
#endif /* SOFM_FIR_FORCEARCH */

#endif /* __SOF_AUDIO_EQ_FIR_FIR_CONFIG_H__ */
3 changes: 2 additions & 1 deletion src/include/sof/math/fir_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
#define __SOF_MATH_FIR_GENERIC_H__

#include <sof/math/fir_config.h>
#include <sof/common.h>

#if FIR_GENERIC
#if SOF_USE_HIFI(NONE, FILTER)

#include <sof/audio/audio_stream.h>
#include <sof/audio/format.h>
Expand Down
3 changes: 2 additions & 1 deletion src/include/sof/math/fir_hifi2ep.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#define __SOF_MATH_FIR_HIFI2EP_H__

#include <sof/math/fir_config.h>
#include <sof/common.h>

#if FIR_HIFIEP
#if SOF_USE_HIFI(2, FILTER)

#include <sof/audio/audio_stream.h>
#include <sof/audio/buffer.h>
Expand Down
3 changes: 2 additions & 1 deletion src/include/sof/math/fir_hifi3.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#define __SOF_MATH_FIR_HIFI3_H__

#include <sof/math/fir_config.h>
#include <sof/common.h>

#if FIR_HIFI3
#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER)

#include <sof/audio/audio_stream.h>
#include <sof/audio/buffer.h>
Expand Down
18 changes: 2 additions & 16 deletions src/include/sof/math/iir_df1.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,10 @@

#include <stddef.h>
#include <stdint.h>
#include <sof/common.h>

#define IIR_DF1_NUM_STATE 4

#if defined __XCC__
#include <xtensa/config/core-isa.h>
#if XCHAL_HAVE_HIFI3
#define IIR_DF1_GENERIC 0
#define IIR_DF1_HIFI3 1
#else
#define IIR_DF1_GENERIC 1
#define IIR_DF1_HIFI3 0
#endif /* XCHAL_HAVE_HIFI3 */
#else
/* GCC */
#define IIR_DF1_GENERIC 1
#define IIR_DF1_HIFI3 0
#endif

struct iir_state_df1 {
unsigned int biquads; /* Number of IIR 2nd order sections total */
unsigned int biquads_in_series; /* Number of IIR 2nd order sections
Expand All @@ -51,7 +37,7 @@ void iir_reset_df1(struct iir_state_df1 *iir);
int32_t iir_df1(struct iir_state_df1 *iir, int32_t x);

/* Inline functions */
#if IIR_DF1_HIFI3
#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER)
#include "iir_df1_hifi3.h"
#else
#include "iir_df1_generic.h"
Expand Down
32 changes: 2 additions & 30 deletions src/include/sof/math/iir_df2t.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,7 @@

#include <stddef.h>
#include <stdint.h>

/* Define SOFM_IIR_DF2T_FORCEARCH 0/3 in build command line or temporarily in
* this file to override the default auto detection.
*/
#ifdef SOFM_IIR_DF2T_FORCEARCH
# if SOFM_IIR_DF2T_FORCEARCH == 3
# define IIR_GENERIC 0
# define IIR_HIFI3 1
# elif SOFM_IIR_DF2T_FORCEARCH == 0
# define IIR_GENERIC 1
# define IIR_HIFI3 0
# else
# error "Unsupported SOFM_IIR_DF2T_FORCEARCH value."
# endif
#else
# if defined __XCC__
# include <xtensa/config/core-isa.h>
# if XCHAL_HAVE_HIFI3 == 1 || XCHAL_HAVE_HIFI4 == 1
# define IIR_GENERIC 0
# define IIR_HIFI3 1
# else
# define IIR_GENERIC 1
# define IIR_HIFI3 0
# endif /* XCHAL_HAVE_HIFIn */
# else
# define IIR_GENERIC 1
# define IIR_HIFI3 0
# endif /* __XCC__ */
#endif /* SOFM_IIR_DF2T_FORCEARCH */
#include <sof/common.h>

#define IIR_DF2T_NUM_DELAYS 2

Expand Down Expand Up @@ -71,7 +43,7 @@ void iir_reset_df2t(struct iir_state_df2t *iir);
int32_t iir_df2t(struct iir_state_df2t *iir, int32_t x);

/* Inline functions with or without HiFi3 intrinsics */
#if IIR_HIFI3
#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER)
#include "iir_df2t_hifi3.h"
#else
#include "iir_df2t_generic.h"
Expand Down
46 changes: 46 additions & 0 deletions src/math/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,52 @@ config MATH_32BIT_FFT

endmenu

# this choice covers math iir, math fir, tdfb, and eqfir, eqiir.
choice "FILTER_SIMD_LEVEL_SELECT"
prompt "choose which SIMD level used for IIR/FIR/TDFB module"
depends on COMP_FIR
depends on COMP_IIR
depends on COMP_TDFB
default FILTER_HIFI_MAX

config FILTER_HIFI_MAX
prompt "SIMD will selected by toolchain pre-defined header"
bool
help
When this was selected, optimization level will be determined
by toolchain pre-defined macros in core isa header file.

config FILTER_HIFI_5
prompt "choose HIFI5 intrinsic optimized FILTER module"
bool
help
This option used to build HIFI5 optimized FILTER code

config FILTER_HIFI_4
prompt "choose HIFI4 intrinsic optimized FILTER module"
bool
help
This option used to build HIFI4 optimized FILTER code

config FILTER_HIFI_3
prompt "choose HIFI3 intrinsic optimized FILTER module"
bool
help
This option used to build HIFI3 intrinsic optimized FILTER code

config FILTER_HIFI_2
prompt "choose HIFI2ep intrinsic optimized FILTER module"
bool
help
This option used to build HIFI2ep intrinsic optimized FILTER code

config FILTER_HIFI_NONE
prompt "choose generic C FILTER module, no HIFI SIMD involved"
bool
help
This option used to build FILTER generic code.
endchoice

config MATH_FIR
bool "FIR filter library"
default n
Expand Down
48 changes: 48 additions & 0 deletions src/math/Kconfig.simd
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# SPDX-License-Identifier: BSD-3-Clause

comment "filter optimization level select"

# this choice covers math iir, math fir, tdfb, and eqfir, eqiir.
choice "FILTER_SIMD_LEVEL_SELECT"
prompt "choose which SIMD level used for filter module"
depends on COMP_FIR
depends on COMP_IIR
default FILTER_HIFI_MAX

config FILTER_HIFI_MAX
prompt "SIMD will selected by toolchain pre-defined header"
bool
help
When this was selected, optimization level will be determined
by toolchain pre-defined macros in core isa header file.

config FILTER_HIFI_5
prompt "choose HIFI5 intrinsic optimized FILTER module"
bool
help
This option used to build HIFI5 optimized FILTER code

config FILTER_HIFI_4
prompt "choose HIFI4 intrinsic optimized FILTER module"
bool
help
This option used to build HIFI4 optimized FILTER code

config FILTER_HIFI_3
prompt "choose HIFI3 intrinsic optimized FILTER module"
bool
help
This option used to build HIFI3 intrinsic optimized FILTER code

config FILTER_HIFI_2
prompt "choose HIFI2ep intrinsic optimized FILTER module"
bool
help
This option used to build HIFI2ep intrinsic optimized FILTER code

config FILTER_HIFI_NONE
prompt "choose generic C FILTER module, no HIFI SIMD involved"
bool
help
This option used to build FILTER generic code.
endchoice
4 changes: 2 additions & 2 deletions src/math/fir_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
// Keyon Jie <yang.jie@linux.intel.com>

#include <sof/math/fir_config.h>
#include <sof/common.h>

#if FIR_GENERIC
#if SOF_USE_HIFI(NONE, FILTER)

#include <sof/common.h>
#include <sof/audio/buffer.h>
#include <sof/audio/format.h>
#include <sof/math/fir_generic.h>
Expand Down
3 changes: 2 additions & 1 deletion src/math/fir_hifi2ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
// Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>

#include <sof/math/fir_config.h>
#include <sof/common.h>

#if FIR_HIFIEP
#if SOF_USE_HIFI(2, FILTER)

#include <sof/audio/format.h>
#include <sof/math/fir_hifi2ep.h>
Expand Down
3 changes: 2 additions & 1 deletion src/math/fir_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
// Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>

#include <sof/math/fir_config.h>
#include <sof/common.h>

#if FIR_HIFI3
#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER)

#include <sof/audio/buffer.h>
#include <sof/math/fir_hifi3.h>
Expand Down
Loading

0 comments on commit ab87904

Please sign in to comment.