257 lines · plain
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 Standalone11# dialect and can add it to the module path.12set(MLIR_CMAKE_DIR13 "${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 STRING20 "If set, arch-specific integration tests are run with Intel SDE.")21 set(ARM_EMULATOR_EXECUTABLE "" CACHE STRING22 "If set, arch-specific Arm integration tests are run with an emulator.")23 set(ARM_EMULATOR_OPTIONS "" CACHE STRING24 "If arch-specific Arm integration tests run emulated, pass these as parameters to the emulator.")25 set(ARM_EMULATOR_MLIR_RUNNER_EXECUTABLE "" CACHE STRING26 "If arch-specific Arm integration tests run emulated, use this Arm native mlir-runner.")27 set(ARM_EMULATOR_LLI_EXECUTABLE "" CACHE STRING28 "If arch-specific Arm integration tests run emulated, use this Arm native lli.")29 set(ARM_EMULATOR_UTILS_LIB_DIR "" CACHE STRING30 "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 STRING32 "The GPU compilation format used by the tests.")33 set(ARM_SME_ABI_ROUTINES_SHLIB "" CACHE STRING34 "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's45 # 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_TESTS55 # configuration flag, we automatically include sm80 tests when build for56 # cuSparse when the configuration flag MLIR_ENABLE_CUDA_CUSPARSE is set and57 # include sm80 lt tests when the MLIR_ENABLE_CUDA_CUSPARSELT is set in58 # 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_EXAMPLES70 LLVM_HAS_NVPTX_TARGET71 LLVM_INCLUDE_SPIRV_TOOLS_TESTS72 MLIR_ENABLE_BINDINGS_PYTHON73 MLIR_ENABLE_CUDA_RUNNER74 MLIR_ENABLE_ROCM_CONVERSIONS75 MLIR_ENABLE_ROCM_RUNNER76 MLIR_ENABLE_SPIRV_CPU_RUNNER77 MLIR_ENABLE_VULKAN_RUNNER78 MLIR_INCLUDE_INTEGRATION_TESTS79 MLIR_RUN_AMX_TESTS80 MLIR_RUN_CUDA_TENSOR_CORE_TESTS81 MLIR_RUN_X86VECTOR_TESTS82 MLIR_RUN_ARM_SVE_TESTS83 MLIR_RUN_ARM_SME_TESTS84 MLIR_RUN_CUDA_SM80_TESTS85 MLIR_RUN_CUDA_SM80_LT_TESTS86 MLIR_RUN_CUDA_SM90_TESTS87 BUILD_SHARED_LIBS88 )89 90configure_lit_site_cfg(91 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in92 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py93 MAIN_CONFIG94 ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py95 )96configure_lit_site_cfg(97 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in98 ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py99 MAIN_CONFIG100 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py101 )102 103set(MLIR_TEST_DEPENDS104 mlir-capi-ir-test105 mlir-capi-irdl-test106 mlir-capi-llvm-test107 mlir-capi-pass-test108 mlir-capi-quant-test109 mlir-capi-rewrite-test110 mlir-capi-smt-test111 mlir-capi-sparse-tensor-test112 mlir-capi-transform-test113 mlir-capi-transform-interpreter-test114 mlir-capi-translation-test115 mlir-linalg-ods-yaml-gen116 mlir-lsp-server117 mlir-opt118 mlir-query119 mlir-reduce120 mlir-rewrite121 mlir-tblgen122 mlir-translate123 tblgen-lsp-server124 tblgen-to-irdl125 )126if(NOT MLIR_STANDALONE_BUILD)127 list(APPEND MLIR_TEST_DEPENDS FileCheck count not split-file yaml2obj)128endif()129# Examples/standalone/test.toy (vis-a-vis the standalone example) depends on these.130if(LLVM_INCLUDE_EXAMPLES)131 list(APPEND MLIR_TEST_DEPENDS MLIRCAPIArith)132endif()133 134set(MLIR_TEST_DEPENDS ${MLIR_TEST_DEPENDS}135 mlir-capi-pdl-test136 mlir-pdll-lsp-server137 mlir-pdll138 )139 140# The native target may not be enabled, in this case we won't141# run tests that involves executing on the host: do not build142# useless binaries.143if(LLVM_ENABLE_PIC AND TARGET ${LLVM_NATIVE_ARCH})144 list(APPEND MLIR_TEST_DEPENDS145 mlir-runner146 llc147 mlir_async_runtime148 mlir-capi-execution-engine-test149 mlir-capi-global-constructors-test150 mlir_c_runner_utils151 mlir_runner_utils152 mlir_float16_utils153 )154endif()155 156if (MLIR_INCLUDE_INTEGRATION_TESTS)157 list(APPEND MLIR_TEST_DEPENDS lli)158endif()159 160if(MLIR_ENABLE_CUDA_RUNNER)161 list(APPEND MLIR_TEST_DEPENDS mlir_cuda_runtime)162endif()163 164if(MLIR_ENABLE_EXECUTION_ENGINE)165 list(APPEND MLIR_TEST_DEPENDS166 mlir-capi-execution-engine-test167 mlir-capi-global-constructors-test168 )169endif()170 171if(MLIR_ENABLE_ROCM_RUNNER)172 list(APPEND MLIR_TEST_DEPENDS mlir_rocm_runtime)173endif()174 175if(MLIR_ENABLE_SYCL_RUNNER)176 list(APPEND MLIR_TEST_DEPENDS mlir_sycl_runtime)177endif()178 179if(MLIR_ENABLE_LEVELZERO_RUNNER)180 list(APPEND MLIR_TEST_DEPENDS mlir_levelzero_runtime)181endif()182 183if (MLIR_RUN_ARM_SME_TESTS AND NOT ARM_SME_ABI_ROUTINES_SHLIB)184 list(APPEND MLIR_TEST_DEPENDS mlir_arm_sme_abi_stubs)185endif()186 187if (MLIR_RUN_ARM_SVE_TESTS OR MLIR_RUN_ARM_SME_TESTS)188 list(APPEND MLIR_TEST_DEPENDS mlir_arm_runner_utils)189endif()190 191list(APPEND MLIR_TEST_DEPENDS MLIRUnitTests)192 193if(LLVM_BUILD_EXAMPLES)194 list(APPEND MLIR_TEST_DEPENDS195 toyc-ch1196 toyc-ch2197 toyc-ch3198 toyc-ch4199 toyc-ch5200 )201 list(APPEND MLIR_TEST_DEPENDS202 transform-opt-ch2203 transform-opt-ch3204 transform-opt-ch4205 mlir-minimal-opt206 mlir-transform-opt207 )208 if(MLIR_ENABLE_EXECUTION_ENGINE)209 list(APPEND MLIR_TEST_DEPENDS210 toyc-ch6211 toyc-ch7212 )213 endif()214endif()215 216if(MLIR_ENABLE_SPIRV_CPU_RUNNER)217 list(APPEND MLIR_TEST_DEPENDS218 mlir_spirv_cpu_runtime219 )220endif()221 222if(MLIR_ENABLE_VULKAN_RUNNER)223 list(APPEND MLIR_TEST_DEPENDS224 mlir_vulkan_runtime225 )226endif()227 228if(MLIR_ENABLE_BINDINGS_PYTHON)229 list(APPEND MLIR_TEST_DEPENDS230 MLIRPythonModules231 )232endif()233 234if (LLVM_INCLUDE_SPIRV_TOOLS_TESTS)235 list(APPEND MLIR_TEST_DEPENDS spirv-as)236 list(APPEND MLIR_TEST_DEPENDS spirv-val)237endif()238 239# This target can be used to just build the dependencies240# for the check-mlir target without executing the tests.241# This is useful for bots when splitting the build step242# from the testing step.243add_custom_target(check-mlir-build-only244 DEPENDS ${MLIR_TEST_DEPENDS}245)246set_target_properties(check-mlir-build-only PROPERTIES FOLDER "MLIR/Tests")247 248add_lit_testsuite(check-mlir "Running the MLIR regression tests"249 ${CMAKE_CURRENT_BINARY_DIR}250 DEPENDS ${MLIR_TEST_DEPENDS}251 )252 253add_lit_testsuites(MLIR ${CMAKE_CURRENT_SOURCE_DIR}254 DEPENDS ${MLIR_TEST_DEPENDS}255 SKIP "^python*"256)257