The Apple M1 based machines are getting popular and for a reason. I’ve got a new MacBook Air, M1, 2020 running Monterey. This should allow to provide M1 binaries in due time. I’ve built SWI-Prolog (current GIT version) using XCode 13, using Macports to provide the dependencies. See here. The build works fine (using the current GIT sources), except for the Qt based console because the console is based on Qt5 which only exists for Intel on the Mac while Qt6 supports both Intel and the M1, but is SWI-Prolog doesn’t build using it.
Here are some comparisons to my dev machine running Ubuntu 21.10 on AMD3950X (16 cores, 32 threads) I get these figures (times in seconds):
Action | M1 | AMD3950X |
---|---|---|
Build time | 26 | 19 |
Benchmark avg | 0.648 | 0.678 |
I also tried building with GCC-11 from Macports (port install gcc11
). The build does something wrong with GCC’s runtime library. You get a working build using
CC=gcc-mp-11 CXX=g++-mp-11 cmake -DCMAKE_BUILD_TYPE=PGO -G Ninja ..
cp /opt/local/lib/libgcc/libgcc_s.1.1.dylib src
ninja
You get some suspicious warnings and a version that doesn’t pass ctest
. It does run the above benchmark in 0.617 seconds compared to 0.648 sec for Clang 13. That is pretty marginal compared to the almost double speed we get from GCC when comparing Clang and GCC on Mac Intel. It is rumored that gcc-12 will provide better support for the M1.
Finally I did some stress testing on concurrency by running chat80 N times concurrently over M threads. Times are elapsed times in seconds.
M | N | M1 | AMD3950X |
---|---|---|---|
1 | 1,000 | 5.599 | 6.416 |
2 | 1,000 | 5.790 | 6.346 |
4 | 1,000 | 6.005 | 6.447 |
8 | 1,000 | 8.840 | 6.553 |
16 | 1,000 | 17.579 | 6.692 |
32 | 1,000 | 42.723 | 9.753 |
16 | 10,000 | 193.825 | 67.625 |
We see the M1 slowing down between 4 and 8. AFAIK it has 4 fast and 4 slower cores which may explain that. The last two rows hint at CPU throttling to avoid overheating. It is still impressive and completely silent as it has no fan! For the desktop we see a slowdown between 16 and 32 due to hyperthreading. Otherwise it scales nearly perfectly.