1include(MLIRCheckHardwareFeatures) 2 3add_subdirectory(CAPI) 4add_subdirectory(lib) 5 6if (MLIR_ENABLE_BINDINGS_PYTHON) 7 add_subdirectory(python) 8endif() 9 10# Provide the MLIR CMake module dir so that the out of tree Standalone 11# dialect and can add it to the module path. 12set(MLIR_CMAKE_DIR 13 "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir") 14 15# Passed to lit.site.cfg.py.in to set up the path where to find libraries. 16set(MLIR_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) 17 18if (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_RUNNER_EXECUTABLE "" CACHE STRING 26 "If arch-specific Arm integration tests run emulated, use this Arm native mlir-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.") 43 44 # Check whether an emulator is required - if yes then make sure that it's 45 # been set. 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) 48 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") 52 endif() 53 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 58 # addition to those. 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) 63 endif() 64 endif() 65 66endif() 67 68llvm_canonicalize_cmake_booleans( 69 LLVM_BUILD_EXAMPLES 70 LLVM_HAS_NVPTX_TARGET 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 78 MLIR_RUN_AMX_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 86 ) 87 88configure_lit_site_cfg( 89 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in 90 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py 91 MAIN_CONFIG 92 ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py 93 ) 94configure_lit_site_cfg( 95 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in 96 ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py 97 MAIN_CONFIG 98 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py 99 ) 100 101set(MLIR_TEST_DEPENDS 102 mlir-capi-ir-test 103 mlir-capi-irdl-test 104 mlir-capi-llvm-test 105 mlir-capi-pass-test 106 mlir-capi-quant-test 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 113 mlir-lsp-server 114 mlir-opt 115 mlir-query 116 mlir-reduce 117 mlir-rewrite 118 mlir-tblgen 119 mlir-translate 120 tblgen-lsp-server 121 tblgen-to-irdl 122 ) 123if(NOT MLIR_STANDALONE_BUILD) 124 list(APPEND MLIR_TEST_DEPENDS FileCheck count not split-file) 125endif() 126 127set(MLIR_TEST_DEPENDS ${MLIR_TEST_DEPENDS} 128 mlir-capi-pdl-test 129 mlir-pdll-lsp-server 130 mlir-pdll 131 ) 132 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 135# useless binaries. 136if(LLVM_ENABLE_PIC AND TARGET ${LLVM_NATIVE_ARCH}) 137 list(APPEND MLIR_TEST_DEPENDS 138 mlir-runner 139 llc 140 mlir_async_runtime 141 mlir-capi-execution-engine-test 142 mlir_c_runner_utils 143 mlir_runner_utils 144 mlir_float16_utils 145 ) 146endif() 147 148if (MLIR_INCLUDE_INTEGRATION_TESTS) 149 list(APPEND MLIR_TEST_DEPENDS lli) 150endif() 151 152if(MLIR_ENABLE_CUDA_RUNNER) 153 list(APPEND MLIR_TEST_DEPENDS mlir_cuda_runtime) 154endif() 155 156if(MLIR_ENABLE_EXECUTION_ENGINE) 157 list(APPEND MLIR_TEST_DEPENDS mlir-capi-execution-engine-test) 158endif() 159 160if(MLIR_ENABLE_ROCM_RUNNER) 161 list(APPEND MLIR_TEST_DEPENDS mlir_rocm_runtime) 162endif() 163 164if(MLIR_ENABLE_SYCL_RUNNER) 165 list(APPEND MLIR_TEST_DEPENDS mlir_sycl_runtime) 166endif() 167 168if (MLIR_RUN_ARM_SME_TESTS AND NOT ARM_SME_ABI_ROUTINES_SHLIB) 169 list(APPEND MLIR_TEST_DEPENDS mlir_arm_sme_abi_stubs) 170endif() 171 172if (MLIR_RUN_ARM_SVE_TESTS OR MLIR_RUN_ARM_SME_TESTS) 173 list(APPEND MLIR_TEST_DEPENDS mlir_arm_runner_utils) 174endif() 175 176list(APPEND MLIR_TEST_DEPENDS MLIRUnitTests) 177 178if(LLVM_BUILD_EXAMPLES) 179 list(APPEND MLIR_TEST_DEPENDS 180 toyc-ch1 181 toyc-ch2 182 toyc-ch3 183 toyc-ch4 184 toyc-ch5 185 ) 186 list(APPEND MLIR_TEST_DEPENDS 187 transform-opt-ch2 188 transform-opt-ch3 189 transform-opt-ch4 190 mlir-minimal-opt 191 mlir-transform-opt 192 ) 193 if(MLIR_ENABLE_EXECUTION_ENGINE) 194 list(APPEND MLIR_TEST_DEPENDS 195 toyc-ch6 196 toyc-ch7 197 ) 198 endif() 199endif() 200 201if(MLIR_ENABLE_SPIRV_CPU_RUNNER) 202 list(APPEND MLIR_TEST_DEPENDS 203 mlir_spirv_cpu_runtime 204 ) 205endif() 206 207if(MLIR_ENABLE_VULKAN_RUNNER) 208 list(APPEND MLIR_TEST_DEPENDS 209 mlir_vulkan_runtime 210 ) 211endif() 212 213if(MLIR_ENABLE_BINDINGS_PYTHON) 214 list(APPEND MLIR_TEST_DEPENDS 215 MLIRPythonModules 216 ) 217endif() 218 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. 223add_custom_target(check-mlir-build-only 224 DEPENDS ${MLIR_TEST_DEPENDS} 225) 226set_target_properties(check-mlir-build-only PROPERTIES FOLDER "MLIR/Tests") 227 228add_lit_testsuite(check-mlir "Running the MLIR regression tests" 229 ${CMAKE_CURRENT_BINARY_DIR} 230 DEPENDS ${MLIR_TEST_DEPENDS} 231 ) 232 233add_lit_testsuites(MLIR ${CMAKE_CURRENT_SOURCE_DIR} 234 DEPENDS ${MLIR_TEST_DEPENDS} 235) 236