Xilinx / mlir-aie

An MLIR-based toolchain for AMD AI Engine-enabled devices.
Other
296 stars 84 forks source link

How to execute a VCK5000-based mlir-tutorial? #1838

Open shibizhao opened 2 days ago

shibizhao commented 2 days ago

Hi, I am new of the mlir-aie. And I have installed the mlir-aie according to the document. And I would like to execute the mlir_tutorials on VCK5000.

First, I check the installed "install/runtime_lib" directory. There is only an "x86_64-hsa".

Secondly, I found the makefile-common is used for aarch64 (I guess it is for VCK190). So I would like to know how I should modify the makefile-common for VCK5000.

Thanks.

shibizhao commented 2 days ago

Update, I tried to modify the makefile-common as:

# Contains common definitions used across the Makefiles of all tutorials.

# MLIR-AIE install directory. If you have sourced utils/env_setup.sh before
# running make, the following should work to find the AIE install directory.
AIE_RUNTIME_LIB ?= $(shell realpath $(dir $(shell which aie-opt))/../runtime_lib)
AIE_INSTALL ?= $(AIE_RUNTIME_LIB)/x86_64-hsa

# VITIS related variables
VITIS_ROOT ?= $(shell realpath $(dir $(shell which vitis))/../)
VITIS_AIETOOLS_DIR ?= ${VITIS_ROOT}/aietools
VITIS_AIE_INCLUDE_DIR ?= ${VITIS_ROOT}/aietools/data/versal_prod/lib
VITIS_AIE2_INCLUDE_DIR ?= ${VITIS_ROOT}/aietools/data/aie_ml/lib

#${VITIS_ROOT}/gnu/aarch64/lin/aarch64-linux/aarch64-xilinx-linux/

# The libstdc++ version that is installed in the sysroot given above. This is
# used for include and library paths. If you built the sysroot with Vitis
# 2022.2 and PetaLinux 2022.2, libstdc++ 11.2.0 will be installed. 
# LIBCXX_VERSION ?= 3.4.30

# The following flags are passed to both AI core and host compilation for
# aiecc.py invocations.
AIECC_FLAGS += --host-target=x86_64-linux-gnu

CHESSCC_FLAGS = -f -p me -P ${VITIS_AIE_INCLUDE_DIR} -I ${VITIS_AIETOOLS_DIR}/include
CHESS_FLAGS = -P ${VITIS_AIE_INCLUDE_DIR}

# The following additional flags are only applied for host code.
AIECC_HOST_FLAGS += \
    -I$(AIE_INSTALL)/test_lib/include \
    -I${AIE_INSTALL}/xaiengine/include \
    --gcc-toolchain=/usr \
    -L$(AIE_INSTALL)/test_lib/lib -ltest_lib 

# Add the
# necessary search paths for the sysroot so clang++ can find the aarch64
# includes and libraries. Some of these shouldn't be necessary, except that
# sysroot shipped with Vitis is slightly broken, so clang can't find things
# automatically just using --gcc-toolchain
AIECC_HOST_FLAGS += \
    -I/usr/include/c++/12 \
    -I/usr/include \
    -I/usr/include/x86_64-linux-gnu/c++/12 \
    -L/usr/lib/x86_64-linux-gnu/ \
    -B/usr/lib/x86_64-linux-gnu/

And I entered to tutorial-1 dir and compiled the elf:

(sandbox) (mlir-aie-dev) bizhao.shi@server:~/research/compiler/mlir-aie/mlir_tutorials_vck5000/tutorial-1$ make core_1_4.elf
aiecc.py -j4 aie.mlir
Found xchesscc at /rshome/software/Xilinx/Vitis/2023.2/aietools
 MLIR compilation: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:-- 0:00:01 0/1 1 Workerwarning: overriding the module target triple with pdarch-unknown-unknown-elf [-Woverride-module]
1 warning generated.
 MLIR compilation: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:-- 0:00:01 0/1 1 WorkerWarning in "../../../../../../software/Xilinx/Vitis/2023.2/aietools/data/versal_prod/lib/me_chess.h", line 647, column 131: ignoring attribute [[deprecated]] on class declaration
 MLIR compilation: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:-- 0:00:02 0/1 1 WorkerWarning in "../../../../../../software/Xilinx/Vitis/2023.2/aietools/data/versal_prod/lib/me_common.h", line 63, column 132: ignoring attribute [[deprecated]] on class declaration
