aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-08-03 15:28:49 +0200
committerTom Stellard <tstellar@redhat.com>2022-08-08 12:18:21 -0700
commit9d1f36d6b7433eecd1bab76ed607d88aefe5e740 (patch)
treefc95e72002d675cc186859234319ecff94a8390b
parentd3897d2f3a4dd5b8f2bed86d115c0432c82b3197 (diff)
downloadllvm-9d1f36d6b7433eecd1bab76ed607d88aefe5e740.zip
llvm-9d1f36d6b7433eecd1bab76ed607d88aefe5e740.tar.gz
llvm-9d1f36d6b7433eecd1bab76ed607d88aefe5e740.tar.bz2
[MLIR] Fix checks for native arch
Using if (TARGET ${LLVM_NATIVE_ARCH}) only works if MLIR is built together with LLVM, but not for standalone builds of MLIR. The correct way to check this is if (${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD), as the LLVM build system exports LLVM_TARGETS_TO_BUILD. To avoid repeating the same check many times, add a MLIR_ENABLE_EXECUTION_ENGINE variable. Differential Revision: https://reviews.llvm.org/D131071 (cherry picked from commit 57a9bccec7dea036dbfa1a78f1ec5e73ecf7a33c)
-rw-r--r--mlir/CMakeLists.txt13
-rw-r--r--mlir/lib/CAPI/CMakeLists.txt3
-rw-r--r--mlir/lib/ExecutionEngine/CMakeLists.txt3
-rw-r--r--mlir/python/CMakeLists.txt3
-rw-r--r--mlir/test/CAPI/CMakeLists.txt3
-rw-r--r--mlir/test/CMakeLists.txt2
-rw-r--r--mlir/tools/CMakeLists.txt5
-rw-r--r--mlir/unittests/CMakeLists.txt3
8 files changed, 18 insertions, 17 deletions
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 3ea0be3..088aec8 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -86,9 +86,16 @@ set_target_properties(mlir-headers PROPERTIES FOLDER "Misc")
add_dependencies(mlir-headers mlir-generic-headers)
add_custom_target(mlir-doc)
+# Only enable execution engine if the native target is available.
+if(${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD)
+ set(MLIR_ENABLE_EXECUTION_ENGINE 1)
+else()
+ set(MLIR_ENABLE_EXECUTION_ENGINE 0)
+endif()
+
# Build the CUDA conversions and run according tests if the NVPTX backend
# is available
-if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
+if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD AND MLIR_ENABLE_EXECUTION_ENGINE)
set(MLIR_ENABLE_CUDA_CONVERSIONS 1)
else()
set(MLIR_ENABLE_CUDA_CONVERSIONS 0)
@@ -97,8 +104,8 @@ endif()
add_definitions(-DMLIR_CUDA_CONVERSIONS_ENABLED=${MLIR_ENABLE_CUDA_CONVERSIONS})
# Build the ROCm conversions and run according tests if the AMDGPU backend
-# is available
-if ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD)
+# is available.
+if ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD AND MLIR_ENABLE_EXECUTION_ENGINE)
set(MLIR_ENABLE_ROCM_CONVERSIONS 1)
else()
set(MLIR_ENABLE_ROCM_CONVERSIONS 0)
diff --git a/mlir/lib/CAPI/CMakeLists.txt b/mlir/lib/CAPI/CMakeLists.txt
index ffb04c2..052eff3 100644
--- a/mlir/lib/CAPI/CMakeLists.txt
+++ b/mlir/lib/CAPI/CMakeLists.txt
@@ -15,8 +15,7 @@ add_subdirectory(IR)
add_subdirectory(RegisterEverything)
add_subdirectory(Transforms)
-# Only enable the ExecutionEngine if the native target is configured in.
-if(TARGET ${LLVM_NATIVE_ARCH})
+if(MLIR_ENABLE_EXECUTION_ENGINE)
add_subdirectory(ExecutionEngine)
endif()
diff --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt
index 22ac4f8..bf62780 100644
--- a/mlir/lib/ExecutionEngine/CMakeLists.txt
+++ b/mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -39,8 +39,7 @@ add_mlir_library(MLIRExecutionEngineUtils
Passes
)
-# Only enable the ExecutionEngine if the native target is configured in.
-if(NOT TARGET ${LLVM_NATIVE_ARCH})
+if(NOT MLIR_ENABLE_EXECUTION_ENGINE)
return()
endif()
diff --git a/mlir/python/CMakeLists.txt b/mlir/python/CMakeLists.txt
index 1fbbadf..7eb6e05 100644
--- a/mlir/python/CMakeLists.txt
+++ b/mlir/python/CMakeLists.txt
@@ -363,8 +363,7 @@ declare_mlir_python_extension(MLIRPythonExtension.AsyncDialectPasses
MLIRCAPIAsync
)
-# Only enable the ExecutionEngine if the native target is configured in.
-if(TARGET ${LLVM_NATIVE_ARCH})
+if(MLIR_ENABLE_EXECUTION_ENGINE)
declare_mlir_python_extension(MLIRPythonExtension.ExecutionEngine
MODULE_NAME _mlirExecutionEngine
ADD_TO_PARENT MLIRPythonSources.ExecutionEngine
diff --git a/mlir/test/CAPI/CMakeLists.txt b/mlir/test/CAPI/CMakeLists.txt
index b089a37..2992b13 100644
--- a/mlir/test/CAPI/CMakeLists.txt
+++ b/mlir/test/CAPI/CMakeLists.txt
@@ -19,8 +19,7 @@ function(_add_capi_test_executable name)
endif()
endfunction(_add_capi_test_executable)
-# Only enable the ExecutionEngine if the native target is configured in.
-if(TARGET ${LLVM_NATIVE_ARCH})
+if(MLIR_ENABLE_EXECUTION_ENGINE)
_add_capi_test_executable(mlir-capi-execution-engine-test
execution_engine.c
LINK_LIBS PRIVATE
diff --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt
index c203f22..74f8058 100644
--- a/mlir/test/CMakeLists.txt
+++ b/mlir/test/CMakeLists.txt
@@ -40,7 +40,7 @@ if (MLIR_INCLUDE_INTEGRATION_TESTS)
# The native target may not be enabled when cross compiling, raise an error.
- if(NOT TARGET ${LLVM_NATIVE_ARCH})
+ if(NOT MLIR_ENABLE_EXECUTION_ENGINE)
message(FATAL_ERROR "MLIR_INCLUDE_INTEGRATION_TESTS requires a native target")
endif()
diff --git a/mlir/tools/CMakeLists.txt b/mlir/tools/CMakeLists.txt
index 86003b7..e9a1e4d 100644
--- a/mlir/tools/CMakeLists.txt
+++ b/mlir/tools/CMakeLists.txt
@@ -9,8 +9,7 @@ add_subdirectory(mlir-translate)
add_subdirectory(mlir-vulkan-runner)
add_subdirectory(tblgen-lsp-server)
-# mlir-cpu-runner requires ExecutionEngine which is only built
-# when the native target is configured in.
-if(TARGET ${LLVM_NATIVE_ARCH})
+# mlir-cpu-runner requires ExecutionEngine.
+if(MLIR_ENABLE_EXECUTION_ENGINE)
add_subdirectory(mlir-cpu-runner)
endif()
diff --git a/mlir/unittests/CMakeLists.txt b/mlir/unittests/CMakeLists.txt
index 25f40d0..78a0f99 100644
--- a/mlir/unittests/CMakeLists.txt
+++ b/mlir/unittests/CMakeLists.txt
@@ -16,7 +16,6 @@ add_subdirectory(Rewrite)
add_subdirectory(TableGen)
add_subdirectory(Transforms)
-# The native target may not be enabled when cross compiling.
-if(TARGET ${LLVM_NATIVE_ARCH})
+if(MLIR_ENABLE_EXECUTION_ENGINE)
add_subdirectory(ExecutionEngine)
endif()