Skip to content

Commit

Permalink
hardcode npu1 for now (different pcie id)
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Aug 23, 2024
1 parent 9f2e389 commit fff8d22
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
strategy:
fail-fast: true
env:
XILINXD_LICENSE_FILE: /home/svcnod/Xilinx.lic
XILINXD_LICENSE_FILE: /opt/xilinx/aie.lic
steps:
- name: "Checking out repository" # for test scripts
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
Expand Down
26 changes: 19 additions & 7 deletions build_tools/ci/run_matmul_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export XRT_HACK_UNSECURE_LOADING_XCLBIN=1

cd ${OUTPUT_DIR}

export MATMUL_TESTS_RUN=0
export MATMUL_TESTS_FAILS=0

###############################################################################
Expand Down Expand Up @@ -353,6 +354,8 @@ function run_matmul_test() {
exit 1
fi

export MATMUL_TESTS_RUN=$(( $MATMUL_TESTS_RUN+1 ))

# Re-enable exit on failure:
set -e

Expand Down Expand Up @@ -403,37 +406,45 @@ function run_matmul_test() {
--iree-amdaie-enable-ukernels=all"
fi

set +e

echo "**** Generating matmul .vmfb file for ${name} ****"
${IREE_COMPILE_EXE} "${matmul_ir}" \
${compilation_flags} -o "${matmul_vmfb}"


compileResult=$?


# Handle cases other than when compilation is expected to, and does, succeed:
if [ $expect_compile_failure -ne 0 ]; then
if [ $compileResult -ne 0 ]; then
echo "Expected compilation failure, got compilation failure."
return 0
else
echo "Expected compilation failure, got compilation success."
exit 1
export MATMUL_TESTS_FAILS=$(( $MATMUL_TESTS_FAILS+1 ))
return
fi
else
if [ $compileResult -ne 0 ]; then
echo "Expected compilation success, got compilation failure."
exit 1
export MATMUL_TESTS_FAILS=$(( $MATMUL_TESTS_FAILS+1 ))
return
fi
fi

# Renable exit on failure:
set -e
echo "**** Generating calls .vmfb file for ${name} ****"
${IREE_COMPILE_EXE} "${calls_ir}" \
--iree-hal-target-backends=${target_backend} \
-o "${calls_vmfb}"

return_status=$?
if [ $return_status -ne 0 ]; then
echo "'${name}' matmul compile failed!"
export MATMUL_TESTS_FAILS=$(( $MATMUL_TESTS_FAILS+1 ))
return
fi

compiled_time=$(date +%s%3N)

echo "**** Running '${name}' matmul tests ****"
Expand All @@ -444,8 +455,6 @@ function run_matmul_test() {
--device=${device} \
--max_elements_to_check=${max_elements_to_check}"

set +e

total_num_runs=$(( num_repeat_runs * num_corruption_repeat_runs))
echo "**** Running '${name}' matmul test ${total_num_runs} times (command ${COMMAND}) ****"
for i in $(seq 1 $num_repeat_runs); do
Expand Down Expand Up @@ -917,6 +926,9 @@ if [ -d "$VITIS" ]; then

fi

echo "\n\n"

echo "$MATMUL_TESTS_RUN matmul tests run!"
if [ $MATMUL_TESTS_FAILS -ne 0 ]; then
echo "$MATMUL_TESTS_FAILS matmul tests failed! Scroll up and look for the 🦄 and 🐞..."
exit 1
Expand Down
29 changes: 15 additions & 14 deletions compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/XCLBinGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,21 @@ using Path = std::filesystem::path;
namespace {

FailureOr<std::string> getNPUVersion() {
std::string errorMessage;
auto maybeVbnv =
openInputFile("/sys/bus/pci/devices/0000:c5:00.1/vbnv", &errorMessage);
if (!maybeVbnv) {
llvm::errs() << "couldn't read pci info for npu because: " << errorMessage;
return failure();
}

std::string vbnv = std::string{maybeVbnv->getBuffer()};
std::regex rgx("RyzenAI-(.*)");
std::smatch matches;
if (std::regex_search(vbnv, matches, rgx)) return {matches[1]};
llvm::errs() << "couldn't find npu version in " << vbnv;
return failure();
// std::string errorMessage;
// auto maybeVbnv =
// openInputFile("/sys/bus/pci/devices/0000:c5:00.1/vbnv", &errorMessage);
// if (!maybeVbnv) {
// llvm::errs() << "couldn't read pci info for npu because: " << errorMessage;
// return failure();
// }
//
// std::string vbnv = std::string{maybeVbnv->getBuffer()};
// std::regex rgx("RyzenAI-(.*)");
// std::smatch matches;
// if (std::regex_search(vbnv, matches, rgx)) return {matches[1]};
// llvm::errs() << "couldn't find npu version in " << vbnv;
// return failure();
return std::string{"npu1"};
}

FailureOr<std::string> getTargetDir() {
Expand Down

0 comments on commit fff8d22

Please sign in to comment.