Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 39 additions & 13 deletions X/XNNPACK/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,44 @@
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
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
Expand All @@ -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 \
Expand All @@ -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 = [
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <cpuinfo/internal-api.h>
#include <cpuinfo/log.h>

-#include <Windows.h>
+#include <windows.h>

static inline uint32_t bit_mask(uint32_t bits) {
return (UINT32_C(1) << bits) - UINT32_C(1);
Original file line number Diff line number Diff line change
@@ -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()
13 changes: 13 additions & 0 deletions X/XNNPACK/bundled/patches/xnnpack-freebsd.patch
Original file line number Diff line number Diff line change
@@ -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()

15 changes: 15 additions & 0 deletions X/XNNPACK/bundled/patches/xnnpack-soversion.patch
Original file line number Diff line number Diff line change
@@ -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 ")