Stockfish
Stockfish copied to clipboard
dotprod unsupported for apple-silicon
Describe the issue
When building with make build ARCH=apple-silicon
on an Apple M1 chip, I get the following error:
/var/folders/5m/v_lfr66s1mg7l9qhv3mjfkfc0000gn/T//ccCMWtGb.s:641:2: error: instruction requires: dotprod
sdot v0.4s, v1.16b, v2.16b
^
/var/folders/5m/v_lfr66s1mg7l9qhv3mjfkfc0000gn/T//ccCMWtGb.s:783:2: error: instruction requires: dotprod
sdot v0.4s, v3.16b, v4.16b
^
(etc.)
make[1]: *** [evaluate_nnue.o] Error 1
make: *** [build] Error 2
Expected behavior
Build should complete successfully.
Steps to reproduce
make build ARCH=apple-silicon
Anything else?
This seems to be caused by PR #4400, which claims to add support for apple-silicon dot product instructions, but this is not working properly.
Operating system
MacOS
Stockfish version
472e726
can you provide the output of cat /proc/cpuinfo
(if the file exists on MacOS), and the version of the compiler used?
Cant reproduce on my M1 make -j build ARCH=apple-silicon
and cat /proc/cpuinfo
doesnt work. But theres this
sysctl -a | grep machdep.cpu
which doesnt give you much information.
machdep.cpu.cores_per_package: 8
machdep.cpu.core_count: 8
machdep.cpu.logical_per_package: 8
machdep.cpu.thread_count: 8
machdep.cpu.brand_string: Apple M1
can you provide the output of
cat /proc/cpuinfo
(if the file exists on MacOS), and the version of the compiler used?
The file doesn't exist on my machine either. Compiler version is gcc version 12.2.0 (Homebrew GCC 12.2.0)
.
actually the error message might be coming from from the assembler or down the toolchain in binutils. Can you see what additional output you get with
CXXFLAGS="-v" make build ARCH=apple-silicon
Weirdly enough, after a restart of the machine the issue no longer occurs. I'll close this issue then.
I ran CXXFLAGS="-v" make build ARCH=apple-silicon
before the restart though, and part of the output was this:
warning: MPC header version 1.2.1 differs from library version 1.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../aarch64-apple-darwin22/include"
ignoring duplicate directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/../../../../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12"
ignoring duplicate directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/../../../../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/aarch64-apple-darwin22"
ignoring duplicate directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/../../../../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/backward"
ignoring duplicate directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/../../../../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/local/include"
ignoring duplicate directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/../../../../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include-fixed"
ignoring nonexistent directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/../../../../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../aarch64-apple-darwin22/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12
/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/aarch64-apple-darwin22
/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/backward
/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include
/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include-fixed
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks
End of search list.
GNU C++17 (Homebrew GCC 12.2.0) version 12.2.0 (aarch64-apple-darwin22)
compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.25-GMP
warning: MPC header version 1.2.1 differs from library version 1.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 92be565a621eebe8268e8cf75aa62159
COLLECT_GCC_OPTIONS='-v' '-Wall' '-Wcast-qual' '-fno-exceptions' '-std=c++17' '-Wpedantic' '-Wextra' '-Wshadow' '-Wmissing-declarations' '-mabi=darwinpcs' '-D' 'USE_PTHREADS' '-D' 'NDEBUG' '-O3' '-D' 'IS_64BIT' '-D' 'USE_POPCNT' '-D' 'USE_NEON=8' '-march=armv8.2-a+dotprod' '-D' 'USE_NEON_DOTPROD' '-D' 'GIT_SHA="472e726b"' '-D' 'GIT_DATE="20230224"' '-flto' '-flto-partition=one' '-c' '-o' 'evaluate_nnue.o' '-mmacosx-version-min=10.14' '-nodefaultexport' '-mlittle-endian'
as -arch arm64 -v -mmacosx-version-min=10.14 -o evaluate_nnue.o /var/folders/5m/v_lfr66s1mg7l9qhv3mjfkfc0000gn/T//ccIVQ4sn.s
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
"/Library/Developer/CommandLineTools/usr/bin/clang" -cc1as -triple arm64-apple-macosx10.14.0 -filetype obj -main-file-name ccIVQ4sn.s -target-cpu apple-m1 -target-feature +v8.5a -target-feature +fp-armv8 -target-feature +neon -target-feature +crc -target-feature +crypto -target-feature +dotprod -target-feature +fp16fml -target-feature +ras -target-feature +lse -target-feature +rdm -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -fdebug-compilation-dir=/Users/jerry/Documents/Chess/Stockfish-dev-official/Stockfish/src -dwarf-debug-producer "Apple clang version 14.0.0 (clang-1400.0.29.202)" -dwarf-version=4 -mrelocation-model pic --mrelax-relocations -mllvm -disable-aligned-alloc-awareness=1 -o evaluate_nnue.o /var/folders/5m/v_lfr66s1mg7l9qhv3mjfkfc0000gn/T//ccIVQ4sn.s
/var/folders/5m/v_lfr66s1mg7l9qhv3mjfkfc0000gn/T//ccIVQ4sn.s:641:2: error: instruction requires: dotprod
sdot v0.4s, v1.16b, v2.16b
etc.
This issue occurs again with latest master.
Can't reproduce on Apple M1 Pro
$ sysctl -a | grep machdep.cpu machdep.cpu.cores_per_package: 8 machdep.cpu.core_count: 8 machdep.cpu.logical_per_package: 8 machdep.cpu.thread_count: 8 machdep.cpu.brand_string: Apple M1 Pro
/Applications/Xcode.app/Contents/Developer/usr/bin/make ARCH=apple-silicon COMP=gcc all g++ -v -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -m64 -mmacosx-version-min=10.14 -arch arm64 -DUSE_PTHREADS -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -DUSE_NEON=8 -march=armv8.2-a+dotprod -DUSE_NEON_DOTPROD -flto=full -c -o misc.o misc.cpp Apple clang version 13.1.6 (clang-1316.0.21.2.5) Target: arm64-apple-darwin21.4.0 Thread model: posix
$ ./stockfish Stockfish dev-20230303-nogit by the Stockfish developers (see AUTHORS file)
I believe this is not a Stockfish issue, but probably some issue with how the toolchain is setup on the user's machine. If anybody wants to help, probably best to have that exchange on discord.
I don't know if this would be helpful, but I had the same issue. I solved it via changing Makefile, in specific, this line:
CXXFLAGS += -march=armv8.2-a+dotprod -DUSE_NEON_DOTPROD
To this:
CXXFLAGS += -march=armv8-a+dotprod -DUSE_NEON_DOTPROD
OK, this latest suggestion might require a closer look, I'm reopening this issue.