Skip to content

Commit

Permalink
add execution_engine.py
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Nov 11, 2023
1 parent af5bfeb commit a9a7e13
Show file tree
Hide file tree
Showing 12 changed files with 226 additions and 142 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ jobs:
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON \
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
-DCMAKE_C_VISIBILITY_PRESET=hidden \
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
Expand Down Expand Up @@ -195,6 +196,10 @@ jobs:
cd build_release
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON \
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
-DCMAKE_C_VISIBILITY_PRESET=hidden \
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
-DAIE_COMPILER=NONE \
-DAIE_LINKER=NONE \
-DHOST_COMPILER=NONE \
Expand Down
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ project(AIE LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)

# Disables generation of "version soname" (i.e. libFoo.so.<version>), which
# causes pure duplication as part of Python wheels.
set(CMAKE_PLATFORM_NO_VERSIONED_SONAME ON)


set(AIE_COMPILER
"XCHESSCC"
CACHE STRING "Backend compiler selection")
Expand Down Expand Up @@ -207,10 +212,9 @@ if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
endif()
endif()

add_subdirectory(cmake/modules)

# Last because each of these has its own CMakeLists.txt which reloads/re-finds LLVM, thus resettings globals.
add_subdirectory(reference_designs)
add_subdirectory(test)
add_subdirectory(tutorials)

add_subdirectory(cmake/modules)
66 changes: 42 additions & 24 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ 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(CoreSources MLIRPythonExtension.Core INTERFACE_SOURCES)

get_target_property(DialectsLinalgPybindSources MLIRPythonExtension.Dialects.Linalg.Pybind INTERFACE_SOURCES)
get_target_property(DialectsQuantPybindSources MLIRPythonExtension.Dialects.Quant.Pybind INTERFACE_SOURCES)
get_target_property(DialectsPDLPybindSources MLIRPythonExtension.Dialects.PDL.Pybind INTERFACE_SOURCES)
get_target_property(DialectsSparseTensorPybindSources MLIRPythonExtension.Dialects.SparseTensor.Pybind INTERFACE_SOURCES)
get_target_property(DialectsTransformPybindSources MLIRPythonExtension.Dialects.Transform.Pybind INTERFACE_SOURCES)

get_target_property(AsyncDialectPassesSources MLIRPythonExtension.AsyncDialectPasses INTERFACE_SOURCES)
get_target_property(ExecutionEngineSources MLIRPythonExtension.ExecutionEngine INTERFACE_SOURCES)
get_target_property(GPUDialectPassesSources MLIRPythonExtension.GPUDialectPasses INTERFACE_SOURCES)
get_target_property(SparseTensorDialectPassesSources MLIRPythonExtension.SparseTensorDialectPasses INTERFACE_SOURCES)
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()

list(SORT _mlir_python_cpp_sources)

declare_mlir_python_extension(AIEPythonExtensions
MODULE_NAME _aie
ROOT_DIR "/"
Expand All @@ -73,18 +73,7 @@ declare_mlir_python_extension(AIEPythonExtensions
${CMAKE_CURRENT_SOURCE_DIR}/AIEMLIRModule.cpp
${CMAKE_CURRENT_SOURCE_DIR}/PythonPass.cpp

${CoreSources}

${DialectsLinalgPybindSources}
${DialectsQuantPybindSources}
${DialectsPDLPybindSources}
${DialectsSparseTensorPybindSources}
${DialectsTransformPybindSources}

${AsyncDialectPassesSources}
${ExecutionEngineSources}
${GPUDialectPassesSources}
${SparseTensorDialectPassesSources}
${_mlir_python_cpp_sources}
${RegisterEverythingSources}

PRIVATE_LINK_LIBS
Expand All @@ -102,13 +91,15 @@ 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"
DECLARED_SOURCES
${mlir_python_sources_deps}
MLIRPythonSources.Core.Python
MLIRPythonSources.ExecutionEngine
AIEPythonExtensions
)

Expand Down Expand Up @@ -157,3 +148,30 @@ foreach(ext ${_other_extensions})
)"
)
endforeach()

set(_runtimes
mlir_async_runtime
mlir_c_runner_utils
mlir_float16_utils
mlir_runner_utils
)

if (TARGET mlir_rocm_runtime)
list(APPEND _runtimes mlir_rocm_runtime)
endif()

foreach(r ${_runtimes})
add_custom_command(
TARGET AIEPythonModules PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:${r}>
${CMAKE_BINARY_DIR}/lib
)
endforeach()

install(IMPORTED_RUNTIME_ARTIFACTS
${_runtimes}
COMPONENT aie-python
LIBRARY DESTINATION "python/aie/_mlir_libs"
)

110 changes: 3 additions & 107 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,108 +1,3 @@
#
# 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(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()

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()

# 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)

if(Vitis_FOUND)
set(DEFAULT_ENABLE_CHESS_TESTS ON)
else()
set(DEFAULT_ENABLE_CHESS_TESTS OFF)
endif()
option(ENABLE_CHESS_TESTS "Enable backend tests using xchesscc" ${DEFAULT_ENABLE_CHESS_TESTS})

if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL aarch64)
set(DEFAULT_ENABLE_BOARD_TESTS ON)
else()
set(DEFAULT_ENABLE_BOARD_TESTS OFF)
endif()
option(ENABLE_BOARD_TESTS "Enable board tests" ${DEFAULT_ENABLE_BOARD_TESTS})

# 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()
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()

# Define the default arguments to use with 'lit', and an option for the user to
# override.
set(LIT_ARGS_DEFAULT "-sv")
if (MSVC_IDE OR XCODE)
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
endif()
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")

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})

if(ENABLE_CHESS_TESTS)
set(CONFIG_ENABLE_CHESS_TESTS 1)
else()
Expand Down Expand Up @@ -134,13 +29,14 @@ set(TEST_DEPENDS
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"
)
)

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")
8 changes: 0 additions & 8 deletions test/lit.local.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,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@/lit.cfg.py")
lit_config.load_config(config, "@PROJECT_SOURCE_DIR@/test/lit.cfg.py")
Loading

0 comments on commit a9a7e13

Please sign in to comment.