Skip to content

Commit

Permalink
[cpuinfo,fbgemm,xnnpack] update cpuinfo to latest (#23944)
Browse files Browse the repository at this point in the history
* [cpuinfo] update to latest

* use official support of CMake find_package

* [cpuinfo] update triplet support

* [nnpack] fix cpuinfo usage

* [qnnpack] fix cpuinfo usage

* [fbgemm] fix cpuinfo usage

* [xnnpack] fix cpuinfo usage

* [cpuinfo] add license

* [nnpack] port license/dependencies

* [qnnpack] port license

* [xnnpack] port license

* [fbgemm] port license

* fix supports

* I think this should work?

* alright, arm&windows is unsupported... for now

Co-authored-by: nicole mazzuca <[email protected]>
  • Loading branch information
luncliff and strega-nil authored Apr 12, 2022
1 parent 3286c67 commit e809a42
Show file tree
Hide file tree
Showing 19 changed files with 117 additions and 126 deletions.
81 changes: 0 additions & 81 deletions ports/cpuinfo/fix-install.patch

This file was deleted.

65 changes: 47 additions & 18 deletions ports/cpuinfo/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,38 +1,68 @@
# On Windows, we can get a cpuinfo.dll, but it exports no symbols.
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO pytorch/cpuinfo
REF 5916273f79a21551890fd3d56fc5375a78d1598d
SHA512 50e537b61d991e8579577fb1ecf8d9ceb2171dbad96dfe159a062eadfdc0b2372b94988fc6f223c20e327453c7f55042ee06779f5b5fe0922f4470f746c9686b
REF b40bae27785787b6dd70788986fd96434cf90ae2
SHA512 dbbe4f3e1d5ae74ffc8ba2cba0ab745a23f4993788f4947825ef5125dd1cbed3e13e0c98e020e6fcfa9879f54f06d7cba4de73ec29f77649b6a27b4ab82c8f1c
HEAD_REF master
PATCHES
fix-install.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
tools CPUINFO_BUILD_TOOLS
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS_DEBUG
-DCPUINFO_BUILD_TOOLS=OFF
-DCPUINFO_LOG_LEVEL=debug
OPTIONS_RELEASE
${FEATURE_OPTIONS}
-DCPUINFO_LOG_LEVEL=default
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
list(APPEND LINK_OPTIONS -DCPUINFO_LIBRARY_TYPE=shared)
else()
list(APPEND LINK_OPTIONS -DCPUINFO_LIBRARY_TYPE=static)
endif()

if(VCPKG_CRT_LINKAGE STREQUAL "dynamic")
list(APPEND LINK_OPTIONS -DCPUINFO_RUNTIME_TYPE=shared)
else()
list(APPEND LINK_OPTIONS -DCPUINFO_RUNTIME_TYPE=static)
endif()

# hack to get around that toolchains/windows.cmake doesn't set CMAKE_SYSTEM_ARCHITECTURE
set(CPUINFO_TARGET_PROCESSOR_param "")
if(VCPKG_TARGET_IS_WINDOWS)
# NOTE: arm64-windows is unsupported for now;
# see https://github.com/pytorch/cpuinfo/pull/82 for updates
# NOTE: arm-windows is unsupported
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(CPUINFO_TARGET_PROCESSOR_param "-DCPUINFO_TARGET_PROCESSOR=x86")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(CPUINFO_TARGET_PROCESSOR_param "-DCPUINFO_TARGET_PROCESSOR=AMD64")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
set(CPUINFO_TARGET_PROCESSOR_param "-DCPUINFO_TARGET_PROCESSOR=ARM")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(CPUINFO_TARGET_PROCESSOR_param "-DCPUINFO_TARGET_PROCESSOR=ARM64")
endif()
endif()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
${LINK_OPTIONS}
${CPUINFO_TARGET_PROCESSOR_param}
-DCPUINFO_BUILD_UNIT_TESTS=OFF
-DCPUINFO_BUILD_MOCK_TESTS=OFF
-DCPUINFO_BUILD_BENCHMARKS=OFF
OPTIONS_DEBUG
-DCPUINFO_LOG_LEVEL=debug
OPTIONS_RELEASE
-DCPUINFO_LOG_LEVEL=default
)
vcpkg_install_cmake()
vcpkg_cmake_install()
vcpkg_cmake_config_fixup()
vcpkg_copy_pdbs()
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/unofficial-${PORT} TARGET_PATH share/unofficial-${PORT})
vcpkg_fixup_pkgconfig() # pkg_check_modules(libcpuinfo)

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)

