Skip to content

Commit

Permalink
Update tests for amdxdna driver (Xilinx#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
fifield authored Feb 7, 2024
1 parent 5ab6e16 commit bbac30c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions utils/run_on_ipu.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bbac30c

Please sign in to comment.