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 · 12 comments
Open

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

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

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?

@cad-audioNDSP
Copy link
Collaborator

Hi @iuliana-prodan
Yes, this should compile directly without any modifications. The release has been tested with RJ2024.3 and RI2023.11 toolchains.
Please let me know the LX version of the HW that you are using.

@iuliana-prodan
Copy link
Author

Hi @iuliana-prodan Yes, this should compile directly without any modifications. The release has been tested with RJ2024.3 and RI2023.11 toolchains. Please let me know the LX version of the HW that you are using.

Hi,

I'm compiling for HiFi4 DSP from i.MX8M Plus - see here my board with "Cadence® Tensilica® HiFi 4 DSP @ 800 MHz".
Is an LX6.

@cad-audioNDSP
Copy link
Collaborator

cad-audioNDSP commented Aug 9, 2024

Hi,
The LX version reads like this LX8.0.3. I cannot find the LX version from the link you shared.
Please see if you can provide the exact LX version.
Meanwhile we will check if we can reproduce the issue on any of our LX6 cores.

If you could also attach the complete build log, that would help.

@cad-audioNDSP cad-audioNDSP self-assigned this Aug 9, 2024
@iuliana-prodan
Copy link
Author

iuliana-prodan commented Aug 9, 2024

Hi, The LX version reads like this LX8.0.3. I cannot find the LX version from the link you shared. Please see if you can provide the exact LX version.

The exact version is LX6.0.4

@cad-audioNDSP
Copy link
Collaborator

Currently the LX8 flag gets defined here in common.h file.
#if (XCHAL_SW_VERSION_MAJOR < 15000)
#define LESSTHANLX8 1
#else
#define LESSTHANLX8 0
#endif

The macro **#define XCHAL_SW_VERSION_MAJOR 15000 is defined in core-isa.h file. (This file is core specific).

Can you please confirm what is the above value: it is expected to be below 15000 to enable the guarded code.

I tried building the code with one of the LX6.0.2 core and is building well, therefore could not reproduce the issue.

@iuliana-prodan
Copy link
Author

XCHAL_SW_VERSION_MAJOR

Hi @cad-audioNDSP,

Sorry for the late reply, I was OOO.

Here's the core-isa.h file that I use and I don't have the XCHAL_SW_VERSION_MAJOR defined. And this file is for NXP i.MX8M Plus
The same happens for 8QUADXPLUS or 8QUADMAX or 8ULP:
image
I only have the HW_VERSION_* defines - see here: https://github.com/zephyrproject-rtos/hal_xtensa/blob/master/zephyr/soc/mimx8ml8/xtensa/config/core-isa.h#L192

Where or how can I get an updated core-isa.h file?

Thanks!

@cad-audioNDSP
Copy link
Collaborator

@iuliana-prodan
I see that you are able to build it with LX6.0.2 core but not with LX6.0.4
The core ISA file that you provided helps. Let me reproduce this on my side and I will get back to you in a couple of days.

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