Use NEON dotprod instructions in Stockfish if supported by CPU

This commit is contained in:
Peter Osterlund 2024-02-25 20:41:45 +01:00
parent bb02fffabd
commit fd23962fc4
3 changed files with 20 additions and 5 deletions

View File

@ -15,9 +15,9 @@ ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
UTIL_SRC_FILES += $(CPU_FEATS_SRC_FILES) $(CPU_FEATS)/src/cpuinfo_arm.c
LOCAL_ARM_NEON := false
endif
#ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
# UTIL_SRC_FILES += $(CPU_FEATS_SRC_FILES) $(CPU_FEATS)/src/cpuinfo_aarch64.c
#endif
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
UTIL_SRC_FILES += $(CPU_FEATS_SRC_FILES) $(CPU_FEATS)/src/cpuinfo_aarch64.c
endif
ifeq ($(TARGET_ARCH_ABI),x86)
UTIL_SRC_FILES += $(CPU_FEATS_SRC_FILES) $(CPU_FEATS)/src/cpuinfo_x86.c
endif

View File

@ -25,6 +25,8 @@
#if defined(__arm__)
#include "cpuinfo_arm.h"
#elif defined(__aarch64__)
#include "cpuinfo_aarch64.h"
#elif defined(__i386__)
#include "cpuinfo_x86.h"
#endif
@ -65,10 +67,14 @@ extern "C" JNIEXPORT jboolean JNICALL Java_org_petero_droidfish_engine_EngineUti
using namespace cpu_features;
ArmFeatures features = GetArmInfo().features;
return features.neon ? JNI_TRUE : JNI_FALSE;
#elif defined(__aarch64__)
using namespace cpu_features;
Aarch64Features features = GetAarch64Info().features;
return features.asimddp ? JNI_TRUE : JNI_FALSE;
#elif defined(__i386__)
using namespace cpu_features;
X86Features features = GetX86Info().features;
return features.sse4_1 ? JNI_TRUE : JNI_FALSE;
#endif
return true;
return JNI_TRUE;
}

View File

@ -12,7 +12,7 @@ ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_ARM_NEON := true
endif
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
MY_ARCH_DEF += -DIS_64BIT -DUSE_POPCNT -DUSE_NEON
MY_ARCH_DEF += -DIS_64BIT -DUSE_POPCNT -DUSE_NEON -march=armv8.2-a+dotprod -DUSE_NEON_DOTPROD
endif
ifeq ($(TARGET_ARCH_ABI),x86_64)
MY_ARCH_DEF += -DIS_64BIT -DUSE_SSE41 -msse4.1
@ -25,6 +25,15 @@ include $(CLEAR_VARS)
LOCAL_MODULE := stockfish
include $(LOCAL_PATH)/build_sf.mk
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
MY_ARCH_DEF := -DIS_64BIT -DUSE_POPCNT -DUSE_NEON
include $(CLEAR_VARS)
LOCAL_ARM_NEON := true
LOCAL_MODULE := stockfish_nosimd
include $(LOCAL_PATH)/build_sf.mk
stockfish : stockfish_nosimd
endif
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
MY_ARCH_DEF := -mthumb -march=armv7-a -mfloat-abi=softfp
include $(CLEAR_VARS)