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

Compile errors on NatureDSP for HiFi4 on i.MX8MP #3

Open
iuliana-prodan opened this issue Apr 26, 2024 · 5 comments
Open

Compile errors on NatureDSP for HiFi4 on i.MX8MP #3

iuliana-prodan opened this issue Apr 26, 2024 · 5 comments

Comments

@iuliana-prodan
Copy link

When compiling the NatureDSP Lib from this github repo, for the HiFi4 DSP from i.MX8MP, I get the following error:

ndsplib-hifi4/NDSP_HiFi4/NDSP_HiFi4_v430/build/project/xtclang/library$ make -e XTENSA_SYSTEM= XTENSA_CORE=hifi4_mscale_v2_0_2_prod
xt-clang -pipe    -DDATA_CACHE=0  -I ../../../../library/include  -I ../../../../library/include_private  -O3   -mlongcalls -fno-builtin  -Wall -Wno-return-type -std=c99 -Werror -D__RENAMING__    -c ../../../../library/fir/conv2d/conv2d_5x5f_hifi4.c -o _llvm-Xtensa-release/conv2d_5x5f_hifi4.o 
xt-clang -pipe    -DDATA_CACHE=0  -I ../../../../library/include  -I ../../../../library/include_private  -O3   -mlongcalls -fno-builtin  -Wall -Wno-return-type -std=c99 -Werror -D__RENAMING__    -c ../../../../library/fir/firblk/stereo_bkfir16x16_hifi4.c -o _llvm-Xtensa-release/stereo_bkfir16x16_hifi4.o 
...
xt-clang -pipe    -DDATA_CACHE=0  -I ../../../../library/include  -I ../../../../library/include_private  -O3   -mlongcalls -fno-builtin  -Wall -Wno-return-type -std=c99 -Werror -D__RENAMING__    -c ../../../../library/fir/firblkf/bkfiraf_process_hifi4.c -o _llvm-Xtensa-release/bkfiraf_process_hifi4.o 
../../../../library/fir/firblkf/bkfiraf_process_hifi4.c:171:13: error: implicit declaration of function 'XT_LSX2XC1' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            XT_LSX2XC1(h01, pH0, 4*sizeof(float32_t));
            ^
../../../../library/fir/firblkf/bkfiraf_process_hifi4.c:225:13: error: implicit declaration of function 'XT_LSX2XC1' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            XT_LSX2XC1(h01, pH0, 4*sizeof(float32_t));
            ^
../../../../library/fir/firblkf/bkfiraf_process_hifi4.c:287:13: error: implicit declaration of function 'XT_LSX2XC1' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            XT_LSX2XC1(h01, pH0, 4*sizeof(float32_t));
            ^
../../../../library/fir/firblkf/bkfiraf_process_hifi4.c:171:24: error: variable 'h01' is uninitialized when used here [-Werror,-Wuninitialized]
            XT_LSX2XC1(h01, pH0, 4*sizeof(float32_t));
                       ^~~
../../../../library/fir/firblkf/bkfiraf_process_hifi4.c:99:18: note: initialize the variable 'h01' to silence this warning
    xtfloatx2 h01, h23;
                 ^
                  = 0
../../../../library/fir/firblkf/bkfiraf_process_hifi4.c:172:24: error: variable 'h23' is uninitialized when used here [-Werror,-Wuninitialized]
            XT_LSX2XC1(h23, pH1, 4*sizeof(float32_t));
                       ^~~
../../../../library/fir/firblkf/bkfiraf_process_hifi4.c:99:23: note: initialize the variable 'h23' to silence this warning
    xtfloatx2 h01, h23;
                      ^
                       = 0
5 errors generated.
make: *** [makefile:1658: _llvm-Xtensa-release/bkfiraf_process_hifi4.o] Error 1
@iuliana-prodan
Copy link
Author

I believe the problem is that, for bkfiraf_process_hifi4 at line 77 is defined XT_LSX2XC1 only for __LESSTHANLX8__ :

#if __LESSTHANLX8__
/* Circular load with using CBEGIN1/CEND1 */
#define XT_LSX2XC1(reg, addr, offs)\
{\
    ae_int32x2 t;\
    AE_L32X2_XC1(t, addr, offs);\
    reg = XT_AE_MOVXTFLOATX2_FROMINT32X2(t);\
}
#endif 

but later is used for both cases (w/ or w/o __LESSTHANLX8__ defined - see line 168)

#if __LESSTHANLX8__
            XT_LSX2XC1(h01, castxcc(ae_int32x2,pH0), 4*sizeof(float32_t));
            XT_LSX2XC1(h23, castxcc(ae_int32x2,pH1), 4*sizeof(float32_t));
#else			
            XT_LSX2XC1(h01, pH0, 4*sizeof(float32_t));
            XT_LSX2XC1(h23, pH1, 4*sizeof(float32_t));
#endif 

or at line 221

#if __LESSTHANLX8__
            XT_LSX2XC1(h01, castxcc(ae_int32x2,pH0), 4*sizeof(float32_t));
            XT_LSX2XC1(h23, castxcc(ae_int32x2,pH1), 4*sizeof(float32_t));
