mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Fix native arch builds on loongarch64
Adds support for LSX and LASX closes https://github.com/official-stockfish/Stockfish/pull/5600 No functional change
This commit is contained in:
parent
60351b9df9
commit
93869d5d0a
3 changed files with 54 additions and 4 deletions
1
AUTHORS
1
AUTHORS
|
@ -237,6 +237,7 @@ Unai Corzo (unaiic)
|
||||||
Uri Blass (uriblass)
|
Uri Blass (uriblass)
|
||||||
Vince Negri (cuddlestmonkey)
|
Vince Negri (cuddlestmonkey)
|
||||||
Viren
|
Viren
|
||||||
|
Wencey Wang
|
||||||
windfishballad
|
windfishballad
|
||||||
xefoci7612
|
xefoci7612
|
||||||
Xiang Wang (KatyushaScarlet)
|
Xiang Wang (KatyushaScarlet)
|
||||||
|
|
|
@ -26,6 +26,17 @@ check_znver_1_2() {
|
||||||
[ "$vendor_id" = "AuthenticAMD" ] && [ "$cpu_family" = "23" ] && znver_1_2=true
|
[ "$vendor_id" = "AuthenticAMD" ] && [ "$cpu_family" = "23" ] && znver_1_2=true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Set the file CPU loongarch64 architecture
|
||||||
|
set_arch_loongarch64() {
|
||||||
|
if check_flags 'lasx'; then
|
||||||
|
true_arch='loongarch64-lasx'
|
||||||
|
elif check_flags 'lsx'; then
|
||||||
|
true_arch='lonngarch64-lsx'
|
||||||
|
else
|
||||||
|
true_arch='loongarch64'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Set the file CPU x86_64 architecture
|
# Set the file CPU x86_64 architecture
|
||||||
set_arch_x86_64() {
|
set_arch_x86_64() {
|
||||||
if check_flags 'avx512vnni' 'avx512dq' 'avx512f' 'avx512bw' 'avx512vl'; then
|
if check_flags 'avx512vnni' 'avx512dq' 'avx512f' 'avx512bw' 'avx512vl'; then
|
||||||
|
@ -90,6 +101,10 @@ case $uname_s in
|
||||||
true_arch="$true_arch-neon"
|
true_arch="$true_arch-neon"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
'loongarch64'*)
|
||||||
|
file_os='linux'
|
||||||
|
set_arch_loongarch64
|
||||||
|
;;
|
||||||
*) # Unsupported machine type, exit with error
|
*) # Unsupported machine type, exit with error
|
||||||
printf 'Unsupported machine type: %s\n' "$uname_m"
|
printf 'Unsupported machine type: %s\n' "$uname_m"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
42
src/Makefile
42
src/Makefile
|
@ -100,6 +100,8 @@ VPATH = syzygy:nnue:nnue/features
|
||||||
# vnni512 = yes/no --- -mavx512vnni --- Use Intel Vector Neural Network Instructions 512
|
# vnni512 = yes/no --- -mavx512vnni --- Use Intel Vector Neural Network Instructions 512
|
||||||
# neon = yes/no --- -DUSE_NEON --- Use ARM SIMD architecture
|
# neon = yes/no --- -DUSE_NEON --- Use ARM SIMD architecture
|
||||||
# dotprod = yes/no --- -DUSE_NEON_DOTPROD --- Use ARM advanced SIMD Int8 dot product instructions
|
# dotprod = yes/no --- -DUSE_NEON_DOTPROD --- Use ARM advanced SIMD Int8 dot product instructions
|
||||||
|
# lsx = yes/no --- -mlsx --- Use Loongson SIMD eXtension
|
||||||
|
# lasx = yes/no --- -mlasx --- use Loongson Advanced SIMD eXtension
|
||||||
#
|
#
|
||||||
# Note that Makefile is space sensitive, so when adding new architectures
|
# Note that Makefile is space sensitive, so when adding new architectures
|
||||||
# or modifying existing flags, you have to make sure there are no extra spaces
|
# or modifying existing flags, you have to make sure there are no extra spaces
|
||||||
|
@ -125,7 +127,8 @@ ifeq ($(ARCH), $(filter $(ARCH), \
|
||||||
x86-64-vnni512 x86-64-vnni256 x86-64-avx512 x86-64-avxvnni x86-64-bmi2 \
|
x86-64-vnni512 x86-64-vnni256 x86-64-avx512 x86-64-avxvnni x86-64-bmi2 \
|
||||||
x86-64-avx2 x86-64-sse41-popcnt x86-64-modern x86-64-ssse3 x86-64-sse3-popcnt \
|
x86-64-avx2 x86-64-sse41-popcnt x86-64-modern x86-64-ssse3 x86-64-sse3-popcnt \
|
||||||
x86-64 x86-32-sse41-popcnt x86-32-sse2 x86-32 ppc-64 ppc-32 e2k \
|
x86-64 x86-32-sse41-popcnt x86-32-sse2 x86-32 ppc-64 ppc-32 e2k \
|
||||||
armv7 armv7-neon armv8 armv8-dotprod apple-silicon general-64 general-32 riscv64 loongarch64))
|
armv7 armv7-neon armv8 armv8-dotprod apple-silicon general-64 general-32 riscv64 \
|
||||||
|
loongarch64 loongarch64-lsx loongarch64-lasx))
|
||||||
SUPPORTED_ARCH=true
|
SUPPORTED_ARCH=true
|
||||||
else
|
else
|
||||||
SUPPORTED_ARCH=false
|
SUPPORTED_ARCH=false
|
||||||
|
@ -151,6 +154,8 @@ vnni512 = no
|
||||||
neon = no
|
neon = no
|
||||||
dotprod = no
|
dotprod = no
|
||||||
arm_version = 0
|
arm_version = 0
|
||||||
|
lsx = no
|
||||||
|
lasx = no
|
||||||
STRIP = strip
|
STRIP = strip
|
||||||
|
|
||||||
ifneq ($(shell which clang-format-18 2> /dev/null),)
|
ifneq ($(shell which clang-format-18 2> /dev/null),)
|
||||||
|
@ -370,8 +375,19 @@ ifeq ($(ARCH),riscv64)
|
||||||
arch = riscv64
|
arch = riscv64
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ARCH),loongarch64)
|
ifeq ($(findstring loongarch64,$(ARCH)),loongarch64)
|
||||||
arch = loongarch64
|
arch = loongarch64
|
||||||
|
prefetch = yes
|
||||||
|
|
||||||
|
ifeq ($(findstring -lasx,$(ARCH)),-lasx)
|
||||||
|
lsx = yes
|
||||||
|
lasx = yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(findstring -lsx,$(ARCH)),-lsx)
|
||||||
|
lsx = yes
|
||||||
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -408,7 +424,7 @@ ifeq ($(COMP),gcc)
|
||||||
ifeq ($(ARCH),riscv64)
|
ifeq ($(ARCH),riscv64)
|
||||||
CXXFLAGS += -latomic
|
CXXFLAGS += -latomic
|
||||||
endif
|
endif
|
||||||
else ifeq ($(ARCH),loongarch64)
|
else ifeq ($(arch),loongarch64)
|
||||||
CXXFLAGS += -latomic
|
CXXFLAGS += -latomic
|
||||||
else
|
else
|
||||||
CXXFLAGS += -m$(bits)
|
CXXFLAGS += -m$(bits)
|
||||||
|
@ -480,7 +496,7 @@ ifeq ($(COMP),clang)
|
||||||
ifeq ($(ARCH),riscv64)
|
ifeq ($(ARCH),riscv64)
|
||||||
CXXFLAGS += -latomic
|
CXXFLAGS += -latomic
|
||||||
endif
|
endif
|
||||||
else ifeq ($(ARCH),loongarch64)
|
else ifeq ($(arch),loongarch64)
|
||||||
CXXFLAGS += -latomic
|
CXXFLAGS += -latomic
|
||||||
else
|
else
|
||||||
CXXFLAGS += -m$(bits)
|
CXXFLAGS += -m$(bits)
|
||||||
|
@ -719,6 +735,18 @@ ifeq ($(dotprod),yes)
|
||||||
CXXFLAGS += -march=armv8.2-a+dotprod -DUSE_NEON_DOTPROD
|
CXXFLAGS += -march=armv8.2-a+dotprod -DUSE_NEON_DOTPROD
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(lasx),yes)
|
||||||
|
ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
|
||||||
|
CXXFLAGS += -mlasx
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(lsx),yes)
|
||||||
|
ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
|
||||||
|
CXXFLAGS += -mlsx
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
### 3.7 pext
|
### 3.7 pext
|
||||||
ifeq ($(pext),yes)
|
ifeq ($(pext),yes)
|
||||||
CXXFLAGS += -DUSE_PEXT
|
CXXFLAGS += -DUSE_PEXT
|
||||||
|
@ -835,6 +863,8 @@ help:
|
||||||
@echo "general-32 > unspecified 32-bit"
|
@echo "general-32 > unspecified 32-bit"
|
||||||
@echo "riscv64 > RISC-V 64-bit"
|
@echo "riscv64 > RISC-V 64-bit"
|
||||||
@echo "loongarch64 > LoongArch 64-bit"
|
@echo "loongarch64 > LoongArch 64-bit"
|
||||||
|
@echo "loongarch64-lsx > LoongArch 64-bit with SIMD eXtension"
|
||||||
|
@echo "loongarch64-lasx > LoongArch 64-bit with Advanced SIMD eXtension"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "Supported compilers:"
|
@echo "Supported compilers:"
|
||||||
@echo ""
|
@echo ""
|
||||||
|
@ -960,6 +990,8 @@ config-sanity: net
|
||||||
@echo "neon: '$(neon)'"
|
@echo "neon: '$(neon)'"
|
||||||
@echo "dotprod: '$(dotprod)'"
|
@echo "dotprod: '$(dotprod)'"
|
||||||
@echo "arm_version: '$(arm_version)'"
|
@echo "arm_version: '$(arm_version)'"
|
||||||
|
@echo "lsx: '$(lsx)'"
|
||||||
|
@echo "lasx: '$(lasx)'"
|
||||||
@echo "target_windows: '$(target_windows)'"
|
@echo "target_windows: '$(target_windows)'"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "Flags:"
|
@echo "Flags:"
|
||||||
|
@ -989,6 +1021,8 @@ config-sanity: net
|
||||||
@test "$(vnni256)" = "yes" || test "$(vnni256)" = "no"
|
@test "$(vnni256)" = "yes" || test "$(vnni256)" = "no"
|
||||||
@test "$(vnni512)" = "yes" || test "$(vnni512)" = "no"
|
@test "$(vnni512)" = "yes" || test "$(vnni512)" = "no"
|
||||||
@test "$(neon)" = "yes" || test "$(neon)" = "no"
|
@test "$(neon)" = "yes" || test "$(neon)" = "no"
|
||||||
|
@test "$(lsx)" = "yes" || test "$(lsx)" = "no"
|
||||||
|
@test "$(lasx)" = "yes" || test "$(lasx)" = "no"
|
||||||
@test "$(comp)" = "gcc" || test "$(comp)" = "icx" || test "$(comp)" = "mingw" || test "$(comp)" = "clang" \
|
@test "$(comp)" = "gcc" || test "$(comp)" = "icx" || test "$(comp)" = "mingw" || test "$(comp)" = "clang" \
|
||||||
|| test "$(comp)" = "armv7a-linux-androideabi16-clang" || test "$(comp)" = "aarch64-linux-android21-clang"
|
|| test "$(comp)" = "armv7a-linux-androideabi16-clang" || test "$(comp)" = "aarch64-linux-android21-clang"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue