diff options
author | Nikita Popov <npopov@redhat.com> | 2022-08-03 15:28:49 +0200 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2022-08-08 12:18:21 -0700 |
commit | 9d1f36d6b7433eecd1bab76ed607d88aefe5e740 (patch) | |
tree | fc95e72002d675cc186859234319ecff94a8390b /mlir/CMakeLists.txt | |
parent | d3897d2f3a4dd5b8f2bed86d115c0432c82b3197 (diff) | |
download | llvm-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)
Diffstat (limited to 'mlir/CMakeLists.txt')
-rw-r--r-- | mlir/CMakeLists.txt | 13 |
1 files changed, 10 insertions, 3 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) |