Skip to content

Commit

Permalink
Merge branch 'main' into fix-matmul
Browse files Browse the repository at this point in the history
  • Loading branch information
andrej committed May 16, 2024
2 parents b896b7f + 71c9229 commit a509e4c
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 73 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/buildAndTestMulti.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand All @@ -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
Expand Down
60 changes: 30 additions & 30 deletions .github/workflows/mlirDistro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 9 additions & 1 deletion aie_kernels/mm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include <aie_api/aie.hpp>

#include "zero.cc"

template <typename T_in, typename T_out, unsigned rowA, unsigned colA,
unsigned colB, unsigned r, unsigned s, unsigned t>
void matmul_vectorized(const T_in *__restrict pA, unsigned offsetA,
Expand Down Expand Up @@ -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<ctype_out, 64, 64, 32>(c_out, offsetC); \
}

combos(matmul_vectorized_c_func) combos(zero_vectorized_c_func)

} // extern "C"
34 changes: 34 additions & 0 deletions aie_kernels/zero.cc
Original file line number Diff line number Diff line change
@@ -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 <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <type_traits>

template <typename T, int M, int N, int r>
void zero_vectorized(T *__restrict pC, unsigned offsetC) {
const aie::vector<T, r> zeros = aie::zeros<T, r>();
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
13 changes: 0 additions & 13 deletions lib/Targets/AIETargetCDODirect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<CoreOp>().empty() &&
failed(generateCDOBinary(
Expand Down Expand Up @@ -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<CoreOp>().empty() &&
failed(ctl.addAieElfsToCDO(targetOp, workDirPath, aieSim)))
return failure();
Expand Down
1 change: 0 additions & 1 deletion python/compiler/aiecc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
17 changes: 0 additions & 17 deletions runtime_lib/xaiengine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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)
5 changes: 3 additions & 2 deletions runtime_lib/xaiengine/aiert.cmake
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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()
Expand Down
20 changes: 19 additions & 1 deletion runtime_lib/xaiengine/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
2 changes: 0 additions & 2 deletions tools/aie2xclbin/XCLBinGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions utils/clone-llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

############################################################################################
Expand Down

0 comments on commit a509e4c

Please sign in to comment.