From 20e778f814956d9639975625438c92afb65f76bb Mon Sep 17 00:00:00 2001 From: Maksim Levental Date: Mon, 19 Aug 2024 15:52:17 -0500 Subject: [PATCH] Windows support (#677) --- .github/workflows/ci.yml | 69 ++- .gitmodules | 3 + README.md | 63 +-- build_tools/ci/build_test_cpp.sh | 22 +- build_tools/ci/build_xrt.sh | 29 - .../print_ir_aie2xclbin.sh | 1 - .../aie_runtime => cmake}/FindOpenSSL.cmake | 1 - .../aie_runtime => cmake}/commonConfig.cmake | 0 cmake/iree_aie_bootgen.cmake | 101 ++++ cmake/iree_aie_rt.cmake | 282 ++++++++++ cmake/iree_aie_utils.cmake | 42 ++ cmake/iree_aie_xrt.cmake | 198 +++++++ .../plugins/target/AMD-AIE/aie/AIEDialect.cpp | 174 +++++- .../plugins/target/AMD-AIE/aie/AIEDialect.h | 4 +- compiler/plugins/target/AMD-AIE/aie/AIEOps.td | 1 + .../plugins/target/AMD-AIE/air/CMakeLists.txt | 24 +- .../plugins/target/AMD-AIE/air/Passes.cpp | 24 - .../iree-amd-aie/Target/CMakeLists.txt | 12 +- .../AMD-AIE/iree-amd-aie/Target/XCLBinGen.cpp | 183 ++++--- .../iree-amd-aie/Target/tests/CMakeLists.txt | 17 +- ...dd_12_i8_using_2d_dma_op_with_padding.mlir | 0 .../add_21_i8_using_dma_op_with_padding.mlir | 0 ...add_378_i32_using_dma_op_with_padding.mlir | 0 .../Target/tests}/aie_cdo_gen_test.cxx | 0 .../Target/tests/bad_padding.mlir | 8 +- ...8xi32__dispatch_0_matmul_16x1_0.aiecc.mlir | 0 ...32xi8__dispatch_0_matmul_tran_0.aiecc.mlir | 0 ...2_512xi32__dispatch_0_matmul__0.aiecc.mlir | 0 ...64xbf16__dispatch_0_matmul_64_0.aiecc.mlir | 0 ...64xi8__dispatch_0_matmul_64x6_0.aiecc.mlir | 0 ...6xi32__dispatch_0_matmul_8x32_0.aiecc.mlir | 0 .../iree-amd-aie/Target/tests}/regenerate.sh | 0 .../AMDAIECreateLogicalObjectFifoLink.cpp | 14 +- .../iree-amd-aie/Transforms/Passes.cpp | 9 +- .../Transforms/test/lower_to_ukernel.mlir | 16 +- experimental/delegate/CMakeLists.txt | 25 +- experimental/delegate/README.md | 2 +- iree_compiler_plugin.cmake | 14 +- iree_runtime_plugin.cmake | 17 +- runtime/src/CMakeLists.txt | 2 - .../iree-amd-aie/aie_runtime/CMakeLists.txt | 511 +----------------- .../aie_runtime/NoOpXclBinSignature.cxx | 20 - .../aie_runtime/iree_aie_configure.cc | 5 +- .../aie_runtime/iree_aie_runtime.cc | 28 +- .../aie_runtime/test/CMakeLists.txt | 10 +- .../aie_runtime/test/cdo/CMakeLists.txt | 29 - ...rol_packets.cc => test_control_packets.cc} | 22 +- ...tch_mode.cc => test_packet_switch_mode.cc} | 19 +- .../aie_runtime/test/test_transaction.cc | 19 +- .../iree-amd-aie/aie_runtime/test/utest.cc | 12 +- .../iree-amd-aie/driver/xrt/CMakeLists.txt | 14 +- third_party/openssl | 1 + 52 files changed, 1132 insertions(+), 915 deletions(-) delete mode 100755 build_tools/ci/build_xrt.sh rename {runtime/src/iree-amd-aie/aie_runtime => cmake}/FindOpenSSL.cmake (99%) rename {runtime/src/iree-amd-aie/aie_runtime => cmake}/commonConfig.cmake (100%) create mode 100644 cmake/iree_aie_bootgen.cmake create mode 100644 cmake/iree_aie_rt.cmake create mode 100644 cmake/iree_aie_utils.cmake create mode 100644 cmake/iree_aie_xrt.cmake delete mode 100644 compiler/plugins/target/AMD-AIE/air/Passes.cpp rename {runtime/src/iree-amd-aie/aie_runtime/test/cdo => compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests}/add_12_i8_using_2d_dma_op_with_padding.mlir (100%) rename {runtime/src/iree-amd-aie/aie_runtime/test/cdo => compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests}/add_21_i8_using_dma_op_with_padding.mlir (100%) rename {runtime/src/iree-amd-aie/aie_runtime/test/cdo => compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests}/add_378_i32_using_dma_op_with_padding.mlir (100%) rename {runtime/src/iree-amd-aie/aie_runtime/test/cdo => compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests}/aie_cdo_gen_test.cxx (100%) rename {runtime/src/iree-amd-aie/aie_runtime/test/cdo => compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests}/matmul_16x16_8xi32__dispatch_0_matmul_16x1_0.aiecc.mlir (100%) rename {runtime/src/iree-amd-aie/aie_runtime/test/cdo => compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests}/matmul_16x64_32xi8__dispatch_0_matmul_tran_0.aiecc.mlir (100%) rename {runtime/src/iree-amd-aie/aie_runtime/test/cdo => compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests}/matmul_512x512_512xi32__dispatch_0_matmul__0.aiecc.mlir (100%) rename {runtime/src/iree-amd-aie/aie_runtime/test/cdo => compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests}/matmul_64x64_64xbf16__dispatch_0_matmul_64_0.aiecc.mlir (100%) rename {runtime/src/iree-amd-aie/aie_runtime/test/cdo => compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests}/matmul_64x64_64xi8__dispatch_0_matmul_64x6_0.aiecc.mlir (100%) rename {runtime/src/iree-amd-aie/aie_runtime/test/cdo => compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests}/matmul_8x32_16xi32__dispatch_0_matmul_8x32_0.aiecc.mlir (100%) rename {runtime/src/iree-amd-aie/aie_runtime/test/cdo => compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests}/regenerate.sh (100%) delete mode 100644 runtime/src/iree-amd-aie/aie_runtime/NoOpXclBinSignature.cxx delete mode 100644 runtime/src/iree-amd-aie/aie_runtime/test/cdo/CMakeLists.txt rename runtime/src/iree-amd-aie/aie_runtime/test/{test_1114_aie_stream_switch_packet_switch_control_packets.cc => test_control_packets.cc} (94%) mode change 100755 => 100644 rename runtime/src/iree-amd-aie/aie_runtime/test/{test_0335_aie_dma_tile_dma_packet_switch_mode.cc => test_packet_switch_mode.cc} (95%) create mode 160000 third_party/openssl diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 610453228..51f27fb60 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,46 +13,76 @@ concurrency: # A PR number if a pull request and otherwise the commit hash. This cancels # queued and in-progress runs for the same PR (presubmit) or commit # (postsubmit). - group: ci-build-test-cpp-linux-${{ github.event.number || github.sha }} + group: ci-build-test-${{ github.event.number || github.sha }} cancel-in-progress: true +defaults: + run: + # force bash for windows + shell: bash + jobs: - build_test_linux: - name: Build and Test (Linux, ASSERTIONS) - runs-on: nod-ai-shared-cpubuilder-manylinux-x86_64 + build_and_ctest: + name: Build and Test (${{ matrix.os }}, ASSERTIONS) + runs-on: ${{ matrix.runs-on }} strategy: - fail-fast: true + fail-fast: false + matrix: + include: + - os: linux + runs-on: nod-ai-shared-cpubuilder-manylinux-x86_64 + - os: windows + runs-on: windows-2019 env: CACHE_DIR: ${{ github.workspace }}/.container-cache steps: - name: Configure local git mirrors + if: ${{ matrix.runs-on == 'nod-ai-shared-cpubuilder-manylinux-x86_64' }} run: | /gitmirror/scripts/trigger_update_mirrors.sh /gitmirror/scripts/git_config.sh + - name: "Checking out repository" uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive - name: Install static libs + if: ${{ matrix.runs-on == 'nod-ai-shared-cpubuilder-manylinux-x86_64' }} run: | dnf install -y almalinux-release-devel - yum remove -y openssl-devel zlib-devel boost boost-all || true - yum install -y openssl-static zlib-static + yum remove -y openssl-devel zlib-devel || true yum install -y protobuf-devel protobuf-compiler - yum install -y boost-static + + - name: Setup Cpp + uses: aminya/setup-cpp@v1 + if: ${{ matrix.os == 'windows' }} + with: + compiler: msvc + vcvarsall: true + cmake: true + ninja: true + ccache: true + + - uses: actions/setup-python@v4 + if: ${{ matrix.os == 'windows' }} + with: + python-version: '3.11' - name: Sync source deps run: | python ./sync_deps.py + - name: Python deps + run: | + pip install "numpy<2" pyyaml "pybind11[global]==2.10.3" nanobind + - name: Enable cache uses: actions/cache/restore@v3 with: path: ${{ env.CACHE_DIR }} - key: linux-build-test-cpp-asserts-manylinux-v2-${{ github.sha }} - restore-keys: | - linux-build-test-cpp- + key: "${{ matrix.os }}-build-test-cpp-asserts-v1-${{ github.sha }}" + restore-keys: "${{ matrix.os }}-build-test-cpp-" - name: Build packages run: | @@ -62,20 +92,16 @@ jobs: - name: Create artifacts if: ${{ !cancelled() }} run: | - # TODO: https://github.com/openxla/iree/issues/16230 - # We should not be packaging clang and llvm-link in the default dist - # installs. rm -f iree-install/bin/clang* rm -f iree-install/bin/llvm-link* - tar cf iree-dist.tar -C iree-install . -C ../iree-build tools/testing/e2e/iree-e2e-matmul-test + tar cf iree-${{ matrix.os }}-dist.tar -C iree-install . -C ../iree-build tools/testing/e2e/iree-e2e-matmul-test - name: Upload artifacts uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: - name: linux_x86_64_release_packages - path: | - iree-dist.tar + name: "${{ matrix.os }}_x86_64_release_packages" + path: "iree-${{ matrix.os }}-dist.tar" if-no-files-found: warn - name: Save cache @@ -83,11 +109,11 @@ jobs: if: ${{ !cancelled() }} with: path: ${{ env.CACHE_DIR }} - key: linux-build-test-cpp-asserts-manylinux-v2-${{ github.sha }} + key: "${{ matrix.os }}-build-test-cpp-asserts-v1-${{ github.sha }}" test_linux: runs-on: amd7940hs - needs: build_test_linux + needs: build_and_ctest strategy: fail-fast: true env: @@ -106,7 +132,7 @@ jobs: - name: Extract artifact run: | mkdir iree-install - tar -xf iree-dist.tar -C iree-install + tar -xf iree-linux-dist.tar -C iree-install bash build_tools/download_peano.sh - name: Create venv and install dependencies @@ -115,7 +141,6 @@ jobs: source .venv/bin/activate pip install -r tests/matmul/requirements.txt - - name: E2E correctness matmul test run: | source .venv/bin/activate diff --git a/.gitmodules b/.gitmodules index a4b6a7412..11197c42f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -14,3 +14,6 @@ path = third_party/bootgen url = https://github.com/Xilinx/bootgen.git shallow = true +[submodule "third_party/openssl"] + path = third_party/openssl + url = https://github.com/viaduck/openssl-cmake.git diff --git a/README.md b/README.md index ed77e1531..85a170671 100644 --- a/README.md +++ b/README.md @@ -21,15 +21,6 @@ Preparing repository: git submodule update --init ``` -Building the runtime driver (see below) for the amd-aie backend/plugin for IREE (this repo) requires Boost: - -``` -# Debian/Ubuntu -sudo apt-get install libboost-all-dev -# Alma/CentOS/RHEL -yum install -y boost-static -``` - ## Building (along with IREE) ### Just show me the CMake @@ -39,7 +30,7 @@ cmake -B $WHERE_YOU_WOULD_LIKE_TO_BUILD -S $IREE_REPO_SRC_DIR \ -DIREE_CMAKE_PLUGIN_PATHS=$IREE_AMD_AIE_REPO_SRC_DIR -DIREE_BUILD_PYTHON_BINDINGS=ON \ -DIREE_INPUT_STABLEHLO=OFF -DIREE_INPUT_TORCH=OFF -DIREE_INPUT_TOSA=OFF \ -DIREE_HAL_DRIVER_DEFAULTS=OFF -DIREE_TARGET_BACKEND_DEFAULTS=OFF -DIREE_TARGET_BACKEND_LLVM_CPU=ON \ --DIREE_BUILD_TESTS=ON -DIREE_EXTERNAL_HAL_DRIVERS=xrt -DXRT_DIR=$XRT_INSTALL_DIR/share/cmake/XRT \ +-DIREE_BUILD_TESTS=ON -DIREE_EXTERNAL_HAL_DRIVERS=xrt \ -DCMAKE_INSTALL_PREFIX=$WHERE_YOU_WOULD_LIKE_TO_INSTALL ``` @@ -97,54 +88,30 @@ ctest -R amd-aie ## Runtime driver setup -To enable the runtime driver. You need to make sure XRT cmake package is discoverable by cmake. -One option is to add it to your PATH. -Note that with a standard setup, XRT is installed in `/opt/xilinx/xrt`. - -Now from within the iree-amd-aie root directory. Then, +To enable the runtime driver, you need to also enable the XRT HAL: ``` cd ../iree-build cmake . -DIREE_CMAKE_PLUGIN_PATHS=../iree-amd-aie \ - -DIREE_EXTERNAL_HAL_DRIVERS=xrt \ - -DXRT_DIR=/opt/xilinx/xrt/share/cmake/XRT + -DIREE_EXTERNAL_HAL_DRIVERS=xrt ninja ``` -### Building XRT - -For the CI, we prefer to build against the pinned XRT. Note that XRT has -submodules so recursively submodule initialization is required. - -You can build using the same script the CI does: - -``` -./build_tools/ci/build_xrt.sh ../xrt-build ../xrt-install -``` - -Then instead of using the default system install location for `-DXRT_DIR=` -above, prepend the `../xrt-install/` prefix for the one you just built. - ### Ubuntu Dependencies -Presently XRT is a monolithic build that unconditionally requires a number of -packages. Here are the requirements for various operating systems: +XRT requires a number of packages. Here are the requirements for various operating systems: ``` apt install \ - libboost-dev libboost-filesystem-dev libboost-program-options-dev \ - libboost-system-dev \ - pkg-config libdrm-dev opencl-headers ocl-icd-opencl-dev ocl-icd-dev \ - libssl-dev \ - rapidjson-dev \ - protobuf-compiler \ - libprotobuf-dev \ - python3-pybind11 \ - uuid-dev \ libcurl4-openssl-dev \ + libdrm-dev \ + libelf-dev \ + libprotobuf-dev \ libudev-dev \ - systemtap-sdt-dev \ - libelf-dev + pkg-config \ + protobuf-compiler \ + python3-pybind11 \ + systemtap-sdt-dev ``` ### RH Based Deps @@ -154,21 +121,13 @@ base manylinux (AlmaLinux 8) image. ``` yum install \ - boost-devel \ - boost-filesystem \ - boost-program-options \ - boost-static \ libcurl-devel \ libdrm-devel \ libudev-devel \ libuuid-devel \ ncurses-devel \ - ocl-icd-devel \ - openssl-devel \ pkgconfig \ protobuf-compiler \ protobuf-devel \ - rapidjson-devel \ systemtap-sdt-devel - ``` diff --git a/build_tools/ci/build_test_cpp.sh b/build_tools/ci/build_test_cpp.sh index 753bcd3cf..1cd4a38d7 100644 --- a/build_tools/ci/build_test_cpp.sh +++ b/build_tools/ci/build_test_cpp.sh @@ -24,9 +24,13 @@ mkdir -p "${cache_dir}/pip" python="$(which python)" echo "Using python: $python" -export CMAKE_TOOLCHAIN_FILE="$this_dir/linux_default_toolchain.cmake" -export CC=clang -export CXX=clang++ +# https://stackoverflow.com/a/8597411/9045206 +# note: on windows (git-bash) result is "msys" +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + export CMAKE_TOOLCHAIN_FILE="$this_dir/linux_default_toolchain.cmake" + export CC=clang + export CXX=clang++ +fi export CCACHE_DIR="${cache_dir}/ccache" export CCACHE_MAXSIZE="700M" export CMAKE_C_COMPILER_LAUNCHER=ccache @@ -35,11 +39,6 @@ export CMAKE_CXX_COMPILER_LAUNCHER=ccache # Clear ccache stats. ccache -z -# Build XRT. -XRT_BUILD_DIR=$repo_root/xrt-build -XRT_INSTALL_DIR=$repo_root/xrt-install -$this_dir/build_xrt.sh $XRT_BUILD_DIR $XRT_INSTALL_DIR - echo "Building IREE" echo "=============" echo '{ @@ -62,7 +61,7 @@ cmake -S "$iree_dir" -B "$build_dir" \ -DCMAKE_INSTALL_LIBDIR=lib \ -DIREE_ENABLE_ASSERTIONS=ON \ -DIREE_BUILD_SAMPLES=OFF \ - -DIREE_BUILD_PYTHON_BINDINGS=OFF \ + -DIREE_BUILD_PYTHON_BINDINGS=ON \ -DIREE_BUILD_BINDINGS_TFLITE=OFF \ -DIREE_HAL_DRIVER_DEFAULTS=OFF \ -DIREE_HAL_DRIVER_LOCAL_SYNC=ON \ @@ -71,9 +70,10 @@ cmake -S "$iree_dir" -B "$build_dir" \ -DIREE_TARGET_BACKEND_LLVM_CPU=ON \ -DIREE_INPUT_TOSA=OFF \ -DIREE_INPUT_STABLEHLO=OFF \ + -DIREE_INPUT_TORCH=OFF \ + -DCMAKE_OBJECT_PATH_MAX=4096 \ -DIREE_CMAKE_PLUGIN_PATHS=../iree-amd-aie \ - -DIREE_EXTERNAL_HAL_DRIVERS=xrt \ - -DXRT_DIR=$XRT_INSTALL_DIR/opt/xilinx/xrt/share/cmake/XRT + -DIREE_EXTERNAL_HAL_DRIVERS=xrt echo "Building all" echo "------------" diff --git a/build_tools/ci/build_xrt.sh b/build_tools/ci/build_xrt.sh deleted file mode 100755 index f45b2e56e..000000000 --- a/build_tools/ci/build_xrt.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -set -eu -o errtrace - -repo_dir="$(cd $(dirname $0)/../.. && pwd)" -src_dir="${repo_dir}/third_party/XRT" -build_dir="$1" -install_dir="$2" - -echo "Building XRT" -echo "============" -echo "Source directory: $src_dir" -echo "Build directory: $build_dir" -echo "Install directory: $install_dir" -mkdir -p "${build_dir}" -mkdir -p "${install_dir}" - -# Note that all of the install prefixes and DESTDIR are required. -# XRT is hard-coded to install to some absolute locations regardless. -cmake -GNinja \ - "-S${src_dir}" \ - "-B${build_dir}" \ - -DDISABLE_ABI_CHECK=ON \ - -DCMAKE_INSTALL_PREFIX=/opt/xilinx \ - -DXRT_INSTALL_PREFIX=/opt/xilinx \ - -DCMAKE_BUILD_TYPE=Release - -cmake --build "$build_dir" -- -k 0 -DESTDIR=$install_dir cmake --build "$build_dir" --target install diff --git a/build_tools/ci/print_ir_aie2xclbin/print_ir_aie2xclbin.sh b/build_tools/ci/print_ir_aie2xclbin/print_ir_aie2xclbin.sh index 0030e575d..a0772efe4 100755 --- a/build_tools/ci/print_ir_aie2xclbin/print_ir_aie2xclbin.sh +++ b/build_tools/ci/print_ir_aie2xclbin/print_ir_aie2xclbin.sh @@ -174,7 +174,6 @@ ${FILECHECK_EXE} --input-file ${STDERR_FULLPATH} ${0} --check-prefix=CHECK-STDER # CHECK-STDERRTIME-DAG: Total ${FILECHECK_EXE} --input-file ${STDERR_FULLPATH} ${0} --check-prefix=CHECK-STDERRTIME -# CHECK-STDOUT-DAG: Bootgen # CHECK-STDOUT-DAG: MEM_TOPOLOGY ${FILECHECK_EXE} --input-file ${STDOUT_FULLPATH} ${0} --check-prefix=CHECK-STDOUT diff --git a/runtime/src/iree-amd-aie/aie_runtime/FindOpenSSL.cmake b/cmake/FindOpenSSL.cmake similarity index 99% rename from runtime/src/iree-amd-aie/aie_runtime/FindOpenSSL.cmake rename to cmake/FindOpenSSL.cmake index 43b6d31d3..494667488 100644 --- a/runtime/src/iree-amd-aie/aie_runtime/FindOpenSSL.cmake +++ b/cmake/FindOpenSSL.cmake @@ -356,7 +356,6 @@ if(WIN32 AND NOT CYGWIN) endif () message(STATUS "searching for MSVC libs in ${_OPENSSL_PATH_SUFFIXES_DEBUG}") message(STATUS "searching for MSVC libs in ${_OPENSSL_PATH_SUFFIXES_RELEASE}") - message(FATAL_ERROR) find_library(LIB_EAY_DEBUG NAMES diff --git a/runtime/src/iree-amd-aie/aie_runtime/commonConfig.cmake b/cmake/commonConfig.cmake similarity index 100% rename from runtime/src/iree-amd-aie/aie_runtime/commonConfig.cmake rename to cmake/commonConfig.cmake diff --git a/cmake/iree_aie_bootgen.cmake b/cmake/iree_aie_bootgen.cmake new file mode 100644 index 000000000..526ed9a6f --- /dev/null +++ b/cmake/iree_aie_bootgen.cmake @@ -0,0 +1,101 @@ +# Copyright 2024 The IREE Authors +# +# 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 + +include(${CMAKE_CURRENT_LIST_DIR}/iree_aie_utils.cmake) + +if(TARGET iree-aie-bootgen) + return() +endif() + +set(_BOOTGEN_SOURCE_DIR ${IREE_AMD_AIE_SOURCE_DIR}/third_party/bootgen) + +# malloc.h is deprecated and should not be used +# https://stackoverflow.com/a/56463133 If you want to use malloc, then include stdlib.h +replace_string_in_file(${_BOOTGEN_SOURCE_DIR}/cdo-npi.c "#include " "#include ") +replace_string_in_file(${_BOOTGEN_SOURCE_DIR}/cdo-alloc.c "#include " "#include ") +replace_string_in_file("${_BOOTGEN_SOURCE_DIR}/main.cpp" + "#include \"openssl/ms/applink.c\"" "//#include \"openssl/ms/applink.c\"") +replace_string_in_file("${_BOOTGEN_SOURCE_DIR}/main.cpp" + "int main" "int iree_aie_bootgen_main") +replace_string_in_file("${_BOOTGEN_SOURCE_DIR}/main.cpp" + "DisplayBanner();" "//DisplayBanner();") + +file(GLOB _bootgen_sources "${_BOOTGEN_SOURCE_DIR}/*.c" "${_BOOTGEN_SOURCE_DIR}/*.cpp") +add_library(iree-aie-bootgen STATIC ${_bootgen_sources}) + +if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + target_compile_definitions(iree-aie-bootgen PUBLIC YY_NO_UNISTD_H) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") + set(_bootgen_c_warning_ignores + -Wno-cast-qual + -Wno-covered-switch-default + -Wno-date-time + -Wno-deprecated-declarations + -Wno-deprecated-register + -Wno-dynamic-class-memaccess + -Wno-format + -Wno-implicit-fallthrough + -Wno-incompatible-function-pointer-types + -Wno-incompatible-pointer-types-discards-qualifiers + -Wno-misleading-indentation + -Wno-pointer-bool-conversion + -Wno-sign-compare + -Wno-tautological-overlap-compare + -Wno-unused) + set(_bootgen_cxx_warning_ignores + -Wno-deprecated-copy -Wno-non-virtual-dtor -Wno-overloaded-virtual + -Wno-register -Wno-reorder -Wno-suggest-override) +endif() + +target_compile_options(iree-aie-bootgen PRIVATE + $<$:${_bootgen_c_warning_ignores}> + $<$:${_bootgen_c_warning_ignores};${_bootgen_cxx_warning_ignores}>) + +set(OPENSSL_USE_STATIC_LIBS TRUE CACHE BOOL "" FORCE) +set(_openssl_libs "") +if(WIN32) + if(NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8) + message( + FATAL_ERROR + "Building on 32bit platforms/toolchains is not supported; if you are seeing this on windows, " + "it's possible you have opened the win32 developer shell rather than the x64 developer shell." + ) + endif() + # We use our own, slightly modified, FindOpenSSL because of issues in CMake's + # distribution of the same for versions prior to 3.29. + # https://gitlab.kitware.com/cmake/cmake/-/issues/25702 + find_package(OpenSSL) + if(NOT DEFINED OPENSSL_FOUND OR NOT ${OPENSSL_FOUND}) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + find_package(OpenSSL) + if(NOT DEFINED USE_IREE_AMD_AIE_FIND_OPENSSL + OR NOT ${USE_IREE_AMD_AIE_FIND_OPENSSL}) + message(FATAL_ERROR "Didn't pickup/use adjacent FindOpenSSL.cmake") + endif() + if(NOT DEFINED OPENSSL_FOUND OR NOT ${OPENSSL_FOUND}) + message(FATAL_ERROR "OpenSSL not found") + endif() + endif() + message(STATUS "OpenSSL include directories:" ${OPENSSL_INCLUDE_DIR}) + list(APPEND _openssl_libs OpenSSL::SSL OpenSSL::Crypto) +else() + set(BUILD_OPENSSL ON) + # openssl-cmake doesn't have 1.1.1b but this one works + set(OPENSSL_BUILD_VERSION 1.1.1k) + # no zlib + set(OPENSSL_MODULES no-comp) + set(OPENSSL_ENABLE_TESTS OFF) + add_subdirectory(${IREE_AMD_AIE_SOURCE_DIR}/third_party/openssl openssl) + list(APPEND _openssl_libs $ $) +endif() +target_include_directories(iree-aie-bootgen PRIVATE ${_BOOTGEN_SOURCE_DIR} ${OPENSSL_INCLUDE_DIR}) +target_link_libraries(iree-aie-bootgen PRIVATE ${_openssl_libs}) + +iree_install_targets( + TARGETS iree-aie-bootgen + COMPONENT IREEBundledLibraries + EXPORT_SET Compiler +) diff --git a/cmake/iree_aie_rt.cmake b/cmake/iree_aie_rt.cmake new file mode 100644 index 000000000..96b9791d2 --- /dev/null +++ b/cmake/iree_aie_rt.cmake @@ -0,0 +1,282 @@ +# Copyright 2024 The IREE Authors +# +# 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 + +include(${CMAKE_CURRENT_LIST_DIR}/iree_aie_utils.cmake) + +if(TARGET cdo_driver OR TARGET cdo_driver) + return() +endif() + +# ############################################################################## +# cdo-drver +# ############################################################################## + +set(_BOOTGEN_SOURCE_DIR ${IREE_AMD_AIE_SOURCE_DIR}/third_party/bootgen) +replace_string_in_file(${_BOOTGEN_SOURCE_DIR}/cdo-driver/cdo_driver.c "\"(Write64)" "\"cdo-driver: (Write64)") +replace_string_in_file(${_BOOTGEN_SOURCE_DIR}/cdo-driver/cdo_driver.c "\"(MaskWrite64)" "\"cdo-driver: (MaskWrite64)") +replace_string_in_file(${_BOOTGEN_SOURCE_DIR}/cdo-driver/cdo_driver.c "\"(NOP Command)" "\"cdo-driver: (NOP Command)") +replace_string_in_file(${_BOOTGEN_SOURCE_DIR}/cdo-driver/cdo_driver.c "\"(BlockWrite-DMAWriteCmd)" "\"cdo-driver: (BlockWrite-DMAWriteCmd)") +replace_string_in_file(${_BOOTGEN_SOURCE_DIR}/cdo-driver/cdo_driver.c "Data@ 0x%\" PRIxPTR \"" "Data") +replace_string_in_file(${_BOOTGEN_SOURCE_DIR}/cdo-driver/cdo_driver.c "(uintptr_t)(pData + i)," "") +replace_string_in_file(${_BOOTGEN_SOURCE_DIR}/cdo-driver/cdo_driver.c "\" Address:" "\"cdo-driver: Address:") +replace_string_in_file(${_BOOTGEN_SOURCE_DIR}/cdo-driver/cdo_driver.c "\"(BlockSet-DMAWriteCmd)" "\"cdo-driver: (BlockSet-DMAWriteCmd)") +replace_string_in_file(${_BOOTGEN_SOURCE_DIR}/cdo-driver/cdo_driver.c "\"(MaskPoll64)" "\"cdo-driver: (MaskPoll64)") + +add_library(cdo_driver STATIC ${_BOOTGEN_SOURCE_DIR}/cdo-driver/cdo_driver.c) +target_include_directories(cdo_driver PUBLIC ${_BOOTGEN_SOURCE_DIR}/cdo-driver) +set_target_properties(cdo_driver PROPERTIES LINKER_LANGUAGE C) +iree_install_targets( + TARGETS cdo_driver + COMPONENT IREEBundledLibraries + EXPORT_SET Compiler +) + +# ############################################################################## +# aie-rt +# ############################################################################## + +set(_aie_rt_source_dir ${IREE_AMD_AIE_SOURCE_DIR}/third_party/aie-rt) +set(_AIE_RT_BINARY_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/iree_aie_runtime/include) + +include(${_aie_rt_source_dir}/fal/cmake/collect.cmake) +set(XAIENGINE_BUILD_SHARED OFF CACHE BOOL "" FORCE) +add_subdirectory(${_aie_rt_source_dir}/driver/src iree_aie_runtime) + +# https://github.com/Xilinx/aie-rt/issues/4 +set(_incorrect_port_map " +static const XAie_StrmSwPortMap AieMlMemTileStrmSwSlavePortMap[] = +{ + { + /* PhyPort 0 */ + .PortType = DMA, + .PortNum = 0, + }, + { + /* PhyPort 1 */ + .PortType = DMA, + .PortNum = 1, + }, + { + /* PhyPort 2 */ + .PortType = DMA, + .PortNum = 2, + }, + { + /* PhyPort 3 */ + .PortType = DMA, + .PortNum = 3, + }, + { + /* PhyPort 4 */ + .PortType = DMA, + .PortNum = 4, + }, + { + /* PhyPort 5 */ + .PortType = DMA, + .PortNum = 5, + }, + { + /* PhyPort 6 */ + .PortType = CTRL, + .PortNum = 0, + }, + { + /* PhyPort 7 */ + .PortType = SOUTH, + .PortNum = 0, + }, + { + /* PhyPort 8 */ + .PortType = SOUTH, + .PortNum = 1, + }, + { + /* PhyPort 9 */ + .PortType = SOUTH, + .PortNum = 2, + }, + { + /* PhyPort 10 */ + .PortType = SOUTH, + .PortNum = 3, + }, + { + /* PhyPort 11 */ + .PortType = NORTH, + .PortNum = 0, + }, + { + /* PhyPort 12 */ + .PortType = NORTH, + .PortNum = 1, + }, + { + /* PhyPort 13 */ + .PortType = NORTH, + .PortNum = 2, + }, + { + /* PhyPort 14 */ + .PortType = NORTH, + .PortNum = 3, + }, + { + /* PhyPort 15 */ + .PortType = NORTH, + .PortNum = 4, + }, + { + /* PhyPort 16 */ + .PortType = NORTH, + .PortNum = 5, + }, + { + /* PhyPort 17 */ + .PortType = TRACE, + .PortNum = 0, + }, +}; +") + +set(_correct_port_map " +static const XAie_StrmSwPortMap AieMlMemTileStrmSwSlavePortMap[] = { + { + /* PhyPort 0 */ + .PortType = DMA, + .PortNum = 0, + }, + { + /* PhyPort 1 */ + .PortType = DMA, + .PortNum = 1, + }, + { + /* PhyPort 2 */ + .PortType = DMA, + .PortNum = 2, + }, + { + /* PhyPort 3 */ + .PortType = DMA, + .PortNum = 3, + }, + { + /* PhyPort 4 */ + .PortType = DMA, + .PortNum = 4, + }, + { + /* PhyPort 5 */ + .PortType = DMA, + .PortNum = 5, + }, + { + /* PhyPort 6 */ + .PortType = CTRL, + .PortNum = 0, + }, + { + /* PhyPort 7 */ + .PortType = SOUTH, + .PortNum = 0, + }, + { + /* PhyPort 8 */ + .PortType = SOUTH, + .PortNum = 1, + }, + { + /* PhyPort 9 */ + .PortType = SOUTH, + .PortNum = 2, + }, + { + /* PhyPort 10 */ + .PortType = SOUTH, + .PortNum = 3, + }, + { + /* PhyPort 11 */ + .PortType = SOUTH, + .PortNum = 4, + }, + { + /* PhyPort 12 */ + .PortType = SOUTH, + .PortNum = 5, + }, + { + /* PhyPort 13 */ + .PortType = NORTH, + .PortNum = 0, + }, + { + /* PhyPort 14 */ + .PortType = NORTH, + .PortNum = 1, + }, + { + /* PhyPort 15 */ + .PortType = NORTH, + .PortNum = 2, + }, + { + /* PhyPort 16 */ + .PortType = NORTH, + .PortNum = 3, + }, + { + /* PhyPort 17 */ + .PortType = TRACE, + .PortNum = 0, + }, +}; +") + +replace_string_in_file( + ${_aie_rt_source_dir}/driver/src/global/xaie2ipugbl_reginit.c + "${_incorrect_port_map}" "${_correct_port_map}") + +get_target_property(_aie_runtime_compile_options xaiengine COMPILE_OPTIONS) +list(REMOVE_ITEM _aie_runtime_compile_options -D__AIEBAREMETAL__) + +set(XAIE_DEBUG "" CACHE STRING "") +if(XAIE_DEBUG STREQUAL "ON") + set(XAIE_DEBUG "__AIEDEBUG__") +endif() + +set_target_properties( + xaiengine + PROPERTIES COMPILE_OPTIONS "${_aie_runtime_compile_options}") +target_compile_definitions(xaiengine PRIVATE ${XAIE_DEBUG} __AIECDO__ XAIE_FEATURE_ALL) +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") + set(xaiengine_c_warning_ignores + -Wno-unused-but-set-variable + -Wno-incompatible-pointer-types) + target_compile_options(xaiengine PRIVATE ${xaiengine_c_warning_ignores}) +endif() +# For +target_include_directories(xaiengine PRIVATE SYSTEM ${_BOOTGEN_SOURCE_DIR}) +target_link_libraries(xaiengine PRIVATE cdo_driver) + +set(_cdo_externs "\ +#include \n +extern void cdo_Write32(uint64_t Addr, uint32_t Data); \ +extern void cdo_MaskWrite32(uint64_t Addr, uint32_t Mask, uint32_t Data); \ +extern void cdo_MaskPoll(uint64_t Addr, uint32_t Mask, uint32_t Expected_Value, uint32_t TimeoutInMS); \ +extern void cdo_BlockWrite32(uint64_t Addr, uint32_t* pData, uint32_t size); \ +extern void cdo_BlockSet32(uint64_t Addr, uint32_t Data, uint32_t size);") + +replace_string_in_file( + ${_aie_rt_source_dir}/driver/src/io_backend/ext/xaie_cdo.c + "#include \"cdo_rts.h\"" "${_cdo_externs}") + +iree_install_targets( + TARGETS xaiengine + COMPONENT IREEBundledLibraries + EXPORT_SET Runtime +) diff --git a/cmake/iree_aie_utils.cmake b/cmake/iree_aie_utils.cmake new file mode 100644 index 000000000..2e0911dfa --- /dev/null +++ b/cmake/iree_aie_utils.cmake @@ -0,0 +1,42 @@ +# Copyright 2024 The IREE Authors +# +# 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 + +# https://stackoverflow.com/a/49216539/9045206 +# TODO(max): https://cmake.org/cmake/help/latest/command/target_compile_options.html#arguments +# these add private flags; implement both private and public/interface +function(remove_flag_from_target _target _flag) + get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS) + if(_target_cxx_flags) + list(REMOVE_ITEM _target_cxx_flags ${_flag}) + set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${_target_cxx_flags}") + endif() +endfunction() + +function(add_flags_to_target _target _flags) + get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS) + if(_target_cxx_flags) + list(APPEND _target_cxx_flags ${_flags}) + set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${_target_cxx_flags}") + else() + set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${_flags}") + endif() +endfunction() + +function(replace_string_in_file _file _match_string _replace_string) + if(NOT (EXISTS ${_file})) + message(FATAL_ERROR "file ${_file} does not exist") + endif() + file(READ "${_file}" _file_contents) + if(_file_contents STREQUAL "") + message(FATAL_ERROR "empty file contents for ${_file}") + endif() + string(REPLACE "${_match_string}" "${_replace_string}" _file_contents "${_file_contents}") + if(_file_contents STREQUAL "") + message(FATAL_ERROR "empty replacement contents for ${_file}") + endif() + file(WRITE "${_file}" "${_file_contents}") +endfunction() + diff --git a/cmake/iree_aie_xrt.cmake b/cmake/iree_aie_xrt.cmake new file mode 100644 index 000000000..0811fbda4 --- /dev/null +++ b/cmake/iree_aie_xrt.cmake @@ -0,0 +1,198 @@ +# Copyright 2024 The IREE Authors +# +# 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 + +if(TARGET iree-aie-xclbinutil) + return() +endif() + +include(${CMAKE_CURRENT_LIST_DIR}/iree_aie_utils.cmake) + +# ############################################################################## +# boost +# ############################################################################## + +include(FetchContent) +find_package(Threads REQUIRED) +set(Boost_USE_STATIC_LIBS ON) +set(BOOST_ENABLE_CMAKE ON) +set(BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY ON) +set(FETCHCONTENT_QUIET FALSE) # Needed to print downloading progress +FetchContent_Declare( + Boost + URL https://github.com/boostorg/boost/releases/download/boost-1.81.0/boost-1.81.0.7z + USES_TERMINAL_DOWNLOAD TRUE + GIT_PROGRESS TRUE + DOWNLOAD_NO_EXTRACT FALSE + # prevents configure from rerunning all the time + URL_HASH MD5=84bc7c861606dc66bcfbeb660fcddfd2) +FetchContent_MakeAvailable(Boost) +set(IREE_AIE_BOOST_LIBS + any + algorithm + asio + exception + format + functional + lexical_cast + process + program_options + property_tree + tokenizer + tuple + uuid) +list(TRANSFORM IREE_AIE_BOOST_LIBS PREPEND Boost::) + +set(IREE_XRT_SOURCE_DIR "${IREE_AMD_AIE_SOURCE_DIR}/third_party/XRT/src") + +# ############################################################################## +# xclbinutil +# ############################################################################## + +set(_xclbinutil_source_dir ${IREE_XRT_SOURCE_DIR}/runtime_src/tools/xclbinutil) + +# remove ssl dep +replace_string_in_file(${_xclbinutil_source_dir}/XclBinUtilMain.cxx + "bValidateSignature == true" "false") + +# transformcdo target +if(NOT WIN32) + replace_string_in_file(${_xclbinutil_source_dir}/aie-pdi-transform/src/CMakeLists.txt + "-Wextra" "") + add_subdirectory(${_xclbinutil_source_dir}/aie-pdi-transform aie-pdi-transform) +endif() + +# otherwise the various stois that read these will explode... +# XRT/src/runtime_src/tools/xclbinutil/XclBinClass.cxx#L55 +file(READ ${IREE_XRT_SOURCE_DIR}/CMakeLists.txt _xrt_cmake_file_contents) +string(REGEX MATCH "XRT_VERSION_MAJOR ([0-9]+)" XRT_VERSION_MAJOR ${_xrt_cmake_file_contents}) +# note CMAKE_MATCH_0 is the whole match... +set(XRT_VERSION_MAJOR ${CMAKE_MATCH_1}) +string(REGEX MATCH "XRT_VERSION_MINOR ([0-9]+)" XRT_VERSION_MINOR ${_xrt_cmake_file_contents}) +set(XRT_VERSION_MINOR ${CMAKE_MATCH_1}) +string(REGEX MATCH "XRT_VERSION_PATCH ([0-9]+)" XRT_VERSION_PATCH ${_xrt_cmake_file_contents}) +set(XRT_VERSION_PATCH ${CMAKE_MATCH_1}) +set(XRT_VERSION_STRING ${XRT_VERSION_MAJOR}.${XRT_VERSION_MINOR}.${XRT_VERSION_PATCH} CACHE INTERNAL "") +set(XRT_SOVERSION ${XRT_VERSION_MAJOR} CACHE INTERNAL "") +set(XRT_HEAD_COMMITS 0xDEADBEEF CACHE INTERNAL "") +set(XRT_BRANCH_COMMITS 0xDEADFACE CACHE INTERNAL "") + +configure_file(${IREE_XRT_SOURCE_DIR}/CMake/config/version.h.in ${_xclbinutil_source_dir}/version.h) +configure_file(${IREE_XRT_SOURCE_DIR}/CMake/config/version.h.in + ${IREE_XRT_SOURCE_DIR}/runtime_src/core/include/xrt/detail/version.h) +file(MAKE_DIRECTORY ${IREE_XRT_SOURCE_DIR}/runtime_src/core/common/gen) +configure_file(${IREE_XRT_SOURCE_DIR}/CMake/config/version.h.in + ${IREE_XRT_SOURCE_DIR}/runtime_src/core/common/gen/version.h) +configure_file(${IREE_XRT_SOURCE_DIR}/CMake/config/version.h.in + ${IREE_XRT_SOURCE_DIR}/runtime_src/core/common/api/version.h) +replace_string_in_file(${IREE_XRT_SOURCE_DIR}/runtime_src/core/common/query.h + "#include " "#include ") + +set(_noop_xclbin_sig_cxx " +#include \"XclBinSignature.h\" +void signXclBinImage(const std::string& _fileOnDisk, + const std::string& _sPrivateKey, + const std::string& _sCertificate, + const std::string& _sDigestAlgorithm, + bool _bEnableDebugOutput) {} +void verifyXclBinImage(const std::string& _fileOnDisk, + const std::string& _sCertificate, + bool _bEnableDebugOutput) {} +void dumpSignatureFile(const std::string& _fileOnDisk, + const std::string& _signatureFile) {} +void getXclBinPKCSStats(const std::string& _xclBinFile, + XclBinPKCSImageStats& _xclBinPKCSImageStats) {}") +file(WRITE "${_xclbinutil_source_dir}/XclBinSignature.cxx" "${_noop_xclbin_sig_cxx}") + +file( + GLOB + _xclbinutil_srcs + "${_xclbinutil_source_dir}/DTC*.cxx" + "${_xclbinutil_source_dir}/FDT*.cxx" + "${_xclbinutil_source_dir}/CBOR.cxx" + "${_xclbinutil_source_dir}/KernelUtilities.cxx" + "${_xclbinutil_source_dir}/ElfUtilities.cxx" + "${_xclbinutil_source_dir}/FormattedOutput.cxx" + "${_xclbinutil_source_dir}/ParameterSectionData.cxx" + # Note: Due to linking dependency issue, this entry needs to be before the other Section*s + "${_xclbinutil_source_dir}/Section.cxx" + "${_xclbinutil_source_dir}/Section*.cxx" + "${_xclbinutil_source_dir}/Resources*.cxx" + "${_xclbinutil_source_dir}/XclBinClass.cxx" + "${_xclbinutil_source_dir}/XclBinSignature.cxx" + "${_xclbinutil_source_dir}/XclBinUtilities.cxx" + "${_xclbinutil_source_dir}/xclbinutil.cxx" + "${_xclbinutil_source_dir}/XclBinUtilMain.cxx" +) +# connects to rapidjson... +list(REMOVE_ITEM _xclbinutil_srcs "${_xclbinutil_source_dir}/SectionSmartNic.cxx") + +# Unlike bootgen, xclbinutil cannot be built separately as a static archive (I wish!) +# because the linker will DCE static initializers in SectionMemTopology.cxx +# and then --add-replace-section:MEM_TOPOLOGY won't work... +# XRT/src/runtime_src/tools/xclbinutil/SectionMemTopology.cxx#L26-L41 +# TODO(max): and for whatever reason -WL,--whole-archive doesn't work +add_executable(iree-aie-xclbinutil ${_xclbinutil_srcs}) + +target_compile_definitions(iree-aie-xclbinutil + PRIVATE + -DBOOST_BIND_GLOBAL_PLACEHOLDERS) +set(THREADS_PREFER_PTHREAD_FLAG ON) +target_link_libraries(iree-aie-xclbinutil + PRIVATE + Threads::Threads + $ + $<$:$>) +target_include_directories(iree-aie-xclbinutil + PRIVATE ${XRT_BINARY_DIR}/gen + ${IREE_XRT_SOURCE_DIR}/runtime_src/core/include + ${_xclbinutil_source_dir}) +target_compile_options(iree-aie-xclbinutil + PRIVATE + $<$:-fexceptions -frtti> + $<$:/EHsc /GR>) +set_target_properties(iree-aie-xclbinutil + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/tools") +iree_install_targets( + TARGETS iree-aie-xclbinutil + COMPONENT IREETools-Runtime + EXPORT_SET Runtime +) + +# ############################################################################## +# xrt_coreutil +# ############################################################################## + +# send xrt_coreutil to trash so it doesn't get installed +set(XRT_INSTALL_LIB_DIR "$ENV{TMP}") +set(XRT_INSTALL_BIN_DIR "$ENV{TMP}") +set(XRT_NAMELINK_SKIP EXCLUDE_FROM_ALL) +set(XRT_NAMELINK_ONLY EXCLUDE_FROM_ALL) +# remove unsupported -Wextra flag on windows +set(GSL_TEST OFF CACHE BOOL "") +add_subdirectory(${IREE_XRT_SOURCE_DIR}/runtime_src/core/common iree-aie-xrt-coreutil) + +# drill this into your head https://stackoverflow.com/a/24991498 +set(_core_libs + core_common_objects + core_common_library_objects + core_common_api_library_objects + core_common_xdp_profile_objects + xrt_coreutil +) +foreach(_core_lib IN LISTS _core_libs) + target_include_directories(${_core_lib} PUBLIC + ${IREE_XRT_SOURCE_DIR}/runtime_src/core/include + ${IREE_XRT_SOURCE_DIR}/runtime_src/core/common/gsl/include + ${IREE_XRT_SOURCE_DIR}/runtime_src) + target_include_directories(${_core_lib} SYSTEM PUBLIC + ${IREE_XRT_SOURCE_DIR}/runtime_src/core/common/elf) + target_compile_definitions(${_core_lib} PUBLIC -DBOOST_BIND_GLOBAL_PLACEHOLDERS) + target_compile_options(${_core_lib} + PRIVATE + $<$:-fexceptions -frtti> + $<$:/EHsc /GR>) + target_link_libraries(${_core_lib} PUBLIC $) +endforeach() diff --git a/compiler/plugins/target/AMD-AIE/aie/AIEDialect.cpp b/compiler/plugins/target/AMD-AIE/aie/AIEDialect.cpp index d790c074f..353ed177f 100644 --- a/compiler/plugins/target/AMD-AIE/aie/AIEDialect.cpp +++ b/compiler/plugins/target/AMD-AIE/aie/AIEDialect.cpp @@ -212,7 +212,8 @@ void printObjectFifoProducerTile(mlir::OpAsmPrinter &printer, } } -mlir::ParseResult parseObjectFifoConsumerTiles( +// actually used in objectfifo parse +[[maybe_unused]] mlir::ParseResult parseObjectFifoConsumerTiles( mlir::OpAsmParser &parser, llvm::SmallVectorImpl &tiles, BDDimLayoutArrayArrayAttr &dimensions) { @@ -241,9 +242,10 @@ mlir::ParseResult parseObjectFifoConsumerTiles( return mlir::success(); } -void printObjectFifoConsumerTiles(mlir::OpAsmPrinter &printer, - mlir::Operation *op, mlir::OperandRange tiles, - BDDimLayoutArrayArrayAttr dimsPerTileAttr) { +// actually used in objectfifo print +[[maybe_unused]] void printObjectFifoConsumerTiles( + mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRange tiles, + BDDimLayoutArrayArrayAttr dimsPerTileAttr) { size_t tileIdx = 0; for (auto tile : tiles) { printer << tile; @@ -261,7 +263,14 @@ void printObjectFifoConsumerTiles(mlir::OpAsmPrinter &printer, TileOp getTileOp(mlir::Operation &op) { mlir::Value t = *op.getOperands().begin(); - return llvm::cast(t.getDefiningOp()); + Operation *definingOp = t.getDefiningOp(); + if (!llvm::isa(definingOp)) { + llvm::errs() << "Parent op's first operand's defining op isn't a TileOp: " + << definingOp; + llvm::report_fatal_error( + "Parent op's first operand's defining op isn't a TileOp"); + } + return llvm::cast(definingOp); } TileOp CoreOp::getTileOp() { return xilinx::AIE::getTileOp(*getOperation()); } @@ -410,4 +419,159 @@ mlir::iree_compiler::AMDAIE::AMDAIEDeviceModel DeviceOp::getTargetModel() { } uint32_t getAddressGenGranularity() { return 32; }; + +LogicalResult DMABDOp::verify() { + // Skip verification of the BDOp outside of mem operations. + // BDOps may appear elsewhere and subsequent lowerings will place them in the + // correct mem ops. + Operation *p = (*this)->getParentOp(); + if (!llvm::isa(*p)) { + return success(); + } + + if (!isa(getBuffer().getDefiningOp())) { + return emitOpError( + "BDs only support BufferOp or ExternalBufferOp operands."); + } + + if (getLenInBytes(*this) % 4) { + return emitOpError( + "transfer length must be multiple of 4 (i.e., represent " + "4 byte aligned address)"); + } + + TileOp parentTileOp = getTileOp(*p); + + BufferOp buffer = cast(getBuffer().getDefiningOp()); + if (getOperation()->getParentOfType() && + (getTileOp(*buffer.getOperation()).getCol() != parentTileOp.getCol() || + getTileOp(*buffer.getOperation()).getRow() != parentTileOp.getRow())) { + return emitOpError( + "Core tile DMAs can only access a buffer in the same tile."); + } + + mlir::iree_compiler::AMDAIE::AMDAIEDeviceModel deviceModel = + getDeviceModel(this->getOperation()); + + uint32_t maxBds = + deviceModel.getNumBDs(parentTileOp.getCol(), parentTileOp.getRow()); + if (std::optional bdId = getBdId(); + bdId.has_value() && static_cast(*bdId) >= maxBds) { + return emitOpError("bdId attribute exceeds max: ") << maxBds - 1; + } + if (std::optional nextBdId = getNextBdId(); + nextBdId.has_value() && static_cast(*nextBdId) >= maxBds) { + return emitOpError("nextBdId attribute exceeds max: ") << maxBds - 1; + } + + if (auto dims = getDimensions(); dims.has_value()) { + size_t maxNDims = 3; + if (isa_and_nonnull(getOperation()->getParentOp())) { + maxNDims = 4; + } + if (dims->size() > maxNDims) { + return emitOpError() << "Cannot give more than " + << std::to_string(maxNDims) + << " dimensions for step sizes and wraps in this " + " tile (got " + << std::to_string(dims->size()) << " dimensions)."; + } + + MemRefType bufferType = buffer.getType(); + int64_t maxIdx = 0; + for (BDDimLayoutAttr dim : *dims) { + maxIdx += dim.getStride() * (dim.getSize() - 1); + if (0 == dim.getStride()) { + return emitOpError() + << "Invalid step size; must be a positive integer."; + } + if (dim.getStride() > bufferType.getNumElements()) { + return emitOpError() + << "Step size " << std::to_string(dim.getStride()) << " " + << "exceeds memref size " + << std::to_string(bufferType.getNumElements()); + } + if (dim.getSize() >= (1UL << 9) + 1) { + return emitOpError() << "Size may not exceed 1023."; + } + if (dim.getStride() >= (1UL << 19)) { + return emitOpError() << "Stride may not exceed " << (1 << 20); + } + } + + if (bufferType.getNumElements() <= maxIdx) { + return emitOpError() << "Specified stride(s) and size(s) result in out " + "of bounds access in buffer, for index " + << std::to_string(maxIdx) << " in memref of length " + << std::to_string(bufferType.getNumElements()); + } + + // Since streams read 32b words, there's no way to read eg 16b with stride + // of 2 (ie lower halfs of each 32b). So force it to be 1 (and then in + // CDODirect scale the size by 4/getBufferElementTypeWidthInBytes). + if (getBufferElementTypeWidthInBytes(*this) < 4 && + dims->back().getStride() != 1) { + return emitOpError( + "For <32b width datatypes, inner-most dim stride must be 1"); + } + } + + if (auto paddims = getPadDimensions(); paddims.has_value()) { + auto dims = getDimensions(); + if (!dims.has_value()) { + return emitOpError() << "Padding requires n-d data layouts expressed as" + << " wrap(s) and stride(s)."; + } + if (dims->size() != paddims->size()) { + return emitOpError() << "Mismatch number of dimensions between padding(s)" + << " and wrap(s) and stride(s)."; + } + if (!deviceModel.isMemTile(parentTileOp.getCol(), parentTileOp.getRow())) { + return emitOpError() << "Padding is only supported by memtile dma bds."; + } + int actuallen = 1; + for (unsigned i = 0; i < paddims->size(); i++) { + auto dim = (*dims)[i]; + auto paddim = (*paddims)[i]; + actuallen *= paddim.getConstPadBefore() + paddim.getConstPadAfter() + + dim.getSize(); + if (actuallen > getLen()) { + return emitOpError() << "Data exceeds len after padding."; + } + } + + if ((paddims->back().getConstPadBefore() * + getBufferElementTypeWidthInBytes(*this)) % + 4) { + return emitOpError() << "Inner-most padding-before count must result in" + << " padding in 32-bit words."; + } + if ((paddims->back().getConstPadAfter() * + getBufferElementTypeWidthInBytes(*this)) % + 4) { + return emitOpError() << "Inner-most padding-after count must result in" + << " padding in 32-bit words."; + } + } + + if (deviceModel.isMemTile(parentTileOp.getCol(), parentTileOp.getRow()) || + deviceModel.isCoreTile(parentTileOp.getCol(), parentTileOp.getRow())) { + if (auto baseAddr = buffer.getAddress(); baseAddr.has_value()) { + int offsetInBytes = *baseAddr + getOffsetInBytes(*this); + if (offsetInBytes % 4) { + return emitOpError( + "bd address must be 4 byte (32b) aligned; got " + "base+offset: ") + << offsetInBytes << " (bytes)"; + } + } + } + + if (!getLen() && !getBuffer().getType().hasStaticShape()) { + return emitOpError() << "buffer with dynamic shape requires static length."; + } + + return success(); +} + } // namespace xilinx::AIE diff --git a/compiler/plugins/target/AMD-AIE/aie/AIEDialect.h b/compiler/plugins/target/AMD-AIE/aie/AIEDialect.h index cf76fea4a..c038657ba 100644 --- a/compiler/plugins/target/AMD-AIE/aie/AIEDialect.h +++ b/compiler/plugins/target/AMD-AIE/aie/AIEDialect.h @@ -98,12 +98,12 @@ void printObjectFifoProducerTile(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::Value operand, BDDimLayoutArrayAttr dimensions); -mlir::ParseResult parseObjectFifoConsumerTiles( +[[maybe_unused]] mlir::ParseResult parseObjectFifoConsumerTiles( mlir::OpAsmParser &parser, llvm::SmallVectorImpl &tiles, BDDimLayoutArrayArrayAttr &dimensions); -void printObjectFifoConsumerTiles(mlir::OpAsmPrinter &printer, +[[maybe_unused]] void printObjectFifoConsumerTiles(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRange tiles, BDDimLayoutArrayArrayAttr dimsPerTileAttr); diff --git a/compiler/plugins/target/AMD-AIE/aie/AIEOps.td b/compiler/plugins/target/AMD-AIE/aie/AIEOps.td index 763d76ff5..8d8a4f929 100644 --- a/compiler/plugins/target/AMD-AIE/aie/AIEOps.td +++ b/compiler/plugins/target/AMD-AIE/aie/AIEOps.td @@ -312,6 +312,7 @@ def AIE_DMABDOp: AIE_Op<"dma_bd", [ OptionalAttr:$next_bd_id ); + let hasVerifier = 1; let assemblyFormat = [{ `(` $buffer `:` type($buffer) `)` attr-dict diff --git a/compiler/plugins/target/AMD-AIE/air/CMakeLists.txt b/compiler/plugins/target/AMD-AIE/air/CMakeLists.txt index 61659076d..8d8799d49 100644 --- a/compiler/plugins/target/AMD-AIE/air/CMakeLists.txt +++ b/compiler/plugins/target/AMD-AIE/air/CMakeLists.txt @@ -21,22 +21,6 @@ iree_cc_library( # AIR Dialect ############################################################################### -function(replace_string_in_file _file _match_string _replace_string) - if(NOT (EXISTS ${_file})) - message(FATAL_ERROR "file ${_file} does not exist") - endif() - file(READ "${_file}" _file_contents) - if(_file_contents STREQUAL "") - message(FATAL_ERROR "empty file contents for ${_file}") - endif() - string(REPLACE "${_match_string}" "${_replace_string}" _file_contents "${_file_contents}") - if(_file_contents STREQUAL "") - message(FATAL_ERROR "empty replacement contents for ${_file}") - endif() - file(WRITE "${_file}" "${_file_contents}") -endfunction() - - iree_cc_library( NAME AIRDialectIR @@ -195,6 +179,12 @@ replace_string_in_file( replace_string_in_file( ${IREE_MLIR_AIR_SOURCE_DIR}/lib/Conversion/AIRRtToNpuPass.cpp "aie/Dialect/AIEX/IR" "aie") +replace_string_in_file( + ${IREE_MLIR_AIR_SOURCE_DIR}/lib/Conversion/AIRRtToNpuPass.cpp + "4UL" "static_cast(4)") +replace_string_in_file( + ${IREE_MLIR_AIR_SOURCE_DIR}/lib/Conversion/AIRRtToNpuPass.cpp + "8UL" "static_cast(8)") replace_string_in_file( ${IREE_MLIR_AIR_SOURCE_DIR}/lib/Conversion/AIRToAIESchedulingUtils.cpp @@ -329,8 +319,6 @@ iree_cc_library( AIRPasses HDRS "${IREE_MLIR_AIR_SOURCE_DIR}/include/air/Transform/Passes.h" - SRCS - "Passes.cpp" DEPS ::AIRConversionPasses ::AIRTransformPasses diff --git a/compiler/plugins/target/AMD-AIE/air/Passes.cpp b/compiler/plugins/target/AMD-AIE/air/Passes.cpp deleted file mode 100644 index 039327be5..000000000 --- a/compiler/plugins/target/AMD-AIE/air/Passes.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2023 The IREE Authors -// -// 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 - -#include "llvm/Support/ErrorHandling.h" - -// TODO(ravishankarm): Remove this when boost is removed. -// See -// https://stackoverflow.com/questions/50133783/c-cmake-build-error-undefined-reference-to-boostthrow-exceptionstdexcep -#define BOOST_NO_EXCEPTIONS -#include -void boost::throw_exception(std::exception const& e) { - // do nothing - llvm_unreachable("no exceptions"); -} -#if BOOST_VERSION >= 107300 -void boost::throw_exception(std::exception const& e, - boost::source_location const&) { - // do nothing - llvm_unreachable("no exceptions"); -} -#endif diff --git a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/CMakeLists.txt b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/CMakeLists.txt index c761b2208..3c7cd4d64 100644 --- a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/CMakeLists.txt +++ b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/CMakeLists.txt @@ -6,12 +6,6 @@ iree_add_all_subdirs() -if(MSVC) - set(UUID "Rpcrt4.lib") -else() - find_library (UUID uuid REQUIRED) -endif() - iree_cc_library( NAME AIETargets @@ -21,15 +15,13 @@ iree_cc_library( "AMDAIETargetLdScript.cpp" "XCLBinGen.cpp" DEPS - ${UUID} iree-amd-aie::aie_runtime::iree_aie_runtime_static iree::target::amd-aie::Transforms + iree-aie-bootgen ) if(IREE_AMD_AIE_ENABLE_XRT_DRIVER) - add_dependencies(iree_target_amd-aie_Target_AIETargets - iree-amd-aie_aie_runtime_amdaie_xclbinutil - iree-amd-aie_aie_runtime_amdaie_bootgen) + add_dependencies(iree_target_amd-aie_Target_AIETargets iree-aie-xclbinutil) endif() iree_cc_library( diff --git a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/XCLBinGen.cpp b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/XCLBinGen.cpp index a9bf83a60..f2bdc6a33 100644 --- a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/XCLBinGen.cpp +++ b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/XCLBinGen.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -32,13 +33,42 @@ #define DEBUG_TYPE "amdaie-xclbingen" -#ifdef _WIN32 -#include "windows.h" -// For UUID stuff -#include "rpcdce.h" -#else -#include -#endif +extern int iree_aie_bootgen_main(int argc, const char *argv[]); + +// https://stackoverflow.com/a/60198074 +namespace uuid { +static std::random_device rd; +static std::mt19937 gen(rd()); +static std::uniform_int_distribution<> dis(0, 15); +static std::uniform_int_distribution<> dis2(8, 11); + +std::string getUUIDString() { + std::stringstream ss; + int i; + ss << std::hex; + for (i = 0; i < 8; i++) { + ss << dis(gen); + } + ss << "-"; + for (i = 0; i < 4; i++) { + ss << dis(gen); + } + ss << "-4"; + for (i = 0; i < 3; i++) { + ss << dis(gen); + } + ss << "-"; + ss << dis2(gen); + for (i = 0; i < 3; i++) { + ss << dis(gen); + } + ss << "-"; + for (i = 0; i < 12; i++) { + ss << dis(gen); + }; + return ss.str(); +} +} // namespace uuid // This is a string that contains the wrapped chess intrinsics (see top of the // included file for deeper explanation). @@ -166,17 +196,17 @@ static FailureOr findAMDAIETool(std::string toolName, Path toolBinExe = ""; if (!amdAIEInstallDir.empty()) { toolBinExe = amdAIEInstallDir / toolName; - if (llvm::sys::fs::exists(toolBinExe.native())) return toolBinExe; + if (std::filesystem::exists(toolBinExe)) return toolBinExe; toolBinExe = amdAIEInstallDir / "bin" / toolName; - if (llvm::sys::fs::exists(toolBinExe.native())) return toolBinExe; + if (std::filesystem::exists(toolBinExe)) return toolBinExe; toolBinExe = amdAIEInstallDir / "tools" / toolName; - if (llvm::sys::fs::exists(toolBinExe.native())) return toolBinExe; + if (std::filesystem::exists(toolBinExe)) return toolBinExe; } toolBinExe = mlir::iree_compiler::findTool(toolName); - if (llvm::sys::fs::exists(toolBinExe.native())) return toolBinExe; + if (std::filesystem::exists(toolBinExe)) return toolBinExe; llvm::errs() << "Could not find " << toolName << ". Check your --iree-amd-aie-install-dir flag"; @@ -222,7 +252,8 @@ std::pair> makeChessArgs(Path &vitisDir, "-I" + (aieToolsDir / "include").string()}; // disassemble output if (verbose) flags.emplace_back("-d"); - return {aieToolsDir / "bin" / "unwrapped" / "lnx64.o" / "xchesscc", flags}; + return {(aieToolsDir / "bin" / "unwrapped" / "lnx64.o" / "xchesscc").string(), + flags}; } std::vector makeChessEnv(Path &vitisDir) { @@ -259,29 +290,6 @@ std::optional dumpStrToDisk(const std::string &payload, return {}; } -static std::string getUUIDString() { - std::string val; -#ifdef _WIN32 - UUID *uuid; - RPC_STATUS status; - status = UuidCreate(uuid); - if (status != RPC_S_OK) errs() << "Failed to create UUID\n"; - RPC_CSTR *uuidstring; - status = UuidToStringA(uuid, uuidstring); - if (status != RPC_S_OK) errs() << "Failed to convert UUID to string\n"; - val = std::string((char *)uuidstring); - status = RpcStringFreeA(uuidstring); - if (status != RPC_S_OK) errs() << "Failed to free UUID string\n"; -#else - uuid_t binuuid; - uuid_generate_random(binuuid); - char uuid[37]; - uuid_unparse_lower(binuuid, uuid); - val = std::string(uuid); -#endif - return val; -} - // Returns either: // -- the output of running the tool, if run without failure, or // -- an empty optional, if the tool fails to run. @@ -440,7 +448,7 @@ static LogicalResult assembleFileUsingPeano( args.emplace_back("-o"); args.emplace_back(outputFile); if (verbose) args.emplace_back("-v"); - if (!runTool(peanoDir / "bin" / "clang", args, verbose)) { + if (!runTool((peanoDir / "bin" / "clang").string(), args, verbose)) { llvm::errs() << "Failed to assemble " << outputFile << ".o with peano"; return failure(); } @@ -457,9 +465,9 @@ static FailureOr assembleStringUsing( Path &outputDir, const std::vector &extraArgs, Path &workDir, Path &toolDir, bool verbose = false) { Path inputFile = workDir / inputFileName; - if (auto maybeErr = dumpStrToDisk(inputFileStr, inputFile); + if (auto maybeErr = dumpStrToDisk(inputFileStr, inputFile.string()); maybeErr.has_value()) { - llvm::errs() << "Failed to dump to disk " << inputFile + llvm::errs() << "Failed to dump to disk " << inputFile.string() << " because: " << maybeErr; return failure(); } @@ -470,8 +478,8 @@ static FailureOr assembleStringUsing( } else { outputFile = outputFileName; } - if (failed(assembler(inputFile, outputFile, extraArgs, workDir, toolDir, - verbose))) { + if (failed(assembler(inputFile.string(), outputFile.string(), extraArgs, + workDir, toolDir, verbose))) { llvm::errs() << "Failed to assemble " << outputFileName << ".o"; return failure(); } @@ -505,7 +513,7 @@ static LogicalResult generateCoreElfFiles( for (auto tileOp : tileOps) { int col = tileOp.getCol(); int row = tileOp.getRow(); - auto coreOp = getCoreOp(tileOp); + auto coreOp = AIE::getCoreOp(tileOp); if (!coreOp) continue; std::string elfFileName; @@ -587,9 +595,9 @@ static LogicalResult generateCoreElfFiles( chessArgs.emplace_back(mmObjectFilePath->string()); } chessArgs.emplace_back("+l"); - chessArgs.emplace_back(bcfPath); + chessArgs.emplace_back(bcfPath.string()); chessArgs.emplace_back("-o"); - chessArgs.emplace_back(elfFile); + chessArgs.emplace_back(elfFile.string()); std::vector env = makeChessEnv(*vitisDir); if (!runTool(xChessCCExe, chessArgs, verbose, env)) { llvm::errs() << "Failed to link with xbridge"; @@ -624,11 +632,11 @@ static LogicalResult generateCoreElfFiles( flags.emplace_back("-Wl,--gc-sections"); flags.emplace_back("-Wl,-T," + ldscriptPath.string()); flags.emplace_back("-o"); - flags.emplace_back(elfFile); + flags.emplace_back(elfFile.string()); if (verbose) flags.emplace_back("-v"); // we run clang (ie cc) so that libc, libm, crt0/1 paths are injected // automatically into the ld.lld invocation - if (!runTool(peanoDir / "bin" / "clang", flags, verbose)) { + if (!runTool((peanoDir / "bin" / "clang").string(), flags, verbose)) { llvm::errs() << "failed to link elf file for core(" << col << "," << row << ")"; return failure(); @@ -749,7 +757,8 @@ static LogicalResult generateXCLBin( ] } })"; - if (auto maybeErr = dumpStrToDisk(memTopologyData, memTopologyJsonFile); + if (auto maybeErr = + dumpStrToDisk(memTopologyData, memTopologyJsonFile.string()); maybeErr.has_value()) { llvm::errs() << "failed to dump to disk mem_topology.json because: " << *maybeErr; @@ -760,7 +769,7 @@ static LogicalResult generateXCLBin( // Create aie_partition.json. Path aiePartitionJsonFile = tempDir / "aie_partition.json"; { - std::string uuidStr = getUUIDString(); + std::string uuidStr = uuid::getUUIDString(); std::string aiePartitionJsonData = R"( { "aie_partition": { @@ -796,7 +805,7 @@ static LogicalResult generateXCLBin( } )"; if (auto maybeErr = - dumpStrToDisk(aiePartitionJsonData, aiePartitionJsonFile); + dumpStrToDisk(aiePartitionJsonData, aiePartitionJsonFile.string()); maybeErr.has_value()) { llvm::errs() << "failed to dump to disk aie_partition.json because: " << *maybeErr; @@ -815,7 +824,7 @@ static LogicalResult generateXCLBin( auto kernelStr = llvm::formatv("{0:2}", json::Value(std::move(kernelsData))); - if (auto maybeErr = dumpStrToDisk(kernelStr, kernelsJsonFile); + if (auto maybeErr = dumpStrToDisk(kernelStr, kernelsJsonFile.string()); maybeErr.has_value()) { llvm::errs() << "failed to dump to disk kernels.json because: " << *maybeErr; @@ -839,9 +848,12 @@ static LogicalResult generateXCLBin( << " {\n" << " name=aie_image, id=0x1c000000\n" << " { type=cdo\n" - << " file=" << tempDir << "/aie_cdo_elfs.bin\n" - << " file=" << tempDir << "/aie_cdo_init.bin\n" - << " file=" << tempDir << "/aie_cdo_enable.bin\n" + << " file=" << tempDir.string() + << "/aie_cdo_elfs.bin\n" + << " file=" << tempDir.string() + << "/aie_cdo_init.bin\n" + << " file=" << tempDir.string() + << "/aie_cdo_enable.bin\n" << " }\n" << " }\n" << "}"; @@ -850,16 +862,23 @@ static LogicalResult generateXCLBin( // Execute the bootgen command. { - std::vector flags{"-arch", "versal", - "-image", designBifFile, - "-o", tempDir / "design.pdi", - "-w"}; - - FailureOr bootgenBin = - findAMDAIETool("amdaie_bootgen", amdAIEInstallDir); - - if (!succeeded(bootgenBin) || - !runTool(bootgenBin.value(), flags, verbose)) { + // first element is empty string because iree_aie_bootgen_main + // is the main of bootgen.exe (and argv[0] is typically the name of the exe) + std::vector flags = {"", + "-arch", + "versal", + "-image", + designBifFile.string(), + "-o", + (tempDir / "design.pdi").string(), + "-w"}; + std::vector cstrings; + cstrings.reserve(flags.size()); + for (const auto &inputFlag : flags) { + cstrings.push_back(const_cast(inputFlag.c_str())); + } + if (iree_aie_bootgen_main(cstrings.size(), + const_cast(&cstrings[0]))) { llvm::errs() << "failed to execute bootgen"; return failure(); } @@ -869,7 +888,7 @@ static LogicalResult generateXCLBin( std::string memArg = "MEM_TOPOLOGY:JSON:" + memTopologyJsonFile.string(); std::string partArg = "AIE_PARTITION:JSON:" + aiePartitionJsonFile.string(); FailureOr xclbinutilBin = - findAMDAIETool("amdaie_xclbinutil", amdAIEInstallDir); + findAMDAIETool("iree-aie-xclbinutil", amdAIEInstallDir); { if (inputXclbin) { @@ -881,7 +900,7 @@ static LogicalResult generateXCLBin( "--force", "--input", *inputXclbin}; if (!succeeded(xclbinutilBin) || - !runTool(xclbinutilBin.value(), inputFlags, verbose)) { + !runTool(xclbinutilBin.value().string(), inputFlags, verbose)) { llvm::errs() << "failed to execute xclbinutil"; return failure(); } @@ -918,7 +937,7 @@ static LogicalResult generateXCLBin( // rewrite aie partion json file if (auto maybeErr = dumpStrToDisk(formatv("{0:2}", *aieInputPartitionOutValue), - aiePartitionJsonFile); + aiePartitionJsonFile.string()); maybeErr.has_value()) { llvm::errs() << "failed to dump to disk aie_input_partition.json because: " @@ -929,12 +948,12 @@ static LogicalResult generateXCLBin( } else { flags.insert(flags.end(), {"--add-replace-section", memArg}); } - flags.insert(flags.end(), - {"--add-kernel", kernelsJsonFile, "--add-replace-section", - partArg, "--force", "--output", std::string(Output)}); + flags.insert(flags.end(), {"--add-kernel", kernelsJsonFile.string(), + "--add-replace-section", partArg, "--force", + "--output", std::string(Output)}); if (!succeeded(xclbinutilBin) || - !runTool(xclbinutilBin.value(), flags, verbose)) { + !runTool(xclbinutilBin.value().string(), flags, verbose)) { llvm::errs() << "failed to execute xclbinutil"; return failure(); } @@ -1065,7 +1084,7 @@ static LogicalResult generateUnifiedObject( if (failed(chessIntrinsicsObjFile)) return failure(); } else { Path LLVMIRFile = tempDir / "input.ll"; - if (auto maybeErr = dumpStrToDisk(inputLLStr, LLVMIRFile); + if (auto maybeErr = dumpStrToDisk(inputLLStr, LLVMIRFile.string()); maybeErr.has_value()) { llvm::errs() << "Failed to dump to disk input.ll" << " because: " << maybeErr; @@ -1076,20 +1095,20 @@ static LogicalResult generateUnifiedObject( Path OptLLVMIRFile = tempDir / "input.opt.ll"; std::vector args{ - "-O2", "--inline-threshold=10", "-S", std::string(LLVMIRFile), + "-O2", "--inline-threshold=10", "-S", LLVMIRFile.string(), // missing from libc - "--disable-builtin=memset", "-o", std::string(OptLLVMIRFile)}; + "--disable-builtin=memset", "-o", OptLLVMIRFile.string()}; std::vector peanoArgs = makePeanoOptArgs(); args.reserve(args.size() + peanoArgs.size()); args.insert(args.end(), peanoArgs.begin(), peanoArgs.end()); - if (!runTool(peanoOptBin, args, verbose)) { + if (!runTool(peanoOptBin.string(), args, verbose)) { llvm::errs() << "Failed to optimize ll with peano"; return failure(); } if (!runTool( - peanoLLCBin, - {std::string(OptLLVMIRFile), "-O2", + peanoLLCBin.string(), + {OptLLVMIRFile.string(), "-O2", "--march=" + StringRef(targetArch).lower(), "--function-sections", "--filetype=obj", "-o", std::string(outputFile)}, verbose)) { @@ -1140,15 +1159,15 @@ LogicalResult aie2xclbin( output->keep(); Path unifiedObj = Path(tempDir) / "input.o"; - if (failed(generateUnifiedObject(ctx, moduleOp, unifiedObj, printIRBeforeAll, - printIRAfterAll, printIRModuleScope, timing, - useChess, verbose, tempDir, vitisDir, - targetArch, peanoDir))) + if (failed(generateUnifiedObject( + ctx, moduleOp, unifiedObj.string(), printIRBeforeAll, printIRAfterAll, + printIRModuleScope, timing, useChess, verbose, tempDir, vitisDir, + targetArch, peanoDir))) return moduleOp.emitOpError("Failed to generate unified object"); - if (failed(generateCoreElfFiles(moduleOp, unifiedObj, tempDir, useChess, - vitisDir, targetArch, verbose, peanoDir, - ukernel))) + if (failed(generateCoreElfFiles(moduleOp, unifiedObj.string(), tempDir, + useChess, vitisDir, targetArch, verbose, + peanoDir, ukernel))) return moduleOp.emitOpError("Failed to generate core ELF file(s)"); if (failed(generateCDO(ctx, moduleOp, printIRBeforeAll, printIRAfterAll, diff --git a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/CMakeLists.txt b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/CMakeLists.txt index 4aab6c5c0..9d447b9f7 100644 --- a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/CMakeLists.txt +++ b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/CMakeLists.txt @@ -4,13 +4,28 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +iree_cc_binary( + NAME + aie_cdo_gen_test + SRCS + aie_cdo_gen_test.cxx + DEPS + iree::target::amd-aie::aie::AIEDialectIR + iree::target::amd-aie::Target::AIETargets +) + +file(GLOB _mlir_files *.mlir) + iree_lit_test_suite( NAME lit SRCS - "amd_aie_target_backend.mlir" + ${_mlir_files} TOOLS ${IREE_LLD_TARGET} + ::aie_cdo_gen_test FileCheck iree-compile + LABELS + "hostonly" ) diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/cdo/add_12_i8_using_2d_dma_op_with_padding.mlir b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/add_12_i8_using_2d_dma_op_with_padding.mlir similarity index 100% rename from runtime/src/iree-amd-aie/aie_runtime/test/cdo/add_12_i8_using_2d_dma_op_with_padding.mlir rename to compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/add_12_i8_using_2d_dma_op_with_padding.mlir diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/cdo/add_21_i8_using_dma_op_with_padding.mlir b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/add_21_i8_using_dma_op_with_padding.mlir similarity index 100% rename from runtime/src/iree-amd-aie/aie_runtime/test/cdo/add_21_i8_using_dma_op_with_padding.mlir rename to compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/add_21_i8_using_dma_op_with_padding.mlir diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/cdo/add_378_i32_using_dma_op_with_padding.mlir b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/add_378_i32_using_dma_op_with_padding.mlir similarity index 100% rename from runtime/src/iree-amd-aie/aie_runtime/test/cdo/add_378_i32_using_dma_op_with_padding.mlir rename to compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/add_378_i32_using_dma_op_with_padding.mlir diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/cdo/aie_cdo_gen_test.cxx b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/aie_cdo_gen_test.cxx similarity index 100% rename from runtime/src/iree-amd-aie/aie_runtime/test/cdo/aie_cdo_gen_test.cxx rename to compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/aie_cdo_gen_test.cxx diff --git a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/bad_padding.mlir b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/bad_padding.mlir index 196667049..6041e1625 100644 --- a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/bad_padding.mlir +++ b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/bad_padding.mlir @@ -8,7 +8,7 @@ module { aie.dma_start("MM2S", 0, ^bd0, ^end) ^bd0: // expected-error@+1 {{'aie.dma_bd' op Inner-most padding-before count must result in padding in 32-bit words.}} - aie.dma_bd(%buf : memref<256xi8>, 0, 8, [], [], pad_value = 0) + aie.dma_bd(%buf : memref<256xi8>) {dimensions = #aie]>, pad_dimensions = #aie]>, len = 8 : i32, pad_value = 0 : i32} aie.next_bd ^end ^end: aie.end @@ -26,7 +26,7 @@ module { aie.dma_start("MM2S", 0, ^bd0, ^end) ^bd0: // expected-error@+1 {{'aie.dma_bd' op Data exceeds len after padding.}} - aie.dma_bd(%buf : memref<256xi32>, 0, 4, [], [], pad_value = 0) + aie.dma_bd(%buf : memref<256xi32>) {len = 4 : i32, dimensions = #aie]>, pad_dimensions = #aie]>, pad_value = 0 : i32} aie.next_bd ^end ^end: aie.end @@ -44,7 +44,7 @@ module { aie.dma_start("MM2S", 0, ^bd0, ^end) ^bd0: // expected-error@+1 {{'aie.dma_bd' op Inner-most padding-before count must result in padding in 32-bit words.}} - aie.dma_bd(%buf : memref<256xbf16>, 0, 256, [], [], pad_value = 0) + aie.dma_bd(%buf : memref<256xbf16>) {len = 256 : i32, dimensions = #aie]>, pad_dimensions = #aie]>, pad_value = 0 : i32} aie.next_bd ^end ^end: aie.end @@ -62,7 +62,7 @@ module { aie.dma_start("MM2S", 0, ^bd0, ^end) ^bd0: // expected-error@+1 {{'aie.dma_bd' op Inner-most padding-after count must result in padding in 32-bit words.}} - aie.dma_bd(%buf : memref<256xbf16>, 0, 256, [], [], pad_value = 0) + aie.dma_bd(%buf : memref<256xbf16>) {len = 256 : i32, dimensions = #aie]>, pad_dimensions = #aie]>, pad_value = 0 : i32} aie.next_bd ^end ^end: aie.end diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/cdo/matmul_16x16_8xi32__dispatch_0_matmul_16x1_0.aiecc.mlir b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/matmul_16x16_8xi32__dispatch_0_matmul_16x1_0.aiecc.mlir similarity index 100% rename from runtime/src/iree-amd-aie/aie_runtime/test/cdo/matmul_16x16_8xi32__dispatch_0_matmul_16x1_0.aiecc.mlir rename to compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/matmul_16x16_8xi32__dispatch_0_matmul_16x1_0.aiecc.mlir diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/cdo/matmul_16x64_32xi8__dispatch_0_matmul_tran_0.aiecc.mlir b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/matmul_16x64_32xi8__dispatch_0_matmul_tran_0.aiecc.mlir similarity index 100% rename from runtime/src/iree-amd-aie/aie_runtime/test/cdo/matmul_16x64_32xi8__dispatch_0_matmul_tran_0.aiecc.mlir rename to compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/matmul_16x64_32xi8__dispatch_0_matmul_tran_0.aiecc.mlir diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/cdo/matmul_512x512_512xi32__dispatch_0_matmul__0.aiecc.mlir b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/matmul_512x512_512xi32__dispatch_0_matmul__0.aiecc.mlir similarity index 100% rename from runtime/src/iree-amd-aie/aie_runtime/test/cdo/matmul_512x512_512xi32__dispatch_0_matmul__0.aiecc.mlir rename to compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/matmul_512x512_512xi32__dispatch_0_matmul__0.aiecc.mlir diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/cdo/matmul_64x64_64xbf16__dispatch_0_matmul_64_0.aiecc.mlir b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/matmul_64x64_64xbf16__dispatch_0_matmul_64_0.aiecc.mlir similarity index 100% rename from runtime/src/iree-amd-aie/aie_runtime/test/cdo/matmul_64x64_64xbf16__dispatch_0_matmul_64_0.aiecc.mlir rename to compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/matmul_64x64_64xbf16__dispatch_0_matmul_64_0.aiecc.mlir diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/cdo/matmul_64x64_64xi8__dispatch_0_matmul_64x6_0.aiecc.mlir b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/matmul_64x64_64xi8__dispatch_0_matmul_64x6_0.aiecc.mlir similarity index 100% rename from runtime/src/iree-amd-aie/aie_runtime/test/cdo/matmul_64x64_64xi8__dispatch_0_matmul_64x6_0.aiecc.mlir rename to compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/matmul_64x64_64xi8__dispatch_0_matmul_64x6_0.aiecc.mlir diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/cdo/matmul_8x32_16xi32__dispatch_0_matmul_8x32_0.aiecc.mlir b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/matmul_8x32_16xi32__dispatch_0_matmul_8x32_0.aiecc.mlir similarity index 100% rename from runtime/src/iree-amd-aie/aie_runtime/test/cdo/matmul_8x32_16xi32__dispatch_0_matmul_8x32_0.aiecc.mlir rename to compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/matmul_8x32_16xi32__dispatch_0_matmul_8x32_0.aiecc.mlir diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/cdo/regenerate.sh b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/regenerate.sh similarity index 100% rename from runtime/src/iree-amd-aie/aie_runtime/test/cdo/regenerate.sh rename to compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/tests/regenerate.sh diff --git a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/AMDAIECreateLogicalObjectFifoLink.cpp b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/AMDAIECreateLogicalObjectFifoLink.cpp index d4b0678bf..f9225e612 100644 --- a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/AMDAIECreateLogicalObjectFifoLink.cpp +++ b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/AMDAIECreateLogicalObjectFifoLink.cpp @@ -33,7 +33,8 @@ namespace mlir::iree_compiler::AMDAIE { /// 63]. template LogicalResult checkForNoOverlappingAccessPatterns( - const SmallVector> &stridedOps) { + const SmallVector> + &stridedOps) { for (auto &&[i, stridedOpAndOffset] : llvm::enumerate(stridedOps)) { DoublyStridedCopyOpInterface stridedOp = stridedOpAndOffset.first; std::optional extent; @@ -117,8 +118,9 @@ LogicalResult createLogicalObjectFifoLink( // Sort the inputs and outputs on offset as the link operation uses this order // to generate correct data buffer sizes. - auto comparator = [](std::pair a, - std::pair b) -> bool { + auto comparator = + [](std::pair a, + std::pair b) -> bool { return a.second < b.second; }; @@ -136,12 +138,12 @@ LogicalResult createLogicalObjectFifoLink( return failure(); } - SmallVector inResults = llvm::map_to_vector( - ins, [](std::pair elem) { + SmallVector inResults = llvm::map_to_vector<8>( + ins, [](std::pair elem) -> Value { return cast(elem.first->getResult(0)); }); SmallVector outResults = llvm::map_to_vector( - outs, [](std::pair elem) { + outs, [](std::pair elem) -> Value { return cast(elem.first->getResult(0)); }); diff --git a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/Passes.cpp b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/Passes.cpp index b0c8f799c..b4a0e502d 100644 --- a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/Passes.cpp +++ b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/Passes.cpp @@ -14,6 +14,7 @@ #include "iree-dialects/Dialect/LinalgTransform/Passes.h" #include "iree/compiler/Codegen/Common/Passes.h" #include "iree/compiler/Utils/PassUtils.h" +#include "iree/compiler/Utils/ToolUtils.h" #include "mlir/Conversion/AffineToStandard/AffineToStandard.h" #include "mlir/Conversion/ArithToLLVM/ArithToLLVM.h" #include "mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h" @@ -68,7 +69,7 @@ static llvm::cl::opt clNumCores( static llvm::cl::opt clPathToUkernels( "iree-amdaie-path-to-ukernels", - llvm::cl::desc("Path to microkernels' directory")); + llvm::cl::desc("Path to microkernels' directory"), llvm::cl::init("")); static llvm::cl::opt clEnableVectorizationPasses( "iree-amdaie-enable-vectorization-passes", @@ -305,7 +306,8 @@ void addPackPeelBasedPassPipeline(OpPassManager &funcPassManager, // Lower to UKernels. { AMDAIELowerToUKernelsOptions options; - options.pathToUkernels = clPathToUkernels; + // windows + options.pathToUkernels = escapeCommandLineComponent(clPathToUkernels); funcPassManager.addPass(createAMDAIELowerToUKernelsPass(options)); } @@ -412,7 +414,8 @@ void addPadPackBasedPassPipeline(OpPassManager &funcPassManager, // Lower to UKernels { AMDAIELowerToUKernelsOptions options; - options.pathToUkernels = clPathToUkernels; + // windows + options.pathToUkernels = escapeCommandLineComponent(clPathToUkernels); funcPassManager.addPass(createAMDAIELowerToUKernelsPass(options)); } // Vectorization passes diff --git a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/test/lower_to_ukernel.mlir b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/test/lower_to_ukernel.mlir index 2dcb7b007..4f767e7be 100644 --- a/compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/test/lower_to_ukernel.mlir +++ b/compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/test/lower_to_ukernel.mlir @@ -1,4 +1,4 @@ -// RUN: iree-opt --split-input-file --pass-pipeline="builtin.module(func.func(iree-amdaie-lower-to-ukernels{path-to-ukernels="/custom/path/to/ukernels"},cse,canonicalize))" %s | FileCheck %s +// RUN: iree-opt --split-input-file --pass-pipeline="builtin.module(func.func(iree-amdaie-lower-to-ukernels{path-to-ukernels=\"/custom/path/to/ukernels\"},cse,canonicalize))" %s | FileCheck %s // This first case demonstrates no lowering to ukernel when the corresponding // config is set to "none". @@ -56,7 +56,7 @@ func.func @generic_matmul_i32i32i32_pad_pack(%arg0 : tensor<8x16x4x8xi32>, %arg1 // CHECK: %[[MICRO_KERNEL:.+]] = iree_codegen.ukernel.generic "matmul_i32_i32_i32_64x64x64_4x8x4" // CHECK-SAME: ins(%[[ARG0]], %[[ARG1]] : // CHECK-SAME: outs(%[[ARG2]] : -// CHECK-SAME: fn_def_attrs {link_with = "/custom/path/to/ukernels/mm.o"} +// CHECK-SAME: fn_def_attrs {link_with = "{{.*}}mm.o"} // CHECK-SAME: strided_outer_dims(0) // CHECK: return %[[MICRO_KERNEL]] @@ -92,7 +92,7 @@ module { // CHECK: %[[MICRO_KERNEL:.+]] = iree_codegen.ukernel.generic "matmul_bf16_bf16_f32_64x64x64_4x8x4" // CHECK-SAME: ins(%[[ARG0]], %[[ARG1]] : // CHECK-SAME: outs(%[[ARG2]] : -// CHECK-SAME: fn_def_attrs {link_with = "/custom/path/to/ukernels/mm.o"} +// CHECK-SAME: fn_def_attrs {link_with = "{{.*}}mm.o"} // CHECK-SAME: strided_outer_dims(0) // CHECK: return %[[MICRO_KERNEL]] @@ -131,7 +131,7 @@ module { // CHECK: %[[MICRO_KERNEL:.+]] = iree_codegen.ukernel.generic "matmul_bf16_bf16_f32_64x64x64_4x8x4" // CHECK-SAME: ins(%[[ARG0]], %[[ARG1]] : // CHECK-SAME: outs(%[[ARG2]] : -// CHECK-SAME: fn_def_attrs {link_with = "/custom/path/to/ukernels/mm.o"} +// CHECK-SAME: fn_def_attrs {link_with = "{{.*}}mm.o"} // CHECK-SAME: strided_outer_dims(0) // CHECK: return %[[MICRO_KERNEL]] @@ -170,7 +170,7 @@ module { // CHECK: %[[MICRO_KERNEL:.+]] = iree_codegen.ukernel.generic "matmul_bf16_bf16_f32_32x32x32_4x8x4" // CHECK-SAME: ins(%[[ARG0]], %[[ARG1]] : // CHECK-SAME: outs(%[[ARG2]] : -// CHECK-SAME: fn_def_attrs {link_with = "/custom/path/to/ukernels/mm.o"} +// CHECK-SAME: fn_def_attrs {link_with = "{{.*}}mm.o"} // CHECK-SAME: strided_outer_dims(0) // CHECK: return %[[MICRO_KERNEL]] @@ -188,7 +188,7 @@ func.func @zero_fill(%arg0 : tensor<16x16x4x4xbf16>) -> tensor<16x16x4x4xbf16> a // CHECK-NOT: linalg.fill // CHECK: %[[MICRO_KERNEL:.+]] = iree_codegen.ukernel.generic "zero_bf16_64x64" // CHECK-SAME: outs(%[[ARG0]] : -// CHECK-SAME: fn_def_attrs {link_with = "/custom/path/to/ukernels/mm.o"} +// CHECK-SAME: fn_def_attrs {link_with = "{{.*}}mm.o"} // CHECK-SAME: strided_outer_dims(0) // CHECK: return %[[MICRO_KERNEL]] @@ -235,13 +235,13 @@ func.func @zero_fill_with_matmul(%arg0 : tensor<8x16x4x8xbf16>, %arg1 : tensor<1 // CHECK-NOT: linalg.fill // CHECK: %[[ZERO_FILL_MICRO_KERNEL:.+]] = iree_codegen.ukernel.generic "zero_bf16_64x64" // CHECK-SAME: outs(%[[ARG2]] : -// CHECK-SAME: fn_def_attrs {link_with = "/custom/path/to/ukernels/mm.o"} +// CHECK-SAME: fn_def_attrs {link_with = "{{.*}}mm.o"} // CHECK-SAME: strided_outer_dims(0) // CHECK-NOT: linalg.generic // CHECK: %[[MATMUL_MICRO_KERNEL:.+]] = iree_codegen.ukernel.generic "matmul_bf16_bf16_bf16_64x64x64_4x8x4" // CHECK-SAME: ins(%[[ARG0]], %[[ARG1]] : // CHECK-SAME: outs(%[[ZERO_FILL_MICRO_KERNEL]] : -// CHECK-SAME: fn_def_attrs {link_with = "/custom/path/to/ukernels/mm.o"} +// CHECK-SAME: fn_def_attrs {link_with = "{{.*}}mm.o"} // CHECK-SAME: strided_outer_dims(0) // CHECK: return %[[MATMUL_MICRO_KERNEL]] diff --git a/experimental/delegate/CMakeLists.txt b/experimental/delegate/CMakeLists.txt index cef3dd7d4..755792df3 100644 --- a/experimental/delegate/CMakeLists.txt +++ b/experimental/delegate/CMakeLists.txt @@ -22,16 +22,9 @@ if(IREE_HAL_EXECUTABLE_PLUGIN_SYSTEM_LIBRARY) iree_add_all_subdirs() -find_package(XRT) - -add_library(mlp_bf16_aie_delegate SHARED - mlp_aie_bf16_plugin.cpp -) -target_include_directories(mlp_bf16_aie_delegate - PRIVATE - ${IREE_SOURCE_DIR}/runtime/src/ - ${XRT_INCLUDE_DIRS} -) +add_library(mlp_bf16_aie_delegate SHARED mlp_aie_bf16_plugin.cpp) +target_include_directories(mlp_bf16_aie_delegate PRIVATE ${IREE_SOURCE_DIR}/runtime/src + ${IREE_XRT_SOURCE_DIR}/runtime_src/core/include) # NOTE: this is only required because we want this sample to run on all # platforms without needing to change the library name (libfoo.so/foo.dll). @@ -45,17 +38,11 @@ set_target_properties(mlp_bf16_aie_delegate target_link_libraries( mlp_bf16_aie_delegate PRIVATE - XRT::xrt_coreutil - Boost::boost -) + $) set_property(TARGET mlp_bf16_aie_delegate PROPERTY CXX_STANDARD 20) -add_dependencies(mlp_bf16_aie_delegate - aie_delegate_kernels -) -add_dependencies(iree-sample-deps - mlp_bf16_aie_delegate -) +add_dependencies(mlp_bf16_aie_delegate aie_delegate_kernels) +add_dependencies(iree-sample-deps mlp_bf16_aie_delegate) iree_lit_test_suite( NAME diff --git a/experimental/delegate/README.md b/experimental/delegate/README.md index 0f947308d..5536e49b9 100644 --- a/experimental/delegate/README.md +++ b/experimental/delegate/README.md @@ -5,7 +5,7 @@ ### Purpose As an early demonstration of the ability to combine executable code for -heterogenious devices, here we partition a simple model such that most of the +heterogeneous devices, here we partition a simple model such that most of the model compiles for running on CPU, except for the model's matmul, which uses a pre-built AIE kernel. diff --git a/iree_compiler_plugin.cmake b/iree_compiler_plugin.cmake index 7ec4465b4..a14b0c094 100644 --- a/iree_compiler_plugin.cmake +++ b/iree_compiler_plugin.cmake @@ -4,13 +4,23 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -find_package(Boost REQUIRED) -include_directories(${Boost_INCLUDE_DIRS}) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") set(IREE_AMD_AIE_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}") set(IREE_AMD_AIE_RUNTIME_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/runtime/src) set(IREE_MLIR_AIR_SOURCE_DIR "${IREE_AMD_AIE_SOURCE_DIR}/third_party/mlir-air/mlir") +set(IREE_AMD_AIE_ENABLE_XRT_DRIVER OFF) +if("xrt" IN_LIST IREE_EXTERNAL_HAL_DRIVERS) + message(STATUS "Enabling XRT build because it is an enabled HAL driver") + set(IREE_AMD_AIE_ENABLE_XRT_DRIVER ON) +endif() + +if(IREE_AMD_AIE_ENABLE_XRT_DRIVER) + include(iree_aie_xrt) + include(iree_aie_bootgen) +endif() + add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/compiler/plugins/target/AMD-AIE target/AMD-AIE) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tests/samples AMD-AIE/tests/samples) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tests/OPT/failing_tests AMD-AIE/tests/OPT/failing_tests) diff --git a/iree_runtime_plugin.cmake b/iree_runtime_plugin.cmake index b76099120..15a4d07da 100644 --- a/iree_runtime_plugin.cmake +++ b/iree_runtime_plugin.cmake @@ -4,7 +4,13 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# for BUILD_LOCAL_INTERFACE for xrt_coreutil +# (see runtime/src/iree-amd-aie/driver/xrt/CMakeLists.txt) +cmake_minimum_required(VERSION 3.26) + include(FetchContent) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") +include(iree_aie_utils) set(IREE_AMD_AIE_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}") set(IREE_MLIR_AIR_SOURCE_DIR "${IREE_AMD_AIE_SOURCE_DIR}/third_party/mlir-air/mlir") @@ -16,15 +22,8 @@ if("xrt" IN_LIST IREE_EXTERNAL_HAL_DRIVERS) endif() if(IREE_AMD_AIE_ENABLE_XRT_DRIVER) - set(Boost_USE_STATIC_LIBS ON CACHE BOOL "" FORCE) - find_package(XRT REQUIRED) - find_package(Threads REQUIRED) - find_package(Boost REQUIRED COMPONENTS filesystem program_options system) - message(STATUS "Boost include directories:" ${Boost_INCLUDE_DIRS}) - - if(NOT WIN32) - find_package(RapidJSON REQUIRED) - endif() + include(iree_aie_xrt) + include(iree_aie_bootgen) endif() add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/runtime/src AMD-AIE) diff --git a/runtime/src/CMakeLists.txt b/runtime/src/CMakeLists.txt index beb004079..4756a630d 100644 --- a/runtime/src/CMakeLists.txt +++ b/runtime/src/CMakeLists.txt @@ -4,8 +4,6 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -set(IREE_XRT_SOURCE_DIR "${IREE_AMD_AIE_SOURCE_DIR}/third_party/XRT/src") - iree_setup_c_src_root( DEFAULT_EXPORT_SET Runtime DEFAULT_INSTALL_COMPONENT IREEDevLibraries-Runtime diff --git a/runtime/src/iree-amd-aie/aie_runtime/CMakeLists.txt b/runtime/src/iree-amd-aie/aie_runtime/CMakeLists.txt index 0358cf23f..247f43eae 100644 --- a/runtime/src/iree-amd-aie/aie_runtime/CMakeLists.txt +++ b/runtime/src/iree-amd-aie/aie_runtime/CMakeLists.txt @@ -4,508 +4,8 @@ # https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# ############################################################################## -# Prerequisites -# ############################################################################## - -if(NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8) - message( - FATAL_ERROR - "Building on 32bit platforms/toolchains is not supported; if you are seeing this on windows, " - "it's possible you have opened the win32 developer shell rather than the x64 developer shell." - ) -endif() - -# See https://github.com/Xilinx/mlir-aie/pull/1095 -cmake_minimum_required(VERSION 3.23) - -# We use our own, slightly modified, FindOpenSSL because of issues in CMake's -# distribution of the same for versions prior to 3.29. -# https://gitlab.kitware.com/cmake/cmake/-/issues/25702 -set(OPENSSL_USE_STATIC_LIBS TRUE CACHE BOOL "" FORCE) -find_package(OpenSSL) -if(NOT DEFINED OPENSSL_FOUND OR NOT ${OPENSSL_FOUND}) - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") - find_package(OpenSSL) - if(NOT DEFINED USE_IREE_AMD_AIE_FIND_OPENSSL - OR NOT ${USE_IREE_AMD_AIE_FIND_OPENSSL}) - message(FATAL_ERROR "Didn't pickup/use adjacent FindOpenSSL.cmake") - endif() - if(NOT DEFINED OPENSSL_FOUND OR NOT ${OPENSSL_FOUND}) - message(FATAL_ERROR "OpenSSL not found") - endif() -endif() -message(STATUS "OpenSSL include directories:" ${OPENSSL_INCLUDE_DIR}) - -# https://stackoverflow.com/a/49216539/9045206 -function(remove_flag_from_target _target _flag) - get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS) - if(_target_cxx_flags) - list(REMOVE_ITEM _target_cxx_flags ${_flag}) - set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${_target_cxx_flags}") - endif() -endfunction() - -function(replace_string_in_file _file _match_string _replace_string) - if(NOT (EXISTS ${_file})) - message(FATAL_ERROR "file ${_file} does not exist") - endif() - file(READ "${_file}" _file_contents) - if(_file_contents STREQUAL "") - message(FATAL_ERROR "empty file contents for ${_file}") - endif() - string(REPLACE "${_match_string}" "${_replace_string}" _file_contents "${_file_contents}") - if(_file_contents STREQUAL "") - message(FATAL_ERROR "empty replacement contents for ${_file}") - endif() - file(WRITE "${_file}" "${_file_contents}") -endfunction() - -# ############################################################################## -# Bootgen -# ############################################################################## - -set(_bootgen_source_dir ${IREE_AMD_AIE_SOURCE_DIR}/third_party/bootgen) - -# malloc.h is deprecated and should not be used -# https://stackoverflow.com/a/56463133 If you want to use malloc, then include stdlib.h -replace_string_in_file(${_bootgen_source_dir}/cdo-npi.c "#include " "#include ") -replace_string_in_file(${_bootgen_source_dir}/cdo-alloc.c "#include " "#include ") - -file(GLOB _bootgen_sources "${_bootgen_source_dir}/*.c" - "${_bootgen_source_dir}/*.cpp") -# build exe separately -list(REMOVE_ITEM _bootgen_sources "${_bootgen_source_dir}/main.cpp") - -add_library(bootgen-lib STATIC ${_bootgen_sources}) - -if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - target_compile_definitions(bootgen-lib PUBLIC YY_NO_UNISTD_H) -elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") - set(_bootgen_c_warning_ignores - -Wno-cast-qual - -Wno-covered-switch-default - -Wno-date-time - -Wno-deprecated-declarations - -Wno-deprecated-register - -Wno-dynamic-class-memaccess - -Wno-format - -Wno-implicit-fallthrough - -Wno-incompatible-function-pointer-types - -Wno-incompatible-pointer-types-discards-qualifiers - -Wno-misleading-indentation - -Wno-pointer-bool-conversion - -Wno-sign-compare - -Wno-tautological-overlap-compare - -Wno-unused) - set(_bootgen_cxx_warning_ignores - -Wno-deprecated-copy -Wno-non-virtual-dtor -Wno-overloaded-virtual - -Wno-register -Wno-reorder -Wno-suggest-override) -endif() -target_compile_options(bootgen-lib PUBLIC - $<$:${_bootgen_c_warning_ignores}> - $<$:${_bootgen_c_warning_ignores};${_bootgen_cxx_warning_ignores}>) -target_include_directories(bootgen-lib PUBLIC ${_bootgen_source_dir} - ${OPENSSL_INCLUDE_DIR}) -target_compile_definitions(bootgen-lib PUBLIC OPENSSL_USE_APPLINK) -target_link_libraries(bootgen-lib PUBLIC OpenSSL::SSL OpenSSL::applink) - -iree_cc_binary( - NAME - amdaie_bootgen - SRCS - "${_bootgen_source_dir}/main.cpp" - COPTS - -fexceptions - INSTALL_COMPONENT - IREETools-Runtime -) - -target_link_libraries(iree-amd-aie_aie_runtime_amdaie_bootgen PRIVATE bootgen-lib) -set_target_properties(iree-amd-aie_aie_runtime_amdaie_bootgen - PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/tools") - -# ############################################################################## -# cdo-drver -# ############################################################################## - -replace_string_in_file(${_bootgen_source_dir}/cdo-driver/cdo_driver.c "\"(Write64)" "\"cdo-driver: (Write64)") -replace_string_in_file(${_bootgen_source_dir}/cdo-driver/cdo_driver.c "\"(MaskWrite64)" "\"cdo-driver: (MaskWrite64)") -replace_string_in_file(${_bootgen_source_dir}/cdo-driver/cdo_driver.c "\"(NOP Command)" "\"cdo-driver: (NOP Command)") -replace_string_in_file(${_bootgen_source_dir}/cdo-driver/cdo_driver.c "\"(BlockWrite-DMAWriteCmd)" "\"cdo-driver: (BlockWrite-DMAWriteCmd)") -replace_string_in_file(${_bootgen_source_dir}/cdo-driver/cdo_driver.c "Data@ 0x%\" PRIxPTR \"" "Data") -replace_string_in_file(${_bootgen_source_dir}/cdo-driver/cdo_driver.c "(uintptr_t)(pData + i)," "") -replace_string_in_file(${_bootgen_source_dir}/cdo-driver/cdo_driver.c "\" Address:" "\"cdo-driver: Address:") -replace_string_in_file(${_bootgen_source_dir}/cdo-driver/cdo_driver.c "\"(BlockSet-DMAWriteCmd)" "\"cdo-driver: (BlockSet-DMAWriteCmd)") -replace_string_in_file(${_bootgen_source_dir}/cdo-driver/cdo_driver.c "\"(MaskPoll64)" "\"cdo-driver: (MaskPoll64)") - -add_library(cdo_driver STATIC ${_bootgen_source_dir}/cdo-driver/cdo_driver.c) -target_include_directories(cdo_driver PUBLIC ${_bootgen_source_dir}/cdo-driver) -set_target_properties(cdo_driver PROPERTIES LINKER_LANGUAGE C) -iree_install_targets( - TARGETS cdo_driver - COMPONENT IREEBundledLibraries - EXPORT_SET Compiler -) - -# ############################################################################## -# aie-rt -# ############################################################################## - -set(common_DIR ${CMAKE_CURRENT_LIST_DIR}) -set(_aie_rt_source_dir ${IREE_AMD_AIE_SOURCE_DIR}/third_party/aie-rt) -set(_aie_rt_binary_include_dir ${CMAKE_CURRENT_BINARY_DIR}/iree_aie_runtime/include) - -include(${_aie_rt_source_dir}/fal/cmake/collect.cmake) -set(XAIENGINE_BUILD_SHARED OFF CACHE BOOL "" FORCE) -add_subdirectory(${_aie_rt_source_dir}/driver/src iree_aie_runtime) - -# https://github.com/Xilinx/aie-rt/issues/4 -set(_incorrect_port_map " -static const XAie_StrmSwPortMap AieMlMemTileStrmSwSlavePortMap[] = -{ - { - /* PhyPort 0 */ - .PortType = DMA, - .PortNum = 0, - }, - { - /* PhyPort 1 */ - .PortType = DMA, - .PortNum = 1, - }, - { - /* PhyPort 2 */ - .PortType = DMA, - .PortNum = 2, - }, - { - /* PhyPort 3 */ - .PortType = DMA, - .PortNum = 3, - }, - { - /* PhyPort 4 */ - .PortType = DMA, - .PortNum = 4, - }, - { - /* PhyPort 5 */ - .PortType = DMA, - .PortNum = 5, - }, - { - /* PhyPort 6 */ - .PortType = CTRL, - .PortNum = 0, - }, - { - /* PhyPort 7 */ - .PortType = SOUTH, - .PortNum = 0, - }, - { - /* PhyPort 8 */ - .PortType = SOUTH, - .PortNum = 1, - }, - { - /* PhyPort 9 */ - .PortType = SOUTH, - .PortNum = 2, - }, - { - /* PhyPort 10 */ - .PortType = SOUTH, - .PortNum = 3, - }, - { - /* PhyPort 11 */ - .PortType = NORTH, - .PortNum = 0, - }, - { - /* PhyPort 12 */ - .PortType = NORTH, - .PortNum = 1, - }, - { - /* PhyPort 13 */ - .PortType = NORTH, - .PortNum = 2, - }, - { - /* PhyPort 14 */ - .PortType = NORTH, - .PortNum = 3, - }, - { - /* PhyPort 15 */ - .PortType = NORTH, - .PortNum = 4, - }, - { - /* PhyPort 16 */ - .PortType = NORTH, - .PortNum = 5, - }, - { - /* PhyPort 17 */ - .PortType = TRACE, - .PortNum = 0, - }, -}; -") - -set(_correct_port_map " -static const XAie_StrmSwPortMap AieMlMemTileStrmSwSlavePortMap[] = { - { - /* PhyPort 0 */ - .PortType = DMA, - .PortNum = 0, - }, - { - /* PhyPort 1 */ - .PortType = DMA, - .PortNum = 1, - }, - { - /* PhyPort 2 */ - .PortType = DMA, - .PortNum = 2, - }, - { - /* PhyPort 3 */ - .PortType = DMA, - .PortNum = 3, - }, - { - /* PhyPort 4 */ - .PortType = DMA, - .PortNum = 4, - }, - { - /* PhyPort 5 */ - .PortType = DMA, - .PortNum = 5, - }, - { - /* PhyPort 6 */ - .PortType = CTRL, - .PortNum = 0, - }, - { - /* PhyPort 7 */ - .PortType = SOUTH, - .PortNum = 0, - }, - { - /* PhyPort 8 */ - .PortType = SOUTH, - .PortNum = 1, - }, - { - /* PhyPort 9 */ - .PortType = SOUTH, - .PortNum = 2, - }, - { - /* PhyPort 10 */ - .PortType = SOUTH, - .PortNum = 3, - }, - { - /* PhyPort 11 */ - .PortType = SOUTH, - .PortNum = 4, - }, - { - /* PhyPort 12 */ - .PortType = SOUTH, - .PortNum = 5, - }, - { - /* PhyPort 13 */ - .PortType = NORTH, - .PortNum = 0, - }, - { - /* PhyPort 14 */ - .PortType = NORTH, - .PortNum = 1, - }, - { - /* PhyPort 15 */ - .PortType = NORTH, - .PortNum = 2, - }, - { - /* PhyPort 16 */ - .PortType = NORTH, - .PortNum = 3, - }, - { - /* PhyPort 17 */ - .PortType = TRACE, - .PortNum = 0, - }, -}; -") - -replace_string_in_file( - ${_aie_rt_source_dir}/driver/src/global/xaie2ipugbl_reginit.c - "${_incorrect_port_map}" "${_correct_port_map}") - -get_target_property(_aie_runtime_compile_options xaiengine COMPILE_OPTIONS) -list(REMOVE_ITEM _aie_runtime_compile_options -D__AIEBAREMETAL__) - -set(XAIE_DEBUG "" CACHE STRING "") -if(XAIE_DEBUG STREQUAL "ON") - set(XAIE_DEBUG "__AIEDEBUG__") -endif() - -set_target_properties( - xaiengine - PROPERTIES COMPILE_OPTIONS "${_aie_runtime_compile_options}") -target_compile_definitions(xaiengine PRIVATE ${XAIE_DEBUG} __AIECDO__) -set(xaiengine_c_warning_ignores - -Wno-unused-but-set-variable - -Wno-incompatible-pointer-types) -target_compile_options(xaiengine PRIVATE ${xaiengine_c_warning_ignores}) -# For -target_include_directories(xaiengine PRIVATE SYSTEM ${_bootgen_source_dir}) -target_link_libraries(xaiengine PRIVATE cdo_driver) - -set(_cdo_externs "\ -#include \n -extern void cdo_Write32(uint64_t Addr, uint32_t Data); \ -extern void cdo_MaskWrite32(uint64_t Addr, uint32_t Mask, uint32_t Data); \ -extern void cdo_MaskPoll(uint64_t Addr, uint32_t Mask, uint32_t Expected_Value, uint32_t TimeoutInMS); \ -extern void cdo_BlockWrite32(uint64_t Addr, uint32_t* pData, uint32_t size); \ -extern void cdo_BlockSet32(uint64_t Addr, uint32_t Data, uint32_t size);") - -replace_string_in_file( - ${_aie_rt_source_dir}/driver/src/io_backend/ext/xaie_cdo.c - "#include \"cdo_rts.h\"" "${_cdo_externs}") - -iree_install_targets( - TARGETS xaiengine - COMPONENT IREEBundledLibraries - EXPORT_SET Runtime -) - -# ############################################################################## -# xclbinutil -# ############################################################################## - -if(IREE_AMD_AIE_ENABLE_XRT_DRIVER) - # Note: we do not simply add the subdirectory and use the imported target because - # XRT will build in its entirety when we do `ninja install` for IREE. - - # obv we have python but XRT uses this var to look for an ancient version of pybind (and fail) - replace_string_in_file(${IREE_XRT_SOURCE_DIR}/python/pybind11/CMakeLists.txt "if (HAS_PYTHON)" "if (FALSE)") - - # remove ssl dep - replace_string_in_file(${IREE_XRT_SOURCE_DIR}/runtime_src/tools/xclbinutil/XclBinUtilMain.cxx "bValidateSignature == true" "false") - - set(_xclbinutil_source_dir ${IREE_XRT_SOURCE_DIR}/runtime_src/tools/xclbinutil) - - # transformcdo target - add_subdirectory(${_xclbinutil_source_dir}/aie-pdi-transform aie-pdi-transform) - - # otherwise the various stois that read these will explode... - # XRT/src/runtime_src/tools/xclbinutil/XclBinClass.cxx#L55 - file(READ ${IREE_XRT_SOURCE_DIR}/CMakeLists.txt _xrt_cmake_file_contents) - string(REGEX MATCH "XRT_VERSION_MAJOR ([0-9]+)" XRT_VERSION_MAJOR ${_xrt_cmake_file_contents}) - # note CMAKE_MATCH_0 is the whole match... - set(XRT_VERSION_MAJOR ${CMAKE_MATCH_1}) - string(REGEX MATCH "XRT_VERSION_MINOR ([0-9]+)" XRT_VERSION_MINOR ${_xrt_cmake_file_contents}) - set(XRT_VERSION_MINOR ${CMAKE_MATCH_1}) - string(REGEX MATCH "XRT_VERSION_PATCH ([0-9]+)" XRT_VERSION_PATCH ${_xrt_cmake_file_contents}) - set(XRT_VERSION_PATCH ${CMAKE_MATCH_1}) - set(XRT_VERSION_STRING ${XRT_VERSION_MAJOR}.${XRT_VERSION_MINOR}.${XRT_VERSION_PATCH} CACHE INTERNAL "") - configure_file(${IREE_XRT_SOURCE_DIR}/CMake/config/version.h.in ${_xclbinutil_source_dir}/version.h) - - file( - GLOB - _xclbinutil_srcs - "${_xclbinutil_source_dir}/DTC*.cxx" - "${_xclbinutil_source_dir}/FDT*.cxx" - "${_xclbinutil_source_dir}/CBOR.cxx" - "${_xclbinutil_source_dir}/RapidJsonUtilities.cxx" - "${_xclbinutil_source_dir}/KernelUtilities.cxx" - "${_xclbinutil_source_dir}/ElfUtilities.cxx" - "${_xclbinutil_source_dir}/FormattedOutput.cxx" - "${_xclbinutil_source_dir}/ParameterSectionData.cxx" - "${_xclbinutil_source_dir}/Section.cxx" - # Note: Due to linking dependency issue, this entry needs to be before the other sections - "${_xclbinutil_source_dir}/Section*.cxx" - "${_xclbinutil_source_dir}/Resources*.cxx" - "${_xclbinutil_source_dir}/XclBinClass.cxx" - NoOpXclBinSignature.cxx - "${_xclbinutil_source_dir}/XclBinUtilities.cxx" - # Unlike bootgen, xclbinutil cannot be built separately as a static archive (I wish!) - # because the linker will DCE static initializers in SectionMemTopology.cxx - # and then --add-replace-section:MEM_TOPOLOGY won't work... - # XRT/src/runtime_src/tools/xclbinutil/SectionMemTopology.cxx#L26-L41 - "${_xclbinutil_source_dir}/xclbinutil.cxx" - "${_xclbinutil_source_dir}/XclBinUtilMain.cxx" - ) - - iree_cc_binary( - NAME - amdaie_xclbinutil - SRCS - ${_xclbinutil_srcs} - COPTS - -fexceptions - -frtti - INSTALL_COMPONENT - IREETools-Runtime - PUBLIC - ) - - set(THREADS_PREFER_PTHREAD_FLAG ON) - set(_xclbin_libs - Boost::filesystem - Boost::program_options - Boost::system - Threads::Threads) - set(_xclbinutil_compile_definitions -DBOOST_BIND_GLOBAL_PLACEHOLDERS) - - if(WIN32) - list(APPEND _xclbinutil_compile_definitions -D"/EHsc") - # Uncomment if you get LINK : fatal error LNK1104: cannot open file - # 'libboost_filesystem-vc142-mt-gd-x64-1_74.lib' - # target_compile_definitions(xclbinutil-lib PUBLIC BOOST_ALL_DYN_LINK - else() - list(APPEND _xclbinutil_compile_definitions -DENABLE_JSON_SCHEMA_VALIDATION) - list(APPEND _xclbin_libs transformcdo) - endif() - - target_compile_options(iree-amd-aie_aie_runtime_amdaie_xclbinutil - PRIVATE ${_xclbinutil_compile_definitions}) - target_link_libraries(iree-amd-aie_aie_runtime_amdaie_xclbinutil - PRIVATE ${_xclbin_libs}) - target_include_directories(iree-amd-aie_aie_runtime_amdaie_xclbinutil - PRIVATE ${XRT_BINARY_DIR}/gen - ${Boost_INCLUDE_DIRS} - ${IREE_XRT_SOURCE_DIR}/runtime_src/core/include - ${_xclbinutil_source_dir}) - set_target_properties(iree-amd-aie_aie_runtime_amdaie_xclbinutil - PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/tools") -endif() - -# ############################################################################## -# iree-aie-runtime-static -# ############################################################################## - add_subdirectory(Utils) -if (IREE_BUILD_TESTS) - add_subdirectory(test) -endif() - iree_tablegen_library( NAME AMDAIEEnumsGen @@ -538,6 +38,8 @@ iree_cc_library( add_dependencies(iree-amd-aie_aie_runtime_AMDAIEEnums iree-amd-aie_aie_runtime_AMDAIEEnumsGen) +include(iree_aie_rt) + iree_cc_library( NAME iree_aie_runtime_static @@ -553,9 +55,9 @@ iree_cc_library( mlir_aie_legacy.cc xaie_hwcfg.c INCLUDES - ${_aie_rt_binary_include_dir} + "${_AIE_RT_BINARY_INCLUDE_DIR}" # For - ${_bootgen_source_dir} + ${_BOOTGEN_SOURCE_DIR} DEPS ::AMDAIEEnums PUBLIC @@ -568,3 +70,8 @@ target_link_libraries(iree-amd-aie_aie_runtime_iree_aie_runtime_static # consumers (like tests) to link individually target_link_libraries(iree-amd-aie_aie_runtime_iree_aie_runtime_static PUBLIC LLVMSupport) + +if (IREE_BUILD_TESTS) + add_subdirectory(test) +endif() + diff --git a/runtime/src/iree-amd-aie/aie_runtime/NoOpXclBinSignature.cxx b/runtime/src/iree-amd-aie/aie_runtime/NoOpXclBinSignature.cxx deleted file mode 100644 index beb746d49..000000000 --- a/runtime/src/iree-amd-aie/aie_runtime/NoOpXclBinSignature.cxx +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2024 The IREE Authors -// -// 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 - -#include "XclBinSignature.h" - -void signXclBinImage(const std::string& _fileOnDisk, - const std::string& _sPrivateKey, - const std::string& _sCertificate, - const std::string& _sDigestAlgorithm, - bool _bEnableDebugOutput) {} -void verifyXclBinImage(const std::string& _fileOnDisk, - const std::string& _sCertificate, - bool _bEnableDebugOutput) {} -void dumpSignatureFile(const std::string& _fileOnDisk, - const std::string& _signatureFile) {} -void getXclBinPKCSStats(const std::string& _xclBinFile, - XclBinPKCSImageStats& _xclBinPKCSImageStats) {} \ No newline at end of file diff --git a/runtime/src/iree-amd-aie/aie_runtime/iree_aie_configure.cc b/runtime/src/iree-amd-aie/aie_runtime/iree_aie_configure.cc index b511027b8..4aba9c188 100644 --- a/runtime/src/iree-amd-aie/aie_runtime/iree_aie_configure.cc +++ b/runtime/src/iree-amd-aie/aie_runtime/iree_aie_configure.cc @@ -213,7 +213,8 @@ LogicalResult addElfToTile(const AMDAIEDeviceModel &deviceModel, const TileLoc &tileLoc, const Path &elfPath, bool aieSim) { auto devInst = const_cast(&deviceModel.devInst); - TRY_XAIE_API_LOGICAL_RESULT(XAie_LoadElf, devInst, tileLoc, elfPath.c_str(), + TRY_XAIE_API_LOGICAL_RESULT(XAie_LoadElf, devInst, tileLoc, + elfPath.string().c_str(), /*loadSym*/ aieSim); return success(); } @@ -361,7 +362,7 @@ void initializeCDOGenerator(byte_ordering endianness, bool cdoDebug) { LogicalResult generateCDOBinary(const Path &outputPath, const std::function &cb) { - startCDOFileStream(outputPath.c_str()); + startCDOFileStream(outputPath.string().c_str()); FileHeader(); // Never generate a completely empty CDO file. If the file only contains a // header, then bootgen flags it as invalid. diff --git a/runtime/src/iree-amd-aie/aie_runtime/iree_aie_runtime.cc b/runtime/src/iree-amd-aie/aie_runtime/iree_aie_runtime.cc index 6ec2616f0..7beb9cdc0 100644 --- a/runtime/src/iree-amd-aie/aie_runtime/iree_aie_runtime.cc +++ b/runtime/src/iree-amd-aie/aie_runtime/iree_aie_runtime.cc @@ -86,6 +86,10 @@ ::StrmSwPortType checkedAieRtCompatStrmSwPortType( return static_cast<::StrmSwPortType>(t); } +#ifdef _WIN32 +#define __PRETTY_FUNCTION__ __FUNCSIG__ +#endif + // macro so that line numbers are preserved for where the check fails #define CheckedAieRtCompatStrmSwPortType(t) \ checkedAieRtCompatStrmSwPortType(t, __FILE__, __LINE__, __PRETTY_FUNCTION__) @@ -119,22 +123,22 @@ AMDAIEDeviceModel::AMDAIEDeviceModel( uint8_t nMemTileRows, uint8_t nShimTileRows, int partitionNumCols, int partitionStartCol, uint64_t partBaseAddr, uint64_t npiAddr, bool aieSim, bool xaieDebug, AMDAIEDevice device) - : configPtr{.AieGen = aieGen, - .BaseAddr = baseAddr, - .ColShift = colShift, - .RowShift = rowShift, - .NumRows = devNRows, - .NumCols = devNColumns, - .ShimRowNum = 0, - .MemTileRowStart = memTileRowStart, - .MemTileNumRows = nMemTileRows, + : configPtr{/*AieGen*/aieGen, + /*BaseAddr*/baseAddr, + /*ColShift*/colShift, + /*RowShift*/rowShift, + /*NumRows*/devNRows, + /*NumCols*/devNColumns, + /*ShimRowNum*/0, + /*MemTileRowStart*/memTileRowStart, + /*MemTileNumRows*/nMemTileRows, // TODO(max): use XAIE*_AIE_TILE_ROW_START here // instead of this (once we eliminate legacy devices) - .AieTileRowStart = + /*AieTileRowStart*/ static_cast(memTileRowStart + nMemTileRows), - .AieTileNumRows = static_cast(devNRows - nMemTileRows - + /*AieTileNumRows*/static_cast(devNRows - nMemTileRows - nShimTileRows), - .PartProp = {}}, + /*PartProp*/{}}, devInst{}, device(device) { TRY_XAIE_API_FATAL_ERROR(XAie_SetupPartitionConfig, &devInst, partBaseAddr, diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/CMakeLists.txt b/runtime/src/iree-amd-aie/aie_runtime/test/CMakeLists.txt index 24f4383d4..eb0d8ae90 100644 --- a/runtime/src/iree-amd-aie/aie_runtime/test/CMakeLists.txt +++ b/runtime/src/iree-amd-aie/aie_runtime/test/CMakeLists.txt @@ -35,7 +35,7 @@ iree_cc_test( NAME test_0335_aie_dma_tile_dma_packet_switch_mode SRCS - test_0335_aie_dma_tile_dma_packet_switch_mode.cc + test_packet_switch_mode.cc DEPS iree-amd-aie::aie_runtime::iree_aie_runtime_static ) @@ -44,7 +44,7 @@ iree_lit_test( NAME test_0335_aie_dma_tile_dma_packet_switch_mode_lit_test TEST_FILE - test_0335_aie_dma_tile_dma_packet_switch_mode.cc + test_packet_switch_mode.cc TOOLS ::test_0335_aie_dma_tile_dma_packet_switch_mode FileCheck @@ -56,7 +56,7 @@ iree_cc_test( NAME test_1114_aie_stream_switch_packet_switch_control_packets SRCS - test_1114_aie_stream_switch_packet_switch_control_packets.cc + test_control_packets.cc DEPS iree-amd-aie::aie_runtime::iree_aie_runtime_static ) @@ -65,7 +65,7 @@ iree_lit_test( NAME test_1114_aie_stream_switch_packet_switch_control_packets_lit_test TEST_FILE - test_1114_aie_stream_switch_packet_switch_control_packets.cc + test_control_packets.cc TOOLS ::test_1114_aie_stream_switch_packet_switch_control_packets FileCheck @@ -93,5 +93,3 @@ iree_lit_test( LABELS "hostonly" ) - -add_subdirectory(cdo) diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/cdo/CMakeLists.txt b/runtime/src/iree-amd-aie/aie_runtime/test/cdo/CMakeLists.txt deleted file mode 100644 index 664c78da6..000000000 --- a/runtime/src/iree-amd-aie/aie_runtime/test/cdo/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2024 The IREE Authors -# -# 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 - -iree_cc_binary( - NAME - aie_cdo_gen_test - SRCS - aie_cdo_gen_test.cxx - DEPS - iree::target::amd-aie::aie::AIEDialectIR - iree_target_amd-aie_Target_AIETargets -) - -file(GLOB _mlir_files *.mlir) - -iree_lit_test_suite( - NAME - lit - SRCS - ${_mlir_files} - TOOLS - ::aie_cdo_gen_test - FileCheck - LABELS - "hostonly" -) diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/test_1114_aie_stream_switch_packet_switch_control_packets.cc b/runtime/src/iree-amd-aie/aie_runtime/test/test_control_packets.cc old mode 100755 new mode 100644 similarity index 94% rename from runtime/src/iree-amd-aie/aie_runtime/test/test_1114_aie_stream_switch_packet_switch_control_packets.cc rename to runtime/src/iree-amd-aie/aie_runtime/test/test_control_packets.cc index 1c3d269f1..f9c204a1b --- a/runtime/src/iree-amd-aie/aie_runtime/test/test_1114_aie_stream_switch_packet_switch_control_packets.cc +++ b/runtime/src/iree-amd-aie/aie_runtime/test/test_control_packets.cc @@ -44,8 +44,6 @@ clang-format on */ -#include - #include #include "interpreter_op_impl.h" @@ -90,11 +88,20 @@ int main(int argc, char **argv) { AieRC RC = XAIE_OK; // setup aie-rt - XAie_SetupConfig(ConfigPtr, XAIE_DEV_GEN_AIEML, XAIE2IPU_BASE_ADDR, - XAIE2IPU_COL_SHIFT, XAIE2IPU_ROW_SHIFT, XAIE2IPU_NUM_COLS, - XAIE2IPU_NUM_ROWS, XAIE2IPU_SHIM_ROW, - XAIE2IPU_MEM_TILE_ROW_START, XAIE2IPU_MEM_TILE_NUM_ROWS, - XAIE2IPU_AIE_TILE_ROW_START, XAIE2IPU_AIE_TILE_NUM_ROWS); + XAie_Config ConfigPtr = { + /*AieGen*/ XAIE_DEV_GEN_AIEML, + /*BaseAddr*/ XAIE2IPU_BASE_ADDR, + /*ColShift*/ XAIE2IPU_COL_SHIFT, + /*RowShift*/ XAIE2IPU_ROW_SHIFT, + /*NumRows*/ XAIE2IPU_NUM_ROWS, + /*NumCols*/ XAIE2IPU_NUM_COLS, + /*ShimRowNum*/ XAIE2IPU_SHIM_ROW, + /*MemTileRowStart*/ XAIE2IPU_MEM_TILE_ROW_START, + /*MemTileNumRows*/ XAIE2IPU_MEM_TILE_NUM_ROWS, + /*AieTileRowStart*/ XAIE2IPU_AIE_TILE_ROW_START, + /*AieTileNumRows*/ XAIE2IPU_AIE_TILE_NUM_ROWS, + /*PartProp*/ {0}, + }; XAie_InstDeclare(DevInst, &ConfigPtr); RC = XAie_CfgInitialize(&DevInst, &ConfigPtr); @@ -227,7 +234,6 @@ int main(int argc, char **argv) { while (TimeOut && XAie_DmaWaitForDone(&DevInst, Loc, MM2S_CHNUM, DMA_MM2S, 1000)) { - sleep(1); TimeOut--; } diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/test_0335_aie_dma_tile_dma_packet_switch_mode.cc b/runtime/src/iree-amd-aie/aie_runtime/test/test_packet_switch_mode.cc similarity index 95% rename from runtime/src/iree-amd-aie/aie_runtime/test/test_0335_aie_dma_tile_dma_packet_switch_mode.cc rename to runtime/src/iree-amd-aie/aie_runtime/test/test_packet_switch_mode.cc index 84d40700b..75afaaa10 100644 --- a/runtime/src/iree-amd-aie/aie_runtime/test/test_0335_aie_dma_tile_dma_packet_switch_mode.cc +++ b/runtime/src/iree-amd-aie/aie_runtime/test/test_packet_switch_mode.cc @@ -149,11 +149,20 @@ using namespace mlir::iree_compiler::AMDAIE; /************************** Function Definitions *****************************/ int main(int argc, char **argv) { // setup aie-rt - XAie_SetupConfig(ConfigPtr, XAIE_DEV_GEN_AIEML, XAIE2IPU_BASE_ADDR, - XAIE2IPU_COL_SHIFT, XAIE2IPU_ROW_SHIFT, XAIE2IPU_NUM_COLS, - XAIE2IPU_NUM_ROWS, XAIE2IPU_SHIM_ROW, - XAIE2IPU_MEM_TILE_ROW_START, XAIE2IPU_MEM_TILE_NUM_ROWS, - XAIE2IPU_AIE_TILE_ROW_START, XAIE2IPU_AIE_TILE_NUM_ROWS); + XAie_Config ConfigPtr = { + /*AieGen*/ XAIE_DEV_GEN_AIEML, + /*BaseAddr*/ XAIE2IPU_BASE_ADDR, + /*ColShift*/ XAIE2IPU_COL_SHIFT, + /*RowShift*/ XAIE2IPU_ROW_SHIFT, + /*NumRows*/ XAIE2IPU_NUM_ROWS, + /*NumCols*/ XAIE2IPU_NUM_COLS, + /*ShimRowNum*/ XAIE2IPU_SHIM_ROW, + /*MemTileRowStart*/ XAIE2IPU_MEM_TILE_ROW_START, + /*MemTileNumRows*/ XAIE2IPU_MEM_TILE_NUM_ROWS, + /*AieTileRowStart*/ XAIE2IPU_AIE_TILE_ROW_START, + /*AieTileNumRows*/ XAIE2IPU_AIE_TILE_NUM_ROWS, + /*PartProp*/ {0}, + }; XAie_InstDeclare(DevInst, &ConfigPtr); AieRC RC = XAie_CfgInitialize(&DevInst, &ConfigPtr); diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/test_transaction.cc b/runtime/src/iree-amd-aie/aie_runtime/test/test_transaction.cc index f5e331811..7af4fc9be 100644 --- a/runtime/src/iree-amd-aie/aie_runtime/test/test_transaction.cc +++ b/runtime/src/iree-amd-aie/aie_runtime/test/test_transaction.cc @@ -52,11 +52,20 @@ using namespace mlir::iree_compiler::AMDAIE; int main(int argc, char **argv) { // setup aie-rt - XAie_SetupConfig(ConfigPtr, XAIE_DEV_GEN_AIEML, XAIE2IPU_BASE_ADDR, - XAIE2IPU_COL_SHIFT, XAIE2IPU_ROW_SHIFT, XAIE2IPU_NUM_COLS, - XAIE2IPU_NUM_ROWS, XAIE2IPU_SHIM_ROW, - XAIE2IPU_MEM_TILE_ROW_START, XAIE2IPU_MEM_TILE_NUM_ROWS, - XAIE2IPU_AIE_TILE_ROW_START, XAIE2IPU_AIE_TILE_NUM_ROWS); + XAie_Config ConfigPtr = { + /*AieGen*/ XAIE_DEV_GEN_AIEML, + /*BaseAddr*/ XAIE2IPU_BASE_ADDR, + /*ColShift*/ XAIE2IPU_COL_SHIFT, + /*RowShift*/ XAIE2IPU_ROW_SHIFT, + /*NumRows*/ XAIE2IPU_NUM_ROWS, + /*NumCols*/ XAIE2IPU_NUM_COLS, + /*ShimRowNum*/ XAIE2IPU_SHIM_ROW, + /*MemTileRowStart*/ XAIE2IPU_MEM_TILE_ROW_START, + /*MemTileNumRows*/ XAIE2IPU_MEM_TILE_NUM_ROWS, + /*AieTileRowStart*/ XAIE2IPU_AIE_TILE_ROW_START, + /*AieTileNumRows*/ XAIE2IPU_AIE_TILE_NUM_ROWS, + /*PartProp*/ {0}, + }; XAie_InstDeclare(DevInst, &ConfigPtr); XAie_CfgInitialize(&DevInst, &ConfigPtr); diff --git a/runtime/src/iree-amd-aie/aie_runtime/test/utest.cc b/runtime/src/iree-amd-aie/aie_runtime/test/utest.cc index e26717697..5fd71a33c 100755 --- a/runtime/src/iree-amd-aie/aie_runtime/test/utest.cc +++ b/runtime/src/iree-amd-aie/aie_runtime/test/utest.cc @@ -248,11 +248,11 @@ int main(int argc, char** argv) { /*npiAddr*/ XAIE2IPU_NPI_BASEADDR, /*aieSim*/ false, /*xaieDebug*/ false, mlir::iree_compiler::AMDAIE::AMDAIEDevice::npu1_4col); - XAie_LocType tile00 = {.Row = 0, .Col = col}; - XAie_LocType tile01 = {.Row = 1, .Col = col}; - XAie_LocType tile02 = {.Row = 2, .Col = col}; - XAie_Lock lock01 = {.LockId = 0, .LockVal = 1}; - XAie_Lock lock10 = {.LockId = 1, .LockVal = 0}; + XAie_LocType tile00 = {/*Row*/ 0, /*Col*/ col}; + XAie_LocType tile01 = {/*Row*/ 1, /*Col*/ col}; + XAie_LocType tile02 = {/*Row*/ 2, /*Col*/ col}; + XAie_Lock lock01 = {/*LockId*/ 0, /*LockVal*/ 1}; + XAie_Lock lock10 = {/*LockId*/ 1, /*LockVal*/ 0}; EnAXIdebug(); setEndianness(Little_Endian); @@ -269,7 +269,7 @@ int main(int argc, char** argv) { XAie_DmaDesc dmaDesc; XAie_DmaDescInit(&deviceModel.devInst, &dmaDesc, tile02); - lock10 = XAie_Lock{.LockId = 1, .LockVal = -1}; + lock10 = XAie_Lock{/*LockId*/ 1, /*LockVal*/ -1}; dmaDesc.DmaMod->SetLock(&dmaDesc, lock10, lock01, /*AcqEn*/ 1, /*RelEn*/ 0); // address 1024 is the beginning of the core's stack diff --git a/runtime/src/iree-amd-aie/driver/xrt/CMakeLists.txt b/runtime/src/iree-amd-aie/driver/xrt/CMakeLists.txt index 8eeb833f9..dbf33eddd 100644 --- a/runtime/src/iree-amd-aie/driver/xrt/CMakeLists.txt +++ b/runtime/src/iree-amd-aie/driver/xrt/CMakeLists.txt @@ -42,8 +42,6 @@ iree_cc_library( "nop_executable_cache.cc" "pipeline_layout.h" "pipeline_layout.cc" - INCLUDES - "${XRT_INCLUDE_DIRS}" DEPS iree::base iree::base::core_headers @@ -54,12 +52,12 @@ iree_cc_library( iree::hal::utils::file_transfer iree::hal iree-amd-aie::schemas::xrt_executable_def_c_fbs - XRT::xrt_coreutil - Boost::boost + # hide the target from all exports so it doesn't need to be installed + # (effectively only available for link time symbol resolution) + # note this requires CMake >= 3.26 + $ COPTS - # currenly this is needed, it can be removed after this issue is resolved - # https://github.com/Xilinx/XRT/issues/7810 - -frtti - -fexceptions + $<$:-fexceptions -frtti> + $<$:/EHsc /GR> PUBLIC ) diff --git a/third_party/openssl b/third_party/openssl new file mode 160000 index 000000000..0e04e1015 --- /dev/null +++ b/third_party/openssl @@ -0,0 +1 @@ +Subproject commit 0e04e101507df752500093ff4b04cce5a898abaa