Warning in "../../../../../../software/Xilinx/Vitis/2023.2/aietools/data/versal_prod/lib/me_common.h", line 96, column 131: ignoring attribute [[deprecated]] on class declaration
 AIE Compilation: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00 0:00:03 2/2 4 Workers

Maybe it works. But when I tried to compile tutorial-1.exe, there was an error:

(sandbox) (mlir-aie-dev) bizhao.shi@server:~/research/compiler/mlir-aie/mlir_tutorials_vck5000/tutorial-1$ make tutorial-1.exe
aiecc.py -j4 --host-target=x86_64-linux-gnu aie.mlir -I/rshome/bizhao.shi/research/compiler/mlir-aie/install/runtime_lib/x86_64-hsa/test_lib/include -I/rshome/bizhao.shi/research/compiler/mlir-aie/install/runtime_lib/x86_64-hsa/xaiengine/include --gcc-toolchain=/usr -L/rshome/bizhao.shi/research/compiler/mlir-aie/install/runtime_lib/x86_64-hsa/test_lib/lib -ltest_lib  -I/usr/include/c++/12 -I/usr/include -I/usr/include/x86_64-linux-gnu/c++/12 -L/usr/lib/x86_64-linux-gnu/ -B/usr/lib/x86_64-linux-gnu/ ./test.cpp -o tutorial-1.exe
Found xchesscc at /rshome/software/Xilinx/Vitis/2023.2/aietools
 MLIR compilation: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:-- 0:00:01 0/1 1 Workerwarning: overriding the module target triple with pdarch-unknown-unknown-elf [-Woverride-module]
1 warning generated.
 MLIR compilation: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:-- 0:00:01 0/1 1 WorkerWarning in "../../../../../../software/Xilinx/Vitis/2023.2/aietools/data/versal_prod/lib/me_chess.h", line 647, column 131: ignoring attribute [[deprecated]] on class declaration
 MLIR compilation: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:-- 0:00:02 0/1 1 WorkerWarning in "../../../../../../software/Xilinx/Vitis/2023.2/aietools/data/versal_prod/lib/me_common.h", line 63, column 132: ignoring attribute [[deprecated]] on class declaration
Warning in "../../../../../../software/Xilinx/Vitis/2023.2/aietools/data/versal_prod/lib/me_common.h", line 96, column 131: ignoring attribute [[deprecated]] on class declaration
 AIE Compilation: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:-- 0:00:00 0/2 4 Workersclang: error: no such file or directory: '/rshome/bizhao.shi/research/compiler/mlir-aie/install/runtime_lib/x86_64/test_lib/lib/libmemory_allocator_ion.a'
Error encountered while running: clang++ -std=c++17 --target=x86_64-linux-gnu /rshome/bizhao.shi/research/compiler/mlir-aie/install/runtime_lib/x86_64/test_lib/lib/libmemory_allocator_ion.a -I/rshome/bizhao.shi/research/compiler/mlir-aie/install/runtime_lib/x86_64/xaiengine/include -L/rshome/bizhao.shi/research/compiler/mlir-aie/install/runtime_lib/x86_64/xaiengine/lib -L/rshome/software/Xilinx/Vitis/2023.2/aietools/lib/lnx64.o -Wl,-R/rshome/bizhao.shi/research/compiler/mlir-aie/install/runtime_lib/x86_64/xaiengine/lib -I/rshome/bizhao.shi/research/compiler/mlir-aie/mlir_tutorials_vck5000/tutorial-1/aie.mlir.prj -fuse-ld=lld -lm -lxaiengine -D__AIEARCH__=10 -I/rshome/bizhao.shi/research/compiler/mlir-aie/install/runtime_lib/x86_64-hsa/test_lib/include -I/rshome/bizhao.shi/research/compiler/mlir-aie/install/runtime_lib/x86_64-hsa/xaiengine/include --gcc-toolchain=/usr -L/rshome/bizhao.shi/research/compiler/mlir-aie/install/runtime_lib/x86_64-hsa/test_lib/lib -ltest_lib -I/usr/include/c++/12 -I/usr/include -I/usr/include/x86_64-linux-gnu/c++/12 -L/usr/lib/x86_64-linux-gnu/ -B/usr/lib/x86_64-linux-gnu/ ./test.cpp -o tutorial-1.exe
 AIE Compilation: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:-- 0:00:00 0/2 4 Workers
make: *** [Makefile:24: tutorial-1.exe] Error 1

But there is not a subdirectory named "x86_64" in the runtime_lib.

I am confused.