diff --git a/X/XNNPACK/build_tarballs.jl b/X/XNNPACK/build_tarballs.jl index 1e34a540f1a..b8ae59826d1 100644 --- a/X/XNNPACK/build_tarballs.jl +++ b/X/XNNPACK/build_tarballs.jl @@ -3,17 +3,32 @@ using BinaryBuilder, Pkg name = "XNNPACK" -version = v"0.0.20200225" +version = v"0.0.20200323" + +cpuinfo_build_version = v"0.0.20200228" + +cpuinfo_compat = [ + cpuinfo_build_version, + v"0.0.20200522", # previously released + v"0.0.20200612", # due to pytorch v1.6.0 - v1.7.1, e.g. https://github.com/pytorch/pytorch/tree/v1.6.0/third_party/cpuinfo @ 63b254577ed77a8004a9be6ac707f3dccc4e1fd9 +] + +pthreadpool_build_version = v"0.0.20200302" + +pthreadpool_compat = [ + pthreadpool_build_version, + v"0.0.20200616", # due to pytorch v1.6.0 - v1.7.1, e.g. https://github.com/pytorch/pytorch/tree/v1.6.0/third_party/pthreadpool @ 029c88620802e1361ccf41d1970bd5b07fd6b7bb +] # Collection of sources required to complete build sources = [ - GitSource("https://github.com/google/XNNPACK.git", "7493bfb9d412e59529bcbced6a902d44cfa8ea1c"), + GitSource("https://github.com/google/XNNPACK.git", "1b354636b5942826547055252f3b359b54acff95"), DirectorySource("./bundled"), - GitSource("https://github.com/pytorch/cpuinfo.git", "d5e37adf1406cf899d7d9ec1d317c47506ccb970"), + GitSource("https://github.com/pytorch/cpuinfo.git", "d5e37adf1406cf899d7d9ec1d317c47506ccb970"; unpack_target="clog"), GitSource("https://github.com/Maratyszcza/FP16.git", "ba1d31f5eed2eb4a69e4dea3870a68c7c95f998f"), GitSource("https://github.com/Maratyszcza/FXdiv.git", "f8c5354679ec2597792bc70a9e06eff50c508b9a"), - GitSource("https://github.com/Maratyszcza/psimd.git", "10b4ffc6ea9e2e11668f86969586f88bc82aaefa"), - GitSource("https://github.com/Maratyszcza/pthreadpool.git", "7ad026703b3109907ad124025918da15cfd3f100"), + GitSource("https://github.com/Maratyszcza/psimd.git", "88882f601f8179e1987b7e7cf4a8012c9080ad44"), + GitSource("https://github.com/Maratyszcza/pthreadpool.git", "ebd50d0cfa3664d454ffdf246fcd228c3b370a11"), ] # Bash recipe for building across all platforms @@ -21,6 +36,11 @@ script = raw""" cd $WORKSPACE/srcdir/XNNPACK atomic_patch -p1 ../patches/xnnpack-disable-fast-math.patch atomic_patch -p1 ../patches/xnnpack-pic.patch +atomic_patch -p1 ../patches/xnnpack-soversion.patch +atomic_patch -p1 ../patches/xnnpack-freebsd.patch +if [[ $target == aarch64-* ]]; then + atomic_patch -p1 ../patches/xnnpack-disable-neon-fp16-arithmetic.patch +fi mkdir build cd build # Omitted cmake define of CPUINFO_SOURCE_DIR as there is a patch for cpuinfo @@ -29,7 +49,7 @@ cmake \ -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_LIBDIR=$libdir \ - -DCLOG_SOURCE_DIR=$WORKSPACE/srcdir/cpuinfo \ + -DCLOG_SOURCE_DIR=$WORKSPACE/srcdir/clog/cpuinfo \ -DFP16_SOURCE_DIR=$WORKSPACE/srcdir/FP16 \ -DFXDIV_SOURCE_DIR=$WORKSPACE/srcdir/FXdiv \ -DPSIMD_SOURCE_DIR=$WORKSPACE/srcdir/psimd \ @@ -38,18 +58,24 @@ cmake \ -DXNNPACK_BUILD_TESTS=OFF \ -DXNNPACK_BUILD_BENCHMARKS=OFF \ .. +if [[ $target == *-w64-mingw32* ]]; then + cd cpuinfo-source + atomic_patch -p1 ../../../patches/cpuinfo-mingw-lowercase-windows-include.patch + cd .. +fi cmake --build . -- -j $nproc -make install +make install/local +if [[ $target == *-w64-mingw32 ]]; then + install -Dvm 755 libXNNPACK.dll "${libdir}/libXNNPACK.dll" +fi install_license ../LICENSE """ # These are the platforms we will build for by default, unless further # platforms are passed in on the command line platforms = supported_platforms() -filter!(p -> !Sys.isfreebsd(p), platforms) # FreeBSD is unsupported -filter!(p -> !Sys.iswindows(p), platforms) # Windows is unsupported -filter!(p -> arch(p) != "powerpc64le", platforms) # PowerPC64LE is unsupported -filter!(p -> arch(p) != "aarch64", platforms) # Disabled aarch64 as XNNPACK seems to specifically support armv8.2-a+fp16 which is not in https://github.com/JuliaPackaging/BinaryBuilderBase.jl/blob/master/src/Platforms.jl#L91 +filter!(p -> !(Sys.iswindows(p) && arch(p) == "i686"), platforms) # i686-Windows fails to link +filter!(p -> arch(p) != "powerpc64le", platforms) # PowerPC64LE is unsupported by XNNPACK (Unsupported architecture in src/init.c) # The products that we will ensure are always built products = [ @@ -58,8 +84,8 @@ products = [ # Dependencies that must be installed before this package can be built dependencies = Dependency[ - Dependency("CPUInfo_jll"; compat="0.0.20200122"), - Dependency("PThreadPool_jll"; compat="0.0.20191029"), + Dependency("CPUInfo_jll", cpuinfo_build_version; compat=join(string.(cpuinfo_compat), ", ")), + Dependency("PThreadPool_jll", pthreadpool_build_version; compat=join(string.(pthreadpool_compat), ", ")), ] # Build the tarballs, and possibly a `build.jl` as well. diff --git a/X/XNNPACK/bundled/patches/cpuinfo-mingw-lowercase-windows-include.patch b/X/XNNPACK/bundled/patches/cpuinfo-mingw-lowercase-windows-include.patch new file mode 100644 index 00000000000..85f17c2e1f3 --- /dev/null +++ b/X/XNNPACK/bundled/patches/cpuinfo-mingw-lowercase-windows-include.patch @@ -0,0 +1,13 @@ +diff --git a/src/x86/windows/init.c b/src/x86/windows/init.c +index eb3498a..7c300c8 100644 +--- a/src/x86/windows/init.c ++++ b/src/x86/windows/init.c +@@ -8,7 +8,7 @@ + #include + #include + +-#include ++#include + + static inline uint32_t bit_mask(uint32_t bits) { + return (UINT32_C(1) << bits) - UINT32_C(1); diff --git a/X/XNNPACK/bundled/patches/xnnpack-disable-neon-fp16-arithmetic.patch b/X/XNNPACK/bundled/patches/xnnpack-disable-neon-fp16-arithmetic.patch new file mode 100644 index 00000000000..0aa0790c3b4 --- /dev/null +++ b/X/XNNPACK/bundled/patches/xnnpack-disable-neon-fp16-arithmetic.patch @@ -0,0 +1,32 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9bcaa5816..8627e0546 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -863,11 +863,6 @@ SET(XNNPACK_AARCH64_NEONFMA_MICROKERNEL_SRCS + src/math/sigmoid-neonfma-rr2-lut64-p2-div.c + src/math/sigmoid-neonfma-rr2-p5-div.c) + +-SET(XNNPACK_AARCH64_NEONFP16ARITH_MICROKERNEL_SRCS +- src/f16-gemm/gen/4x8-neonfp16arith-ld64.c +- src/f16-gemm/gen/6x8-neonfp16arith-ld64.c +- src/f16-gemm/gen/8x8-neonfp16arith-ld64.c) +- + SET(XNNPACK_SSE_MICROKERNEL_SRCS + src/f32-avgpool/9p8x-sse-c4.c + src/f32-avgpool/9x-sse-c4.c +@@ -1482,7 +1477,6 @@ IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR IOS_ARCH MATCHES "^arm64.*") + LIST(APPEND XNNPACK_MICROKERNEL_SRCS ${XNNPACK_NEON_MICROKERNEL_SRCS}) + LIST(APPEND XNNPACK_MICROKERNEL_SRCS ${XNNPACK_NEONFMA_MICROKERNEL_SRCS}) + LIST(APPEND XNNPACK_MICROKERNEL_SRCS ${XNNPACK_AARCH64_NEONFMA_MICROKERNEL_SRCS}) +- LIST(APPEND XNNPACK_MICROKERNEL_SRCS ${XNNPACK_AARCH64_NEONFP16ARITH_MICROKERNEL_SRCS}) + LIST(APPEND XNNPACK_MICROKERNEL_SRCS ${XNNPACK_AARCH64_ASM_MICROKERNEL_SRCS}) + ENDIF() + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|x86_64|AMD64)$" OR IOS_ARCH MATCHES "^(i386|x86_64|AMD64)$") +@@ -1518,7 +1512,6 @@ IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^armv[5-8]" OR IOS_ARCH MATCHES "^armv7") + ENDIF() + ENDIF() + IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR IOS_ARCH MATCHES "^arm64.*") +- SET_PROPERTY(SOURCE ${XNNPACK_AARCH64_NEONFP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+fp16 ") + IF(IOS) + SET_PROPERTY(SOURCE ${XNNPACK_AARCH64_ASM_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -arch ${IOS_ARCH} ") + ENDIF() diff --git a/X/XNNPACK/bundled/patches/xnnpack-freebsd.patch b/X/XNNPACK/bundled/patches/xnnpack-freebsd.patch new file mode 100644 index 00000000000..8ee76cd974b --- /dev/null +++ b/X/XNNPACK/bundled/patches/xnnpack-freebsd.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9bcaa5816..56b28ef39 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -51,7 +51,7 @@ ENDIF() + + IF(NOT CMAKE_SYSTEM_NAME) + MESSAGE(FATAL_ERROR "CMAKE_SYSTEM_NAME not defined") +-ELSEIF(NOT CMAKE_SYSTEM_NAME MATCHES "^(Darwin|Linux|Android|Windows)$") ++ELSEIF(NOT CMAKE_SYSTEM_NAME MATCHES "^(Darwin|FreeBSD|Linux|Android|Windows)$") + MESSAGE(FATAL_ERROR "Unrecognized CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}") + ENDIF() + diff --git a/X/XNNPACK/bundled/patches/xnnpack-soversion.patch b/X/XNNPACK/bundled/patches/xnnpack-soversion.patch new file mode 100644 index 00000000000..4317f2b6e92 --- /dev/null +++ b/X/XNNPACK/bundled/patches/xnnpack-soversion.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9bcaa5816..dbe149f85 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1507,7 +1507,9 @@ ELSE() + ENDIF() + SET_TARGET_PROPERTIES(XNNPACK PROPERTIES + C_STANDARD 99 +- C_EXTENSIONS YES) ++ C_EXTENSIONS YES ++ VERSION 0.0 ++ SOVERSION 0) + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^armv[5-8]" OR IOS_ARCH MATCHES "^armv7") + SET_PROPERTY(SOURCE ${XNNPACK_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -marm ") + SET_PROPERTY(SOURCE ${XNNPACK_PSIMD_FASTMATH_MICROKERNEL_SRCS} ${XNNPACK_PSIMD_ACCMATH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mfpu=neon ")