diff --git a/test/lit.cfg.py b/test/lit.cfg.py index ccba23966..26e6b9c19 100644 --- a/test/lit.cfg.py +++ b/test/lit.cfg.py @@ -89,14 +89,16 @@ [xbutil, "examine"], stdout=subprocess.PIPE, stderr=subprocess.PIPE ) result = result.stdout.decode("utf-8").split("\n") - p = re.compile("\[.+:.+:.+\].+Phoenix.+Yes") + p = re.compile("\[.+:.+:.+\].+Phoenix") for l in result: m = p.match(l) if m: print("Found Ryzen AI device:", m.group().split()[0]) config.available_features.add("ryzen_ai") if config.enable_run_xrt_tests: - run_on_ipu = "flock /tmp/ipu.lock /opt/xilinx/run_on_ipu.sh" + run_on_ipu = ( + f"flock /tmp/ipu.lock {config.air_src_root}/utils/run_on_ipu.sh" + ) else: print("Skipping execution of Ryzen AI tests (ENABLE_RUN_XRT_TESTS=OFF)") break diff --git a/utils/run_on_ipu.sh b/utils/run_on_ipu.sh new file mode 100755 index 000000000..c559d5345 --- /dev/null +++ b/utils/run_on_ipu.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# (c) Copyright 2023 Advanced Micro Devices, Inc. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# duplicate of mlir-aie/utils/run_on_ipu.sh + +FIRMWARE_DIR=/lib/firmware/amdipu/1502 +XRT_DIR=/opt/xilinx/xrt +source $XRT_DIR/setup.sh + +rm_xclbin() { + XCLBIN_FN=$1 + if [ -f "$XCLBIN_FN" ] && [ x"${XCLBIN_FN##*.}" == x"xclbin" ]; then + UUID=$($XRT_DIR/bin/xclbinutil --info -i $XCLBIN_FN | grep 'UUID (xclbin)' | awk '{print $3}') + rm -rf "$(readlink -f $FIRMWARE_DIR/$UUID.xclbin)" + unlink $FIRMWARE_DIR/$UUID.xclbin + fi + + # -xtype l tests for links that are broken (it is the opposite of -type) + find $FIRMWARE_DIR -xtype l -delete; +} + +if [ x"$1" == x"--clean-xclbin" ]; then + rm_xclbin $2 + exit 0 +fi + +XCLBIN_FN="" +for f in "$@"; do + if [ -f "$f" ]; then + filename=$(basename "$f") + extension="${f##*.}" + if [ x"$extension" = x"xclbin" ]; then + XCLBIN_FN="$filename" + $XRT_DIR/amdxdna/setup_xclbin_firmware.sh -dev Phoenix -xclbin $XCLBIN_FN + fi + fi +done + +"$@" +err=$? + +if [ x"$XCLBIN_FN" != x"" ]; then + rm_xclbin $XCLBIN_FN +fi + +exit $err