Skip to content

Update aie and llvm (#533) #26

Update aie and llvm (#533)

Update aie and llvm (#533) #26

# Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: MIT
name: Build and Test Compiler Only
on:
push:
branches:
- main
pull_request:
types: [assigned, opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
jobs:
build-repo:
name: Build and Test
runs-on: ubuntu-${{ matrix.ubuntu_version }}
strategy:
fail-fast: false
matrix:
build_type: [ Assert, Release ]
ubuntu_version: [ 20.04, 22.04 ]
steps:
# Clone the repo and its submodules. Do shallow clone to save clone
# time.
- name: Get repo
uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: "true"
- name: Upgrade gcc
if: matrix.ubuntu_version == '20.04'
run: |
sudo apt install build-essential manpages-dev software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
GCC_VERSION=11
sudo apt update && sudo apt install gcc-$GCC_VERSION g++-$GCC_VERSION
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 \
--slave /usr/bin/g++ g++ /usr/bin/g++-9 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-9 \
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-9 \
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 110 \
--slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION \
--slave /usr/bin/gcov gcov /usr/bin/gcov-$GCC_VERSION \
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-$GCC_VERSION \
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-$GCC_VERSION
- name: Install packages
run: sudo apt-get install -y libboost-all-dev clang lld && sudo apt-get clean
- name: Install Ninja
uses: llvm/actions/install-ninja@55d844821959226fab4911f96f37071c1d4c3268
- name: Get Submodule Hash
id: get-submodule-hash
run: echo "::set-output name=hash::$(md5sum $(echo utils/clone-llvm.sh))"
shell: bash
- name: Ccache for C++ compilation
uses: hendrikmuhs/ccache-action@4687d037e4d7cf725512d9b819137a3af34d39b3
with:
key: ${{ matrix.build_type }}-${{ runner.os }}-${{ matrix.ubuntu_version }}
max-size: 1G
- name: Get mlir-aie
id: clone-mlir-aie
run: utils/clone-mlir-aie.sh
shell: bash
- name: Install pip packages
run: |
pushd mlir-aie
pip install -r python/requirements.txt
popd
- name: Get LLVM
id: clone-llvm
run: utils/clone-llvm.sh
shell: bash
- name: Rebuild and Install LLVM
run: utils/github-build-llvm.sh
- name: Rebuild and Install libxaie
run: utils/github-clone-build-libxaie.sh
- name: Rebuild and Install mlir-aie
run: |
mkdir -p mlir-aie/build
mkdir -p mlir-aie/install
pushd mlir-aie/build
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DAIE_COMPILER=NONE \
-DAIE_LINKER=NONE \
-DHOST_COMPILER=NONE \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_MODULE_PATH=`pwd`/../cmake/modulesXilinx \
-DMLIR_DIR=`pwd`/../../llvm/install/lib/cmake/mlir/ \
-DLLVM_DIR=`pwd`/../../llvm/install/lib/cmake/llvm/ \
-DCMAKE_LINKER=lld \
-DLLVM_EXTERNAL_LIT=$(which lit) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DLibXAIE_x86_64_DIR=`pwd`/../../aienginev2/install/lib \
-DCMAKE_INSTALL_PREFIX=`pwd`/../install
ninja install
popd
rm -rf mlir-aie/build
# Build the repo test target in debug mode to build and test.
- name: Build and test (Assert)
if: matrix.build_type == 'Assert'
run: |
mkdir build_assert
pushd build_assert
cmake .. \
-GNinja \
-DCMAKE_TOOLCHAIN_FILE=`pwd`/../cmake/modules/toolchain_x86_64.cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_MODULE_PATH=`pwd`/../mlir-aie/cmake/modulesXilinx \
-DMLIR_DIR=`pwd`/../llvm/install/lib/cmake/mlir/ \
-DLLVM_DIR=`pwd`/../llvm/install/lib/cmake/llvm/ \
-DAIE_DIR=`pwd`/../mlir-aie/install/lib/cmake/aie/ \
-DLibXAIE_ROOT=`pwd`/../aienginev2/install \
-DAIR_RUNTIME_TARGETS:STRING="x86_64" \
-Dx86_64_TOOLCHAIN_FILE=`pwd`/../cmake/modules/toolchain_x86_64.cmake \
-DLLVM_EXTERNAL_LIT=$(which lit) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_INSTALL_PREFIX=install
ninja
ninja check-air-cpp
ninja check-air-mlir
ninja check-air-python
popd
env:
LD_LIBRARY_PATH: ${{ github.workspace }}/aienginev2/install/lib
# Build the repo test target in release mode to build and test.
- name: Build and test (Release)
if: matrix.build_type == 'Release'
run: |
mkdir build_release
pushd build_release
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=`pwd`/../cmake/modules/toolchain_x86_64.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DCMAKE_MODULE_PATH=`pwd`/../mlir-aie/cmake/modulesXilinx \
-DMLIR_DIR=`pwd`/../llvm/install/lib/cmake/mlir/ \
-DLLVM_DIR=`pwd`/../llvm/install/lib/cmake/llvm/ \
-DAIE_DIR=`pwd`/../mlir-aie/install/lib/cmake/aie/ \
-DLibXAIE_ROOT=`pwd`/../aienginev2/install \
-DAIR_RUNTIME_TARGETS:STRING="x86_64" \
-Dx86_64_TOOLCHAIN_FILE=`pwd`/../cmake/modules/toolchain_x86_64.cmake \
-DLLVM_EXTERNAL_LIT=$(which lit) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_INSTALL_PREFIX=install
make -j$(nproc)
make check-air-cpp check-air-mlir check-air-python
popd
env:
LD_LIBRARY_PATH: ${{ github.workspace }}/aienginev2/install/lib