Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ryzen ai sw test branch #9

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .github/workflows/buildAndTestRyzenAISw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Build and Test with Ryzen AI Sofware

on:
push:
branches:
- main
- ryzen-ai-sw-test
# pull_request:
workflow_dispatch:
inputs:
AIE_COMMIT:
description: 'which aie commit to build'
type: string
required: false
default: ''
LIT_FILTER:
description: 'LIT_FILTER for tests (regex of paths in test/)'
type: string
required: false
default: ''

defaults:
run:
shell: bash

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-ryzenai-tools-linux-${{ github.event.number || github.sha }}
cancel-in-progress: true

env:
DEBIAN_FRONTEND: noninteractive

jobs:
build-repo:
name: Build and Test with Ryzen AI Software

runs-on: ubuntu-latest

steps:

- name: Free disk space
uses: descriptinc/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: false

- name: Docker prune
shell: bash
run: |
docker system prune -a -f

- uses: uraimo/[email protected]
name: Build and Test
id: runcmd
with:
distro: none
base_image: ghcr.io/fifield/mlir-aie/ubuntu22-ryzenai-1.3.0ea
githubToken: ${{ github.token }}
dockerRunArgs: |
--mac-address ${{ secrets.XILINX_MAC }}
run: |
cd /workspace

# this is the inverse of `base64 -w 1000000 Xilinx.lic`
# the -w ("wrap after 1000000 cols") is so that there are no spaces in the XILINX_LIC env var
echo -n "${{ secrets.XILINX_LIC }}" | base64 --decode > /workspace/Xilinx.lic
export XILINXD_LICENSE_FILE=/workspace/Xilinx.lic

ccrypt -d -K ${{ secrets.RYZEN_AI_SW_KEY }} /workspace/ryzen_ai-1.3.0ea1.tgz.cpt
tar xvf /workspace/ryzen_ai-1.3.0ea1.tgz
pushd /workspace/ryzen_ai-1.3.0
./install_ryzen_ai_1_3.sh -a yes -p /workspace/venv -l
popd

export LD_LIBRARY_PATH=
export PYTHONPATH=
source /workspace/venv/bin/activate
source /opt/xilinx/xrt/setup.sh

git clone https://github.com/Xilinx/mlir-aie.git
pushd mlir-aie

git checkout ${{ github.ref_name }}
if [ x"${{ inputs.AIE_COMMIT }}" != x"" ]; then
git reset --hard ${{ inputs.AIE_COMMIT }}
fi

git submodule update --init --recursive

pip install onnxruntime==1.17.0
pip install -r python/requirements.txt
pip install -r python/requirements_ml.txt

VERSION=$(utils/clone-llvm.sh --get-wheel-version)
popd

pip -q download mlir==$VERSION \
-f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro
unzip -q mlir-*.whl

mkdir -p /workspace/install
mkdir -p /workspace/build

pushd /workspace/build

cmake /workspace/mlir-aie -G Ninja \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_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" \
-DXRT_ROOT=/opt/xilinx/xrt \
-DAIE_ENABLE_PYTHON_PASSES=OFF \
-DAIE_ENABLE_XRT_PYTHON_BINDINGS=ON \
-DAIE_INCLUDE_INTEGRATION_TESTS=OFF \
-DAIE_VITIS_COMPOONENTS=AIE2 \
-DPython3_EXECUTABLE=$(which python) \
-DLLVM_EXTERNAL_LIT=$(which lit) \
-DCMAKE_INSTALL_PREFIX=/workspace/install \
-DCMAKE_MODULE_PATH=/workspace/mlir-aie/cmake/modulesXilinx \
-DMLIR_DIR=/workspace/mlir/lib/cmake/mlir

ninja install
ninja check-aie

popd
6 changes: 5 additions & 1 deletion aie_kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ function(add_aie_kernels arch)
if(EXISTS "${PROJECT_SOURCE_DIR}/tools/chess-clang/xchesscc_wrapper")
add_custom_target(${arch}_kernels ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mm.o)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mm.o
COMMAND ${PROJECT_SOURCE_DIR}/tools/chess-clang/xchesscc_wrapper ${arch} -I ${VITIS_AIETOOLS_DIR}/include -c ${CMAKE_CURRENT_SOURCE_DIR}/mm.cc -o ${CMAKE_CURRENT_BINARY_DIR}/mm.o
COMMAND ${PROJECT_SOURCE_DIR}/tools/chess-clang/xchesscc_wrapper ${arch}
-aietools ${VITIS_AIETOOLS_DIR}
-I ${VITIS_AIETOOLS_DIR}/include
-c ${CMAKE_CURRENT_SOURCE_DIR}/mm.cc
-o ${CMAKE_CURRENT_BINARY_DIR}/mm.o
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/mm.cc)
add_dependencies(aie-kernels ${arch}_kernels)

