1 include(MLIRCheckHardwareFeatures)
6 if (MLIR_ENABLE_BINDINGS_PYTHON)
7 add_subdirectory(python)
10 # Provide the MLIR CMake module dir so that the out of tree Standalone
11 # dialect and can add it to the module path.
13 "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir")
15 # Passed to lit.site.cfg.py.in to set up the path where to find libraries.
16 set(MLIR_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
18 if (MLIR_INCLUDE_INTEGRATION_TESTS)
19 set(INTEL_SDE_EXECUTABLE "" CACHE STRING
20 "If set, arch-specific integration tests are run with Intel SDE.")
21 set(ARM_EMULATOR_EXECUTABLE "" CACHE STRING
22 "If set, arch-specific Arm integration tests are run with an emulator.")
23 set(ARM_EMULATOR_OPTIONS "" CACHE STRING
24 "If arch-specific Arm integration tests run emulated, pass these as parameters to the emulator.")
25 set(ARM_EMULATOR_MLIR_CPU_RUNNER_EXECUTABLE "" CACHE STRING
26 "If arch-specific Arm integration tests run emulated, use this Arm native mlir-cpu-runner.")
27 set(ARM_EMULATOR_LLI_EXECUTABLE "" CACHE STRING
28 "If arch-specific Arm integration tests run emulated, use this Arm native lli.")
29 set(ARM_EMULATOR_UTILS_LIB_DIR "" CACHE STRING
30 "If arch-specific Arm integration tests run emulated, find Arm native utility libraries in this directory.")
31 set(MLIR_GPU_COMPILATION_TEST_FORMAT "fatbin" CACHE STRING
32 "The GPU compilation format used by the tests.")
33 set(ARM_SME_ABI_ROUTINES_SHLIB "" CACHE STRING
34 "Path to a shared library containing Arm SME ABI routines, required for Arm SME integration tests.")
35 option(MLIR_RUN_AMX_TESTS "Run AMX tests.")
36 option(MLIR_RUN_X86VECTOR_TESTS "Run X86Vector tests.")
37 option(MLIR_RUN_CUDA_TENSOR_CORE_TESTS "Run CUDA Tensor core WMMA tests.")
38 option(MLIR_RUN_CUDA_SM80_TESTS "Run CUDA A100 tests.")
39 option(MLIR_RUN_CUDA_SM80_LT_TESTS "Run CUDA A100 structured sparsity tests.")
40 option(MLIR_RUN_CUDA_SM90_TESTS "Run CUDA H100 tests.")
41 option(MLIR_RUN_ARM_SVE_TESTS "Run Arm SVE tests.")
42 option(MLIR_RUN_ARM_SME_TESTS "Run Arm SME tests.")
44 # Check whether an emulator is required - if yes then make sure that it's
46 check_emulator(MLIR_RUN_ARM_SVE_TESTS "HWCAP_SVE" ARM_EMULATOR_EXECUTABLE)
47 check_emulator(MLIR_RUN_ARM_SME_TESTS "HWCAP2_SME" ARM_EMULATOR_EXECUTABLE)
49 # The native target may not be enabled when cross compiling, raise an error.
50 if(NOT MLIR_ENABLE_EXECUTION_ENGINE)
51 message(FATAL_ERROR "MLIR_INCLUDE_INTEGRATION_TESTS requires a native target")
54 # When the Integration tests are requested via the MLIR_INCLUDE_INTEGRATION_TESTS
55 # configuration flag, we automatically include sm80 tests when build for
56 # cuSparse when the configuration flag MLIR_ENABLE_CUDA_CUSPARSE is set and
57 # include sm80 lt tests when the MLIR_ENABLE_CUDA_CUSPARSELT is set in
59 if (MLIR_ENABLE_CUDA_CUSPARSE)
60 set(MLIR_RUN_CUDA_SM80_TESTS ON)
61 if (MLIR_ENABLE_CUDA_CUSPARSELT)
62 set(MLIR_RUN_CUDA_SM80_LT_TESTS ON)
68 llvm_canonicalize_cmake_booleans(
71 MLIR_ENABLE_BINDINGS_PYTHON
72 MLIR_ENABLE_CUDA_RUNNER
73 MLIR_ENABLE_ROCM_CONVERSIONS
74 MLIR_ENABLE_ROCM_RUNNER
75 MLIR_ENABLE_SPIRV_CPU_RUNNER
76 MLIR_ENABLE_VULKAN_RUNNER
77 MLIR_INCLUDE_INTEGRATION_TESTS
79 MLIR_RUN_CUDA_TENSOR_CORE_TESTS
80 MLIR_RUN_X86VECTOR_TESTS
81 MLIR_RUN_ARM_SVE_TESTS
82 MLIR_RUN_ARM_SME_TESTS
83 MLIR_RUN_CUDA_SM80_TESTS
84 MLIR_RUN_CUDA_SM80_LT_TESTS
85 MLIR_RUN_CUDA_SM90_TESTS
88 configure_lit_site_cfg(
89 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
90 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
92 ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
94 configure_lit_site_cfg(
95 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
96 ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
98 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
101 set(MLIR_TEST_DEPENDS
102 FileCheck count not split-file
108 mlir-capi-rewrite-test
109 mlir-capi-sparse-tensor-test
110 mlir-capi-transform-test
111 mlir-capi-transform-interpreter-test
112 mlir-capi-translation-test
113 mlir-linalg-ods-yaml-gen
125 set(MLIR_TEST_DEPENDS ${MLIR_TEST_DEPENDS}
131 # The native target may not be enabled, in this case we won't
132 # run tests that involves executing on the host: do not build
134 if(LLVM_ENABLE_PIC AND TARGET ${LLVM_NATIVE_ARCH})
135 list(APPEND MLIR_TEST_DEPENDS
139 mlir-capi-execution-engine-test
146 if (MLIR_INCLUDE_INTEGRATION_TESTS)
147 list(APPEND MLIR_TEST_DEPENDS lli)
150 if(MLIR_ENABLE_CUDA_RUNNER)
151 list(APPEND MLIR_TEST_DEPENDS mlir_cuda_runtime)
154 if(MLIR_ENABLE_EXECUTION_ENGINE)
155 list(APPEND MLIR_TEST_DEPENDS mlir-capi-execution-engine-test)
158 if(MLIR_ENABLE_ROCM_RUNNER)
159 list(APPEND MLIR_TEST_DEPENDS mlir_rocm_runtime)
162 if(MLIR_ENABLE_SYCL_RUNNER)
163 list(APPEND MLIR_TEST_DEPENDS mlir_sycl_runtime)
166 if (MLIR_RUN_ARM_SME_TESTS AND NOT ARM_SME_ABI_ROUTINES_SHLIB)
167 list(APPEND MLIR_TEST_DEPENDS mlir_arm_sme_abi_stubs)
170 if (MLIR_RUN_ARM_SVE_TESTS OR MLIR_RUN_ARM_SME_TESTS)
171 list(APPEND MLIR_TEST_DEPENDS mlir_arm_runner_utils)
174 list(APPEND MLIR_TEST_DEPENDS MLIRUnitTests)
176 if(LLVM_BUILD_EXAMPLES)
177 list(APPEND MLIR_TEST_DEPENDS
184 list(APPEND MLIR_TEST_DEPENDS
191 if(MLIR_ENABLE_EXECUTION_ENGINE)
192 list(APPEND MLIR_TEST_DEPENDS
199 if(MLIR_ENABLE_SPIRV_CPU_RUNNER)
200 list(APPEND MLIR_TEST_DEPENDS
201 mlir_spirv_cpu_runtime
205 if(MLIR_ENABLE_VULKAN_RUNNER)
206 list(APPEND MLIR_TEST_DEPENDS
211 if(MLIR_ENABLE_BINDINGS_PYTHON)
212 list(APPEND MLIR_TEST_DEPENDS
217 # This target can be used to just build the dependencies
218 # for the check-mlir target without executing the tests.
219 # This is useful for bots when splitting the build step
220 # from the testing step.
221 add_custom_target(check-mlir-build-only
222 DEPENDS ${MLIR_TEST_DEPENDS}
224 set_target_properties(check-mlir-build-only PROPERTIES FOLDER "MLIR/Tests")
226 add_lit_testsuite(check-mlir "Running the MLIR regression tests"
227 ${CMAKE_CURRENT_BINARY_DIR}
228 DEPENDS ${MLIR_TEST_DEPENDS}
231 add_lit_testsuites(MLIR ${CMAKE_CURRENT_SOURCE_DIR}
232 DEPENDS ${MLIR_TEST_DEPENDS}