weixin_39582656
weixin_39582656
2021-01-11 04:35

Use __ARM_NEON instead of __ARM_NEON__?

According to http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053b/IHI0053B_arm_c_language_extensions_2013.pdf (the ARM(R) C Language Extensions Release 1.1) __ARM_NEON has to be tested before including .

Also, apparently, __ARM_NEON__ is legacy, since it is not defined in the ARM C language extensions. (Seems to be confirmed by https://gcc.gnu.org/ml/gcc-patches/2015-01/msg02717.html).

So, we should make sure to replace all occurrences of __ARM_NEON__ with __ARM_NEON. Since some __ARM_NEON__ references are in src/DES_bs_b.c, I'll also post this in john-dev.

Also, src/configure and src/m4/jtr_arm_logic.m4 seem to use without any test of __ARM_NEON or __ARM_NEON__:


(bleeding-jumbo)JtR $ git grep -i -n ARM_NEON
src/DES_bs_b.c:34:#if defined(__ARM_NEON__) && DES_BS_DEPTH == 64
src/DES_bs_b.c:35:#include <arm_neon.h>
src/DES_bs_b.c:65:#elif defined(__ARM_NEON__) && ARCH_BITS == 32 && DES_BS_DEPTH == 96
src/DES_bs_b.c:66:#include <arm_neon.h>
src/DES_bs_b.c:99:#elif defined(__ARM_NEON__) && DES_BS_DEPTH == 128 && defined(DES_BS_2X64)
src/DES_bs_b.c:100:#include <arm_neon.h>
src/DES_bs_b.c:134:#elif defined(__ARM_NEON__) && DES_BS_DEPTH == 128
src/DES_bs_b.c:135:#include <arm_neon.h>
src/DES_bs_b.c:165:#elif defined(__ARM_NEON__) && \
src/DES_bs_b.c:168:#include <arm_neon.h>
src/DES_bs_b.c:201:#elif defined(__ARM_NEON__) && DES_BS_DEPTH == 256
src/DES_bs_b.c:202:#include <arm_neon.h>
src/arm32le.h:44:#ifdef __ARM_NEON__
src/arm32le.h:80:#ifdef __ARM_NEON__
src/configure:7838:    #include <arm_neon.h>
src/configure:7869:    #include <arm_neon.h>
src/m4/jtr_arm_logic.m4:34:       [[#include <arm_neon.h>
src/m4/jtr_arm_logic.m4:53:       [[#include <arm_neon.h>
src/pseudo_intrinsics.h:39:#ifdef __ARM_NEON__
src/pseudo_intrinsics.h:40:#include <arm_neon.h>
src/rawSHA1_ng_fmt_plug.c:26:#if defined(SIMD_COEF_32) && (SIMD_COEF_32 < 16 || ARCH_BITS >= 64) && !_MSC_VER && !__ARM_NEON__
src/rawSHA1_ng_fmt_plug.c:279:#if (__AVX512F__ && !__AVX512BW__) || __MIC__ || __ALTIVEC__ || __ARM_NEON__
src/rawSHA1_ng_fmt_plug.c:796:#elif __ARM_NEON__
src/rawSHA256_ng_fmt_plug.c:61:#elif __ARM_NEON__
src/rawSHA512_ng_fmt_plug.c:57:#elif __ARM_NEON__
src/simd-intrinsics.c:70:#elif __ARM_NEON__
src/simd-intrinsics.c:134:#if !__AVX512F__ && !__ARM_NEON__
src/simd-intrinsics.c:438:#if (ARCH_SIZE >= 8) || defined(__i386__) || defined(__ARM_NEON__)
src/simd-intrinsics.h:33:#elif __ARM_NEON__
</arm_neon.h></arm_neon.h></arm_neon.h></arm_neon.h></arm_neon.h></arm_neon.h></arm_neon.h></arm_neon.h></arm_neon.h></arm_neon.h></arm_neon.h>

When testing for __ARM_NEON in configure, the test might need some adjustment.

On my raspbian system with this CPU


pi ~ $ lscpu 
Architecture:          armv7l
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Core(s) per socket:    4
Socket(s):             1
Model name:            ARMv7 Processor rev 5 (v7l)
CPU max MHz:           900.0000
CPU min MHz:           600.0000
pi ~ $ cat /proc/cpuinfo 
processor   : 0
model name  : ARMv7 Processor rev 5 (v7l)
BogoMIPS    : 57.60
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xc07
CPU revision    : 5
[...]
processor   : 3
model name  : ARMv7 Processor rev 5 (v7l)
BogoMIPS    : 57.60
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xc07
CPU revision    : 5

Hardware    : BCM2709
Revision    : a01041
Serial      : 00000000........

Unfortunately, with these compilers


pi ~ $ gcc --version
gcc (Raspbian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

pi ~ $ clang --version
Raspbian clang version 3.5.0-10+rpi1 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: arm-unknown-linux-gnueabihf
Thread model: posix

I need some tricks to enable __ARM_NEON

clang:


pi ~ $ clang -dM -E -x c /dev/null | grep -i -E "(SIMD|NEON)"
pi ~ $ clang -march=armv7 -dM -E -x c /dev/null | grep -i -E "(SIMD|NEON)"
#define __ARM_NEON 1
#define __ARM_NEON__ 1

gcc:


pi ~ $ gcc -dM -E -x c /dev/null | grep -i -E "(SIMD|NEON)"
#define __ARM_NEON_FP 4
#define __ARM_FEATURE_SIMD32 1
pi ~ $ gcc -mfpu=neon -dM -E -x c /dev/null | grep -i -E "(SIMD|NEON)"
#define __ARM_NEON_FP 4
#define __ARM_NEON__ 1
#define __ARM_FEATURE_SIMD32 1
#define __ARM_NEON 1
pi ~ $ gcc -mfpu=neon-vfpv4 -dM -E -x c /dev/null | grep -i -E "(SIMD|NEON)"
#define __ARM_NEON_FP 6
#define __ARM_NEON__ 1
#define __ARM_FEATURE_SIMD32 1
#define __ARM_NEON 1

该提问来源于开源项目:openwall/john

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

10条回答