fbgemm: add package (#4192)
* fbgemm: add package
* asmjit: enable all platform
* Revert "asmjit: enable all platform"
This reverts commit 5ddf6ec6fc
.
* fbgemm: fix openmp
* limit plat
pull/4200/head
parent
afdaf1a804
commit
ae87044f3c
2 changed files with 103 additions and 0 deletions
@ -0,0 +1,57 @@ |
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 0b51071..ecc2c9e 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -240,8 +240,8 @@ message(WARNING "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
|
||||
message(WARNING "CMAKE_CXX_FLAGS_DEBUG is ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
message(WARNING "CMAKE_CXX_FLAGS_RELEASE is ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
message(WARNING "==========")
|
||||
-
|
||||
-if(NOT TARGET asmjit)
|
||||
+find_package(asmjit CONFIG REQUIRED)
|
||||
+if(0)
|
||||
#Download asmjit from github if ASMJIT_SRC_DIR is not specified.
|
||||
if(NOT DEFINED ASMJIT_SRC_DIR)
|
||||
set(ASMJIT_SRC_DIR "${FBGEMM_SOURCE_DIR}/third_party/asmjit"
|
||||
@@ -269,8 +269,8 @@ if(NOT TARGET asmjit)
|
||||
target_compile_options_if_supported(asmjit -Wno-unused-but-set-variable)
|
||||
endif()
|
||||
endif()
|
||||
-
|
||||
-if(NOT TARGET cpuinfo)
|
||||
+find_package(cpuinfo CONFIG REQUIRED)
|
||||
+if(0)
|
||||
#Download cpuinfo from github if CPUINFO_SOURCE_DIR is not specified.
|
||||
if(NOT DEFINED CPUINFO_SOURCE_DIR)
|
||||
set(CPUINFO_SOURCE_DIR "${FBGEMM_SOURCE_DIR}/third_party/cpuinfo"
|
||||
@@ -354,12 +354,7 @@ target_include_directories(fbgemm BEFORE
|
||||
PUBLIC $<BUILD_INTERFACE:${FBGEMM_SOURCE_DIR}>
|
||||
PUBLIC $<BUILD_INTERFACE:${FBGEMM_SOURCE_DIR}/include>)
|
||||
|
||||
-target_link_libraries(fbgemm
|
||||
- $<BUILD_INTERFACE:asmjit>
|
||||
- $<BUILD_INTERFACE:cpuinfo>)
|
||||
-add_dependencies(fbgemm
|
||||
- asmjit
|
||||
- cpuinfo)
|
||||
+target_link_libraries(fbgemm asmjit cpuinfo)
|
||||
|
||||
if(OpenMP_FOUND)
|
||||
target_link_libraries(fbgemm OpenMP::OpenMP_CXX)
|
||||
@@ -383,12 +378,12 @@ install(
|
||||
|
||||
if(MSVC)
|
||||
if(FBGEMM_LIBRARY_TYPE STREQUAL "shared")
|
||||
- install(
|
||||
- FILES $<TARGET_PDB_FILE:fbgemm> $<TARGET_PDB_FILE:asmjit>
|
||||
- DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL)
|
||||
+ # install(
|
||||
+ # FILES $<TARGET_PDB_FILE:fbgemm> $<TARGET_PDB_FILE:asmjit>
|
||||
+ # DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL)
|
||||
endif()
|
||||
install(TARGETS fbgemm DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
- install(TARGETS asmjit DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
+ # install(TARGETS asmjit DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
#Make project importable from the build directory
|
@ -0,0 +1,46 @@ |
||||
package("fbgemm") |
||||
set_homepage("https://github.com/pytorch/FBGEMM") |
||||
set_description("FB (Facebook) + GEMM (General Matrix-Matrix Multiplication) - https://code.fb.com/ml-applications/fbgemm/") |
||||
set_license("BSD") |
||||
|
||||
add_urls("https://github.com/pytorch/FBGEMM/archive/refs/tags/$(version).tar.gz", |
||||
"https://github.com/pytorch/FBGEMM.git") |
||||
|
||||
add_versions("v0.7.0", "c51ac26bc0aa8fef7e80631c4abdd3a7c33d1a097359cef9b008bf9e1203c071") |
||||
|
||||
add_patches("0.7.0", "patches/0.7.0/dep-unbundle.patch", "f3117ff728989146d5ab0c370fe410c73459091f65cae5f6b304e5637889fb8f") |
||||
|
||||
-- need libtorch |
||||
add_configs("gpu", {description = "Build fbgemm_gpu library", default = false, type = "boolean"}) |
||||
add_configs("cpu", {description = "Build FBGEMM_GPU without GPU support", default = false, type = "boolean"}) |
||||
add_configs("rocm", {description = "Build FBGEMM_GPU for ROCm", default = false, type = "boolean"}) |
||||
|
||||
add_deps("cmake", "python", {kind = "binary"}) |
||||
add_deps("asmjit", "cpuinfo", "openmp") |
||||
|
||||
-- mingw support: https://github.com/pytorch/FBGEMM/pull/2114 |
||||
-- arm support: https://github.com/pytorch/FBGEMM/issues/2074 |
||||
on_install("windows|x64", "linux|x86_64", "macosx|x86_64", function (package) |
||||
io.replace("CMakeLists.txt", "-Werror", "", {plain = true}) |
||||
|
||||
if not package:config("shared") then |
||||
package:add("defines", "FBGEMM_STATIC") |
||||
end |
||||
|
||||
local configs = {"-DFBGEMM_BUILD_TESTS=OFF", "-DFBGEMM_BUILD_BENCHMARKS=OFF"} |
||||
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) |
||||
table.insert(configs, "-DFBGEMM_LIBRARY_TYPE=" .. (package:config("shared") and "shared" or "static")) |
||||
|
||||
table.insert(configs, "-DFBGEMM_BUILD_FBGEMM_GPU=" .. (package:config("gpu") and "ON" or "OFF")) |
||||
table.insert(configs, "-DFBGEMM_CPU_ONLY=" .. (package:config("cpu") and "ON" or "OFF")) |
||||
table.insert(configs, "-DUSE_ROCM=" .. (package:config("rocm") and "ON" or "OFF")) |
||||
import("package.tools.cmake").install(package, configs, {packagedeps = {"asmjit", "cpuinfo"}}) |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
assert(package:check_cxxsnippets({test = [[ |
||||
void test() { |
||||
fbgemm::Xor128(); |
||||
} |
||||
]]}, {configs = {languages = "c++20"}, includes = "fbgemm/QuantUtilsAvx2.h"})) |
||||
end) |
Loading…
Reference in new issue