Skip to content

Commit

Permalink
remove xclbin (and XRT) dep
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Oct 12, 2024
1 parent 793714d commit c5aeb01
Show file tree
Hide file tree
Showing 26 changed files with 456 additions and 432 deletions.
46 changes: 9 additions & 37 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
git reset --hard FETCH_HEAD
git -c submodule."third_party/torch-mlir".update=none \
-c submodule."third_party/stablehlo".update=none \
-c submodule."src/runtime_src/core/common/aiebu".update=none \
-c submodule."third_party/XRT".update=none \
submodule update --init --recursive --depth 1 --single-branch -j 10
- name: Install deps
Expand All @@ -64,11 +64,6 @@ jobs:
run: |
pip install "numpy<2" pyyaml "pybind11[global]==2.10.3" nanobind pytest
- name: Peano dep
run: |
bash build_tools/download_peano.sh
echo "PEANO_INSTALL_DIR=$PWD/llvm-aie" >> $GITHUB_ENV
- name: Run Pytest
run: |
pytest build_tools/ci
Expand All @@ -80,6 +75,11 @@ jobs:
key: ${{ env.CACHE_KEY }}
restore-keys: linux-build-test-cpp-

- name: Peano dep
run: |
bash build_tools/download_peano.sh
echo "PEANO_INSTALL_DIR=$PWD/llvm-aie" >> $GITHUB_ENV
- name: Build packages
run: |
export cache_dir="${{ env.CACHE_DIR }}"
Expand Down Expand Up @@ -161,64 +161,36 @@ jobs:
- name : E2E comparison of AIE to llvm-cpu
run: |
source .venv/bin/activate
source /opt/xilinx/xrt/setup.sh
python build_tools/ci/cpu_comparison/run.py \
test_aie_vs_cpu \
$PWD/iree-install \
$PWD/llvm-aie \
--xrt-dir /opt/xilinx/xrt \
--vitis-dir /opt/Xilinx/Vitis/2024.2 \
--reset-npu-between-runs -v
- name: E2E correctness matmul test
run: |
# Without this additional line an error like
#
# [XRT] ERROR: Failed to allocate host memory buffer (mmap(len=10616832, prot=3, flags=8193, offset=4294967296)
# failed (err=11): Resource temporarily unavailable), make sure host bank is enabled (see xbutil configure --host-mem)
# iree-amd-aie/runtime/src/iree-amd-aie/driver/xrt/direct_allocator.cc:179: RESOURCE_EXHAUSTED; could not allocate
# memory for buffer; while invoking C++ function matmul_test.generate_random_matrix; while calling import;
#
# might be observed when too much memory is allocated. This
# error was seen when running a bf16->f32 matmul with m=n=k=2304.
#
# This line was suggested at https://github.com/Xilinx/mlir-air/issues/566
#
# Note that this is only half of the fix. It is also necessary that
# the machine that CI is running on has permission to run this line.
#
# This permission can be adding by adding the line
# ```
# %github ALL=(ALL) NOPASSWD: /usr/bin/prlimit *
# ```
#
# to the file /etc/sudoers.d/github, which can be done by running
# ```
# sudo visudo -f /etc/sudoers.d/github
# ```
# on the github CI machine.
# https://stackoverflow.com/a/17567422
# shim_xdna::bo::map_drm_bo does an mmap with MAP_LOCKED
# which can fail if limit is to low
sudo prlimit -lunlimited --pid $$
source .venv/bin/activate
source /opt/xilinx/xrt/setup.sh
bash build_tools/ci/run_matmul_test.sh \
test_matmuls \
iree-install \
$PWD/llvm-aie \
/opt/xilinx/xrt \
/opt/Xilinx/Vitis/2024.2
- name: Python tests
run: |
source .venv/bin/activate
source /opt/xilinx/xrt/setup.sh
pytest -v tests \
--capture=tee-sys \
--iree-install-dir=$PWD/iree-install \
--peano-install-dir=$PWD/llvm-aie
- name: XRT-LITE tests
run: |
source /opt/xilinx/xrt/setup.sh
DEVICE_TEST_DIR="$PWD/iree-install/device_tests"
for t in $(ls $DEVICE_TEST_DIR); do
$DEVICE_TEST_DIR/$t
Expand Down
18 changes: 3 additions & 15 deletions build_tools/ci/run_matmul_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,11 @@ if [ ! -d "${PEANO}" ]; then
exit 1
fi

# Parameter 4) <xrt-dir>
# Parameter 4) <vitis-install-dir>
if [ -z "${4-}" ]; then
XRT_DIR=/opt/xilinx/xrt
else
XRT_DIR=`realpath "$4"`
fi
if [ -d "$XRT_DIR" ]; then
source $XRT_DIR/setup.sh
fi

# Parameter 5) <vitis-install-dir>
if [ -z "${5-}" ]; then
VITIS=/opt/Xilinx/Vitis/2024.2
else
VITIS=`realpath "$5"`
VITIS=`realpath "$4"`
fi

THIS_DIR="$(cd $(dirname $0) && pwd)"
Expand All @@ -139,9 +129,6 @@ fi

GITHUB_ACTIONS="${GITHUB_ACTIONS:-false}"

# Circumvent xclbin security (no longer needed as of April 2024 XDNA driver)
export XRT_HACK_UNSECURE_LOADING_XCLBIN=1

cd ${OUTPUT_DIR}

export MATMUL_TESTS_RUN=0
Expand Down Expand Up @@ -405,6 +392,7 @@ function run_matmul_test() {
--iree-amd-aie-enable-chess=${use_chess} \
--iree-amdaie-enable-packet-flow=${enable_packet_flow} \
--iree-hal-dump-executable-files-to=$PWD \
--iree-amdaie-device-hal=xrt-lite \
--iree-hal-memoization=false \
--iree-hal-indirect-command-buffers=false \
--mlir-elide-resource-strings-if-larger=10 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ iree_cc_library(
iree::base::core_headers
iree::base::internal::flatcc::building
iree-amd-aie::schemas::xrt_executable_def_c_fbs
iree-amd-aie::schemas::pdi_executable_def_c_fbs
PUBLIC
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,16 @@ struct AMDAIESession
}

void populateHALTargetDevices(IREE::HAL::TargetDeviceList &targets) override {
// #hal.device.target<"xrt", ...
targets.add("xrt", [=] {
options.deviceHal = AMDAIE::AMDAIEOptions::DeviceHAL::XRT;
return AMDAIE::createTarget(options);
});
// #hal.device.target<"xrt-lite", ...
// #hal.executable.target<"amd-aie", ...
targets.add("xrt-lite", [=]() { return AMDAIE::createTarget(options); });
targets.add("xrt-lite", [=] {
options.deviceHal = AMDAIE::AMDAIEOptions::DeviceHAL::XRT_LITE;
return AMDAIE::createTarget(options);
});
}

void populateHALTargetBackends(
Expand Down
Loading

0 comments on commit c5aeb01

Please sign in to comment.