Unverified Commit 8c881bc3 authored by Sang Ik Lee's avatar Sang Ik Lee Committed by GitHub

[MLIR] Use more threads when building mlir+llvm (#4147)

* Use optimal processor count for parallel build.

* Add missing dependency.
parent 34bf01c8
......@@ -41,20 +41,20 @@ set(NGRAPH_LIT_TEST_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/test/mlir)
# MLIR has to be pre-built before ngraph build starts
# this will clone and build MLIR during cmake config instead
# we will fetch and build it from the source if cmake is not configured to use
# we will fetch and build it from the source if cmake is not configured to use
# the prebuilt mlir
if (NOT NGRAPH_USE_PREBUILT_MLIR)
configure_file(${CMAKE_SOURCE_DIR}/cmake/mlir_fetch.cmake.in ${MLIR_PROJECT_ROOT}/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${MLIR_PROJECT_ROOT}")
configure_file(${CMAKE_SOURCE_DIR}/cmake/mlir_fetch.cmake.in ${MLIR_PROJECT_ROOT}/CMakeLists.txt @ONLY)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${MLIR_PROJECT_ROOT}")
# clone and build llvm
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --target ext_mlir_llvm
WORKING_DIRECTORY "${MLIR_PROJECT_ROOT}")
# clone and build llvm
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --target ext_mlir_llvm
WORKING_DIRECTORY "${MLIR_PROJECT_ROOT}")
# clone and build mlir
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --target ext_mlir
WORKING_DIRECTORY "${MLIR_PROJECT_ROOT}")
# clone and build mlir
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --target ext_mlir
WORKING_DIRECTORY "${MLIR_PROJECT_ROOT}")
endif()
# Enable modules for LLVM.
......
......@@ -23,35 +23,43 @@ project(mlir-fetch NONE)
ExternalProject_Add(
ext_mlir_llvm
PREFIX mlir_llvm
GIT_REPOSITORY ${MLIR_LLVM_REPO_URL}
GIT_TAG ${MLIR_LLVM_COMMIT_ID}
GIT_REPOSITORY @MLIR_LLVM_REPO_URL@
GIT_TAG @MLIR_LLVM_COMMIT_ID@
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
SOURCE_DIR ${MLIR_LLVM_ROOT}
SOURCE_DIR @MLIR_LLVM_ROOT@
DOWNLOAD_NO_PROGRESS TRUE
EXCLUDE_FROM_ALL TRUE
)
set(MLIR_DEPENDS ext_mlir_llvm)
include(ProcessorCount)
ProcessorCount(N)
if(N EQUAL 0)
set(N 8)
endif()
ExternalProject_Add(
ext_mlir
PREFIX mlir
DEPENDS ${MLIR_DEPENDS}
GIT_REPOSITORY ${MLIR_REPO_URL}
GIT_TAG ${MLIR_COMMIT_ID}
GIT_REPOSITORY @MLIR_REPO_URL@
GIT_TAG @MLIR_COMMIT_ID@
CONFIGURE_COMMAND ""
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_GENERATOR "@CMAKE_GENERATOR@"
CMAKE_GENERATOR_PLATFORM @CMAKE_GENERATOR_PLATFORM@
CMAKE_GENERATOR_TOOLSET @CMAKE_GENERATOR_TOOLSET@
BUILD_COMMAND ${CMAKE_COMMAND} ../llvm -DLLVM_BUILD_EXAMPLES=ON -DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_RTTI=ON -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
COMMAND ${CMAKE_COMMAND} --build . --target check-mlir -- -j8
BUILD_COMMAND @CMAKE_COMMAND@ ../llvm -DLLVM_BUILD_EXAMPLES=ON -DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_RTTI=ON -DCMAKE_BUILD_TYPE=@CMAKE_BUILD_TYPE@
COMMAND @CMAKE_COMMAND@ --build . --target check-mlir -- -j${N}
INSTALL_COMMAND ""
UPDATE_COMMAND ""
SOURCE_DIR ${MLIR_SOURCE_DIR}
BINARY_DIR ${MLIR_BUILD_DIR}
STAMP_DIR "${MLIR_PROJECT_ROOT}/mlir/stamp"
SOURCE_DIR @MLIR_SOURCE_DIR@
BINARY_DIR @MLIR_BUILD_DIR@
STAMP_DIR "@MLIR_PROJECT_ROOT@/mlir/stamp"
DOWNLOAD_NO_PROGRESS TRUE
EXCLUDE_FROM_ALL TRUE
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment