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
107 mlir-capi-rewrite-test
108 mlir-capi-sparse-tensor-test
109 mlir-capi-transform-test
110 mlir-capi-transform-interpreter-test
111 mlir-capi-translation-test
112 mlir-linalg-ods-yaml-gen
123 if(NOT MLIR_STANDALONE_BUILD)
124 list(APPEND MLIR_TEST_DEPENDS FileCheck count not split-file)
127 set(MLIR_TEST_DEPENDS ${MLIR_TEST_DEPENDS}
133 # The native target may not be enabled, in this case we won't
134 # run tests that involves executing on the host: do not build
136 if(LLVM_ENABLE_PIC AND TARGET ${LLVM_NATIVE_ARCH})
137 list(APPEND MLIR_TEST_DEPENDS
141 mlir-capi-execution-engine-test
148 if (MLIR_INCLUDE_INTEGRATION_TESTS)
149 list(APPEND MLIR_TEST_DEPENDS lli)
152 if(MLIR_ENABLE_CUDA_RUNNER)
153 list(APPEND MLIR_TEST_DEPENDS mlir_cuda_runtime)
156 if(MLIR_ENABLE_EXECUTION_ENGINE)
157 list(APPEND MLIR_TEST_DEPENDS mlir-capi-execution-engine-test)
160 if(MLIR_ENABLE_ROCM_RUNNER)
161 list(APPEND MLIR_TEST_DEPENDS mlir_rocm_runtime)
164 if(MLIR_ENABLE_SYCL_RUNNER)
165 list(APPEND MLIR_TEST_DEPENDS mlir_sycl_runtime)
168 if (MLIR_RUN_ARM_SME_TESTS AND NOT ARM_SME_ABI_ROUTINES_SHLIB)
169 list(APPEND MLIR_TEST_DEPENDS mlir_arm_sme_abi_stubs)
172 if (MLIR_RUN_ARM_SVE_TESTS OR MLIR_RUN_ARM_SME_TESTS)
173 list(APPEND MLIR_TEST_DEPENDS mlir_arm_runner_utils)
176 list(APPEND MLIR_TEST_DEPENDS MLIRUnitTests)
178 if(LLVM_BUILD_EXAMPLES)
179 list(APPEND MLIR_TEST_DEPENDS
186 list(APPEND MLIR_TEST_DEPENDS
193 if(MLIR_ENABLE_EXECUTION_ENGINE)
194 list(APPEND MLIR_TEST_DEPENDS
201 if(MLIR_ENABLE_SPIRV_CPU_RUNNER)
202 list(APPEND MLIR_TEST_DEPENDS
203 mlir_spirv_cpu_runtime
207 if(MLIR_ENABLE_VULKAN_RUNNER)
208 list(APPEND MLIR_TEST_DEPENDS
213 if(MLIR_ENABLE_BINDINGS_PYTHON)
214 list(APPEND MLIR_TEST_DEPENDS
219 # This target can be used to just build the dependencies
220 # for the check-mlir target without executing the tests.
221 # This is useful for bots when splitting the build step
222 # from the testing step.
223 add_custom_target(check-mlir-build-only
224 DEPENDS ${MLIR_TEST_DEPENDS}
226 set_target_properties(check-mlir-build-only PROPERTIES FOLDER "MLIR/Tests")
228 add_lit_testsuite(check-mlir "Running the MLIR regression tests"
229 ${CMAKE_CURRENT_BINARY_DIR}
230 DEPENDS ${MLIR_TEST_DEPENDS}
233 add_lit_testsuites(MLIR ${CMAKE_CURRENT_SOURCE_DIR}
234 DEPENDS ${MLIR_TEST_DEPENDS}