From a080fc159e8939fbbd2422f96388f08449932fd5 Mon Sep 17 00:00:00 2001 From: Sang Ik Lee Date: Tue, 26 Apr 2022 15:26:33 -0700 Subject: [PATCH 1/4] Add initial support for third-party projects --- CMakeLists.txt | 30 ++++++++++++++- cmake/modules/update_level_zero.cmake | 55 +++++++++++++++++++++++++++ cmake/modules/update_mlir.cmake | 55 +++++++++++++++++++++++++++ third-party/CMakeLists.txt | 18 +++++++++ third-party/README.md | 3 ++ third-party/level-zero/CMakeLists.txt | 26 +++++++++++++ third-party/mlir/CMakeLists.txt | 39 +++++++++++++++++++ tools/CMakeLists.txt | 4 +- 8 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 cmake/modules/update_level_zero.cmake create mode 100644 cmake/modules/update_mlir.cmake create mode 100644 third-party/CMakeLists.txt create mode 100644 third-party/README.md create mode 100644 third-party/level-zero/CMakeLists.txt create mode 100644 third-party/mlir/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 808bcd35b..fc0250099 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.5) +# Match requirement from LLVM/MLIR +cmake_minimum_required(VERSION 3.13.4) project(mlir-extensions) @@ -70,6 +71,33 @@ macro(apply_llvm_compile_flags target) target_compile_definitions(${target} PRIVATE ${LLVM_DEFINITIONS}) endmacro() +# Check if using external LLVM/MLIR install tree +set(MLIR_EXT_USE_LLVM_INSTALL_TREE (DEFINED LLVM_DIR) AND (DEFINED MLIR_DIR)) +if (DEFINED MLIR_DIR) + if (NOT (DEFINED LLVM_DIR)) + message(FATAL_ERROR "Need to define both LLVM_DIR and MLIR_DIR or none.") + endif() +elseif (DEFINED LLVM_DIR) + message(FATAL_ERROR "Need to define both LLVM_DIR and MLIR_DIR or none.") +endif() + +# Check if using external level-zero +set(MLIR_EXT_USE_EXT_LEVEL_ZERO (DEFINED LEVEL_ZERO_DIR)) + +add_subdirectory(third-party) + +if(NOT MLIR_EXT_USE_LLVM_INSTALL_TREE) + set(LLVM_DIR ${PROJECT_BINARY_DIR}/lib/cmake/llvm) + message(STATUS "LLVM_DIR set to: ${PROJECT_BINARY_DIR}/lib/cmake/llvm") + set(MLIR_DIR ${PROJECT_BINARY_DIR}/lib/cmake/mlir) + message(STATUS "MLIR_DIR set to: ${PROJECT_BINARY_DIR}/lib/cmake/mlir") +endif() + +if(NOT MLIR_EXT_USE_EXT_LEVEL_ZERO) + set(LEVEL_ZERO_DIR ${PROJECT_BINARY_DIR}) + message(STATUS "LEVEL_ZERO_DIR set to: ${PROJECT_BINARY_DIR}") +endif() + if(GPU_ENABLE) add_subdirectory(dpcomp_gpu_runtime) endif() diff --git a/cmake/modules/update_level_zero.cmake b/cmake/modules/update_level_zero.cmake new file mode 100644 index 000000000..81898881b --- /dev/null +++ b/cmake/modules/update_level_zero.cmake @@ -0,0 +1,55 @@ +#=============================================================================== +# Copyright 2022 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#=============================================================================== + +set(LEVEL_ZERO_VERSION_FILE "${PROJECT_SOURCE_DIR}/level-zero-sha.txt") +file(READ "${LEVEL_ZERO_VERSION_FILE}" REVISION_FILE) +string(REGEX MATCH "([A-Za-z0-9]+)" _ ${REVISION_FILE}) +set(MLIR_EXT_LEVEL_ZERO_COMMIT_ID ${CMAKE_MATCH_1}) +message(STATUS "LEVEL_ZERO COMMIT ID: ${MLIR_EXT_LEVEL_ZERO_COMMIT_ID}") +set(MLIR_EXT_LEVEL_ZERO_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/level-zero") + +if (NOT EXISTS "${MLIR_EXT_LEVEL_ZERO_SOURCE_DIR}") + message(STATUS "Cloning LEVEL_ZERO git repo") + execute_process(COMMAND git clone https://github.com/oneapi-src/level-zero.git + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND_ECHO STDOUT + OUTPUT_VARIABLE LEVEL_ZERO_CLONE_OUTPUT + ERROR_VARIABLE LEVEL_ZERO_CLONE_ERROR + ECHO_OUTPUT_VARIABLE + ECHO_ERROR_VARIABLE + ) +else() + message(STATUS "LEVEL_ZERO git repo already cloned.") +endif() +execute_process(COMMAND git fetch --prune + WORKING_DIRECTORY ${MLIR_EXT_LEVEL_ZERO_SOURCE_DIR} + COMMAND_ECHO STDOUT + OUTPUT_VARIABLE LEVEL_ZERO_PULL_OUTPUT + ERROR_VARIABLE LEVEL_ZERO_PULL_ERROR + ECHO_OUTPUT_VARIABLE + ECHO_ERROR_VARIABLE + ) + +message(STATUS "LEVEL_ZERO: checkout ${MLIR_EXT_LEVEL_ZERO_COMMIT_ID}") + +execute_process(COMMAND git checkout ${MLIR_EXT_LEVEL_ZERO_COMMIT_ID} + WORKING_DIRECTORY ${MLIR_EXT_LEVEL_ZERO_SOURCE_DIR} + COMMAND_ECHO STDOUT + OUTPUT_VARIABLE LEVEL_ZERO_CHECKOUT_OUTPUT + ERROR_VARIABLE LEVEL_ZERO_CHECKOUT_ERROR + ECHO_OUTPUT_VARIABLE + ECHO_ERROR_VARIABLE + ) diff --git a/cmake/modules/update_mlir.cmake b/cmake/modules/update_mlir.cmake new file mode 100644 index 000000000..6bc0e58cc --- /dev/null +++ b/cmake/modules/update_mlir.cmake @@ -0,0 +1,55 @@ +#=============================================================================== +# Copyright 2022 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#=============================================================================== + +set(LLVM_VERSION_FILE "${PROJECT_SOURCE_DIR}/llvm-sha.txt") +file(READ "${LLVM_VERSION_FILE}" REVISION_FILE) +string(REGEX MATCH "([A-Za-z0-9]+)" _ ${REVISION_FILE}) +set(MLIR_EXT_LLVM_COMMIT_ID ${CMAKE_MATCH_1}) +message(STATUS "LLVM COMMIT ID: ${MLIR_EXT_LLVM_COMMIT_ID}") +set(MLIR_EXT_LLVM_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/llvm-project") + +if (NOT EXISTS "${MLIR_EXT_LLVM_SOURCE_DIR}") + message(STATUS "Cloning LLVM git repo") + execute_process(COMMAND git clone https://github.com/llvm/llvm-project.git + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND_ECHO STDOUT + OUTPUT_VARIABLE LLVM_CLONE_OUTPUT + ERROR_VARIABLE LLVM_CLONE_ERROR + ECHO_OUTPUT_VARIABLE + ECHO_ERROR_VARIABLE + ) +else() + message(STATUS "LLVM git repo already cloned.") +endif() +execute_process(COMMAND git fetch --prune + WORKING_DIRECTORY ${MLIR_EXT_LLVM_SOURCE_DIR} + COMMAND_ECHO STDOUT + OUTPUT_VARIABLE LLVM_PULL_OUTPUT + ERROR_VARIABLE LLVM_PULL_ERROR + ECHO_OUTPUT_VARIABLE + ECHO_ERROR_VARIABLE + ) + +message(STATUS "LLVM: checkout ${MLIR_EXT_LLVM_COMMIT_ID}") + +execute_process(COMMAND git checkout ${MLIR_EXT_LLVM_COMMIT_ID} + WORKING_DIRECTORY ${MLIR_EXT_LLVM_SOURCE_DIR} + COMMAND_ECHO STDOUT + OUTPUT_VARIABLE LLVM_CHECKOUT_OUTPUT + ERROR_VARIABLE LLVM_CHECKOUT_ERROR + ECHO_OUTPUT_VARIABLE + ECHO_ERROR_VARIABLE + ) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt new file mode 100644 index 000000000..e66768a5c --- /dev/null +++ b/third-party/CMakeLists.txt @@ -0,0 +1,18 @@ +#=============================================================================== +# Copyright 2022 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#=============================================================================== + +# third party projects +add_subdirectory(mlir) diff --git a/third-party/README.md b/third-party/README.md new file mode 100644 index 000000000..e4ed2dde4 --- /dev/null +++ b/third-party/README.md @@ -0,0 +1,3 @@ +# third party repo sources. + +Source files for third party projects will be placed in this directory. diff --git a/third-party/level-zero/CMakeLists.txt b/third-party/level-zero/CMakeLists.txt new file mode 100644 index 000000000..592305b5a --- /dev/null +++ b/third-party/level-zero/CMakeLists.txt @@ -0,0 +1,26 @@ +#=============================================================================== +# Copyright 2022 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#=============================================================================== + +if (MLIR_EXT_USE_EXT_LEVEL_ZERO) + return() +endif() + +# Update MLIR source +include(update_level_zero) +include(ExternalProject) +ExternalProject_Add(level-zero + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/level-zero) + diff --git a/third-party/mlir/CMakeLists.txt b/third-party/mlir/CMakeLists.txt new file mode 100644 index 000000000..dfbbe5830 --- /dev/null +++ b/third-party/mlir/CMakeLists.txt @@ -0,0 +1,39 @@ +#=============================================================================== +# Copyright 2022 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#=============================================================================== + +if (MLIR_EXT_USE_LLVM_INSTALL_TREE) + return() +endif() + +# Update MLIR source +include(update_mlir) + +# Add MLIR/LLVM +if (LINUX) + set(LLVM_ENABLE_LLD ON CACHE INTERNAL "") +endif() +set(LLVM_INSTALL_UTILS ON CACHE INTERNAL "") +set(LLVM_ENABLE_PROJECTS mlir CACHE INTERNAL "") +set(LLVM_TARGETS_TO_BUILD "host" CACHE INTERNAL "") +set(LLVM_INCLUDE_TOOLS ON CACHE INTERNAL "") +set(LLVM_BUILD_EXAMPLES ON CACHE INTERNAL "") +set(LLVM_ENABLE_ASSERTIONS ON CACHE INTERNAL "") +set(LLVM_ENABLE_RTTI ON CACHE INTERNAL "") +# ON by default +#set(LLVM_INCLUDE_TESTS ON CACHE INTERNAL "") +set(MLIR_INCLUDE_INTEGRATION_TESTS ON CACHE INTERNAL "") +add_subdirectory(llvm-project/llvm) + diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 34f0bd715..fdf03f4e9 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -13,4 +13,6 @@ # limitations under the License. add_subdirectory(dpcomp-opt) -add_subdirectory(FileCheck) +if (MLIR_EXT_USE_LLVM_INSTALL_TREE) + add_subdirectory(FileCheck) +endif() From 38b1cac17759dc5fc62ac89a63b3428083b67a25 Mon Sep 17 00:00:00 2001 From: Sang Ik Lee Date: Tue, 26 Apr 2022 15:29:54 -0700 Subject: [PATCH 2/4] Add level-zero only if gpu is enabled --- CMakeLists.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc0250099..543b754d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,8 +81,10 @@ elseif (DEFINED LLVM_DIR) message(FATAL_ERROR "Need to define both LLVM_DIR and MLIR_DIR or none.") endif() -# Check if using external level-zero -set(MLIR_EXT_USE_EXT_LEVEL_ZERO (DEFINED LEVEL_ZERO_DIR)) +if(GPU_ENABLE) + # Check if using external level-zero + set(MLIR_EXT_USE_EXT_LEVEL_ZERO (DEFINED LEVEL_ZERO_DIR)) +endif() add_subdirectory(third-party) @@ -93,9 +95,11 @@ if(NOT MLIR_EXT_USE_LLVM_INSTALL_TREE) message(STATUS "MLIR_DIR set to: ${PROJECT_BINARY_DIR}/lib/cmake/mlir") endif() -if(NOT MLIR_EXT_USE_EXT_LEVEL_ZERO) - set(LEVEL_ZERO_DIR ${PROJECT_BINARY_DIR}) - message(STATUS "LEVEL_ZERO_DIR set to: ${PROJECT_BINARY_DIR}") +if(GPU_ENABLE) + if(NOT MLIR_EXT_USE_EXT_LEVEL_ZERO) + set(LEVEL_ZERO_DIR ${PROJECT_BINARY_DIR}) + message(STATUS "LEVEL_ZERO_DIR set to: ${PROJECT_BINARY_DIR}") + endif() endif() if(GPU_ENABLE) From 8b15685ffc942e3e8956cc3005ceb04b5e87ac11 Mon Sep 17 00:00:00 2001 From: Sang Ik Lee Date: Tue, 26 Apr 2022 23:52:21 +0000 Subject: [PATCH 3/4] Update. --- CMakeLists.txt | 12 +++++++----- cmake/modules/update_level_zero.cmake | 6 ------ cmake/modules/update_mlir.cmake | 6 ------ level-zero-sha.txt | 1 + mlir/CMakeLists.txt | 2 ++ third-party/CMakeLists.txt | 2 ++ third-party/level-zero/CMakeLists.txt | 2 +- third-party/mlir/CMakeLists.txt | 1 + 8 files changed, 14 insertions(+), 18 deletions(-) create mode 100644 level-zero-sha.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 543b754d2..4db172a58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ cmake_minimum_required(VERSION 3.13.4) project(mlir-extensions) +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules/") set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -72,13 +73,16 @@ macro(apply_llvm_compile_flags target) endmacro() # Check if using external LLVM/MLIR install tree -set(MLIR_EXT_USE_LLVM_INSTALL_TREE (DEFINED LLVM_DIR) AND (DEFINED MLIR_DIR)) if (DEFINED MLIR_DIR) - if (NOT (DEFINED LLVM_DIR)) + if (DEFINED MLIR_DIR) + set(MLIR_EXT_USE_LLVM_INSTALL_TREE ON) + else() message(FATAL_ERROR "Need to define both LLVM_DIR and MLIR_DIR or none.") endif() elseif (DEFINED LLVM_DIR) message(FATAL_ERROR "Need to define both LLVM_DIR and MLIR_DIR or none.") +else() + set(MLIR_EXT_USE_LLVM_INSTALL_TREE OFF) endif() if(GPU_ENABLE) @@ -89,10 +93,8 @@ endif() add_subdirectory(third-party) if(NOT MLIR_EXT_USE_LLVM_INSTALL_TREE) - set(LLVM_DIR ${PROJECT_BINARY_DIR}/lib/cmake/llvm) - message(STATUS "LLVM_DIR set to: ${PROJECT_BINARY_DIR}/lib/cmake/llvm") + set(LLVM_DIR ${PROJECT_BINARY_DIR}/third-party/mlir/llvm-project/llvm/lib/cmake/llvm) set(MLIR_DIR ${PROJECT_BINARY_DIR}/lib/cmake/mlir) - message(STATUS "MLIR_DIR set to: ${PROJECT_BINARY_DIR}/lib/cmake/mlir") endif() if(GPU_ENABLE) diff --git a/cmake/modules/update_level_zero.cmake b/cmake/modules/update_level_zero.cmake index 81898881b..28cd91e07 100644 --- a/cmake/modules/update_level_zero.cmake +++ b/cmake/modules/update_level_zero.cmake @@ -28,8 +28,6 @@ if (NOT EXISTS "${MLIR_EXT_LEVEL_ZERO_SOURCE_DIR}") COMMAND_ECHO STDOUT OUTPUT_VARIABLE LEVEL_ZERO_CLONE_OUTPUT ERROR_VARIABLE LEVEL_ZERO_CLONE_ERROR - ECHO_OUTPUT_VARIABLE - ECHO_ERROR_VARIABLE ) else() message(STATUS "LEVEL_ZERO git repo already cloned.") @@ -39,8 +37,6 @@ execute_process(COMMAND git fetch --prune COMMAND_ECHO STDOUT OUTPUT_VARIABLE LEVEL_ZERO_PULL_OUTPUT ERROR_VARIABLE LEVEL_ZERO_PULL_ERROR - ECHO_OUTPUT_VARIABLE - ECHO_ERROR_VARIABLE ) message(STATUS "LEVEL_ZERO: checkout ${MLIR_EXT_LEVEL_ZERO_COMMIT_ID}") @@ -50,6 +46,4 @@ execute_process(COMMAND git checkout ${MLIR_EXT_LEVEL_ZERO_COMMIT_ID} COMMAND_ECHO STDOUT OUTPUT_VARIABLE LEVEL_ZERO_CHECKOUT_OUTPUT ERROR_VARIABLE LEVEL_ZERO_CHECKOUT_ERROR - ECHO_OUTPUT_VARIABLE - ECHO_ERROR_VARIABLE ) diff --git a/cmake/modules/update_mlir.cmake b/cmake/modules/update_mlir.cmake index 6bc0e58cc..1ce12a3f6 100644 --- a/cmake/modules/update_mlir.cmake +++ b/cmake/modules/update_mlir.cmake @@ -28,8 +28,6 @@ if (NOT EXISTS "${MLIR_EXT_LLVM_SOURCE_DIR}") COMMAND_ECHO STDOUT OUTPUT_VARIABLE LLVM_CLONE_OUTPUT ERROR_VARIABLE LLVM_CLONE_ERROR - ECHO_OUTPUT_VARIABLE - ECHO_ERROR_VARIABLE ) else() message(STATUS "LLVM git repo already cloned.") @@ -39,8 +37,6 @@ execute_process(COMMAND git fetch --prune COMMAND_ECHO STDOUT OUTPUT_VARIABLE LLVM_PULL_OUTPUT ERROR_VARIABLE LLVM_PULL_ERROR - ECHO_OUTPUT_VARIABLE - ECHO_ERROR_VARIABLE ) message(STATUS "LLVM: checkout ${MLIR_EXT_LLVM_COMMIT_ID}") @@ -50,6 +46,4 @@ execute_process(COMMAND git checkout ${MLIR_EXT_LLVM_COMMIT_ID} COMMAND_ECHO STDOUT OUTPUT_VARIABLE LLVM_CHECKOUT_OUTPUT ERROR_VARIABLE LLVM_CHECKOUT_ERROR - ECHO_OUTPUT_VARIABLE - ECHO_ERROR_VARIABLE ) diff --git a/level-zero-sha.txt b/level-zero-sha.txt new file mode 100644 index 000000000..ec03887f5 --- /dev/null +++ b/level-zero-sha.txt @@ -0,0 +1 @@ +bb7fff05b801e26c3d7858e03e509d1089914d59 diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index 5a68e31aa..61f2ff101 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -27,6 +27,7 @@ include(HandleLLVMOptions) file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/../llvm-sha.txt EXPECTED_LLVM_SHA) message(STATUS "Expected llvm sha: \"${EXPECTED_LLVM_SHA}\"") +if(MLIR_EXT_USE_LLVM_INSTALL_TREE) file(STRINGS ${LLVM_INCLUDE_DIR}/llvm/Support/VCSRevision.h REVISION_FILE_DATA) message(DEBUG "VCSRevision: ${REVISION_FILE_DATA}") string(REGEX MATCH "\"([^\"]*)\"" LLVM_SHA ${REVISION_FILE_DATA}) @@ -36,6 +37,7 @@ message(STATUS "llvm sha: \"${LLVM_SHA}\"") if (NOT EXPECTED_LLVM_SHA STREQUAL LLVM_SHA) message(FATAL_ERROR "Invalid llvm version") endif() +endif() add_subdirectory(include/mlir-extensions/dialect/plier) add_subdirectory(include/mlir-extensions/dialect/plier_util) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index e66768a5c..3763577a0 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -15,4 +15,6 @@ #=============================================================================== # third party projects +message(STATUS "Configure third-party projects.") add_subdirectory(mlir) +add_subdirectory(level-zero) diff --git a/third-party/level-zero/CMakeLists.txt b/third-party/level-zero/CMakeLists.txt index 592305b5a..d8746f0ca 100644 --- a/third-party/level-zero/CMakeLists.txt +++ b/third-party/level-zero/CMakeLists.txt @@ -14,7 +14,7 @@ # limitations under the License. #=============================================================================== -if (MLIR_EXT_USE_EXT_LEVEL_ZERO) +if ((NOT GPU_ENABLE) OR MLIR_EXT_USE_EXT_LEVEL_ZERO) return() endif() diff --git a/third-party/mlir/CMakeLists.txt b/third-party/mlir/CMakeLists.txt index dfbbe5830..a1568b2d3 100644 --- a/third-party/mlir/CMakeLists.txt +++ b/third-party/mlir/CMakeLists.txt @@ -15,6 +15,7 @@ #=============================================================================== if (MLIR_EXT_USE_LLVM_INSTALL_TREE) + message(STATUS "Using LLVM install tree.") return() endif() From da070bb7d83524221ad8e67da704c91b46f45f1d Mon Sep 17 00:00:00 2001 From: Sang Ik Lee Date: Wed, 27 Apr 2022 01:08:04 +0000 Subject: [PATCH 4/4] Fix some issues. --- .gitignore | 4 ++++ CMakeLists.txt | 7 ++++++- mlir/CMakeLists.txt | 1 + third-party/level-zero/CMakeLists.txt | 4 +++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2684a546f..a2d365bce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# Third party projects +third-party/level-zero/level-zero/ +third-party/mlir/llvm-project/ + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/CMakeLists.txt b/CMakeLists.txt index 4db172a58..3ae88c884 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,7 +87,12 @@ endif() if(GPU_ENABLE) # Check if using external level-zero - set(MLIR_EXT_USE_EXT_LEVEL_ZERO (DEFINED LEVEL_ZERO_DIR)) + if(DEFINED LEVEL_ZERO_DIR) + set(MLIR_EXT_USE_EXT_LEVEL_ZERO ON) + else() + set(MLIR_EXT_USE_EXT_LEVEL_ZERO OFF) + endif() + message(STATUS "MLIR_EXT_USE_EXT_LEVEL_ZERO: ${MLIR_EXT_USE_EXT_LEVEL_ZERO}") endif() add_subdirectory(third-party) diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index 61f2ff101..d905869e3 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -145,6 +145,7 @@ target_link_libraries(${MLIR_EXTENSIONS_LIB} PRIVATE target_include_directories(${MLIR_EXTENSIONS_LIB} SYSTEM PRIVATE ${MLIR_INCLUDE_DIRS} + ${LLVM_INCLUDE_DIRS} PRIVATE ./lib ) diff --git a/third-party/level-zero/CMakeLists.txt b/third-party/level-zero/CMakeLists.txt index d8746f0ca..eceed8b96 100644 --- a/third-party/level-zero/CMakeLists.txt +++ b/third-party/level-zero/CMakeLists.txt @@ -22,5 +22,7 @@ endif() include(update_level_zero) include(ExternalProject) ExternalProject_Add(level-zero - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/level-zero) + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/level-zero + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR} + )