4 if (MLIR_ENABLE_BINDINGS_PYTHON)
5 add_subdirectory(python)
8 # Provide the MLIR CMake module dir so that the out of tree Standalone
9 # dialect and can add it to the module path.
11 "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir")
13 # Passed to lit.site.cfg.py.in to set up the path where to find libraries.
14 set(MLIR_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
16 if (MLIR_INCLUDE_INTEGRATION_TESTS)
17 set(INTEL_SDE_EXECUTABLE "" CACHE STRING
18 "If set, arch-specific integration tests are run with Intel SDE.")
19 set(ARM_EMULATOR_EXECUTABLE "" CACHE STRING
20 "If set, arch-specific Arm integration tests are run with an emulator.")
21 set(ARM_EMULATOR_OPTIONS "" CACHE STRING
22 "If arch-specific Arm integration tests run emulated, pass these as parameters to the emulator.")
23 set(ARM_EMULATOR_MLIR_CPU_RUNNER_EXECUTABLE "" CACHE STRING
24 "If arch-specific Arm integration tests run emulated, use this Arm native mlir-cpu-runner.")
25 set(ARM_EMULATOR_LLI_EXECUTABLE "" CACHE STRING
26 "If arch-specific Arm integration tests run emulated, use this Arm native lli.")
27 set(ARM_EMULATOR_UTILS_LIB_DIR "" CACHE STRING
28 "If arch-specific Arm integration tests run emulated, find Arm native utility libraries in this directory.")
29 set(MLIR_GPU_COMPILATION_TEST_FORMAT "fatbin" CACHE STRING
30 "The GPU compilation format used by the tests.")
31 set(ARM_SME_ABI_ROUTINES_SHLIB "" CACHE STRING
32 "Path to a shared library containing Arm SME ABI routines, required for Arm SME integration tests.")
33 option(MLIR_RUN_AMX_TESTS "Run AMX tests.")
34 option(MLIR_RUN_X86VECTOR_TESTS "Run X86Vector tests.")
35 option(MLIR_RUN_CUDA_TENSOR_CORE_TESTS "Run CUDA Tensor core WMMA tests.")
36 option(MLIR_RUN_CUDA_SM80_TESTS "Run CUDA A100 tests.")
37 option(MLIR_RUN_CUDA_SM80_LT_TESTS "Run CUDA A100 structured sparsity tests.")
38 option(MLIR_RUN_CUDA_SM90_TESTS "Run CUDA H100 tests.")
39 option(MLIR_RUN_ARM_SVE_TESTS "Run Arm SVE tests.")
40 option(MLIR_RUN_ARM_SME_TESTS "Run Arm SME tests.")
43 # The native target may not be enabled when cross compiling, raise an error.
44 if(NOT MLIR_ENABLE_EXECUTION_ENGINE)
45 message(FATAL_ERROR "MLIR_INCLUDE_INTEGRATION_TESTS requires a native target")
48 # When the Integration tests are requested via the MLIR_INCLUDE_INTEGRATION_TESTS
49 # configuration flag, we automatically include sm80 tests when build for
50 # cuSparse when the configuration flag MLIR_ENABLE_CUDA_CUSPARSE is set and
51 # include sm80 lt tests when the MLIR_ENABLE_CUDA_CUSPARSELT is set in
53 if (MLIR_ENABLE_CUDA_CUSPARSE)
54 set(MLIR_RUN_CUDA_SM80_TESTS ON)
55 if (MLIR_ENABLE_CUDA_CUSPARSELT)
56 set(MLIR_RUN_CUDA_SM80_LT_TESTS ON)
62 llvm_canonicalize_cmake_booleans(
64 MLIR_ENABLE_BINDINGS_PYTHON
65 MLIR_ENABLE_CUDA_CONVERSIONS
66 MLIR_ENABLE_CUDA_RUNNER
67 MLIR_ENABLE_ROCM_CONVERSIONS
68 MLIR_ENABLE_ROCM_RUNNER
69 MLIR_ENABLE_SPIRV_CPU_RUNNER
70 MLIR_ENABLE_VULKAN_RUNNER
71 MLIR_INCLUDE_INTEGRATION_TESTS
73 MLIR_RUN_CUDA_TENSOR_CORE_TESTS
74 MLIR_RUN_X86VECTOR_TESTS
75 MLIR_RUN_ARM_SVE_TESTS
76 MLIR_RUN_ARM_SME_TESTS
77 MLIR_RUN_CUDA_SM80_TESTS
78 MLIR_RUN_CUDA_SM80_LT_TESTS
79 MLIR_RUN_CUDA_SM90_TESTS
82 configure_lit_site_cfg(
83 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
84 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
86 ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
88 configure_lit_site_cfg(
89 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
90 ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
92 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
96 FileCheck count not split-file
101 mlir-capi-sparse-tensor-test
102 mlir-capi-transform-test
103 mlir-capi-translation-test
104 mlir-linalg-ods-yaml-gen
115 set(MLIR_TEST_DEPENDS ${MLIR_TEST_DEPENDS}
121 # The native target may not be enabled, in this case we won't
122 # run tests that involves executing on the host: do not build
124 if(LLVM_ENABLE_PIC AND TARGET ${LLVM_NATIVE_ARCH})
125 list(APPEND MLIR_TEST_DEPENDS
129 mlir-capi-execution-engine-test
136 if (MLIR_INCLUDE_INTEGRATION_TESTS)
137 list(APPEND MLIR_TEST_DEPENDS lli)
140 if(MLIR_ENABLE_CUDA_RUNNER)
141 list(APPEND MLIR_TEST_DEPENDS mlir_cuda_runtime)
144 if(MLIR_ENABLE_ROCM_RUNNER)
145 list(APPEND MLIR_TEST_DEPENDS mlir_rocm_runtime)
148 if(MLIR_ENABLE_SYCL_RUNNER)
149 list(APPEND MLIR_TEST_DEPENDS mlir_sycl_runtime)
152 if (MLIR_RUN_ARM_SME_TESTS AND NOT ARM_SME_ABI_ROUTINES_SHLIB)
153 list(APPEND MLIR_TEST_DEPENDS mlir_arm_sme_abi_stubs)
156 list(APPEND MLIR_TEST_DEPENDS MLIRUnitTests)
158 if(LLVM_BUILD_EXAMPLES)
159 list(APPEND MLIR_TEST_DEPENDS
166 list(APPEND MLIR_TEST_DEPENDS
170 if(MLIR_ENABLE_EXECUTION_ENGINE)
171 list(APPEND MLIR_TEST_DEPENDS
178 if(MLIR_ENABLE_SPIRV_CPU_RUNNER)
179 add_subdirectory(mlir-spirv-cpu-runner)
180 list(APPEND MLIR_TEST_DEPENDS
181 mlir-spirv-cpu-runner
182 mlir_test_spirv_cpu_runner_c_wrappers
186 if(MLIR_ENABLE_VULKAN_RUNNER)
187 list(APPEND MLIR_TEST_DEPENDS
192 if(MLIR_ENABLE_BINDINGS_PYTHON)
193 list(APPEND MLIR_TEST_DEPENDS
198 # This target can be used to just build the dependencies
199 # for the check-mlir target without executing the tests.
200 # This is useful for bots when splitting the build step
201 # from the testing step.
202 add_custom_target(check-mlir-build-only
203 DEPENDS ${MLIR_TEST_DEPENDS}
206 add_lit_testsuite(check-mlir "Running the MLIR regression tests"
207 ${CMAKE_CURRENT_BINARY_DIR}
208 DEPENDS ${MLIR_TEST_DEPENDS}
210 set_target_properties(check-mlir PROPERTIES FOLDER "Tests")
212 add_lit_testsuites(MLIR ${CMAKE_CURRENT_SOURCE_DIR}
213 DEPENDS ${MLIR_TEST_DEPENDS}