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 option(MLIR_RUN_AMX_TESTS "Run AMX tests.")
32 option(MLIR_RUN_X86VECTOR_TESTS "Run X86Vector tests.")
33 option(MLIR_RUN_CUDA_TENSOR_CORE_TESTS "Run CUDA Tensor core WMMA tests.")
34 option(MLIR_RUN_CUDA_SM80_TESTS "Run CUDA A100 tests.")
35 option(MLIR_RUN_CUDA_SM80_LT_TESTS "Run CUDA A100 structured sparsity tests.")
36 option(MLIR_RUN_CUDA_SM90_TESTS "Run CUDA H100 tests.")
37 option(MLIR_RUN_ARM_SVE_TESTS "Run Arm SVE tests.")
38 option(MLIR_RUN_ARM_SME_TESTS "Run Arm SME tests.")
41 # The native target may not be enabled when cross compiling, raise an error.
42 if(NOT MLIR_ENABLE_EXECUTION_ENGINE)
43 message(FATAL_ERROR "MLIR_INCLUDE_INTEGRATION_TESTS requires a native target")
46 # When the Integration tests are requested via the MLIR_INCLUDE_INTEGRATION_TESTS
47 # configuration flag, we automatically include sm80 tests when build for
48 # cuSparse when the configuration flag MLIR_ENABLE_CUDA_CUSPARSE is set and
49 # include sm80 lt tests when the MLIR_ENABLE_CUDA_CUSPARSELT is set in
51 if (MLIR_ENABLE_CUDA_CUSPARSE)
52 set(MLIR_RUN_CUDA_SM80_TESTS ON)
53 if (MLIR_ENABLE_CUDA_CUSPARSELT)
54 set(MLIR_RUN_CUDA_SM80_LT_TESTS ON)
60 llvm_canonicalize_cmake_booleans(
62 MLIR_ENABLE_BINDINGS_PYTHON
63 MLIR_ENABLE_CUDA_CONVERSIONS
64 MLIR_ENABLE_CUDA_RUNNER
65 MLIR_ENABLE_ROCM_CONVERSIONS
66 MLIR_ENABLE_ROCM_RUNNER
67 MLIR_ENABLE_SPIRV_CPU_RUNNER
68 MLIR_ENABLE_VULKAN_RUNNER
69 MLIR_INCLUDE_INTEGRATION_TESTS
71 MLIR_RUN_CUDA_TENSOR_CORE_TESTS
72 MLIR_RUN_X86VECTOR_TESTS
73 MLIR_RUN_ARM_SVE_TESTS
74 MLIR_RUN_ARM_SME_TESTS
75 MLIR_RUN_CUDA_SM80_TESTS
76 MLIR_RUN_CUDA_SM80_LT_TESTS
77 MLIR_RUN_CUDA_SM90_TESTS
80 configure_lit_site_cfg(
81 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
82 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
84 ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
86 configure_lit_site_cfg(
87 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
88 ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
90 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
94 FileCheck count not split-file
100 mlir-capi-sparse-tensor-test
101 mlir-capi-transform-test
102 mlir-linalg-ods-yaml-gen
115 # The native target may not be enabled, in this case we won't
116 # run tests that involves executing on the host: do not build
118 if(LLVM_ENABLE_PIC AND TARGET ${LLVM_NATIVE_ARCH})
119 list(APPEND MLIR_TEST_DEPENDS
123 mlir-capi-execution-engine-test
130 if (MLIR_INCLUDE_INTEGRATION_TESTS)
131 list(APPEND MLIR_TEST_DEPENDS lli)
134 if(MLIR_ENABLE_CUDA_RUNNER)
135 list(APPEND MLIR_TEST_DEPENDS mlir_cuda_runtime)
138 if(MLIR_ENABLE_ROCM_RUNNER)
139 list(APPEND MLIR_TEST_DEPENDS mlir_rocm_runtime)
142 list(APPEND MLIR_TEST_DEPENDS MLIRUnitTests)
144 if(LLVM_BUILD_EXAMPLES)
145 list(APPEND MLIR_TEST_DEPENDS
155 if(MLIR_ENABLE_EXECUTION_ENGINE)
156 list(APPEND MLIR_TEST_DEPENDS
163 if(MLIR_ENABLE_SPIRV_CPU_RUNNER)
164 add_subdirectory(mlir-spirv-cpu-runner)
165 list(APPEND MLIR_TEST_DEPENDS
166 mlir-spirv-cpu-runner
167 mlir_test_spirv_cpu_runner_c_wrappers
171 if(MLIR_ENABLE_VULKAN_RUNNER)
172 list(APPEND MLIR_TEST_DEPENDS
177 if(MLIR_ENABLE_BINDINGS_PYTHON)
178 list(APPEND MLIR_TEST_DEPENDS
183 # This target can be used to just build the dependencies
184 # for the check-mlir target without executing the tests.
185 # This is useful for bots when splitting the build step
186 # from the testing step.
187 add_custom_target(check-mlir-build-only
188 DEPENDS ${MLIR_TEST_DEPENDS}
191 add_lit_testsuite(check-mlir "Running the MLIR regression tests"
192 ${CMAKE_CURRENT_BINARY_DIR}
193 DEPENDS ${MLIR_TEST_DEPENDS}
195 set_target_properties(check-mlir PROPERTIES FOLDER "Tests")
197 add_lit_testsuites(MLIR ${CMAKE_CURRENT_SOURCE_DIR}
198 DEPENDS ${MLIR_TEST_DEPENDS}