Question:
How to disable SIMD only for specific function fir_interp() eventhough SIMD is enabled in project for ADSP-21569?
Answer:
The library contains two versions of the fir_interp() function:
- a simd version called "fir_interp_vec()"
- a non-simd version called "fir_interp_vec_nonSIMD()"
We can use non-simd version selected by going to the Project Options, selecting "CrossCore SHARC C/C++ Compiler" -> "Processor" and selecting "Disable automatic SIMD code generation". If we are using the command line tools, we can use the compiler switch "-no-simd".
When SIMD generation is disabled, the header file filter.h will convert calls to "fir_interp()" to the non-simd version of the function.
There are therefore a couple of ways we can do ensure the non-simd version is called, even when SIMD is enabled in the project:
1) Add the following to code, after the #include of filter.h:
asm volatile ("#define fir_interp_vec. fir_interp_vec_nonSIMD.");
asm volatile ("#define _fir_interp_vec _fir_interp_vec_nonSIMD");
This forces the assembler preprocessor to ensure that the non-simd version is called.
2) Copy the source file for fir_interp() to the project and modify it. The source file is <<INSTALL>>/SHARC/lib/src/libdsp_src/fir_interp.asm
We will see the following code at line approx 480:
#if defined(__NOSIMD__)
#pragma function_name fir_interp_vec_nonSIMD
#else
#pragma function_name fir_interp_vec
#endif
If we change this to:
#pragma function_name fir_interp_vec_nonSIMD // Always use the non-simd version
We should find that the application will always call the non-simd version.
Note that we will need to add the following include path to the assembler preprocessor options in the Project Options:
<<INSTALL>\SHARC\lib\src\libcc_src
where "<<INSTALL>>" is the path to the installation of CrossCore Embedded Studio.