nod-ai / iree-amd-aie

IREE plugin repository for the AMD AIE accelerator
Apache License 2.0
64 stars 29 forks source link

Vendor `bootgen` and `xclbinutil` #501

Closed makslevental closed 3 months ago

makslevental commented 3 months ago

This PR adds executable targets to our CMakes to build both xclbinutil and bootgen; previously these were fetched/gotten from a distro of mlir-aie and/or env. We already have these same submodules (XRT and bootgen) so the only thing we're really vendoring here is the CMake. The advantages of this are :

  1. After this PR and a follow-up taking care of me_basic.o (once https://github.com/Xilinx/llvm-aie/pull/109 lands) we will no longer need a distro of mlir-aie (but obv still need the submodule for a little while longer);
    • Also we will be able to run lit tests for xclbin generation (i.e., during the build test step in CI);
  2. We eliminate one dependency on OpenSSL (within XRT's xclbinutil);
  3. We will eventually move to not shelling out to these utilities and just calling the APIs directly (like xaiepy) so this was going to happen anyway[^1].

Note, all of the CMake shenanigans are very necessary because the respective code bases are quite questionable...............

Note also that it's clear XCLBinGenConfig needlessly duplicates many of the options in AMDAIEOptions. I'll get rid of the former in the a follow-up PR (see https://github.com/nod-ai/iree-amd-aie/issues/504).

[^1]: Indeed bootgen is already here as bootgen-lib.

makslevental commented 3 months ago

After an inordinant amount of thrashing, this PR is ready for review @daveliddell @newling @nirvedhmeshram

makslevental commented 3 months ago

Also just making sure this is working e2e for some matmul example for Chess as well locally for you since we dont test that in CI but it is something we definitely care about.

Chess shouldn't be affected at all here but sure I can test that locally.

makslevental commented 3 months ago

Adding the full iree-compile command (that I basically pulled from run_matmul_test.sh):

iree-compile \
  test_matmuls/mm_test1_bf16_f32_m64_n64_k64_ir.mlir \
  --iree-hal-target-backends=amd-aie \
  --iree-amdaie-lower-to-aie-pipeline=air \
  --iree-amdaie-tile-pipeline=pad-pack \
  --iree-amd-aie-peano-install-dir=/tmp/llvm-aie \
  --iree-amd-aie-mlir-aie-install-dir=/tmp/mlir_aie \
  --iree-amd-aie-install-dir=/tmp/iree-install \
  --iree-amd-aie-vitis-install-dir=/opt/Xilinx/Vitis/2023.2 \
  --iree-hal-dump-executable-files-to=test_matmuls \
  --iree-amd-aie-show-invoked-commands \
  -o test_matmuls/mm_test1_bf16_f32_m64_n64_k64.vmfb

I'll note here though that these tests currently do not pass with Peano tip so the iree-amd-aie-peano-install-dir=/tmp/llvm-aie is the same that we have here in CI. This is next on my TODO list (update our CI to use tip Peano).

makslevental commented 3 months ago

Doing

export PATH=/opt/Xilinx/Vitis/2023.2/aietools/bin:$PATH
export VITIS=/opt/Xilinx/Vitis/2023.2

and adding --iree-amd-aie-enable-chess=true to the above command works.

Of course this is all very annoying but I have fixes/QoL improvements for this too in upcoming PRs.