#else
            XT_LSX2XC1(h01, pH0, 4*sizeof(float32_t));
            XT_LSX2XC1(h23, pH1, 4*sizeof(float32_t));
#endif

or line 283:

#if __LESSTHANLX8__
            XT_LSX2XC1(h01, castxcc(ae_int32x2,pH0), 4*sizeof(float32_t));
            XT_LSX2XC1(h23, castxcc(ae_int32x2,pH1), 4*sizeof(float32_t));
#else
            XT_LSX2XC1(h01, pH0, 4*sizeof(float32_t));
            XT_LSX2XC1(h23, pH1, 4*sizeof(float32_t));
#endif

@cad-audio @cad-audioNDSP can you please let me know how can I overcome this?
Thanks.

@cad-audioNDSP
Copy link
Collaborator

Hi Iulia Prodan,

Which toolchain are you using and what is the LX version of the core used?
If you are using a toolchain earlier than RJ2024.3 (i.e the core is pre LX8), then you need to enable the flag LESSTHANLX8
In /hifi4_library/include_private/common.h
Set #define LESSTHANLX8 1
This should solve the build issue.

@iuliana-prodan
Copy link
Author

Hi @cad-audioNDSP,

I'm using Xtensa Toolchain version RI-2023.11-linux, Xtensa Core = hifi4_mscale_v2_0_2_prod.
The core is a HiFi4 core which is LX6.

When setting LESSTHANLX8=1 the compilation is ok, I get the library.
But I would like to be able to compile the library without modifying the code - just take the code, unzip and compile.

Can we make LESSTHANLX8 a different variable that can be changed from command line, as argument to make command?

Thanks,
Iulia

@iuliana-prodan
Copy link
Author

@cad-audioNDSP can you please make the following changes:
in common.h (from /NDSP_HiFi4_v430/library/include_private/common.h):

diff /ndsplib-hifi4/NDSP_HiFi4/NDSP_HiFi4_v430/library/include_private/common.h ndsplib-hifi4/NDSP_HiFi4/original/NDSP_HiFi4_v430/library/include_private/common.h
35d34
< #ifndef __LESSTHANLX8__
37d35
< #endif

in makefile (from NDSP_HiFi4_v430/build/project/xtclang/library/):

diff makefile ../../../../../original/NDSP_HiFi4_v430/build/project/xtclang/library/
126,130d125
< __LESSTHANLX8__ ?= ""
<  ifneq ($(__LESSTHANLX8__), "")
<     CFLAGS  += -D__LESSTHANLX8__=$(__LESSTHANLX8__)
< endif
< 

With these 2 changes any user can take the code and compile the library for an LX8 or less than LX8 core with a make argument, no need to change the code.

With the above modifications, for an LX6 core I'm compiling the library with:
make -e XTENSA_SYSTEM= XTENSA_CORE=hifi4_mscale_v2_0_2_prod __LESSTHANLX8__=1

I can create a pull request for this, but I have access only to the archive.
So, is it possible to make these changes?

Thank you!

@iuliana-prodan
Copy link
Author

iuliana-prodan commented Jul 30, 2024

Hi @cad-audioNDSP,

When trying to compile latest release NDSP_HiFi4_v500.zip, using RJ-2024.3 toolchain I get:

xt-clang -pipe    -DDATA_CACHE=0  -I ../../../../library/include  -I ../../../../library/include_private  -O3   -mlongcalls -fno-builtin  -Wall -Wno-return-type -std=c99 -Werror -D__RENAMING__    -c ../../../../library/fir/firblkf/bkfiraf_hifi4.c -o _llvm-Xtensa-release/bkfiraf_hifi4.o 
xt-clang -pipe    -DDATA_CACHE=0  -I ../../../../library/include  -I ../../../../library/include_private  -O3   -mlongcalls -fno-builtin  -Wall -Wno-return-type -std=c99 -Werror -D__RENAMING__    -c ../../../../library/fir/firblkf/bkfiraf_process_hifi4.c -o _llvm-Xtensa-release/bkfiraf_process_hifi4.o 
../../../../library/fir/firblkf/bkfiraf_process_hifi4.c:79:9: error: 'XT_LSX2XC1' macro redefined [-Werror,-Wmacro-redefined]
#define XT_LSX2XC1(reg, addr, offs)\
        ^
/opt/samba/nxa06898/xcc/natureDSP/imx-audio-toolchain/Xtensa_Tool/builds/RJ-2024.3-linux/hifi4_mscale_RJ_2024/xtensa-elf/arch/include/xtensa/tie/xt_FP.h:491:9: note: previous definition is here
#define XT_LSX2XC1 _TIE_xt_FP_LSX2XC1
        ^
1 error generated.
make: *** [makefile:1699: _llvm-Xtensa-release/bkfiraf_process_hifi4.o] Error 1

Shouldn't this compile directly, without any modifications ?
Am I missing something?

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

No branches or pull requests

2 participants