Expand All @@ -43,5 +73,4 @@ if("tools" IN_LIST FEATURES)
)
endif()

# Handle copyright
configure_file(${SOURCE_PATH}/LICENSE ${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright COPYONLY)
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
14 changes: 13 additions & 1 deletion ports/cpuinfo/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{
"name": "cpuinfo",
"version-date": "2021-04-04",
"version-date": "2022-04-02",
"description": "CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)",
"homepage": "https://github.com/pytorch/cpuinfo",
"license": "BSD-2-Clause",
"supports": "!(arm & windows)",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"tools": {
"description": "Build cpuinfo command-line tools"
Expand Down
10 changes: 5 additions & 5 deletions ports/fbgemm/fix-cmakelists.patch
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ index 6f19a16..3c758d2 100644
endif()

-if(NOT TARGET cpuinfo)
+find_package(unofficial-cpuinfo CONFIG REQUIRED) # target 'unofficial::cpuinfo::cpuinfo'
+find_package(cpuinfo CONFIG REQUIRED) # target 'cpuinfo::cpuinfo'
+if(FALSE)
#Download cpuinfo from github if CPUINFO_SOURCE_DIR is not specified.
if(NOT DEFINED CPUINFO_SOURCE_DIR)
Expand All @@ -68,15 +68,15 @@ index 6f19a16..3c758d2 100644
- PRIVATE "${ASMJIT_SRC_DIR}/src"
- PRIVATE "${CPUINFO_SOURCE_DIR}/include")
+)
+target_link_libraries(fbgemm_generic PUBLIC asmjit::asmjit unofficial::cpuinfo::cpuinfo)
+target_link_libraries(fbgemm_generic PUBLIC asmjit::asmjit cpuinfo::cpuinfo)

target_include_directories(fbgemm_avx2 BEFORE
PUBLIC $<BUILD_INTERFACE:${FBGEMM_SOURCE_DIR}>
PUBLIC $<BUILD_INTERFACE:${FBGEMM_SOURCE_DIR}/include>
- PRIVATE "${ASMJIT_SRC_DIR}/src"
- PRIVATE "${CPUINFO_SOURCE_DIR}/include")
+)
+target_link_libraries(fbgemm_avx2 PUBLIC asmjit::asmjit unofficial::cpuinfo::cpuinfo)
+target_link_libraries(fbgemm_avx2 PUBLIC asmjit::asmjit cpuinfo::cpuinfo)

