diff --git a/python/compiler/aiecc/main.py b/python/compiler/aiecc/main.py index 5903dde182..fdb936ce03 100644 --- a/python/compiler/aiecc/main.py +++ b/python/compiler/aiecc/main.py @@ -430,7 +430,6 @@ async def chesshack(self, task, llvmir, aie_target): llvmir_chesslinked_path = llvmir + "chesslinked.ll" if not self.opts.execute: return llvmir_chesslinked_path - llvmir = await read_file_async(llvmir) install_path = aie.compiler.aiecc.configure.install_path() runtime_lib_path = os.path.join(install_path, "aie_runtime_lib") @@ -438,12 +437,18 @@ async def chesshack(self, task, llvmir, aie_target): runtime_lib_path, aie_target.upper(), "chess_intrinsic_wrapper.ll" ) - await write_file_async(llvmir, llvmir_chesshack) + llvmir_ir = await read_file_async(llvmir) + llvmir_hacked_ir = downgrade_ir_for_chess(llvmir_ir) + await write_file_async(llvmir_hacked_ir, llvmir_chesshack) + assert os.path.exists(llvmir_chesshack) await self.do_call( task, [ - "llvm-link", + # The path below is cheating a bit since it refers directly to the AIE1 + # version of llvm-link, rather than calling the architecture-specific + # tool version. + opts.aietools_path + "/tps/lnx64/target/bin/LNa64bin/chess-llvm-link", llvmir_chesshack, chess_intrinsic_wrapper_ll_path, "-S", @@ -452,10 +457,6 @@ async def chesshack(self, task, llvmir, aie_target): ], ) - llvmir_chesslinked_ir = await read_file_async(llvmir_chesslinked_path) - llvmir_chesslinked_ir = downgrade_ir_for_chess(llvmir_chesslinked_ir) - await write_file_async(llvmir_chesslinked_ir, llvmir_chesslinked_path) - return llvmir_chesslinked_path async def process_core( @@ -513,9 +514,9 @@ async def process_core( file_core_llvmir_chesslinked = await self.chesshack(task, file_core_llvmir, aie_target) if self.opts.link and self.opts.xbridge: link_with_obj = await extract_input_files(file_core_bcf) - await self.do_call(task, ["xchesscc_wrapper", aie_target.lower(), "+w", self.prepend_tmp("work"), "-d", "-f", "+P", "4", file_core_llvmir_chesslinked, link_with_obj, "+l", file_core_bcf, "-o", file_core_elf]) + await self.do_call(task, ["xchesscc_wrapper", aie_target.lower(), "+w", self.prepend_tmp("work"), "-d", "+Wclang,-xir", "-f", file_core_llvmir_chesslinked, link_with_obj, "+l", file_core_bcf, "-o", file_core_elf]) elif self.opts.link: - await self.do_call(task, ["xchesscc_wrapper", aie_target.lower(), "+w", self.prepend_tmp("work"), "-c", "-d", "-f", "+P", "4", file_core_llvmir_chesslinked, "-o", file_core_obj]) + await self.do_call(task, ["xchesscc_wrapper", aie_target.lower(), "+w", self.prepend_tmp("work"), "-c", "-d", "+Wclang,-xir", "-f", file_core_llvmir_chesslinked, "-o", file_core_obj]) await self.do_call(task, [self.peano_clang_path, "-O2", "--target=" + aie_peano_target, file_core_obj, *clang_link_args, "-Wl,-T," + file_core_ldscript, "-o", file_core_elf]) else: file_core_obj = self.unified_file_core_obj @@ -1113,7 +1114,7 @@ async def run_flow(self): self.unified_file_core_obj = self.prepend_tmp("input.o") if opts.compile and opts.xchesscc: file_llvmir_hacked = await self.chesshack(progress_bar.task, file_llvmir, aie_target) - await self.do_call(progress_bar.task, ["xchesscc_wrapper", aie_target.lower(), "+w", self.prepend_tmp("work"), "-c", "-d", "-f", "+P", "4", file_llvmir_hacked, "-o", self.unified_file_core_obj]) + await self.do_call(progress_bar.task, ["xchesscc_wrapper", aie_target.lower(), "+w", self.prepend_tmp("work"), "-c", "-d", "+Wclang,-xir", "-f", file_llvmir_hacked, "-o", self.unified_file_core_obj]) elif opts.compile: file_llvmir_opt = self.prepend_tmp("input.opt.ll") await self.do_call(progress_bar.task, [self.peano_opt_path, "--passes=default", "-inline-threshold=10", "-S", file_llvmir, "-o", file_llvmir_opt]) diff --git a/tools/chess-clang/CMakeLists.txt b/tools/chess-clang/CMakeLists.txt index 9bda3f7ff0..c3a8360f70 100644 --- a/tools/chess-clang/CMakeLists.txt +++ b/tools/chess-clang/CMakeLists.txt @@ -10,24 +10,4 @@ if(NOT DEFINED CMAKE_CROSSCOMPILE) # These files are only useful on host x86 compiles. install(PROGRAMS xchesscc_wrapper DESTINATION ${PROJECT_BINARY_DIR}/bin) install(PROGRAMS xchesscc_wrapper DESTINATION ${SCRIPT_INSTALL_PATH}) - - set(FILES - chess-clang) - - set(TARGETS ${FILES}) - list(TRANSFORM TARGETS PREPEND ${PROJECT_BINARY_DIR}/bin/) - - # stuff into the build directory - add_custom_target(copy-scripts ALL DEPENDS ${TARGETS}) - foreach(file ${FILES}) - add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/bin/${file} - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${file} - ${PROJECT_BINARY_DIR}/bin/${file} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}) - endforeach() - - # install too! - foreach(file ${FILES}) - install(PROGRAMS ${file} DESTINATION ${SCRIPT_INSTALL_PATH}) - endforeach() endif() \ No newline at end of file diff --git a/tools/chess-clang/chess-clang b/tools/chess-clang/chess-clang deleted file mode 100755 index 3c1a32d546..0000000000 --- a/tools/chess-clang/chess-clang +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -# (c) Copyright 2021 Xilinx Inc. - -# ------------- Secondary Test Implementation, Take File input ----------------- -# Need to find these as they're compiler supplied, although the .ll file is optional -# It could be possible just to ask a user to set these up as Env variables though. -# Ripping arguments from the xchesscc input that we might require, perhaps a -# little brittle for now. -# All of the Include directories -# The chess-proc-dir i.e. the cervino library -#declare -a ArgsArr -#for VAR in "$@" -#do -# if [ ${VAR:0:11} = "-ochesswork" ]; then -# ArgsArr+=( "$VAR" ) -# elif [ ${VAR:0:2} = "-I" ]; then -# ArgsArr+=( "$VAR" ) -# elif [ ${VAR:0:17} = "--chess-proc-dir=" ]; then -# ArgsArr+=( "$VAR" ) -# fi -#done - -# just testing if its feasible to read in a file containing args and use them as -# an arg to the real clang-chess in place of the xchesscc args -# Very simple format at the moment, just a line per arg that's read into the -# array, includes the input file/s -# It may be feasible to generate these args in sycl-chess, place them in tmp -# and then read them in here. This may make life much easier if this script -# gets more complex. -#while IFS= read -r LINE; do - # ArgsArr+=( "$LINE" ) -#done < "$WRAPPER_SCRIPT_BIN/compile_ll_args" - -# --------- First Test Implementation, Simple Arg Manipulation ----------------- -declare -a ArgsArr -for var in "$@" -do - if [ $var = "-xc++" ]; then - echo "" - echo "chess-clang script: removed '-xc++' argument from chess-clang - invocation"; - echo "" - # Force using C++2a instead of C++11, it should be irrelevant when passing - # LLVM IR but it will remain for now so that if someone wishes to compile some - # modern C++ with xchescc for AI Engine they can do so. It also helps to show - # how you can manipulate the chess-clang arguments at the moment. - elif [ $var = "-std=c++11" ]; then - ArgsArr+=( "-std=c++2a" ) - else - ArgsArr+=( "$var" ) - fi -done - -# aie_api.h spews tons of warnings here. -ArgsArr+=( "-Wno-deprecated-declarations" ) - -# Has to be invoked with exec, which means it never returns to this script -# so this has to be the final invocation. -exec $CHESSROOT/target/bin/LNa64bin/chess-clang "${ArgsArr[@]}" \ No newline at end of file diff --git a/tools/chess-clang/xchesscc_wrapper b/tools/chess-clang/xchesscc_wrapper index 1855dfb60f..fa6169c813 100755 --- a/tools/chess-clang/xchesscc_wrapper +++ b/tools/chess-clang/xchesscc_wrapper @@ -5,13 +5,10 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # # (c) Copyright 2021 Xilinx Inc. -# (c) Copyright 2022-2023 Advanced Micro Devices, Inc. +# (c) Copyright 2022-2024 Advanced Micro Devices, Inc. AIETOOLS=`realpath $(dirname $(which xchesscc))/../` -TARGET_AIE_LIBDIR=$AIETOOLS/data/versal_prod/lib -TARGET_AIE2_LIBDIR=$AIETOOLS/data/aie_ml/lib - TARGET=${1^^} shift @@ -23,9 +20,11 @@ fi if [ $TARGET == "AIE" ] then EXTRA_DEFS="-D__AIE_ARCH__=10 -D__AIEARCH__=10" + AIEARCH=versal_prod elif [ $TARGET == "AIE2" ] then EXTRA_DEFS="-D__AIE_ARCH__=20 -D__AIEARCH__=20" + AIEARCH=aie_ml fi if [ -z "$AIETOOLS" ] then @@ -33,19 +32,7 @@ if [ -z "$AIETOOLS" ] exit 1 fi -if [ -z "$AIETOOLS" ] - then - echo "xchesscc_wrapper needs a valid Vitis installation" - exit 1 -fi - -TARGETVAR=TARGET_${TARGET}_LIBDIR -LIBDIR=${!TARGETVAR} +LIBDIR=${AIETOOLS}/data/${AIEARCH}/lib DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -export RDI_DATADIR=$AIETOOLS/data -export UNWRAPPED_XCHESSCC=$AIETOOLS/bin/unwrapped/lnx64.o/xchesscc -export LD_LIBRARY_PATH=$AIETOOLS/lib/lnx64.o:$AIETOOLS/lnx64/tools/dot/lib:$LD_LIBRARY_PATH -# Carefully crafted path so that we can inject other scripts into the chess path, namely chess-clang -export PATH=$DIR:$AIETOOLS/bin/unwrapped/lnx64.o:$AIETOOLS/tps/lnx64/target/bin/LNa64bin -$UNWRAPPED_XCHESSCC -p me -C Release_LLVM -D__AIENGINE__ $EXTRA_DEFS -Y clang=$DIR/chess-clang -P $LIBDIR -d -f $@ +xchesscc --aiearch ${AIEARCH} -p me -C Release_LLVM -D__AIENGINE__ $EXTRA_DEFS -P $LIBDIR -d -f $@