Expand Down
1 change: 1 addition & 0 deletions aie_runtime_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function(add_aie_runtime_libs arch)
add_custom_target(${arch}_chess_intrinsic_wrapper ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/chess_intrinsic_wrapper.ll)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/chess_intrinsic_wrapper.ll
COMMAND ${PROJECT_BINARY_DIR}/bin/xchesscc_wrapper ${arch}
-aietools ${AIETOOLS_DIR}
-c ${CMAKE_CURRENT_SOURCE_DIR}/chess_intrinsic_wrapper.cpp
-d # Disassemble output
-f # Use LLVM frontend
Expand Down
2 changes: 1 addition & 1 deletion cmake/modulesXilinx
4 changes: 2 additions & 2 deletions mlir_tutorials/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

config.unsupported = []

if not config.has_libxaie:
config.unsupported = ['tutorials']
if 'AIE' not in config.vitis_components:
config.unsupported = ['mlir-tutorials']
7 changes: 7 additions & 0 deletions mlir_tutorials/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@LIT_SITE_CFG_IN_HEADER@

import sys
import lit.util

config.host_triple = "@LLVM_HOST_TRIPLE@"
config.target_triple = "@TARGET_TRIPLE@"
Expand Down Expand Up @@ -54,6 +55,12 @@ config.extraAieCcFlags = "@extraAieCcFlags@"
config.aieHostTarget = "@AIE_RUNTIME_TEST_TARGET@"
config.aieInstallPrefix = "@CMAKE_INSTALL_PREFIX@"

config.vitis_components = []
if lit.util.pythonize_bool("@AIETools_AIE_FOUND@"):
config.vitis_components.append("AIE")
if lit.util.pythonize_bool("@AIETools_AIE2_FOUND@"):
config.vitis_components.append("AIE2")

# Support substitution of the tools_dir with user parameters. This is
# used when we can't determine the tool dir at configuration time.
try:
Expand Down
16 changes: 13 additions & 3 deletions programming_examples/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,10 @@ def prepend_path(path):
except Exception as e:
print("Peano not found, but expected at ", config.peano_tools_dir)

print("Looking for Chess...")
# test if LM_LICENSE_FILE valid
if config.enable_chess_tests:
if not config.enable_chess_tests:
print("Chess tests disabled")
else:
print("Looking for Chess...")
result = None
if config.vitis_root:
result = shutil.which("xchesscc")
Expand All @@ -265,6 +266,7 @@ def prepend_path(path):
if xilinxd_license_file != None:
llvm_config.with_environment("XILINXD_LICENSE_FILE", xilinxd_license_file)

# test if LM_LICENSE_FILE valid
validate_chess = False
if validate_chess:
import subprocess
Expand All @@ -288,6 +290,14 @@ def prepend_path(path):
else:
print("Chess not found")

# look for aiesimulator
result = shutil.which("aiesimulator")
if result != None:
print("aiesimulator found: " + result)
config.available_features.add("aiesimulator")
else:
print("aiesimulator not found")

