From 896cebb784371bb928653a1b2fc2e870c2322725 Mon Sep 17 00:00:00 2001 From: Abhishek Varma Date: Wed, 15 May 2024 05:39:13 +0000 Subject: [PATCH 1/5] [AMD-AIE] Add zero fill ukernel for iree-amd-aie (#1479) Signed-off-by: Abhishek Varma --- aie_kernels/mm.cc | 10 +++++++++- aie_kernels/zero.cc | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 aie_kernels/zero.cc diff --git a/aie_kernels/mm.cc b/aie_kernels/mm.cc index 90d06b7657..eba9367388 100644 --- a/aie_kernels/mm.cc +++ b/aie_kernels/mm.cc @@ -22,6 +22,8 @@ #include +#include "zero.cc" + template void matmul_vectorized(const T_in *__restrict pA, unsigned offsetA, @@ -273,6 +275,12 @@ extern "C" { 64, 64, 64>(a_in, offsetA, b_in, offsetB, c_out, offsetC); \ } -combos(matmul_vectorized_c_func) +#define zero_vectorized_c_func(ctype_in, mlir_type_in, ctype_out, \ + mlir_type_out, r, s, t) \ + void zero_##mlir_type_out(ctype_out *c_out, unsigned offsetC) { \ + zero_vectorized(c_out, offsetC); \ + } + +combos(matmul_vectorized_c_func) combos(zero_vectorized_c_func) } // extern "C" diff --git a/aie_kernels/zero.cc b/aie_kernels/zero.cc new file mode 100644 index 0000000000..67223d1f30 --- /dev/null +++ b/aie_kernels/zero.cc @@ -0,0 +1,34 @@ +//===- zero.cc --------------------------------------------000---*- C++ -*-===// +// +// This file is licensed under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// Copyright (C) 2024, Advanced Micro Devices, Inc. +// +//===----------------------------------------------------------------------===// + +#ifndef ZERO_CC +#define ZERO_CC + +#include +#include +#include +#include + +template +void zero_vectorized(T *__restrict pC, unsigned offsetC) { + const aie::vector zeros = aie::zeros(); + T *__restrict pC1 = pC + offsetC; + const T *__restrict c_end = pC1 + M * N; + for (; pC1 + r < c_end; pC1 += r) { + aie::store_v(pC1, zeros); + } + // Do a scalar write for any remainder not divisible by vector instruction + // size r + for (; pC1 < c_end; pC1++) { + *pC1 = 0; + } +} + +#endif From ff8fa44631d4cab9365272eaf5df71af716b08ac Mon Sep 17 00:00:00 2001 From: Jeff Fifield Date: Wed, 15 May 2024 05:54:48 -0600 Subject: [PATCH 2/5] Update mlirDistro.yml (#1482) --- .github/workflows/mlirDistro.yml | 60 ++++++++++++++++---------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/mlirDistro.yml b/.github/workflows/mlirDistro.yml index 694b2848cb..7714141c59 100644 --- a/.github/workflows/mlirDistro.yml +++ b/.github/workflows/mlirDistro.yml @@ -100,13 +100,13 @@ jobs: ARCH: AMD64 ENABLE_RTTI: ON - - OS: macos-12 - ARCH: x86_64 - ENABLE_RTTI: ON + # - OS: macos-12 + # ARCH: x86_64 + # ENABLE_RTTI: ON - - OS: macos-12 - ARCH: arm64 - ENABLE_RTTI: ON + # - OS: macos-12 + # ARCH: arm64 + # ENABLE_RTTI: ON - OS: ubuntu-20.04 ARCH: x86_64 @@ -120,13 +120,13 @@ jobs: ARCH: AMD64 ENABLE_RTTI: OFF - - OS: macos-12 - ARCH: x86_64 - ENABLE_RTTI: OFF + # - OS: macos-12 + # ARCH: x86_64 + # ENABLE_RTTI: OFF - - OS: macos-12 - ARCH: arm64 - ENABLE_RTTI: OFF + # - OS: macos-12 + # ARCH: arm64 + # ENABLE_RTTI: OFF steps: @@ -378,9 +378,9 @@ jobs: ARCH: AMD64 ENABLE_RTTI: ON - - OS: macos-12 - ARCH: x86_64 - ENABLE_RTTI: ON + # - OS: macos-12 + # ARCH: x86_64 + # ENABLE_RTTI: ON - OS: ubuntu-20.04 ARCH: x86_64 @@ -390,9 +390,9 @@ jobs: ARCH: AMD64 ENABLE_RTTI: OFF - - OS: macos-12 - ARCH: x86_64 - ENABLE_RTTI: OFF + # - OS: macos-12 + # ARCH: x86_64 + # ENABLE_RTTI: OFF steps: - uses: actions/download-artifact@v3 @@ -438,13 +438,13 @@ jobs: ARCH: AMD64 ENABLE_RTTI: ON - - OS: macos-12 - ARCH: x86_64 - ENABLE_RTTI: ON + # - OS: macos-12 + # ARCH: x86_64 + # ENABLE_RTTI: ON - - OS: macos-12 - ARCH: arm64 - ENABLE_RTTI: ON + # - OS: macos-12 + # ARCH: arm64 + # ENABLE_RTTI: ON - OS: ubuntu-20.04 ARCH: x86_64 @@ -458,13 +458,13 @@ jobs: ARCH: AMD64 ENABLE_RTTI: OFF - - OS: macos-12 - ARCH: x86_64 - ENABLE_RTTI: OFF + # - OS: macos-12 + # ARCH: x86_64 + # ENABLE_RTTI: OFF - - OS: macos-12 - ARCH: arm64 - ENABLE_RTTI: OFF + # - OS: macos-12 + # ARCH: arm64 + # ENABLE_RTTI: OFF permissions: id-token: write From e876089458ff69ff619798da8bd14c2295503f6b Mon Sep 17 00:00:00 2001 From: Jeff Fifield Date: Wed, 15 May 2024 12:36:25 -0600 Subject: [PATCH 3/5] bump llvm (#1488) --- .github/workflows/buildAndTestMulti.yml | 5 +---- utils/clone-llvm.sh | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/buildAndTestMulti.yml b/.github/workflows/buildAndTestMulti.yml index eb4e58d76c..971f3c15c6 100644 --- a/.github/workflows/buildAndTestMulti.yml +++ b/.github/workflows/buildAndTestMulti.yml @@ -39,7 +39,7 @@ jobs: # Run the tests on the Cartesian product of the following matrix: - OS: [ ubuntu-20.04, ubuntu-22.04, macos-12 ] + OS: [ ubuntu-20.04, ubuntu-22.04 ] COMPILER: [ llvm, gcc ] ENABLE_ASSERTIONS: [ ON, OFF ] ENABLE_RTTI: [ ON, OFF ] @@ -61,9 +61,6 @@ jobs: COMPILER: msvc ENABLE_ASSERTIONS: OFF ENABLE_RTTI: OFF - exclude: - - OS: macos-12 - COMPILER: gcc steps: # Clone the repo and its submodules. Do shallow clone to save clone diff --git a/utils/clone-llvm.sh b/utils/clone-llvm.sh index a9385e2739..bfd3dae037 100755 --- a/utils/clone-llvm.sh +++ b/utils/clone-llvm.sh @@ -13,8 +13,8 @@ ##===----------------------------------------------------------------------===## # The LLVM commit to use. -LLVM_PROJECT_COMMIT=1cde1240ed6e45012d7510f4aa39badbdb4a4721 -DATETIME=2024050314 +LLVM_PROJECT_COMMIT=8a71284cb9463a90fab0d9e8edbeb5d879531e32 +DATETIME=2024051512 WHEEL_VERSION=19.0.0.$DATETIME+${LLVM_PROJECT_COMMIT:0:8} ############################################################################################ From aba1887b9750dea8db14fbe16417068f83a6b94c Mon Sep 17 00:00:00 2001 From: Jeff Fifield Date: Wed, 15 May 2024 14:17:33 -0600 Subject: [PATCH 4/5] remove aie_cdo_error_handling.bin from cdo backend (#1489) --- lib/Targets/AIETargetCDODirect.cpp | 13 ------------- python/compiler/aiecc/main.py | 1 - tools/aie2xclbin/XCLBinGen.cpp | 2 -- 3 files changed, 16 deletions(-) diff --git a/lib/Targets/AIETargetCDODirect.cpp b/lib/Targets/AIETargetCDODirect.cpp index 9429698471..6527bcb4bc 100644 --- a/lib/Targets/AIETargetCDODirect.cpp +++ b/lib/Targets/AIETargetCDODirect.cpp @@ -437,11 +437,6 @@ struct AIEControl { TRY_XAIE_API_FATAL_ERROR(XAie_UpdateNpiAddr, &devInst, NPI_ADDR); } - LogicalResult addErrorHandlingToCDO() { - TRY_XAIE_API_LOGICAL_RESULT(XAie_ErrorHandlingInit, &devInst); - return success(); - } - LogicalResult addAieElfToCDO(uint8_t col, uint8_t row, const StringRef elfPath, bool aieSim) { // loadSym: Load symbols from .map file. This argument is not used when @@ -721,12 +716,6 @@ LogicalResult generateCDOBinariesSeparately(AIEControl &ctl, const StringRef workDirPath, DeviceOp &targetOp, bool aieSim, bool enableCores) { - if (failed(generateCDOBinary( - (llvm::Twine(workDirPath) + std::string(1, ps) + - "aie_cdo_error_handling.bin") - .str(), - std::bind(&AIEControl::addErrorHandlingToCDO, ctl)))) - return failure(); if (!targetOp.getOps().empty() && failed(generateCDOBinary( @@ -759,8 +748,6 @@ LogicalResult generateCDOUnified(AIEControl &ctl, const StringRef workDirPath, return generateCDOBinary( (llvm::Twine(workDirPath) + std::string(1, ps) + "aie_cdo.bin").str(), [&ctl, &targetOp, &workDirPath, &aieSim, &enableCores] { - if (failed(ctl.addErrorHandlingToCDO())) - return failure(); if (!targetOp.getOps().empty() && failed(ctl.addAieElfsToCDO(targetOp, workDirPath, aieSim))) return failure(); diff --git a/python/compiler/aiecc/main.py b/python/compiler/aiecc/main.py index 36bfda99a5..7678a8a3a0 100644 --- a/python/compiler/aiecc/main.py +++ b/python/compiler/aiecc/main.py @@ -267,7 +267,6 @@ def emit_design_bif(root_path, has_cores=True, enable_cores=True): {{ name=aie_image, id=0x1c000000 {{ type=cdo - file={root_path}/aie_cdo_error_handling.bin {elf_file} file={root_path}/aie_cdo_init.bin {enable_file} diff --git a/tools/aie2xclbin/XCLBinGen.cpp b/tools/aie2xclbin/XCLBinGen.cpp index a7aa589182..50e8a443ec 100644 --- a/tools/aie2xclbin/XCLBinGen.cpp +++ b/tools/aie2xclbin/XCLBinGen.cpp @@ -527,8 +527,6 @@ static LogicalResult generateXCLBin(MLIRContext *context, ModuleOp moduleOp, << "\t{\n" << "\t\tname=aie_image, id=0x1c000000\n" << "\t\t{ type=cdo\n" - << "\t\t file=" << TK.TempDir - << "/aie_cdo_error_handling.bin\n" << "\t\t file=" << TK.TempDir << "/aie_cdo_elfs.bin\n" << "\t\t file=" << TK.TempDir << "/aie_cdo_init.bin\n" << "\t\t file=" << TK.TempDir << "/aie_cdo_enable.bin\n" From 71c92296473c97ae0ffac6708426fc8d1809d6af Mon Sep 17 00:00:00 2001 From: Stephen Neuendorffer Date: Wed, 15 May 2024 15:12:45 -0700 Subject: [PATCH 5/5] update runtime_lib to support vitis 2024.* (#1491) --- runtime_lib/xaiengine/CMakeLists.txt | 17 ----------------- runtime_lib/xaiengine/aiert.cmake | 5 +++-- runtime_lib/xaiengine/lib/CMakeLists.txt | 20 +++++++++++++++++++- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/runtime_lib/xaiengine/CMakeLists.txt b/runtime_lib/xaiengine/CMakeLists.txt index 3d31afa742..3efb146601 100644 --- a/runtime_lib/xaiengine/CMakeLists.txt +++ b/runtime_lib/xaiengine/CMakeLists.txt @@ -10,26 +10,10 @@ project("xaiengine lib for ${AIE_RUNTIME_TARGET}") include("aiert.cmake") if (${CMAKE_CROSSCOMPILING}) - - #tmp path to header files since we use an older (3_0) version of xaiengine. need to fix when we upgrade to 2023.1 - if(${Vitis_VERSION_MAJOR} EQUAL "2022") - set(aieRTIncludePath "${VITIS_ROOT}/data/embeddedsw/XilinxProcessorIPLib/drivers/aienginev2_v3_0/src" CACHE STRING "AIE-RT include path") - elseif(${Vitis_VERSION_MAJOR} EQUAL "2023") - set(aieRTIncludePath "${VITIS_AIETOOLS_DIR}/include/drivers/aiengine" CACHE STRING "AIE-RT include path") - else() - message(FATAL_ERROR "Unsupported Vitis version: ${Vitis_VERSION_MAJOR}") - endif() - message("Building xaiengine for ${AIE_RUNTIME_TARGET} from Vitis at ${VITIS_ROOT}.") - add_aiert_headers(xaiengine - ${aieRTIncludePath} - ${CMAKE_CURRENT_BINARY_DIR}/include - ${CMAKE_INSTALL_PREFIX}/runtime_lib/${AIE_RUNTIME_TARGET}/xaiengine/include) - add_subdirectory(lib) else() - message("Copying xaiengine for ${AIE_RUNTIME_TARGET} from ${AIERT_LIBS}.") add_aiert_headers(xaiengine ${AIERT_INCLUDE_DIR} @@ -47,7 +31,6 @@ else() # install library and headers install(FILES ${libs} DESTINATION ${CMAKE_INSTALL_PREFIX}/runtime_lib/${AIE_RUNTIME_TARGET}/xaiengine/lib) - endif() add_subdirectory(cdo) \ No newline at end of file diff --git a/runtime_lib/xaiengine/aiert.cmake b/runtime_lib/xaiengine/aiert.cmake index db7c5ef41b..966979feb8 100644 --- a/runtime_lib/xaiengine/aiert.cmake +++ b/runtime_lib/xaiengine/aiert.cmake @@ -1,6 +1,6 @@ function(add_aiert_headers TARGET SRCPATH BUILDPATH INSTALLPATH) - message("${TARGET} ${SRCPATH} ${BUILDPATH}") + message("Installing aie-rt includes for ${TARGET} from ${SRCPATH} in ${BUILDPATH}") file(GLOB libheaders ${SRCPATH}/*.h) file(GLOB libheadersSub ${SRCPATH}/*/*.h) @@ -37,7 +37,8 @@ function(add_aiert_headers TARGET SRCPATH BUILDPATH INSTALLPATH) endfunction() function(add_aiert_library TARGET XAIE_SOURCE) - cmake_parse_arguments(ARG "STATIC" "" "" ${ARGN}) +message("Building aie-rt library for ${TARGET} from ${SRCPATH}") +cmake_parse_arguments(ARG "STATIC" "" "" ${ARGN}) if(ARG_STATIC) set(LIBTYPE STATIC) else() diff --git a/runtime_lib/xaiengine/lib/CMakeLists.txt b/runtime_lib/xaiengine/lib/CMakeLists.txt index e823fea2f1..fc15e941f0 100644 --- a/runtime_lib/xaiengine/lib/CMakeLists.txt +++ b/runtime_lib/xaiengine/lib/CMakeLists.txt @@ -6,7 +6,25 @@ include("../aiert.cmake") -set(XAIE_SOURCE ${VITIS_ROOT}/data/embeddedsw/XilinxProcessorIPLib/drivers/aienginev2_v3_0/src) +#tmp path to header files since we use an older (3_0) version of xaiengine. need to fix when we upgrade to 2023.1 +if(${Vitis_VERSION_MAJOR} EQUAL "2022") + set(XAIE_SOURCE ${VITIS_ROOT}/data/embeddedsw/XilinxProcessorIPLib/drivers/aienginev2_v3_0/src) + set(aieRTIncludePath "${XAIE_SOURCE}") +elseif(${Vitis_VERSION_MAJOR} EQUAL "2023") + set(XAIE_SOURCE ${VITIS_ROOT}/data/embeddedsw/XilinxProcessorIPLib/drivers/aienginev2_v3_0/src) + set(aieRTIncludePath "${VITIS_AIETOOLS_DIR}/include/drivers/aiengine") +elseif(${Vitis_VERSION_MAJOR} EQUAL "2024") + set(XAIE_SOURCE ${VITIS_ROOT}/data/embeddedsw/XilinxProcessorIPLib/drivers/aienginev2_v3_5/src) + set(aieRTIncludePath "${VITIS_AIETOOLS_DIR}/include/drivers/aiengine") +else() + message(FATAL_ERROR "Unsupported Vitis version: ${Vitis_VERSION_MAJOR}") +endif() + +message("Building xaiengine for ${AIE_RUNTIME_TARGET} from Vitis at ${VITIS_ROOT}.") +add_aiert_headers(xaiengine + ${aieRTIncludePath} + ${CMAKE_CURRENT_BINARY_DIR}/include + ${CMAKE_INSTALL_PREFIX}/runtime_lib/${AIE_RUNTIME_TARGET}/xaiengine/include) add_aiert_library(xaiengine ${XAIE_SOURCE})