首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在ARM下编译霓虹灯代码时出错

在ARM下编译霓虹灯代码时出错
EN

Stack Overflow用户
提问于 2018-08-11 14:33:51
回答 1查看 1.5K关注 0票数 4

我正在尝试使用以下标题将SSE4优化代码移植到霓虹灯优化:https://github.com/jratcliff63367/sse2neon/blob/master/SSE2NEON.h

在ODROID-xu4上编译此代码时出现编译错误:https://github.com/k06a/creepMiner/tree/feature/neon

代码语言:javascript
运行
复制
[  2%] Building CXX object CMakeFiles/creepMiner.dir/src/shabal/mshabal/mshabal_neon.cpp.o
In file included from /root/creepMiner-neon/src/shabal/mshabal/sse2neon.hpp:123:0,
                 from /root/creepMiner-neon/src/shabal/mshabal/mshabal_neon.cpp:22:
/usr/lib/gcc/arm-linux-gnueabihf/7/include/arm_neon.h: In function '__m128i _mm_set1_epi32(int)':
/usr/lib/gcc/arm-linux-gnueabihf/7/include/arm_neon.h:6733:1: error: inlining failed in call to always_inline 'int32x4_t vdupq_n_s32(int32_t)': target specific option mismatch
 vdupq_n_s32 (int32_t __a)
 ^~~~~~~~~~~
In file included from /root/creepMiner-neon/src/shabal/mshabal/mshabal_neon.cpp:22:0:
/root/creepMiner-neon/src/shabal/mshabal/sse2neon.hpp:230:7: note: called from here
     (x)
       ^
/root/creepMiner-neon/src/shabal/mshabal/sse2neon.hpp:383:12: note: in expansion of macro 'vreinterpretq_m128i_s32'
     return vreinterpretq_m128i_s32(vdupq_n_s32(_i));
            ^~~~~~~~~~~~~~~~~~~~~~~
CMakeFiles/creepMiner.dir/build.make:878: recipe for target 'CMakeFiles/creepMiner.dir/src/shabal/mshabal/mshabal_neon.cpp.o' failed
make[2]: *** [CMakeFiles/creepMiner.dir/src/shabal/mshabal/mshabal_neon.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/creepMiner.dir/all' failed
make[1]: *** [CMakeFiles/creepMiner.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

源文件具有以下特定选项:

代码语言:javascript
运行
复制
-marm -march=armv7-a+simd -mtune=cortex-a15.cortex-a7

CMakeLists.txt:

代码语言:javascript
运行
复制
if (USE_NEON AND NOT MINIMAL_BUILD)
    add_definitions(-DUSE_NEON)
    set(SOURCE_FILES ${SOURCE_FILES} src/shabal/mshabal/mshabal_neon.cpp)
    if (UNIX OR APPLE)
        set_source_files_properties(src/shabal/mshabal/mshabal_neon.cpp PROPERTIES COMPILE_FLAGS -marm)
        set_source_files_properties(src/shabal/mshabal/mshabal_neon.cpp PROPERTIES COMPILE_FLAGS -march=armv7-a+simd)
        set_source_files_properties(src/shabal/mshabal/mshabal_neon.cpp PROPERTIES COMPILE_FLAGS -mtune=cortex-a15.cortex-a7)
    elseif (MSVC)
        set_source_files_properties(src/shabal/mshabal/mshabal_neon.cpp PROPERTIES COMPILE_FLAGS /arch:ARMv7)
    endif ()
endif ()

看起来当前的架构不支持vdupq_n_s32,但它应该支持,因为它支持armv7

处理器信息:

代码语言:javascript
运行
复制
$ cat /proc/cpuinfo

提供了以下内容:

代码语言:javascript
运行
复制
processor   : 0
model name  : ARMv7 Processor rev 3 (v7l)
BogoMIPS    : 90.00
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xc07
CPU revision    : 3

processor   : 1
model name  : ARMv7 Processor rev 3 (v7l)
BogoMIPS    : 90.00
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xc07
CPU revision    : 3

processor   : 2
model name  : ARMv7 Processor rev 3 (v7l)
BogoMIPS    : 90.00
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xc07
CPU revision    : 3

processor   : 3
model name  : ARMv7 Processor rev 3 (v7l)
BogoMIPS    : 90.00
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xc07
CPU revision    : 3

processor   : 4
model name  : ARMv7 Processor rev 3 (v7l)
BogoMIPS    : 120.00
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x2
CPU part    : 0xc0f
CPU revision    : 3

processor   : 5
model name  : ARMv7 Processor rev 3 (v7l)
BogoMIPS    : 120.00
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x2
CPU part    : 0xc0f
CPU revision    : 3

processor   : 6
model name  : ARMv7 Processor rev 3 (v7l)
BogoMIPS    : 120.00
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x2
CPU part    : 0xc0f
CPU revision    : 3

processor   : 7
model name  : ARMv7 Processor rev 3 (v7l)
BogoMIPS    : 120.00
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x2
CPU part    : 0xc0f
CPU revision    : 3

Hardware    : ODROID-XU4
Revision    : 0100
Serial      : 0000000000000000

获取本机arch:

代码语言:javascript
运行
复制
gcc -march=native -v

GIves如下:

代码语言:javascript
运行
复制
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/7/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 7.3.0-16ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --with-as=/usr/bin/arm-linux-gnueabihf-as --with-ld=/usr/bin/arm-linux-gnueabihf-ld --program-suffix=-7 --program-prefix=arm-linux-gnueabihf- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-multilib --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 7.3.0 (Ubuntu/Linaro 7.3.0-16ubuntu3)

也许这是一个问题?我只看到--with-arch=armv7-a --with-fpu=vfpv3-d16支持,但它应该是vfpv4支持。是吗?我应该重新配置GCC吗?这会有帮助吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-11 23:39:41

-mfpu=neon应该可以解决这个问题。

顺便说一句,你真的希望仅仅包含头文件就能达到目的吗?

霓虹灯有大量的指令,这些指令在Intel机器上是不可用的,特别是在排列方面。

你将得到的是大量的vtbl指令,这些指令到处都有令人讨厌的延迟,它们疯狂地消耗着周期。

简单地依赖别人的通用解决方案不能称为优化IMO。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51797123

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档