tool_dirs = [config.aie_tools_dir, config.peano_tools_dir, config.llvm_tools_dir]
tools = [
"aie-opt",
Expand Down
4 changes: 2 additions & 2 deletions programming_examples/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

config.unsupported = []

if not config.has_libxaie:
config.unsupported = ["programming_examples"]
if 'AIE2' not in config.vitis_components:
config.unsupported = True
6 changes: 6 additions & 0 deletions programming_examples/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ config.extraAieCcFlags = "@extraAieCcFlags@"
config.aieHostTarget = "@AIE_RUNTIME_TEST_TARGET@"
config.aieInstallPrefix = "@CMAKE_INSTALL_PREFIX@"

config.vitis_components = []
if lit.util.pythonize_bool("@AIETools_AIE_FOUND@"):
config.vitis_components.append("AIE")
if lit.util.pythonize_bool("@AIETools_AIE2_FOUND@"):
config.vitis_components.append("AIE2")

# Support substitution of the tools_dir with user parameters. This is
# used when we can't determine the tool dir at configuration time.
try:
Expand Down
4 changes: 2 additions & 2 deletions programming_examples/mlir/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
config.suffixes = ['.lit']
config.unsupported = []

if not config.has_libxaie:
config.unsupported = ['mlir']
if 'AIE' not in config.vitis_components:
config.unsupported = ["mlir"]
16 changes: 13 additions & 3 deletions programming_guide/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,10 @@ def prepend_path(path):
except Exception as e:
print("Peano not found, but expected at ", config.peano_tools_dir)

print("Looking for Chess...")
# test if LM_LICENSE_FILE valid
if config.enable_chess_tests:
if not config.enable_chess_tests:
print("Chess tests disabled")
else:
print("Looking for Chess...")
result = None
if config.vitis_root:
result = shutil.which("xchesscc")
Expand All @@ -265,6 +266,7 @@ def prepend_path(path):
if xilinxd_license_file != None:
llvm_config.with_environment("XILINXD_LICENSE_FILE", xilinxd_license_file)

# test if LM_LICENSE_FILE valid
validate_chess = False
if validate_chess:
import subprocess
Expand All @@ -288,6 +290,14 @@ def prepend_path(path):
else:
print("Chess not found")

# look for aiesimulator
result = shutil.which("aiesimulator")
if result != None:
print("aiesimulator found: " + result)
config.available_features.add("aiesimulator")
else:
print("aiesimulator not found")

tool_dirs = [config.aie_tools_dir, config.peano_tools_dir, config.llvm_tools_dir]
tools = [
"aie-opt",
Expand Down
4 changes: 2 additions & 2 deletions programming_guide/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ config.unsupported = []

config.suffixes = ['.lit']

if not config.has_libxaie:
config.unsupported = ["programming_guide"]
if 'AIE2' not in config.vitis_components:
config.unsupported = True
6 changes: 6 additions & 0 deletions programming_guide/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ config.extraAieCcFlags = "@extraAieCcFlags@"
config.aieHostTarget = "@AIE_RUNTIME_TEST_TARGET@"
config.aieInstallPrefix = "@CMAKE_INSTALL_PREFIX@"

config.vitis_components = []
if lit.util.pythonize_bool("@AIETools_AIE_FOUND@"):
config.vitis_components.append("AIE")
if lit.util.pythonize_bool("@AIETools_AIE2_FOUND@"):
config.vitis_components.append("AIE2")

# Support substitution of the tools_dir with user parameters. This is
# used when we can't determine the tool dir at configuration time.
try:
Expand Down
29 changes: 22 additions & 7 deletions python/compiler/aiecc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,20 +1181,35 @@ def run(mlir_module, args=None):
if args is not None:
opts = aie.compiler.aiecc.cl_arguments.parse_args(args)

opts.aietools_path = ""
# Try to find vitis in the path
ryzen_ai_version = None
opts.aietools_path = None

try:
import ryzen_ai.__about__
version = ryzen_ai.__about__.__version__

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
version = ryzen_ai.__about__.__version__
version = ryzen_ai.__about__.__version__

path = os.path.realpath(ryzen_ai.__path__[0])
print(f"Found Ryzen AI software version {version} at {path}")
# if ryzenai software is pip installed then the path is something like:
# <workdir>/venv/lib/python3.10/site-packages/
opts.aietools_path = os.path.join(path, "..")
except:
print("Ryzen AI software not found.")
pass

# Try to find xchesscc in the path
xchesscc_path = shutil.which("xchesscc")
if xchesscc_path:
xchesscc_bin_path = os.path.dirname(os.path.realpath(xchesscc_path))
xchesscc_path = os.path.dirname(xchesscc_bin_path)
os.environ["AIETOOLS"] = xchesscc_path
print("Found xchesscc at " + xchesscc_path)
print(f"Found xchesscc at {xchesscc_path}")
os.environ["PATH"] = os.pathsep.join([os.environ["PATH"], xchesscc_bin_path])
opts.aietools_path = xchesscc_path
if opts.aietools_path is None:
opts.aietools_path = xchesscc_path
else:
print("xchesscc not found...")
print("xchesscc not found.")

os.environ["AIETOOLS"] = opts.aietools_path

# This path should be generated from cmake
aie_path = aie.compiler.aiecc.configure.install_path()
peano_path = os.path.join(opts.peano_install_dir, "bin")
os.environ["PATH"] = os.pathsep.join([aie_path, os.environ["PATH"]])
Expand Down
2 changes: 1 addition & 1 deletion python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PyYAML>=5.3.1, <=6.0.1
aiofiles
cmake==3.27.9
cmake>=3.29
dataclasses>=0.6, <=0.8
filelock==3.13.1
lit
Expand Down
3 changes: 3 additions & 0 deletions test/benchmarks/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@

config.unsupported = []

if len([c for c in config.vitis_components if c == 'AIE']) == 0:
config.unsupported = True

if not config.enable_chess_tests:
config.unsupported = True
Loading
Loading