diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index f77694d801..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,9 +0,0 @@ -[submodule "third_party/asmjit"] - path = third_party/asmjit - url = https://github.com/asmjit/asmjit.git -[submodule "third_party/cpuinfo"] - path = third_party/cpuinfo - url = https://github.com/pytorch/cpuinfo.git -[submodule "third_party/googletest"] - path = third_party/googletest - url = https://github.com/google/googletest.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 036b824a67..494e261dba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,8 +106,16 @@ target_compile_options(fbgemm_avx512 PRIVATE if(NOT TARGET asmjit) #Download asmjit from github if ASMJIT_SRC_DIR is not specified. if(NOT DEFINED ASMJIT_SRC_DIR) - set(ASMJIT_SRC_DIR "${CMAKE_SOURCE_DIR}/third_party/asmjit" CACHE STRING - "asmjit source directory from submodules") + message(STATUS "Downloading asmjit to ${FBGEMM_THIRDPARTY_DIR}/asmjit + (define ASMJIT_SRC_DIR to avoid it)") + configure_file("${FBGEMM_SOURCE_DIR}/cmake/modules/DownloadASMJIT.cmake" + "${FBGEMM_BINARY_DIR}/asmjit-download/CMakeLists.txt") + execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . + WORKING_DIRECTORY "${FBGEMM_BINARY_DIR}/asmjit-download") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . + WORKING_DIRECTORY "${FBGEMM_BINARY_DIR}/asmjit-download") + set(ASMJIT_SRC_DIR "${FBGEMM_THIRDPARTY_DIR}/asmjit" CACHE STRING + "asmjit source directory") endif() #build asmjit @@ -119,8 +127,16 @@ endif() if(NOT TARGET cpuinfo) #Download cpuinfo from github if CPUINFO_SOURCE_DIR is not specified. if(NOT DEFINED CPUINFO_SOURCE_DIR) - set(CPUINFO_SOURCE_DIR "${CMAKE_SOURCE_DIR}/third_party/cpuinfo" CACHE STRING - "cpuinfo source directory from submodules") + message(STATUS "Downloading cpuinfo to ${FBGEMM_THIRDPARTY_DIR}/cpuinfo + (define CPUINFO_SOURCE_DIR to avoid it)") + configure_file("${FBGEMM_SOURCE_DIR}/cmake/modules/DownloadCPUINFO.cmake" + "${FBGEMM_BINARY_DIR}/cpuinfo-download/CMakeLists.txt") + execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . + WORKING_DIRECTORY "${FBGEMM_BINARY_DIR}/cpuinfo-download") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . + WORKING_DIRECTORY "${FBGEMM_BINARY_DIR}/cpuinfo-download") + set(CPUINFO_SOURCE_DIR "${FBGEMM_THIRDPARTY_DIR}/cpuinfo" CACHE STRING + "cpuinfo source directory") endif() #build cpuinfo diff --git a/README.md b/README.md index 9eea98b3f6..63d431dff7 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,8 @@ is **on**. Turn it off by setting FBGEMM\_BUILD\_TESTS to off. You can download [asmjit][1], [cpuinfo][2], [googletest][3] and set ASMJIT\_SRC\_DIR, CPUINFO\_SRC\_DIR, GOOGLETEST\_SOURCE\_DIR respectively for cmake to find these libraries. If any of these variables is not set, cmake will -build the git submodules found in the third\_party directory. +try to download that missing library in a folder called third\_party in the +build directory and build it using the downloaded source code. FBGEMM, in general, does not have any dependency on Intel MKL. However, for performance comparison, some benchmarks use MKL functions. If MKL is found or @@ -62,8 +63,6 @@ not found, the benchmarks are not built. General build instructions are as follows: ``` -git clone --recursive https://github.com/pytorch/FBGEMM.git -cd FBGEMM mkdir build && cd build cmake .. make diff --git a/cmake/modules/DownloadASMJIT.cmake b/cmake/modules/DownloadASMJIT.cmake new file mode 100644 index 0000000000..ca396002bc --- /dev/null +++ b/cmake/modules/DownloadASMJIT.cmake @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + +project(asmjit-download NONE) + +include(ExternalProject) + +ExternalProject_Add(asmjit + GIT_REPOSITORY https://github.com/asmjit/asmjit + GIT_TAG 673dcefaa048c5f5a2bf8b85daf8f7b9978d018a + SOURCE_DIR "${FBGEMM_THIRDPARTY_DIR}/asmjit" + BINARY_DIR "${FBGEMM_BINARY_DIR}/asmjit" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) diff --git a/cmake/modules/DownloadCPUINFO.cmake b/cmake/modules/DownloadCPUINFO.cmake new file mode 100644 index 0000000000..529dcc22dd --- /dev/null +++ b/cmake/modules/DownloadCPUINFO.cmake @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + +project(cpuinfo-download NONE) + +include(ExternalProject) + +ExternalProject_Add(cpuinfo + GIT_REPOSITORY https://github.com/pytorch/cpuinfo + GIT_TAG master + SOURCE_DIR "${FBGEMM_THIRDPARTY_DIR}/cpuinfo" + BINARY_DIR "${FBGEMM_BINARY_DIR}/cpuinfo" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) diff --git a/cmake/modules/DownloadGTEST.cmake b/cmake/modules/DownloadGTEST.cmake new file mode 100644 index 0000000000..2d1286b158 --- /dev/null +++ b/cmake/modules/DownloadGTEST.cmake @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + +project(googletest-download NONE) + +include(ExternalProject) + +ExternalProject_Add(googletest + GIT_REPOSITORY https://github.com/google/googletest + GIT_TAG 0fc5466dbb9e623029b1ada539717d10bd45e99e + SOURCE_DIR "${FBGEMM_THIRDPARTY_DIR}/googletest" + BINARY_DIR "${FBGEMM_BINARY_DIR}/googletest" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index dfd1f24557..f68da73015 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,8 +4,17 @@ if(FBGEMM_BUILD_TESTS AND NOT TARGET gtest) #Download Googletest framework from github if #GOOGLETEST_SOURCE_DIR is not specified. if(NOT DEFINED GOOGLETEST_SOURCE_DIR) - set(GOOGLETEST_SOURCE_DIR "${CMAKE_SOURCE_DIR}/third_party/googletest" - CACHE STRING "googletest source directory from submodules") + message(STATUS "Downloading googletest to + ${FBGEMM_THIRDPARTY_DIR}/googletest + (define GOOGLETEST_SOURCE_DIR to avoid it)") + configure_file("${FBGEMM_SOURCE_DIR}/cmake/modules/DownloadGTEST.cmake" + "${FBGEMM_BINARY_DIR}/googletest-download/CMakeLists.txt") + execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . + WORKING_DIRECTORY "${FBGEMM_BINARY_DIR}/googletest-download") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . + WORKING_DIRECTORY "${FBGEMM_BINARY_DIR}/googletest-download") + set(GOOGLETEST_SOURCE_DIR "${FBGEMM_THIRDPARTY_DIR}/googletest" CACHE STRING + "googletest source directory") endif() #build Googletest framework diff --git a/third_party/asmjit b/third_party/asmjit deleted file mode 120000 index c03bbae73f..0000000000 --- a/third_party/asmjit +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fc251c914e77cd079e58982cdab00a47539d7fc5 diff --git a/third_party/cpuinfo b/third_party/cpuinfo deleted file mode 120000 index 093645e198..0000000000 --- a/third_party/cpuinfo +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d5e37adf1406cf899d7d9ec1d317c47506ccb970 diff --git a/third_party/googletest b/third_party/googletest deleted file mode 120000 index 88ae7c60fa..0000000000 --- a/third_party/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3f5b5b8f8493a03fa25f1e4a7eae7678514a431d