target_include_directories(fbgemm_avx512 BEFORE
PUBLIC $<BUILD_INTERFACE:${FBGEMM_SOURCE_DIR}>
Expand All @@ -95,7 +95,7 @@ index 6f19a16..3c758d2 100644
- $<TARGET_OBJECTS:fbgemm_avx2>
- $<TARGET_OBJECTS:fbgemm_avx512>)
+)
+target_link_libraries(fbgemm_avx512 PUBLIC asmjit::asmjit unofficial::cpuinfo::cpuinfo)
+target_link_libraries(fbgemm_avx512 PUBLIC asmjit::asmjit cpuinfo::cpuinfo)
+
+add_library(fbgemm
+ $<TARGET_OBJECTS:fbgemm_generic>
Expand Down Expand Up @@ -131,7 +131,7 @@ index 6f19a16..3c758d2 100644
-target_link_libraries(fbgemm $<BUILD_INTERFACE:asmjit>
- $<BUILD_INTERFACE:cpuinfo>)
-add_dependencies(fbgemm asmjit cpuinfo)
+target_link_libraries(fbgemm PUBLIC asmjit::asmjit unofficial::cpuinfo::cpuinfo)
+target_link_libraries(fbgemm PUBLIC asmjit::asmjit cpuinfo::cpuinfo)

install(TARGETS fbgemm EXPORT fbgemmLibraryConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down
3 changes: 2 additions & 1 deletion ports/fbgemm/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "fbgemm",
"version-date": "2021-03-18",
"port-version": 3,
"port-version": 4,
"description": "FB (Facebook) + GEMM (General Matrix-Matrix Multiplication)",
"homepage": "https://code.fb.com/ml-applications/fbgemm/",
"license": "BSD-3-Clause",
"supports": "!(x86 | uwp)",
"dependencies": [
"asmjit",
Expand Down
4 changes: 2 additions & 2 deletions ports/nnpack/fix-cmakelists.patch
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ index 5ecd2df..8565044 100644
"${CONFU_DEPENDENCIES_BINARY_DIR}/cpuinfo")
ENDIF()
-TARGET_LINK_LIBRARIES(nnpack PRIVATE cpuinfo)
+find_package(unofficial-cpuinfo CONFIG REQUIRED)
+target_link_libraries(nnpack PUBLIC unofficial::cpuinfo::cpuinfo)
+find_package(cpuinfo CONFIG REQUIRED)
+target_link_libraries(nnpack PUBLIC cpuinfo::cpuinfo)

# ---[ Configure pthreadpool
-IF(NOT TARGET pthreadpool)
Expand Down
5 changes: 2 additions & 3 deletions ports/nnpack/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ vcpkg_from_github(
fix-cmakelists.patch
)

vcpkg_configure_cmake(
vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DNNPACK_BACKEND=psimd
-DNNPACK_BUILD_TESTS=OFF
-DNNPACK_BUILD_BENCHMARKS=OFF
-DNNPACK_CUSTOM_THREADPOOL=OFF
)
vcpkg_install_cmake()
vcpkg_cmake_install()
vcpkg_copy_pdbs()

file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
Expand Down
11 changes: 8 additions & 3 deletions ports/nnpack/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
{
"name": "nnpack",
"version-date": "2021-02-21",
"port-version": 2,
"port-version": 3,
"description": "Acceleration package for neural networks on multi-core CPUs",
"homepage": "https://github.com/Maratyszcza/NNPACK",
"supports": "linux & osx",
"license": "BSD-2-Clause",
"supports": "linux | osx",
"dependencies": [
"cpuinfo",
"fp16",
"fxdiv",
"psimd",
"pthreadpool"
"pthreadpool",
{
"name": "vcpkg-cmake",
"host": true
}
]
}
4 changes: 2 additions & 2 deletions ports/qnnpack/use-packages.patch
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ index a5ddc49..05e1279 100644
ENDIF()
-TARGET_LINK_LIBRARIES(qnnpack PRIVATE cpuinfo)
+
+find_package(unofficial-cpuinfo CONFIG REQUIRED)
+target_link_libraries(qnnpack PUBLIC unofficial::cpuinfo::clog unofficial::cpuinfo::cpuinfo)
+find_package(cpuinfo CONFIG REQUIRED)
+target_link_libraries(qnnpack PUBLIC cpuinfo::clog cpuinfo::cpuinfo)

# ---[ Configure pthreadpool
-IF(NOT TARGET pthreadpool)
Expand Down
3 changes: 2 additions & 1 deletion ports/qnnpack/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "qnnpack",
"version-date": "2021-02-26",
"port-version": 1,
"port-version": 2,
"description": "Quantized Neural Network PACKage - mobile-optimized implementation of quantized neural network operators",
"homepage": "https://github.com/pytorch/QNNPACK",
"license": "BSD-3-Clause",
"supports": "linux | osx",
"dependencies": [
"cpuinfo",
Expand Down
4 changes: 2 additions & 2 deletions ports/xnnpack/use-packages.patch
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ index b69ce50c..1e8938b7 100755
ENDIF()
ENDIF()
-TARGET_LINK_LIBRARIES(XNNPACK PRIVATE cpuinfo)
+find_package(unofficial-cpuinfo CONFIG REQUIRED)
+target_link_libraries(XNNPACK PUBLIC unofficial::cpuinfo::clog unofficial::cpuinfo::cpuinfo)
+find_package(cpuinfo CONFIG REQUIRED)
+target_link_libraries(XNNPACK PUBLIC cpuinfo::clog cpuinfo::cpuinfo)

# ---[ Configure pthreadpool
-IF(NOT TARGET pthreadpool)
Expand Down
3 changes: 2 additions & 1 deletion ports/xnnpack/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "xnnpack",
"version-date": "2021-05-17",
"port-version": 1,
"port-version": 2,
"description": "High-efficiency floating-point neural network inference operators for mobile, server, and Web",
"homepage": "https://github.com/google/XNNPACK",
"license": "BSD-3-Clause",
"supports": "!(arm & windows) & !uwp",
"dependencies": [
"cpuinfo",
Expand Down
1 change: 0 additions & 1 deletion scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ cppcoro:x64-uwp=fail
# The x64-linux pipeline uses gcc 9.3.0, which lacks C++20 coroutine support.
# This is known to work on x64-linux as of gcc 10.3.0.
cppgraphqlgen:x64-linux=fail
cpuinfo:arm64-windows=fail
crashpad:arm64-windows=fail
crashpad:arm-uwp=fail
crashpad:x64-linux=fail
Expand Down
Loading

0 comments on commit e809a42

Please sign in to comment.