Skip to content

Enable dynamic lock acquisition for ObjectFIFO acquire/release in cores #13997

Enable dynamic lock acquisition for ObjectFIFO acquire/release in cores

Enable dynamic lock acquisition for ObjectFIFO acquire/release in cores #13997

Workflow file for this run

# Copyright (C) 2021 Xilinx, Inc.
# Copyright (C) 2022-2026 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: Lint and Format
permissions:
contents: read
on:
pull_request:
types: [assigned, opened, synchronize, reopened]
workflow_dispatch:
merge_group:
schedule:
# Runs at midnight (00:00) every day
- cron: '0 0 * * *'
env:
# Run apt package manager in the CI in non-interactive mode.
# Otherwise, on Ubuntu 20.04 the installation of tzdata asking question
DEBIAN_FRONTEND: noninteractive
jobs:
lockfiles:
name: Lockfiles match inputs
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: '3.12'
# Regenerate the hash-pinned lockfiles from their source manifests, then
# fail (and post the fix as a PR suggestion) if anything changed. Catches
# drift from source bumps (e.g. Dependabot editing requirements.txt/.in)
# that never regenerated the committed .lock files. The uv version must
# match the one pinned in regenerate_lockfiles.sh, otherwise
# resolution/header differences show up as spurious diffs, so read it
# straight from the script.
- name: Install pinned uv
run: |
UV_VERSION=$(sed -n 's/^UV_VERSION="\(.*\)"$/\1/p' utils/regenerate_lockfiles.sh)
echo "installing uv==${UV_VERSION}"
python -m pip install "uv==${UV_VERSION}"
- name: Regenerate lockfiles
run: utils/regenerate_lockfiles.sh
# Fail on any drift, regardless of which files the PR touched.
# action-suggester uses filter_mode: diff_context and silently passes
# when drift is in files not already in the PR diff (e.g. a Dependabot
# bump that updates requirements.txt but not the compiled .lock).
- name: Fail on lockfile drift
run: |
if ! git diff --exit-code; then
echo "::error::Lockfiles are out of date. Run utils/regenerate_lockfiles.sh and commit the result."
exit 1
fi
# Post the fix as inline PR suggestions (best-effort; does not gate merge).
- name: Suggest lockfile updates
if: failure()
uses: reviewdog/action-suggester@2558ba17e65a9039e73764a73009fc05fef28a46 # v1.24
with:
tool_name: regenerate-lockfiles
level: error
fail_level: any
# Cross-lock check: the regen above proves each lock matches its own
# source, but not that shared ABI-coupled deps (nanobind, pybind11, ...)
# resolve to the SAME version across locks. A per-directory Dependabot
# bump that moves one manifest and not another passes regen but breaks
# the wheel at import time; this guard turns that into a fast failure.
- name: Check shared dependency versions agree
run: python3 utils/check_shared_dep_versions.py
clang-tidy-pylint:
name: Python and C/C++ Lint
runs-on: ubuntu-22.04
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 2
submodules: "true"
- name: Install clang-tidy
run: |
sudo apt-get update
sudo apt-get install -y clang-tidy ninja-build clang libelf-dev
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: '3.12'
- name: Install Python packages
run: |
pip install --upgrade pip
python utils/mlir_aie_wheels/vendor_eudsl.py \
--requirements python/requirements.txt \
--install-non-eudsl
python -m pip install --require-hashes -r python/requirements_dev.lock
- name: Get MLIR
id: mlir-wheels
run: |
VERSION=$(utils/clone-llvm.sh --get-wheel-version)
pip -q download mlir==$VERSION \
-f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro
unzip -q mlir-*.whl
- name: Prepare compile_commands.json
run: |
mkdir -p build/install
pushd build
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON \
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
-DCMAKE_C_VISIBILITY_PRESET=hidden \
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
-DCMAKE_INSTALL_PREFIX=$PWD/install \
-DAIE_COMPILER=NONE \
-DAIE_LINKER=NONE \
-DAIE_ENABLE_AIRBIN=OFF \
-DHOST_COMPILER=NONE \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_MODULE_PATH=`pwd`/../cmake/modulesXilinx \
-DMLIR_DIR=$PWD/../mlir/lib/cmake/mlir \
-DLLVM_DIR=$PWD/../mlir/lib/cmake/llvm \
-DLLVM_EXTERNAL_LIT=$(which lit) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
ninja aie-headers mlir-headers
# Assemble the Python package sources (hand-written + tablegen'd op/enum
# wrappers) into build/python/aie. This needs only tablegen, not a full
# C++ build, so it stays cheap enough for the lint job. pyright resolves
# generated bindings from here; aie._mlir_libs (compiled) is not required
# because the few core-IR symbols it would provide are already handled by
# targeted per-line ignores in the sources.
#
# The MLIRPythonSources.Core.Python[.Extras] targets stage aie.ir,
# aie.passmanager, and the aie.extras package root; the _aie_enum_gen.py
# copy stages the trace/event enum bindings. Without these, those package
# roots don't exist in build/python and the imports fail with
# reportMissingImports (which the per-line reportAttributeAccessIssue
# ignores do not cover).
ninja \
python/AIEPythonSources.Dialects.aie.ops_gen \
python/AIEPythonSources.Dialects.aiex.ops_gen \
python/AIEPythonSources.Dialects.aievec.ops_gen \
python/AIEPythonModules.sources.AIEPythonSources \
python/AIEPythonModules.sources.MLIRPythonSources.Core.Python \
python/AIEPythonModules.sources.MLIRPythonSources.Core.Python.Extras \
python/aie/dialects/_aie_enum_gen.py
popd
- name: Type check Python (pyright)
run: |
# pyrightconfig.json expects the built aie tree at install/python (see
# utils/pyright_stubs/README.md). Point it at the lint build output.
rm -rf install && mkdir install
ln -sfn "$PWD/build/python" install/python
pyright
- name: Analyze
id: clang-tidy-fixes
run: |
git fetch origin main
git diff -U0 origin/main | clang-tidy-diff -p1 -path build -export-fixes fixes.yml
if [ -f fixes.yml ]; then
echo "FIXES=true" | tee $GITHUB_OUTPUT
fi
- name: Upload clang-tidy fixes
if: ${{ steps.clang-tidy-fixes.outputs.FIXES }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
path: fixes.yml
name: clang-tidy-fixes.yml
formatting:
name: Check code format
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Get the project repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 2
submodules: "true"
- name: Install clang-format
uses: aminya/setup-cpp@8170d66c458f4a045220b7b0966c10940bb2a15d # v1.8.1
with:
clangformat: 17.0.1
- name: Setup Python env
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: '3.12'
- name: Check Liquid Syntax
run: python3 utils/check_liquid_syntax.py
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
python -m pip install --require-hashes -r python/requirements_dev.lock
- name: Check filename case conflicts
run: pre-commit run check-case-conflict --all-files --color never
- name: Check filename case conflicts
run: pre-commit run check-case-conflict --all-files --color never
- name: Run git-clang-format
id: git-clang-format
run: |
git fetch origin main
# git clang-format returns an error if changes made?
git clang-format origin/main || true
git diff > clang-format.diff
cat clang-format.diff
- name: Upload clang-format
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
path: clang-format.diff
name: clang_format_diffs
- name: Check C/C++ format
uses: reviewdog/action-suggester@2558ba17e65a9039e73764a73009fc05fef28a46 # v1.24
with:
tool_name: clang-format
level: error
cleanup: true
fail_level: any
- name: Run black format
if: success() || failure()
id: black-format
run: |
pre-commit run black --hook-stage pre-push --all-files --color never || true
git diff > black-format.diff
cat black-format.diff
- name: Upload black-format
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
path: black-format.diff
name: black_format_diffs
- name: Check Python format
if: success() || failure()
uses: reviewdog/action-suggester@2558ba17e65a9039e73764a73009fc05fef28a46 # v1.24
with:
tool_name: black
level: error
fail_level: any
code-coverage:
name: C/C++ test code coverage
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
issues: write
pull-requests: write
steps:
- name: Free disk space
uses: descriptinc/free-disk-space@1b4b157593c6801212a2ed488c205e0a810b4592 # main
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: false
- name: Get the project repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 2
submodules: "true"
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: '3.12'
- name: Install Python and other packages
run: |
pip install --upgrade pip
python utils/mlir_aie_wheels/vendor_eudsl.py \
--requirements python/requirements.txt \
--install-non-eudsl
python -m pip install --require-hashes -r python/requirements_dev.lock
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install -y ninja-build clang lld llvm libelf-dev
- name: Get changed files
id: changed-files
run: |
git fetch origin main
# Because for the life of me I cannot figure out how to read the output of git diff into a bash array.
CHANGED_FILES=$(python utils/get_git_changed_files.py)
echo "changed-files=${CHANGED_FILES}" | tee $GITHUB_OUTPUT
- name: Get MLIR
id: mlir-wheels
run: |
VERSION=$(utils/clone-llvm.sh --get-wheel-version)
pip -q download mlir==$VERSION \
-f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro
unzip -q mlir-*.whl
- name: Ccache for C++ compilation
if: steps.changed-files.outputs.changed-files != ''
uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
with:
key: ${{ runner.os }}-${{ matrix.ubuntu_version }}-${{ steps.get-llvm-commit-hash.outputs.hash }}-code-cov
max-size: 1G
- name: Install our python reqs
if: steps.changed-files.outputs.changed-files != ''
run: |
pip install --upgrade pip
python utils/mlir_aie_wheels/vendor_eudsl.py \
--requirements python/requirements.txt \
--install-non-eudsl
python -m pip install --require-hashes -r python/requirements_dev.lock
- name: Build and generate coverage (Release)
if: steps.changed-files.outputs.changed-files != ''
run: |
mkdir -p build_release/install
cd build_release
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON \
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
-DCMAKE_C_VISIBILITY_PRESET=hidden \
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
-DCMAKE_INSTALL_PREFIX=$PWD/install \
-DAIE_COMPILER=NONE \
-DAIE_LINKER=NONE \
-DHOST_COMPILER=NONE \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_MODULE_PATH=$PWD/../cmake/modulesXilinx \
-DMLIR_DIR=$PWD/../mlir/lib/cmake/mlir \
-DLLVM_DIR=$PWD/../mlir/lib/cmake/llvm \
-DLLVM_USE_LINKER=lld \
-DLLVM_EXTERNAL_LIT=$(which lit) \
\
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld" \
-DBUILD_INSTRUMENTED_COVERAGE=ON \
-DINSTRUMENTED_COVERAGE_FILES="${{ steps.changed-files.outputs.changed-files }}"
# filter out slow tests (e.g. create-flows/vecmul_4x4_slow_test.mlir) due to timeout.
export LIT_OPTS="-sv --timeout 600 --filter-out slow_test"
ninja && ninja generate-aie-coverage-report
cat /home/runner/work/mlir-aie/mlir-aie/build_release/report/summary.txt
- name: Format coverage report
if: steps.changed-files.outputs.changed-files != ''
id: format-report
run: |
sed -i.bak 's/<!doctype html>/<!--<!doctype codecov html>-->/g' /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak 's/<pre>//g' /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak 's/<\/pre>//g' /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak 's/([0-9]*\/[0-9]*)//g' /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak "s/href=/href=''/g" /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
WORKSPACE=$(echo "/home/runner/work/mlir-aie/mlir-aie/" | sed 's/\//\\\//g')
sed -i.bak "s/$WORKSPACE//g" /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
- name: Update PR with coverage results
if: steps.changed-files.outputs.changed-files != '' && github.event.pull_request.head.repo.full_name == github.repository
uses: edumserrano/find-create-or-update-comment@82880b65c8a3a6e4c70aa05a204995b6c9696f53 # v3
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: '<!--<!doctype codecov html>-->'
comment-author: 'github-actions[bot]'
body-path: /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
edit-mode: replace
license-compliance:
name: License Compliance Check
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup Python env
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install "reuse[charset-normalizer]==6.2.0"
- name: Check Licenses
shell: bash
run: |
reuse download --all
reuse lint
- name: Check copyright notice format
run: python utils/check_copyright_format.py