ARM-software / CMSIS-NN

CMSIS-NN Library
https://arm-software.github.io/CMSIS-NN
Apache License 2.0
202 stars 56 forks source link

Occur an ASM error when compiling arm_nn_mat_mul_core_4x_s8 #87

Closed WORsjlt closed 11 months ago

WORsjlt commented 11 months ago

Processor: Cortex-M55 Error message: cmsis-nn/Source/NNSupportFunctions/arm_nn_mat_mul_core_4x_s8.c: In function 'arm_nn_mat_mul_core_4x_s8': /(my project path)/cmsis-nn/Include/Internal/arm_nn_compiler.h:97:23: error: 'asm' operand has impossible constraints 97 | #define ASM asm | ^~~~~ cmsis-nn/Source/NNSupportFunctions/arm_nn_mat_mul_core_4x_s8.c:84:9: note: in expansion of macro 'ASM' 84 | ASM volatile(" .p2align 2 \n" | ^~~~~

Why is this happening? And how to fix it? Appreciate!

mansnils commented 11 months ago

Hi @WORsjlt Thanks for reporting this. What compiler and version are you using?

mansnils commented 11 months ago

Also would like to check if it may be related to compiler options? https://github.com/ARM-software/CMSIS-NN#compiler-options

WORsjlt commented 11 months ago

Hi @mansnils Here is the output message about compiler and version when compiling: GNU C17 (Arm GNU Toolchain 11.3.Rel1) version 11.3.1 20220712 (arm-none-eabi) compiled by GNU C version 4.8.5 20150623 (Red Hat 4.8.5-44), GMP version 6.2.1, MPFR version 3.1.6, MPC version 1.0.3, isl version isl-0.15-1-g835ea3a-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 801c9e4705ed9ec92526a3ce66f3ab92 GNU assembler version 2.38 (arm-none-eabi) using BFD version (Arm GNU Toolchain 11.3.Rel1) 2.38.20220708

Hope it helps!

mansnils commented 11 months ago

It looks like a supported compiler. Question is how to reproduce this. Do you build like described here: https://github.com/ARM-software/CMSIS-NN#building-cmsis-nn-as-a-library Or do you set some custom build options?

WORsjlt commented 11 months ago

I tried to build cmsis-nn inside a project using Nuttx. I defined -DTARGET_CPU=cortex-m55 and some custom options, but I'm not sure which option produces this. Here are some options filtering out header files: -imultilib thumb/v8-m.main+dp/hard -iprefix /(my project path)/prebuilts/gcc/linux/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/ -isysroot /(my project path)/prebuilts/gcc/linux/arm/bin/../arm-none-eabi -D__USES_INITFINI -D NuttX__ -isystem /(my project path)/nuttx/include cmsis-nn/Source/NNSupportFunctions/arm_nn_mat_mul_core_4x_s8.c -quiet -dumpdir cmsis-nn/Source/NNSupportFunctions/ -dumpbase arm_nn_mat_mul_core_4x_s8.c.(my project path).cmsis-nn.c -dumpbase-ext .c -mlittle-endian -mtune=cortex-m55 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -mlibarch=armv8.1-m.main+fp.dp+mve.fp -march=armv8.1-m.main+fp.dp+mve.fp -EL -march=armv8.1-m.main+fp.dp+mve.fp -mfloat-abi=hard -mfpu=fpv5-d16 -meabi=5 -mthumb -mimplicit-it=always

felix-johnny commented 11 months ago

@WORsjlt The optimization level is missing in this. Could you try with atleast -O1 or higher?

WORsjlt commented 11 months ago

@felix-johnny I used -O3.

mansnils commented 11 months ago

@WORsjlt Could you post the complete line from above (...arm_nn_mat_mul_core_4x_s8.c -quiet -dumpdir ...) with all compiler options?

WORsjlt commented 11 months ago

@mansnils Sure! Some of the project information has been removed for personal academic reasons. Sorry about that.

COLLECT_GCC_OPTIONS='-c' '-Wstrict-prototypes' '-Wno-attributes' '-Wno-unknown-pragmas' '-Wno-psabi' '-nostdlib' '-pipe' '-O3' '-fno-strict-aliasing' '-fno-omit-frame-pointer' '-fno-optimize-sibling-calls' '-funwind-tables' '-fasynchronous-unwind-tables' '-fno-common' '-Wall' '-Wshadow' '-Wundef' '-ffunction-sections' '-fdata-sections' '-g' '-mlittle-endian' '-mtune=cortex-m55' '-mfpu=fpv5-d16' '-mfloat-abi=hard' '-mthumb' '-isystem' '-D' 'NuttX' '-Wno-cpp' '-v' '-o' 'cmsis-nn/Source/NNSupportFunctions/arm_nn_mat_mul_core_4x_s8.c.(my project path).cmsis-nn.o' '-mlibarch=armv8.1-m.main+fp.dp+mve.fp' '-march=armv8.1-m.main+fp.dp+mve.fp' '-dumpdir' 'cmsis-nn/Source/NNSupportFunctions/' /(my project path)/prebuilts/gcc/linux/arm/bin/../libexec/gcc/arm-none-eabi/11.3.1/cc1 -quiet -v thumb/v8-m.main+dp/hard -iprefix /(my project path)/prebuilts/gcc/linux/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/ -isysroot /(my project path)/prebuilts/gcc/linux/arm/bin/../arm-none-eabi -D__USES_INITFINI -D NuttX__ -isystem /(my project path)/nuttx/include cmsis-nn/Source/NNSupportFunctions/arm_nn_mat_mul_core_4x_s8.c -quiet -dumpdir cmsis-nn/Source/NNSupportFunctions/ -dumpbase arm_nn_mat_mul_core_4x_s8.c.(my project path).cmsis-nn.c -dumpbase-ext .c -mlittle-endian -mtune=cortex-m55 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -mlibarch=armv8.1-m.main+fp.dp+mve.fp -march=armv8.1-m.main+fp.dp+mve.fp -g -O3 -Wstrict-prototypes -Wno-attributes -Wno-unknown-pragmas -Wno-psabi -Wall -Wshadow -Wundef -Wno-cpp -version -fno-strict-aliasing -fno-omit-frame-pointer -fno-optimize-sibling-calls -funwind-tables -fasynchronous-unwind-tables -fno-common -ffunction-sections -fdata-sections -o - | /(my project path)/prebuilts/gcc/linux/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/as -v -EL -march=armv8.1-m.main+fp.dp+mve.fp -mfloat-abi=hard -mfpu=fpv5-d16 -meabi=5 -mthumb -mimplicit-it=always -o cmsis-nn/Source/NNSupportFunctions/arm_nn_mat_mul_core_4x_s8.c.(my project path).cmsis-nn.o

mansnils commented 11 months ago

Can you try without -fno-omit-frame-pointer?

WORsjlt commented 11 months ago

Cancelling-fno-omit-frame-pointer works! Thank you very much! @mansnils @felix-johnny