diff --git a/CMakeLists.txt b/CMakeLists.txt index 20722ef63..6fdd741fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,6 +170,21 @@ foreach(target ${AIR_RUNTIME_TARGETS}) TEST_EXCLUDE_FROM_MAIN true) endforeach() +if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/runtime_lib/airhost/include + DESTINATION include/.. + COMPONENT runtime_lib-headers + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp") + + if(NOT LLVM_ENABLE_IDE) + add_llvm_install_targets(install-runtime_lib-headers DEPENDS + runtime_lib-headers COMPONENT runtime_lib-headers) + endif() +endif() + add_subdirectory(python) if(NOT AIR_RUNTIME_TEST_TARGET_VAL) message( @@ -181,5 +196,5 @@ else() add_subdirectory(test) endif() add_subdirectory(tools) -add_subdirectory(cmake/modules) add_subdirectory(mlir) +add_subdirectory(cmake/modules) diff --git a/cmake/modules/AIRConfig.cmake.in b/cmake/modules/AIRConfig.cmake.in index 0ea36be22..139193b19 100644 --- a/cmake/modules/AIRConfig.cmake.in +++ b/cmake/modules/AIRConfig.cmake.in @@ -14,4 +14,4 @@ set(AIR_INCLUDE_DIRS "@AIR_CONFIG_INCLUDE_DIRS@") # Provide all our library targets to users. include("@AIR_CONFIG_EXPORTS_FILE@") - +include("@MLIR_CONFIG_INCLUDE_EXPORTS_FILE@") diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index 17c5c380f..676d6d7e8 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -2,9 +2,9 @@ # Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT -# Generate a list of CMake library targets so that other CMake projects can -# link against them. LLVM calls its version of this file LLVMExports.cmake, but -# the usual CMake convention seems to be ${Project}Targets.cmake. +# Generate a list of CMake library targets so that other CMake projects can link +# against them. LLVM calls its version of this file LLVMExports.cmake, but the +# usual CMake convention seems to be ${Project}Targets.cmake. set(AIR_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/air) set(air_cmake_builddir "${CMAKE_BINARY_DIR}/${AIR_INSTALL_PACKAGE_DIR}") @@ -15,15 +15,11 @@ export(EXPORT AIRTargets FILE ${air_cmake_builddir}/AIRTargets.cmake) set(AIR_CONFIG_CMAKE_DIR "${air_cmake_builddir}") set(AIR_CONFIG_BINARY_DIR "${PROJECT_BINARY_DIR}") set(AIR_CONFIG_TOOLS_BINARY_DIR "${PROJECT_BINARY_DIR}/bin") -set(AIR_CONFIG_INCLUDE_DIRS - "${PROJECT_SOURCE_DIR}/include" - "${PROJECT_BINARY_DIR}/include" - ) +set(AIR_CONFIG_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" + "${PROJECT_BINARY_DIR}/include") set(AIR_CONFIG_EXPORTS_FILE "\${AIR_CMAKE_DIR}/AIRTargets.cmake") -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/AIRConfig.cmake.in - ${air_cmake_builddir}/AIRConfig.cmake - @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/AIRConfig.cmake.in + ${air_cmake_builddir}/AIRConfig.cmake @ONLY) set(AIR_CONFIG_CMAKE_DIR) set(AIR_CONFIG_BINARY_DIR) set(AIR_CONFIG_TOOLS_BINARY_DIR) @@ -31,11 +27,13 @@ set(AIR_CONFIG_INCLUDE_DIRS) set(AIR_CONFIG_EXPORTS_FILE) # Generate AIRConfig.cmake for the install tree. -set(AIR_CONFIG_CODE " +set(AIR_CONFIG_CODE + " # Compute the installation prefix from this file location. -get_filename_component(AIR_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") -# Construct the proper number of get_filename_component(... PATH) -# calls to compute the installation prefix. +get_filename_component(AIR_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)" +) +# Construct the proper number of get_filename_component(... PATH) calls to +# compute the installation prefix. string(REGEX REPLACE "/" ";" _count "${AIR_INSTALL_PACKAGE_DIR}") foreach(p ${_count}) set(AIR_CONFIG_CODE "${AIR_CONFIG_CODE} @@ -45,14 +43,11 @@ endforeach(p) set(AIR_CONFIG_CMAKE_DIR "\${AIR_INSTALL_PREFIX}/${AIR_INSTALL_PACKAGE_DIR}") set(AIR_CONFIG_BINARY_DIR "\${AIR_INSTALL_PREFIX}") set(AIR_CONFIG_TOOLS_BINARY_DIR "\${AIR_INSTALL_PREFIX}/bin") -set(AIR_CONFIG_INCLUDE_DIRS - "\${AIR_INSTALL_PREFIX}/include" - ) +set(AIR_CONFIG_INCLUDE_DIRS "\${AIR_INSTALL_PREFIX}/include") set(AIR_CONFIG_EXPORTS_FILE "\${AIR_CMAKE_DIR}/AIRTargets.cmake") -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/AIRConfig.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/AIRConfig.cmake - @ONLY) +set(MLIR_CONFIG_INCLUDE_EXPORTS_FILE "\${AIR_CMAKE_DIR}/MLIRTargets.cmake") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/AIRConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/AIRConfig.cmake @ONLY) set(AIR_CONFIG_CODE) set(AIR_CONFIG_CMAKE_DIR) set(AIR_CONFIG_BINARY_DIR) @@ -61,9 +56,15 @@ set(AIR_CONFIG_INCLUDE_DIRS) set(AIR_CONFIG_EXPORTS_FILE) # export targets for the install directory -install(EXPORT AIRTargets DESTINATION ${AIR_INSTALL_PACKAGE_DIR} - COMPONENT air-cmake-exports) -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/AIRConfig.cmake +install( + EXPORT AIRTargets DESTINATION ${AIR_INSTALL_PACKAGE_DIR} - COMPONENT air-cmake-exports) \ No newline at end of file + COMPONENT air-cmake-exports) +install( + EXPORT MLIRTargets + DESTINATION ${AIR_INSTALL_PACKAGE_DIR} + COMPONENT air-cmake-exports) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/AIRConfig.cmake + DESTINATION ${AIR_INSTALL_PACKAGE_DIR} + COMPONENT air-cmake-exports) diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index 5d8de8ab3..5bd5b4fd0 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -5,3 +5,34 @@ add_subdirectory(lib) add_subdirectory(include) add_subdirectory(test) + +if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + install( + DIRECTORY include/air include/air-c + DESTINATION include + COMPONENT air-headers + FILES_MATCHING + PATTERN "*.def" + PATTERN "*.h" + PATTERN "*.inc" + PATTERN "*.td" + PATTERN "LICENSE.TXT") + + install( + DIRECTORY ${PROJECT_BINARY_DIR}/include/air + DESTINATION include + COMPONENT air-headers + FILES_MATCHING + PATTERN "*.def" + PATTERN "*.h" + PATTERN "*.gen" + PATTERN "*.inc" + PATTERN "*.td" + PATTERN "CMakeFiles" EXCLUDE + PATTERN "config.h" EXCLUDE) + + if(NOT LLVM_ENABLE_IDE) + add_llvm_install_targets(install-air-headers DEPENDS air-headers COMPONENT + air-headers) + endif() +endif() diff --git a/mlir/lib/CMakeLists.txt b/mlir/lib/CMakeLists.txt index 148e667b8..16addbcd0 100644 --- a/mlir/lib/CMakeLists.txt +++ b/mlir/lib/CMakeLists.txt @@ -12,7 +12,8 @@ add_subdirectory(Util) get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS) -add_air_library(AIRInitAll +add_mlir_library( + AIRInitAll InitAll.cpp DEPENDS @@ -29,5 +30,4 @@ add_air_library(AIRInitAll AIRUtil MLIRSupport ${conversion_libs} - ${dialect_libs} - ) \ No newline at end of file + ${dialect_libs}) diff --git a/mlir/lib/Conversion/CMakeLists.txt b/mlir/lib/Conversion/CMakeLists.txt index e6c39703b..9942d2e40 100644 --- a/mlir/lib/Conversion/CMakeLists.txt +++ b/mlir/lib/Conversion/CMakeLists.txt @@ -2,31 +2,31 @@ # Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT -add_air_library(AIRConversionPasses -ConvertToAIRPass.cpp -AIRLoweringPass.cpp -AIRRtToLLVMPass.cpp -AIRToAIEPass.cpp -AIRToAsyncPass.cpp -AIRPipeline.cpp -Passes.cpp +add_mlir_library( + AIRConversionPasses + ConvertToAIRPass.cpp + AIRLoweringPass.cpp + AIRRtToLLVMPass.cpp + AIRToAIEPass.cpp + AIRToAsyncPass.cpp + AIRPipeline.cpp + Passes.cpp -DEPENDS -AIRConversionPassIncGen -AIRDialect -AIRRtDialect + DEPENDS + AIRConversionPassIncGen + AIRDialect + AIRRtDialect -LINK_COMPONENTS -Core + LINK_COMPONENTS + Core -LINK_LIBS -AIRDialect -AIRRtDialect -AIRUtil -AIE -MLIRIR -MLIRLinalgUtils -MLIRLinalgTransforms -MLIRSupport -MLIRTransforms -) \ No newline at end of file + LINK_LIBS + AIRDialect + AIRRtDialect + AIRUtil + AIE + MLIRIR + MLIRLinalgUtils + MLIRLinalgTransforms + MLIRSupport + MLIRTransforms) diff --git a/mlir/lib/Dialect/AIR/IR/CMakeLists.txt b/mlir/lib/Dialect/AIR/IR/CMakeLists.txt index da46a4a1b..1a8203f90 100644 --- a/mlir/lib/Dialect/AIR/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/AIR/IR/CMakeLists.txt @@ -2,7 +2,8 @@ # Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT -add_air_dialect_library(AIRDialect +add_mlir_dialect_library( + AIRDialect AIRDialect.cpp ADDITIONAL_HEADER_DIRS @@ -13,5 +14,4 @@ add_air_dialect_library(AIRDialect MLIRAIROpInterfacesIncGen LINK_LIBS PUBLIC - MLIRIR -) \ No newline at end of file + MLIRIR) diff --git a/mlir/lib/Dialect/AIRRt/IR/CMakeLists.txt b/mlir/lib/Dialect/AIRRt/IR/CMakeLists.txt index 3848cc202..337fe7dda 100644 --- a/mlir/lib/Dialect/AIRRt/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/AIRRt/IR/CMakeLists.txt @@ -2,7 +2,8 @@ # Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT -add_air_dialect_library(AIRRtDialect +add_mlir_dialect_library( + AIRRtDialect AIRRtDialect.cpp AIRRtOps.cpp @@ -13,5 +14,4 @@ add_air_dialect_library(AIRRtDialect MLIRAIRRtOpsIncGen LINK_LIBS PUBLIC - MLIRIR -) \ No newline at end of file + MLIRIR) diff --git a/mlir/lib/Targets/CMakeLists.txt b/mlir/lib/Targets/CMakeLists.txt index 6d07ea03d..9dce1abff 100644 --- a/mlir/lib/Targets/CMakeLists.txt +++ b/mlir/lib/Targets/CMakeLists.txt @@ -2,16 +2,14 @@ # Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT -add_air_library(AIRTargets +add_mlir_library( + AIRTargets AIRTargets.cpp AIRHerdToJSON.cpp - LINK_LIBS - - PUBLIC + LINK_LIBS PUBLIC AIRRtDialect AIRDialect MLIRIR MLIRSupport - MLIRTransforms - ) + MLIRTransforms) diff --git a/mlir/lib/Transform/CMakeLists.txt b/mlir/lib/Transform/CMakeLists.txt index a40986b34..58a1f1a36 100644 --- a/mlir/lib/Transform/CMakeLists.txt +++ b/mlir/lib/Transform/CMakeLists.txt @@ -2,42 +2,42 @@ # Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT -add_air_library(AIRTransformPasses -AffineLoopOptPass.cpp -AIRAutomaticTilingPass.cpp -AIRHerdAssignPass.cpp -AIRHerdPlacementPass.cpp -AIRLinalgCodegen.cpp -AIRLinalgOpStats.cpp -AIRLoopMergingPass.cpp -AIRLoopPermutationPass.cpp -AIRLowerLinalgTensors.cpp -AIRMiscPasses.cpp -AIRRegularizeLoopPass.cpp -AIRTilingUtils.cpp -AIRTransformInterpreter.cpp -AIRDependency.cpp -AIRDependencyScheduleOpt.cpp -AIRDependencyCanonicalize.cpp -AIRDependencyParseGraph.cpp -Passes.cpp -ReturnEliminationPass.cpp +add_mlir_library( + AIRTransformPasses + AffineLoopOptPass.cpp + AIRAutomaticTilingPass.cpp + AIRHerdAssignPass.cpp + AIRHerdPlacementPass.cpp + AIRLinalgCodegen.cpp + AIRLinalgOpStats.cpp + AIRLoopMergingPass.cpp + AIRLoopPermutationPass.cpp + AIRLowerLinalgTensors.cpp + AIRMiscPasses.cpp + AIRRegularizeLoopPass.cpp + AIRTilingUtils.cpp + AIRTransformInterpreter.cpp + AIRDependency.cpp + AIRDependencyScheduleOpt.cpp + AIRDependencyCanonicalize.cpp + AIRDependencyParseGraph.cpp + Passes.cpp + ReturnEliminationPass.cpp -DEPENDS -AIRTransformOpsIncGen -AIRTransformPassIncGen -AIRDialect -AIRRtDialect + DEPENDS + AIRTransformOpsIncGen + AIRTransformPassIncGen + AIRDialect + AIRRtDialect -LINK_COMPONENTS -Core + LINK_COMPONENTS + Core -LINK_LIBS PUBLIC -AIRDialect -AIRRtDialect -AIRUtil -MLIRIR -MLIRLinalgTransforms -MLIRLinalgUtils -MLIRSupport -) \ No newline at end of file + LINK_LIBS PUBLIC + AIRDialect + AIRRtDialect + AIRUtil + MLIRIR + MLIRLinalgTransforms + MLIRLinalgUtils + MLIRSupport) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 20fff7b5d..1353b7236 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -60,6 +60,7 @@ declare_mlir_python_extension(AirPythonExtensions.MLIR SOURCES AIRMLIRModule.cpp AIRRunnerModule.cpp + AIRRunnerModule.h EMBED_CAPI_LINK_LIBS AIRCAPI PRIVATE_LINK_LIBS @@ -73,6 +74,7 @@ declare_mlir_python_extension(AirPythonExtensions.AIRRt SOURCES Module.cpp LibAirHostModule.cpp + LibAirHostModule.h EMBED_CAPI_LINK_LIBS AIRCAPI PRIVATE_LINK_LIBS diff --git a/runtime_lib/airhost/include/CMakeLists.txt b/runtime_lib/airhost/include/CMakeLists.txt index b9bc86c0f..a03a853c7 100644 --- a/runtime_lib/airhost/include/CMakeLists.txt +++ b/runtime_lib/airhost/include/CMakeLists.txt @@ -2,18 +2,33 @@ # Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT -set(INSTALLS air_tensor.h air_host.h air_channel.h air_host_impl.h air_queue.h hsa_defs.h pcie-ernic.h pcie-ernic-dev-mem-allocator.h air_network.h air.hpp utility.hpp) +set(INSTALLS + air.hpp + air_channel.h + air_host.h + air_host_impl.h + air_network.h + air_queue.h + air_tensor.h + hsa_defs.h + pcie-ernic.h + pcie-ernic-defines.h + pcie-ernic-dev-mem-allocator.h + utility.hpp) # Stuff into the build area: add_custom_target(copy-runtime-includes ALL) foreach(file ${INSTALLS}) - add_custom_target(copy-runtime-includes-${file} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${file}) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${file} - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${file} - ${CMAKE_CURRENT_BINARY_DIR}/${file} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}) - add_dependencies(copy-runtime-includes copy-runtime-includes-${file} ) + add_custom_target(copy-runtime-includes-${file} ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${file}) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${file} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${file} + ${CMAKE_CURRENT_BINARY_DIR}/${file} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}) + add_dependencies(copy-runtime-includes copy-runtime-includes-${file}) endforeach() # Install too -install(FILES ${INSTALLS} DESTINATION ${CMAKE_INSTALL_PREFIX}/runtime_lib/airhost/include) +install(FILES ${INSTALLS} + DESTINATION ${CMAKE_INSTALL_PREFIX}/runtime_lib/airhost/include)