diff --git a/.github/workflows/buildAndTest.yml b/.github/workflows/buildAndTest.yml index 82507e0b29..32b4040841 100644 --- a/.github/workflows/buildAndTest.yml +++ b/.github/workflows/buildAndTest.yml @@ -157,7 +157,7 @@ jobs: max-size: 1G - name: Build and install LLVM - run: utils/build-llvm.sh + run: LLVM_ENABLE_RTTI=ON utils/build-llvm.sh # Build the repo test target in debug mode to build and test. - name: Build and test (Assert) diff --git a/CMakeLists.txt b/CMakeLists.txt index f74481285a..fe894caa1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,11 +125,13 @@ set(LLVM_LIT_ARGS list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}") list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") + include(TableGen) include(AddLLVM) include(AddMLIR) include(HandleLLVMOptions) include(ExternalProject) +include(CMakeDependentOption) include_directories(${LLVM_INCLUDE_DIRS}) include_directories(${MLIR_INCLUDE_DIRS}) @@ -137,6 +139,14 @@ include_directories(${PROJECT_SOURCE_DIR}/include) include_directories(${PROJECT_BINARY_DIR}/include) add_definitions(${LLVM_DEFINITIONS}) + +cmake_dependent_option(AIE_ENABLE_BINDINGS_PYTHON + "Enables building of Python bindings." ON "MLIR_ENABLE_BINDINGS_PYTHON" OFF) + +cmake_dependent_option(AIE_ENABLE_PYTHON_PASSES + "Enables building of passes that connect to python." ON "AIE_ENABLE_BINDINGS_PYTHON;LLVM_ENABLE_RTTI" OFF) + + # Silence a false positive GCC -Wunused-but-set-parameter warning in constexpr # cases, by marking SelectedCase as used. See # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827 for details. The issue is @@ -159,18 +169,17 @@ if(AIE_INCLUDE_DOCS) add_dependencies(docs mlir-doc) endif() -# setup python -include(MLIRDetectPythonEnv) -mlir_configure_python_dev_packages() +if(AIE_ENABLE_BINDINGS_PYTHON) + include(MLIRDetectPythonEnv) + mlir_configure_python_dev_packages() -# python install directory -if(NOT AIE_PYTHON_PACKAGES_DIR) - set(AIE_PYTHON_PACKAGES_DIR "${CMAKE_CURRENT_BINARY_DIR}/python") -endif() + if(NOT AIE_PYTHON_PACKAGES_DIR) + set(AIE_PYTHON_PACKAGES_DIR "${CMAKE_CURRENT_BINARY_DIR}/python") + endif() -# python install directory -if(NOT AIE_PYTHON_INSTALL_DIR) - set(AIE_PYTHON_INSTALL_DIR "python") + if(NOT AIE_PYTHON_INSTALL_DIR) + set(AIE_PYTHON_INSTALL_DIR "python") + endif() endif() add_subdirectory(include) @@ -179,7 +188,10 @@ add_subdirectory(runtime_lib) add_subdirectory(aie_runtime_lib) add_subdirectory(tools) add_subdirectory(data) -add_subdirectory(python) + +if(AIE_ENABLE_BINDINGS_PYTHON) + add_subdirectory(python) +endif() if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install( diff --git a/cmake/modules/AIEConfig.cmake.in b/cmake/modules/AIEConfig.cmake.in index 1220ba4a1c..6eb6b0a1e0 100644 --- a/cmake/modules/AIEConfig.cmake.in +++ b/cmake/modules/AIEConfig.cmake.in @@ -15,6 +15,7 @@ set(AIE_CMAKE_DIR "@AIE_CONFIG_CMAKE_DIR@") set(AIE_BINARY_DIR "@AIE_CONFIG_BINARY_DIR@") set(AIE_TOOLS_BINARY_DIR "@AIE_CONFIG_TOOLS_BINARY_DIR@") set(AIE_INCLUDE_DIRS "@AIE_CONFIG_INCLUDE_DIRS@") +set(LLVM_ENABLE_RTTI @LLVM_ENABLE_RTTI@) # Provide AIE configurations for users to inherit from. set(AIE_RUNTIME_TARGETS "@AIE_RUNTIME_TARGETS@") diff --git a/python/AIEMLIRModule.cpp b/python/AIEMLIRModule.cpp index e0b22dc551..f47b4331f6 100644 --- a/python/AIEMLIRModule.cpp +++ b/python/AIEMLIRModule.cpp @@ -5,8 +5,6 @@ // //===----------------------------------------------------------------------===// -#include "PythonPass.h" - #include "aie-c/Dialects.h" #include "aie-c/Registration.h" @@ -46,10 +44,6 @@ PYBIND11_MODULE(_aie, m) { }, py::arg("context"), py::arg("load") = true); - m.def("register_python_pass_demo_pass", [](py::function func) { - registerPythonPassDemoPassWithFunc(std::move(func)); - }); - // AIE types bindings mlir_type_subclass(m, "ObjectFifoType", aieTypeIsObjectFifoType) .def_classmethod( diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 9b3bf2b78f..5a582449b6 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -19,6 +19,8 @@ declare_mlir_python_sources(AIEPythonSources ROOT_DIR "${AIE_PYTHON_ROOT_DIR}" ) +declare_mlir_python_sources(AIEPythonExtensions) + declare_mlir_python_sources(AIEPythonSources.Dialects ADD_TO_PARENT AIEPythonSources ) @@ -47,61 +49,151 @@ declare_mlir_dialect_python_bindings( # Extensions ################################################################################ -get_property(MLIR_CONVERSION_LIBS GLOBAL PROPERTY MLIR_CONVERSION_LIBS) -get_property(MLIR_DIALECT_LIBS GLOBAL PROPERTY MLIR_DIALECT_LIBS) -get_property(MLIR_EXTENSION_LIBS GLOBAL PROPERTY MLIR_EXTENSION_LIBS) -get_property(MLIR_TRANSLATION_LIBS GLOBAL PROPERTY MLIR_TRANSLATION_LIBS) -get_property(MLIR_UPSTREAM_CAPI_LIBS GLOBAL PROPERTY MLIR_UPSTREAM_CAPI_LIBS) - -get_target_property(RegisterEverythingSources MLIRPythonExtension.RegisterEverything INTERFACE_SOURCES) - -_flatten_mlir_python_targets(mlir_python_sources MLIRPythonSources) -set(_mlir_python_cpp_sources) -foreach(s ${mlir_python_sources}) - get_target_property(_sources ${s} INTERFACE_SOURCES) - list(FILTER _sources INCLUDE REGEX "(\.cpp|\.h)$") - if(_sources) - list(APPEND _mlir_python_cpp_sources ${_sources}) - endif() -endforeach() +if (AIE_ENABLE_PYTHON_PASSES) + # What's going on here? This branch builds a single shared library Python C extension module + # with absolutely everything, including the kitchen sink. I.e, this "omnibus" shared library + # will have absolutely all the MLIR code (including C APIs), all the upstream C extension modules, + # our main C extension module (AIEMLIRModule.cpp) and the PythonPass.cpp C extension module. + # + # Why do this? This is a way to call arbitrary MLIR code from the python bindings. Such as, for example, + # PythonPass.cpp does. + # + # Note, this depends on MLIR being compiled with RTTI (i.e., LLVM_ENABLE_RTTI=ON) and the + # guard includes this. + + get_property(MLIR_CONVERSION_LIBS GLOBAL PROPERTY MLIR_CONVERSION_LIBS) + get_property(MLIR_DIALECT_LIBS GLOBAL PROPERTY MLIR_DIALECT_LIBS) + get_property(MLIR_EXTENSION_LIBS GLOBAL PROPERTY MLIR_EXTENSION_LIBS) + get_property(MLIR_TRANSLATION_LIBS GLOBAL PROPERTY MLIR_TRANSLATION_LIBS) + get_property(MLIR_UPSTREAM_CAPI_LIBS GLOBAL PROPERTY MLIR_UPSTREAM_CAPI_LIBS) + + # Dig out all of the upstream cpp source files associated with the C extension modules. + _flatten_mlir_python_targets(mlir_python_sources MLIRPythonSources) + set(_mlir_python_cpp_sources) + foreach(s ${mlir_python_sources}) + get_target_property(_sources ${s} INTERFACE_SOURCES) + list(FILTER _sources INCLUDE REGEX "(\.cpp|\.h)$") + if(_sources) + list(APPEND _mlir_python_cpp_sources ${_sources}) + endif() + endforeach() + + # Missed one... + get_target_property(RegisterEverythingSources MLIRPythonExtension.RegisterEverything INTERFACE_SOURCES) + + declare_mlir_python_extension(AIEPythonExtensions.MLIR + MODULE_NAME _aie + ADD_TO_PARENT AIEPythonExtensions + ROOT_DIR "/" + + SOURCES + + ${CMAKE_CURRENT_SOURCE_DIR}/AIEMLIRModule.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/PythonPass.cpp + + ${_mlir_python_cpp_sources} + ${RegisterEverythingSources} + + PRIVATE_LINK_LIBS + LLVMSupport + AIECAPI + ${MLIR_CONVERSION_LIBS} + ${MLIR_DIALECT_LIBS} + ${MLIR_EXTENSION_LIBS} + ${MLIR_TRANSLATION_LIBS} + ${MLIR_UPSTREAM_CAPI_LIBS} + ) -list(SORT _mlir_python_cpp_sources) + # Kill all of the dependencies (mlir_python_DEPENDS) on cpp sources in the dialect build targets + # so the C extension modules don't get built but the Python sources do get installed. + _flatten_mlir_python_targets(mlir_python_sources_deps MLIRPythonSources) + list(FILTER mlir_python_sources_deps INCLUDE REGEX "^MLIRPythonSources.Dialects") + foreach(t ${mlir_python_sources_deps}) + set_property(TARGET ${t} PROPERTY mlir_python_DEPENDS "") + endforeach() + set_property(TARGET MLIRPythonSources.ExecutionEngine PROPERTY mlir_python_DEPENDS "") + + add_mlir_python_modules(AIEPythonModules + ROOT_PREFIX "${AIE_PYTHON_PACKAGES_DIR}/aie" + INSTALL_PREFIX "python/aie" + DECLARED_SOURCES + ${mlir_python_sources_deps} + MLIRPythonSources.Core.Python + MLIRPythonSources.ExecutionEngine + AIEPythonExtensions.MLIR + AIEPythonSources + ) -declare_mlir_python_extension(AIEPythonExtensions - MODULE_NAME _aie - ROOT_DIR "/" + set(_other_extensions + _aie_python_passes + _mlir + _mlirAsyncPasses + _mlirDialectsLinalg + _mlirDialectsPDL + _mlirDialectsQuant + _mlirDialectsSparseTensor + _mlirDialectsTransform + _mlirExecutionEngine + _mlirGPUPasses + _mlirLinalgPasses + _mlirPythonTest + _mlirRegisterEverything + _mlirSparseTensorPasses + ) + file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/python/aie/_mlir_libs") + + # This is the trick that makes multiple Python C extension modules packaged into one shared library work; + # Python importlib machinery looks for PyInit__your_module based on the filename _your_module.so. + # Thus, if you have a symlink _your_module.so -> BIGOMNIBUS.so, it will look for PyInit__your_module in + # BIGOMNIBUS.so. + foreach(ext ${_other_extensions}) + # Build time/directory creation. + add_custom_target("symlink_${ext}" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "_aie${PYTHON_MODULE_EXTENSION}" + "${ext}${PYTHON_MODULE_EXTENSION}" + DEPENDS AIEPythonExtensions + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/python/aie/_mlir_libs" + ) + add_dependencies(AIEPythonModules "symlink_${ext}") + # Install time/directory creation. + install(CODE "execute_process( + COMMAND ${CMAKE_COMMAND} -E create_symlink + _aie${PYTHON_MODULE_EXTENSION} + ${ext}${PYTHON_MODULE_EXTENSION} + WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/python/aie/_mlir_libs + )" + ) + endforeach() + +else () + + # Standard Python C extension bindings. + +declare_mlir_python_extension(AIEPythonExtensions.MLIR + MODULE_NAME _aie + ADD_TO_PARENT AIEPythonExtensions + ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/AIEMLIRModule.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/PythonPass.cpp - - ${_mlir_python_cpp_sources} - ${RegisterEverythingSources} - + AIEMLIRModule.cpp + EMBED_CAPI_LINK_LIBS + AIECAPI PRIVATE_LINK_LIBS - LLVMSupport - AIECAPI - ${MLIR_CONVERSION_LIBS} - ${MLIR_DIALECT_LIBS} - ${MLIR_EXTENSION_LIBS} - ${MLIR_TRANSLATION_LIBS} - ${MLIR_UPSTREAM_CAPI_LIBS} + LLVMSupport ) -_flatten_mlir_python_targets(mlir_python_sources_deps MLIRPythonSources) -list(FILTER mlir_python_sources_deps INCLUDE REGEX "^MLIRPythonSources.Dialects") -foreach(t ${mlir_python_sources_deps}) - set_property(TARGET ${t} PROPERTY mlir_python_DEPENDS "") -endforeach() -set_property(TARGET MLIRPythonSources.ExecutionEngine PROPERTY mlir_python_DEPENDS "") - -add_mlir_python_modules(AIEMLIRPythonModules - ROOT_PREFIX "${AIE_PYTHON_PACKAGES_DIR}/aie" - INSTALL_PREFIX "python/aie" +add_mlir_python_common_capi_library(AIEAggregateCAPI + INSTALL_COMPONENT AIEPythonModules + INSTALL_DESTINATION python/aie/_mlir_libs + OUTPUT_DIRECTORY "${AIE_PYTHON_PACKAGES_DIR}/aie/_mlir_libs" + RELATIVE_INSTALL_ROOT "../../../.." DECLARED_SOURCES - ${mlir_python_sources_deps} - MLIRPythonSources.Core.Python - MLIRPythonSources.ExecutionEngine + MLIRPythonSources + MLIRPythonExtension.Core + MLIRPythonExtension.RegisterEverything + MLIRPythonExtension.ExecutionEngine + AIEPythonSources AIEPythonExtensions ) @@ -110,47 +202,19 @@ add_mlir_python_modules(AIEPythonModules INSTALL_PREFIX "python/aie" DECLARED_SOURCES AIEPythonSources + MLIRPythonSources + MLIRPythonExtension.Core + MLIRPythonExtension.RegisterEverything + MLIRPythonExtension.ExecutionEngine + AIEPythonExtensions + COMMON_CAPI_LINK_LIBS + AIEAggregateCAPI + AIECAPI ) -add_subdirectory(compiler) -add_dependencies(AIEPythonModules AIECompilerPythonModules) - -set(_other_extensions - _mlir - _mlirAsyncPasses - _mlirDialectsLinalg - _mlirDialectsPDL - _mlirDialectsQuant - _mlirDialectsSparseTensor - _mlirDialectsTransform - _mlirExecutionEngine - _mlirGPUPasses - _mlirLinalgPasses - _mlirPythonTest - _mlirRegisterEverything - _mlirSparseTensorPasses -) - -file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/python/aie/_mlir_libs") - -foreach(ext ${_other_extensions}) - add_custom_target("symlink_${ext}" - COMMAND ${CMAKE_COMMAND} -E create_symlink - "_aie${PYTHON_MODULE_EXTENSION}" - "${ext}${PYTHON_MODULE_EXTENSION}" - DEPENDS AIEPythonExtensions - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/python/aie/_mlir_libs" - ) - add_dependencies(AIEPythonModules "symlink_${ext}") - install(CODE "execute_process( - COMMAND ${CMAKE_COMMAND} -E create_symlink - _aie${PYTHON_MODULE_EXTENSION} - ${ext}${PYTHON_MODULE_EXTENSION} - WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/python/aie/_mlir_libs - )" - ) -endforeach() +endif () +# Copy the runtime libs into the _mlir_libs directory for convenience. set(_runtimes mlir_async_runtime mlir_c_runner_utils @@ -177,3 +241,5 @@ install(IMPORTED_RUNTIME_ARTIFACTS LIBRARY DESTINATION "python/aie/_mlir_libs" ) +add_subdirectory(compiler) +add_dependencies(AIEPythonModules AIECompilerPythonModules) diff --git a/python/PythonPass.cpp b/python/PythonPass.cpp index 207c65838f..5e1d9d6ca0 100644 --- a/python/PythonPass.cpp +++ b/python/PythonPass.cpp @@ -1,12 +1,10 @@ -//===- PythonPassDemo.cpp -------------------------------*- C++ -*-===// +//===- PythonPassDemo.cpp ---------------------------------------*- C++ -*-===// // // Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#include "PythonPass.h" - #include "aie/Dialect/AIE/IR/AIEDialect.h" #include "mlir/Bindings/Python/PybindAdaptors.h" @@ -15,10 +13,11 @@ #include "mlir/Pass/Pass.h" using namespace mlir; -namespace py = pybind11; using namespace mlir::python::adaptors; using namespace xilinx::AIE; +namespace py = pybind11; + struct PythonPassDemo : public PassWrapper> { MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PythonPassDemo) @@ -40,3 +39,10 @@ createPythonPassDemoPassWithFunc(py::function func) { void registerPythonPassDemoPassWithFunc(py::function func) { registerPass([func]() { return createPythonPassDemoPassWithFunc(func); }); } + +PYBIND11_MODULE(_aie_python_passes, m) { + + m.def("register_python_pass_demo_pass", [](py::function func) { + registerPythonPassDemoPassWithFunc(std::move(func)); + }); +} diff --git a/python/PythonPass.h b/python/PythonPass.h deleted file mode 100644 index 22da324c36..0000000000 --- a/python/PythonPass.h +++ /dev/null @@ -1,14 +0,0 @@ -//===- PythonPassDemo.h ---------------------------------*- C -*-===// -// -// Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include -#include -#include - -namespace py = pybind11; - -void registerPythonPassDemoPassWithFunc(py::function func); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fc3bb17186..d102b7128f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,20 +1,95 @@ -if(ENABLE_CHESS_TESTS) -set(CONFIG_ENABLE_CHESS_TESTS 1) -else() -set(CONFIG_ENABLE_CHESS_TESTS 0) +# This file is licensed under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +# (c) Copyright 2021 Xilinx Inc. + +cmake_minimum_required(VERSION 3.10) + +if(POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) endif() -if(ENABLE_BOARD_TESTS) -set(CONFIG_ENABLE_BOARD_TESTS 1) -else() -set(CONFIG_ENABLE_BOARD_TESTS 0) + +if(POLICY CMP0068) + cmake_policy(SET CMP0068 NEW) + set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) +endif() + +if(POLICY CMP0075) + cmake_policy(SET CMP0075 NEW) +endif() + +if(POLICY CMP0077) + cmake_policy(SET CMP0077 NEW) +endif() + +include(CMakeDependentOption) + +if(POLICY CMP0127) + cmake_policy(SET CMP0127 NEW) +endif() + +project(aie-test LANGUAGES CXX C) + +# find package AIE if running tests from AIE installation +if(NOT AIE_BINARY_DIR) + find_package(AIE REQUIRED CONFIG) + set(LibXAIE_${AIE_RUNTIME_TEST_TARGET}_DIR CACHE STRING "") #pick up libxaiengine from installation folder if no other location specified endif() -if(LibXAIE_FOUND) -set(CONFIG_HAS_LIBXAIE 1) + +# default to x86_64 system architecture for runtime target +set(AIE_RUNTIME_TARGETS "x86_64" CACHE STRING "Architectures to compile the runtime libraries for.") +list(GET AIE_RUNTIME_TARGETS 0 firstRuntimeTarget) +set(AIE_RUNTIME_TEST_TARGET ${firstRuntimeTarget} CACHE STRING "Runtime architecture to test with.") + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED YES) + +option(LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON) +option(LLVM_BUILD_TOOLS "Build the LLVM tools. If OFF, just generate build targets." ON) + +find_package(MLIR REQUIRED CONFIG) + +message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}") +message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") + +set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin) +set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib) +set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR}) + +find_package(Vitis 2023.2 COMPONENTS AIE AIE2) +find_package(Python3 COMPONENTS Interpreter) + +cmake_dependent_option(ENABLE_CHESS_TESTS "Enable backend tests using xchesscc" ON "Vitis_FOUND" OFF) +cmake_dependent_option(ENABLE_BOARD_TESTS "Enable board tests" ON "CMAKE_HOST_SYSTEM_PROCESSOR MATCHES aarch64" OFF) + +# Look for LibXAIE +if (DEFINED LibXAIE_${AIE_RUNTIME_TEST_TARGET}_DIR) + message("Test using xaiengine from LibXAIE_${AIE_RUNTIME_TEST_TARGET}_DIR=${LibXAIE_${AIE_RUNTIME_TEST_TARGET}_DIR}") + set(LibXAIE_ROOT ${LibXAIE_${target}_DIR}) + find_package(LibXAIE) else() -set(CONFIG_HAS_LIBXAIE 0) + if(DEFINED VITIS_ROOT) + message(STATUS "Test has Vitis available, no libxaie location specified so pick up from build area") + set(LibXAIE_FOUND TRUE) + endif() endif() -set(ENABLE_PYTHON_TESTS 1) +list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}") +list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") + +include(TableGen) +include(AddLLVM) +include(AddMLIR) +include(HandleLLVMOptions) + +include_directories(${LLVM_INCLUDE_DIRS}) +include_directories(${MLIR_INCLUDE_DIRS}) +include_directories(${PROJECT_SOURCE_DIR}/include) +include_directories(${PROJECT_BINARY_DIR}/include) +add_definitions(${LLVM_DEFINITIONS}) + +cmake_dependent_option(ENABLE_PYTHON_TESTS "Enable Python tests" ON "AIE_ENABLE_BINDINGS_PYTHON" OFF) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in @@ -28,15 +103,12 @@ set(TEST_DEPENDS aiecc.py aie-opt aie-translate - AIEPythonModules ) add_lit_testsuite(check-aie "Running the aie regression tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${TEST_DEPENDS} - ARGS "-sv --timeout 600 --time-tests --show-unsupported" + ARGS "-sv --timeout 600" ) set_target_properties(check-aie PROPERTIES FOLDER "Tests") - -add_lit_testsuites(AIE ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${TEST_DEPENDS} ARGS "-sv --timeout 600 --time-tests --show-unsupported") diff --git a/test/lit.cfg.py b/test/lit.cfg.py index 2028ba2265..a4fc8ab854 100644 --- a/test/lit.cfg.py +++ b/test/lit.cfg.py @@ -23,83 +23,106 @@ # Configuration file for the 'lit' test runner. # name: The name of this test suite. -config.name = 'AIE' +config.name = "AIE" config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) -config.environment['PYTHONPATH'] = "{}".format(os.path.join(config.aie_obj_root, "python")) +config.environment["PYTHONPATH"] = "{}".format( + os.path.join(config.aie_obj_root, "python") +) # suffixes: A list of file extensions to treat as test files. -config.suffixes = ['.mlir'] +config.suffixes = [".mlir", ".py"] # test_source_root: The root path where tests are located. config.test_source_root = os.path.dirname(__file__) -config.substitutions.append(('%PATH%', config.environment['PATH'])) -config.substitutions.append(('%PYTHON', config.python_executable)) -config.substitutions.append(('%shlibext', config.llvm_shlib_ext)) -config.substitutions.append(('%extraAieCcFlags%', config.extraAieCcFlags)) -config.substitutions.append(('%aie_runtime_lib%', os.path.join(config.aie_obj_root, "aie_runtime_lib"))) -config.substitutions.append(('%host_runtime_lib%', os.path.join(config.aie_obj_root, "runtime_lib", config.aieHostTarget))) -config.substitutions.append(('%aietools', config.vitis_aietools_dir)) +config.substitutions.append(("%PATH%", config.environment["PATH"])) +config.substitutions.append(("%PYTHON", config.python_executable)) +config.substitutions.append(("%shlibext", config.llvm_shlib_ext)) +config.substitutions.append(("%extraAieCcFlags%", config.extraAieCcFlags)) +config.substitutions.append( + ("%aie_runtime_lib%", os.path.join(config.aie_obj_root, "aie_runtime_lib")) +) +config.substitutions.append( + ( + "%host_runtime_lib%", + os.path.join(config.aie_obj_root, "runtime_lib", config.aieHostTarget), + ) +) +config.substitutions.append(("%aietools", config.vitis_aietools_dir)) # for xchesscc_wrapper -llvm_config.with_environment('AIETOOLS', config.vitis_aietools_dir) +llvm_config.with_environment("AIETOOLS", config.vitis_aietools_dir) -if(config.enable_board_tests): - config.substitutions.append(('%run_on_board', "echo %T >> /home/xilinx/testlog | sync | sudo")) +if config.enable_board_tests: + config.substitutions.append( + ("%run_on_board", "echo %T >> /home/xilinx/testlog | sync | sudo") + ) else: - config.substitutions.append(('%run_on_board', "echo")) + config.substitutions.append(("%run_on_board", "echo")) -VitisSysrootFlag = '' -if (config.aieHostTarget == 'x86_64'): - config.substitutions.append(('%aieHostTargetTriplet%', 'x86_64-unknown-linux-gnu')) -elif (config.aieHostTarget == 'aarch64'): - config.substitutions.append(('%aieHostTargetTriplet%', 'aarch64-linux-gnu')) - VitisSysrootFlag = '--sysroot='+config.vitis_sysroot +VitisSysrootFlag = "" +if config.aieHostTarget == "x86_64": + config.substitutions.append(("%aieHostTargetTriplet%", "x86_64-unknown-linux-gnu")) +elif config.aieHostTarget == "aarch64": + config.substitutions.append(("%aieHostTargetTriplet%", "aarch64-linux-gnu")) + VitisSysrootFlag = "--sysroot=" + config.vitis_sysroot -config.substitutions.append(('%VitisSysrootFlag%', VitisSysrootFlag)) -config.substitutions.append(('%aieHostTargetArch%', config.aieHostTarget)) +config.substitutions.append(("%VitisSysrootFlag%", VitisSysrootFlag)) +config.substitutions.append(("%aieHostTargetArch%", config.aieHostTarget)) -llvm_config.with_system_environment( - ['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP']) +llvm_config.with_system_environment(["HOME", "INCLUDE", "LIB", "TMP", "TEMP"]) llvm_config.use_default_substitutions() # excludes: A list of directories to exclude from the testsuite. The 'Inputs' # subdirectories contain auxiliary inputs for various tests in their parent # directories. -config.excludes = ['Inputs', 'Examples', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt', 'aie.mlir.prj'] +config.excludes = [ + "Inputs", + "Examples", + "CMakeLists.txt", + "README.txt", + "LICENSE.txt", + "aie.mlir.prj", + "lit.cfg.py", +] + +config.aie_tools_dir = os.path.join(config.aie_obj_root, "bin") -config.aie_tools_dir = os.path.join(config.aie_obj_root, 'bin') def prepend_path(path): global llvm_config paths = [path] - current_paths = llvm_config.config.environment.get('PATH', None) + current_paths = llvm_config.config.environment.get("PATH", None) if current_paths: paths.extend(current_paths.split(os.path.pathsep)) paths = [os.path.normcase(os.path.normpath(p)) for p in paths] else: paths = [] - llvm_config.config.environment['PATH'] = os.pathsep.join(paths) + llvm_config.config.environment["PATH"] = os.pathsep.join(paths) + # Setup the path. -if(config.vitis_root): - config.vitis_aietools_bin = os.path.join(config.vitis_aietools_dir, "bin") - prepend_path(config.vitis_aietools_bin) - llvm_config.with_environment('VITIS', config.vitis_root) - #llvm_config.with_environment('LM_LICENSE_FILE', os.getenv('LM_LICENSE_FILE')) - #llvm_config.with_environment('XILINXD_LICENSE_FILE', os.getenv('XILINXD_LICENSE_FILE')) +if config.vitis_root: + config.vitis_aietools_bin = os.path.join(config.vitis_aietools_dir, "bin") + prepend_path(config.vitis_aietools_bin) + llvm_config.with_environment("VITIS", config.vitis_root) + prepend_path(config.llvm_tools_dir) prepend_path(config.peano_tools_dir) prepend_path(config.aie_tools_dir) # Test to see if we have the peano backend. try: - result = subprocess.run([os.path.join(config.peano_tools_dir, 'llc'),'-mtriple=aie','--version'],stdout=subprocess.PIPE,stderr=subprocess.PIPE) - if (re.search("Xilinx AI Engine", result.stdout.decode('utf-8')) is not None): - config.available_features.add('peano') + result = subprocess.run( + [os.path.join(config.peano_tools_dir, "llc"), "-mtriple=aie", "--version"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + if re.search("Xilinx AI Engine", result.stdout.decode("utf-8")) is not None: + config.available_features.add("peano") print("Peano found: " + shutil.which("llc")) else: print("Peano not found, but expected at ", config.peano_tools_dir) @@ -107,51 +130,56 @@ def prepend_path(path): print("Peano not found, but expected at ", config.peano_tools_dir) print("Looking for Chess...") -#test if LM_LICENSE_FILE valid -if(config.enable_chess_tests): +# test if LM_LICENSE_FILE valid +if config.enable_chess_tests: result = None - if(config.vitis_root): + if config.vitis_root: result = shutil.which("xchesscc") if result != None: print("Chess found: " + result) - config.available_features.add('chess') - config.available_features.add('valid_xchess_license') - lm_license_file = os.getenv('LM_LICENSE_FILE') - if(lm_license_file != None): - llvm_config.with_environment('LM_LICENSE_FILE', lm_license_file) - xilinxd_license_file = os.getenv('XILINXD_LICENSE_FILE') - if(xilinxd_license_file != None): - llvm_config.with_environment('XILINXD_LICENSE_FILE', xilinxd_license_file) + config.available_features.add("chess") + config.available_features.add("valid_xchess_license") + lm_license_file = os.getenv("LM_LICENSE_FILE") + if lm_license_file != None: + llvm_config.with_environment("LM_LICENSE_FILE", lm_license_file) + xilinxd_license_file = os.getenv("XILINXD_LICENSE_FILE") + if xilinxd_license_file != None: + llvm_config.with_environment("XILINXD_LICENSE_FILE", xilinxd_license_file) validate_chess = False - if(validate_chess): + if validate_chess: import subprocess - result = subprocess.run(['xchesscc','+v'],stdout=subprocess.PIPE,stderr=subprocess.PIPE) - validLMLicense = (len(result.stderr.decode('utf-8')) == 0) + + result = subprocess.run( + ["xchesscc", "+v"], stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) + validLMLicense = len(result.stderr.decode("utf-8")) == 0 else: validLMLicense = lm_license_file or xilinxd_license_file - if(not lm_license_file and not xilinxd_license_file): - print("WARNING: no valid xchess license that is required by some of the lit tests") + if not lm_license_file and not xilinxd_license_file: + print( + "WARNING: no valid xchess license that is required by some of the lit tests" + ) else: print("Chess not found") tool_dirs = [config.aie_tools_dir, config.peano_tools_dir, config.llvm_tools_dir] tools = [ - 'aie-opt', - 'aie-translate', - 'aiecc.py', - 'ld.lld', - 'llc', - 'llvm-objdump', - 'opt', - 'xchesscc_wrapper', + "aie-opt", + "aie-translate", + "aiecc.py", + "ld.lld", + "llc", + "llvm-objdump", + "opt", + "xchesscc_wrapper", ] llvm_config.add_tool_substitutions(tools, tool_dirs) -if(config.enable_board_tests): +if config.enable_board_tests: lit_config.parallelism_groups["board"] = 1 config.parallelism_group = "board" diff --git a/test/lit.site.cfg.py.in b/test/lit.site.cfg.py.in index e2f89c0615..21c2e87cbf 100644 --- a/test/lit.site.cfg.py.in +++ b/test/lit.site.cfg.py.in @@ -9,6 +9,7 @@ @LIT_SITE_CFG_IN_HEADER@ import sys +import lit.util config.host_triple = "@LLVM_HOST_TRIPLE@" config.target_triple = "@TARGET_TRIPLE@" @@ -43,17 +44,20 @@ config.aie_obj_root = "@AIE_BINARY_DIR@" # test_exec_root: The root path where tests should be run. config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@" +# available features +config.enable_chess_tests = lit.util.pythonize_bool("@ENABLE_CHESS_TESTS@") +config.enable_board_tests = lit.util.pythonize_bool("@ENABLE_BOARD_TESTS@") +config.enable_python_tests = lit.util.pythonize_bool("@ENABLE_PYTHON_TESTS@") +config.python_passes = lit.util.pythonize_bool("@AIE_ENABLE_PYTHON_PASSES@") +config.has_libxaie = lit.util.pythonize_bool("@LibXAIE_FOUND@") + # pass on vitis settings -config.enable_chess_tests = @CONFIG_ENABLE_CHESS_TESTS@ -config.enable_board_tests = @CONFIG_ENABLE_BOARD_TESTS@ config.vitis_root = "@VITIS_ROOT@" config.vitis_aietools_dir = "@VITIS_AIETOOLS_DIR@" config.vitis_sysroot = "@Sysroot@" -config.has_libxaie = @CONFIG_HAS_LIBXAIE@ config.extraAieCcFlags = "@extraAieCcFlags@" config.aieHostTarget = "@AIE_RUNTIME_TEST_TARGET@" config.aieInstallPrefix = "@CMAKE_INSTALL_PREFIX@" -config.enable_python_tests = @ENABLE_PYTHON_TESTS@ # Support substitution of the tools_dir with user parameters. This is # used when we can't determine the tool dir at configuration time. @@ -71,4 +75,4 @@ import lit.llvm lit.llvm.initialize(lit_config, config) # Let the main config do the real work. -lit_config.load_config(config, "@PROJECT_SOURCE_DIR@/test/lit.cfg.py") +lit_config.load_config(config, "@PROJECT_SOURCE_DIR@/lit.cfg.py") diff --git a/test/python/aie_ops.py b/test/python/aie_ops.py index c025611e20..a2b81192f3 100644 --- a/test/python/aie_ops.py +++ b/test/python/aie_ops.py @@ -193,41 +193,3 @@ def objFifoRelease(): with InsertionPoint(bb): acq = Release(ObjectFifoPort.Produce, "of0", 1) EndOp() - - -def testPythonPassDemo(): - # CHECK-LABEL: testPythonPassDemo - print("\nTEST: testPythonPassDemo") - - def print_ops(op): - print(op.name) - - module = """ - module { - %12 = AIE.tile(1, 2) - %buf = AIE.buffer(%12) : memref<256xi32> - %4 = AIE.core(%12) { - %0 = arith.constant 0 : i32 - %1 = arith.constant 0 : index - memref.store %0, %buf[%1] : memref<256xi32> - AIE.end - } - } - """ - - # CHECK: AIE.tile - # CHECK: AIE.buffer - # CHECK: arith.constant - # CHECK: arith.constant - # CHECK: memref.store - # CHECK: AIE.end - # CHECK: AIE.core - # CHECK: builtin.module - with Context() as ctx, Location.unknown(): - aie.dialects.aie.register_dialect(ctx) - aie.dialects.aie.register_python_pass_demo_pass(print_ops) - mlir_module = Module.parse(module) - PassManager.parse("builtin.module(python-pass-demo)").run(mlir_module.operation) - - -testPythonPassDemo() diff --git a/test/python/lit.local.cfg b/test/python/lit.local.cfg index a7c0590854..4801d918f5 100644 --- a/test/python/lit.local.cfg +++ b/test/python/lit.local.cfg @@ -1,9 +1,11 @@ -# # This file is licensed under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # # (c) Copyright 2023 Advanced Micro Devices Inc. -if config.enable_python_tests: - config.suffixes = ['.py'] +if not config.enable_python_tests: + config.unsupported = True + +if config.python_passes: + config.available_features.add("python_passes") \ No newline at end of file diff --git a/test/python/python_passes.py b/test/python/python_passes.py new file mode 100644 index 0000000000..3a03ecf26f --- /dev/null +++ b/test/python/python_passes.py @@ -0,0 +1,62 @@ +# Copyright (C) 2022, Advanced Micro Devices, Inc. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# RUN: %PYTHON %s | FileCheck %s +# REQUIRES: python_passes + + +import aie +from aie.ir import * +from aie.dialects.aie import * +from aie.passmanager import PassManager +from aie._mlir_libs import _aie_python_passes + +from typing import List + + +def constructAndPrintInModule(f): + with Context() as ctx, Location.unknown(): + aie.dialects.aie.register_dialect(ctx) + module = Module.create() + print("\nTEST:", f.__name__) + with InsertionPoint(module.body): + f() + print(module) + + +def testPythonPassDemo(): + # CHECK-LABEL: testPythonPassDemo + print("\nTEST: testPythonPassDemo") + + def print_ops(op): + print(op.name) + + module = """ + module { + %12 = AIE.tile(1, 2) + %buf = AIE.buffer(%12) : memref<256xi32> + %4 = AIE.core(%12) { + %0 = arith.constant 0 : i32 + %1 = arith.constant 0 : index + memref.store %0, %buf[%1] : memref<256xi32> + AIE.end + } + } + """ + + # CHECK: AIE.tile + # CHECK: AIE.buffer + # CHECK: arith.constant + # CHECK: arith.constant + # CHECK: memref.store + # CHECK: AIE.end + # CHECK: AIE.core + # CHECK: builtin.module + with Context() as ctx, Location.unknown(): + aie.dialects.aie.register_dialect(ctx) + _aie_python_passes.register_python_pass_demo_pass(print_ops) + mlir_module = Module.parse(module) + PassManager.parse("builtin.module(python-pass-demo)").run(mlir_module.operation) + + +testPythonPassDemo() diff --git a/tools/aiecc/CMakeLists.txt b/tools/aiecc/CMakeLists.txt index a2a68d2069..67177a6bef 100644 --- a/tools/aiecc/CMakeLists.txt +++ b/tools/aiecc/CMakeLists.txt @@ -1,66 +1,73 @@ +# This file is licensed under the Apache License v2.0 with LLVM Exceptions. See +# https://llvm.org/LICENSE.txt for license information. SPDX-License-Identifier: +# Apache-2.0 WITH LLVM-exception # -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -# (c) Copyright 2021 Xilinx Inc. +# Copyright (C) 2023, Advanced Micro Devices, Inc. set(AIECC_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin) -set(AIECC_FILES - aiecc.py) +set(AIECC_FILES aiecc.py) set(AIECC_TARGETS ${AIECC_FILES}) list(TRANSFORM AIECC_TARGETS PREPEND ${PROJECT_BINARY_DIR}/bin/) if(${AIE_COMPILER} STREQUAL XCHESSCC) -set(CONFIG_COMPILE_WITH_XCHESSCC True) + set(CONFIG_COMPILE_WITH_XCHESSCC True) else() -set(CONFIG_COMPILE_WITH_XCHESSCC False) + set(CONFIG_COMPILE_WITH_XCHESSCC False) endif() if(${AIE_COMPILER} STREQUAL NONE) -set(CONFIG_DISABLE_COMPILE True) + set(CONFIG_DISABLE_COMPILE True) else() -set(CONFIG_DISABLE_COMPILE False) + set(CONFIG_DISABLE_COMPILE False) endif() if(${HOST_COMPILER} STREQUAL NONE) -set(CONFIG_DISABLE_HOST_COMPILE True) + set(CONFIG_DISABLE_HOST_COMPILE True) else() -set(CONFIG_DISABLE_HOST_COMPILE False) + set(CONFIG_DISABLE_HOST_COMPILE False) endif() if(${AIE_LINKER} STREQUAL XCHESSCC) -set(CONFIG_LINK_WITH_XCHESSCC True) + set(CONFIG_LINK_WITH_XCHESSCC True) else() -set(CONFIG_LINK_WITH_XCHESSCC False) + set(CONFIG_LINK_WITH_XCHESSCC False) endif() if(${AIE_LINKER} STREQUAL NONE) -set(CONFIG_DISABLE_LINK True) + set(CONFIG_DISABLE_LINK True) else() -set(CONFIG_DISABLE_LINK False) + set(CONFIG_DISABLE_LINK False) endif() set(CONFIG_PEANO_INSTALL_DIR ${PEANO_INSTALL_DIR}) -configure_file(aiecc/configure.py.in ${PROJECT_BINARY_DIR}/python/aie/compiler/aiecc/configure.py) -install(PROGRAMS ${PROJECT_BINARY_DIR}/python/aie/compiler/aiecc/configure.py DESTINATION ${AIE_PYTHON_INSTALL_DIR}/aie/compiler/aiecc) +configure_file(aiecc/configure.py.in + ${PROJECT_BINARY_DIR}/python/aie/compiler/aiecc/configure.py +) + +install( + PROGRAMS ${PROJECT_BINARY_DIR}/python/aie/compiler/aiecc/configure.py + DESTINATION ${AIE_PYTHON_INSTALL_DIR}/aie/compiler/aiecc +) # Stuff our python into the build area: add_custom_target(aiecc.py ALL DEPENDS ${AIECC_TARGETS}) # This chicanery is necessary to ensure executable permissions. -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/copy_aiecc.cmake" +file( + WRITE "${CMAKE_CURRENT_BINARY_DIR}/copy_aiecc.cmake" "file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/aiecc.py DESTINATION ${PROJECT_BINARY_DIR}/bin FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_WRITE -GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)") - -add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/bin/aiecc.py COMMAND -${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/copy_aiecc.cmake) +GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)" +) +add_custom_command( + OUTPUT ${PROJECT_BINARY_DIR}/bin/aiecc.py + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/copy_aiecc.cmake +) # Install our python stuff too. install(PROGRAMS aiecc.py DESTINATION ${AIECC_INSTALL_PATH}) diff --git a/utils/build-llvm-cross-local.sh b/utils/build-llvm-cross-local.sh index 8977b214f4..353a410569 100755 --- a/utils/build-llvm-cross-local.sh +++ b/utils/build-llvm-cross-local.sh @@ -37,6 +37,7 @@ SYSROOT_DIR=$1 LLVM_DIR=${2:-"llvm"} BUILD_DIR=${3:-"${LLVM_DIR}/build-aarch64"} INSTALL_DIR=${4:-"${LLVM_DIR}/install-aarch64"} +LLVM_ENABLE_RTTI=${LLVM_ENABLE_RTTI:OFF} BUILD_DIR=`realpath ${BUILD_DIR}` INSTALL_DIR=`realpath ${INSTALL_DIR}` @@ -63,7 +64,7 @@ CMAKE_CONFIGS="\ -DLLVM_ENABLE_PROJECTS=mlir \ -DLLVM_TARGETS_TO_BUILD:STRING=ARM;AArch64 \ -DLLVM_ENABLE_ASSERTIONS=ON \ - -DLLVM_ENABLE_RTTI=ON \ + -DLLVM_ENABLE_RTTI=$LLVM_ENABLE_RTTI \ -DLLVM_OPTIMIZED_TABLEGEN=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_BUILD_LLVM_DYLIB=OFF \ diff --git a/utils/build-llvm-local.sh b/utils/build-llvm-local.sh index 79547719bc..55fc784987 100755 --- a/utils/build-llvm-local.sh +++ b/utils/build-llvm-local.sh @@ -24,6 +24,8 @@ INSTALL_DIR=${3:-"install"} mkdir -p $LLVM_DIR/$BUILD_DIR mkdir -p $LLVM_DIR/$INSTALL_DIR +LLVM_ENABLE_RTTI=${LLVM_ENABLE_RTTI:OFF} + # Enter a sub-shell to avoid messing up with current directory in case of error ( cd $LLVM_DIR/$BUILD_DIR @@ -36,7 +38,7 @@ CMAKE_CONFIGS="\ -DLLVM_LINK_LLVM_DYLIB=ON \ -DLLVM_BUILD_EXAMPLES=OFF \ -DLLVM_BUILD_UTILS=ON \ - -DLLVM_ENABLE_RTTI=ON \ + -DLLVM_ENABLE_RTTI=$LLVM_ENABLE_RTTI \ -DLLVM_INSTALL_UTILS=ON \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ -DCMAKE_INSTALL_PREFIX=../$INSTALL_DIR \ diff --git a/utils/build-llvm.sh b/utils/build-llvm.sh index ff41da4b5f..7cb2cf2ea8 100755 --- a/utils/build-llvm.sh +++ b/utils/build-llvm.sh @@ -14,6 +14,7 @@ BUILD_DIR=${1:-"build"} INSTALL_DIR=${2:-"install"} +LLVM_ENABLE_RTTI=${LLVM_ENABLE_RTTI:OFF} mkdir -p llvm/$BUILD_DIR mkdir -p llvm/$INSTALL_DIR @@ -30,7 +31,7 @@ CMAKE_CONFIGS="\ -DLLVM_OPTIMIZED_TABLEGEN=OFF \ -DLLVM_ENABLE_OCAMLDOC=OFF \ -DLLVM_ENABLE_BINDINGS=OFF \ - -DLLVM_ENABLE_RTTI=ON \ + -DLLVM_ENABLE_RTTI=$LLVM_ENABLE_RTTI \ -DLLVM_INSTALL_UTILS=ON \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ -DCMAKE_BUILD_TYPE=Release \ diff --git a/utils/build-mlir-aie-cross.sh b/utils/build-mlir-aie-cross.sh index 6f6f571742..87831fe21e 100755 --- a/utils/build-mlir-aie-cross.sh +++ b/utils/build-mlir-aie-cross.sh @@ -38,6 +38,7 @@ INSTALL_DIR=${4:-"install-aarch64"} BUILD_DIR=`realpath ${BUILD_DIR}` INSTALL_DIR=`realpath ${INSTALL_DIR}` +LLVM_ENABLE_RTTI=${LLVM_ENABLE_RTTI:OFF} mkdir -p $BUILD_DIR mkdir -p $INSTALL_DIR @@ -52,7 +53,7 @@ CMAKE_CONFIGS="\ -DArch=arm64 \ -DLLVM_DIR=${LLVM_BUILD_DIR}/lib/cmake/llvm \ -DMLIR_DIR=${LLVM_BUILD_DIR}/lib/cmake/mlir \ - -DLLVM_ENABLE_RTTI=ON \ + -DLLVM_ENABLE_RTTI=$LLVM_ENABLE_RTTI \ -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON \ diff --git a/utils/build-mlir-aie.sh b/utils/build-mlir-aie.sh index 1d9b9edc8b..cd0feb46be 100755 --- a/utils/build-mlir-aie.sh +++ b/utils/build-mlir-aie.sh @@ -31,6 +31,7 @@ echo "LLVM BUILD DIR: $LLVM_BUILD_DIR" BUILD_DIR=${2:-"build"} INSTALL_DIR=${3:-"install"} +LLVM_ENABLE_RTTI=${LLVM_ENABLE_RTTI:OFF} mkdir -p $BUILD_DIR mkdir -p $INSTALL_DIR @@ -50,7 +51,7 @@ CMAKE_CONFIGS="\ -DCMAKE_C_VISIBILITY_PRESET=hidden \ -DCMAKE_CXX_VISIBILITY_PRESET=hidden \ -DLLVM_ENABLE_ASSERTIONS=ON \ - -DLLVM_ENABLE_RTTI=ON \ + -DLLVM_ENABLE_RTTI=$LLVM_ENABLE_RTTI \ -DAIE_RUNTIME_TARGETS=x86_64;aarch64 \ -DAIE_RUNTIME_TEST_TARGET=aarch64"