diff --git a/python/compiler/aiecc/cl_arguments.py b/python/compiler/aiecc/cl_arguments.py index 0a2931bb99..57222bcf20 100644 --- a/python/compiler/aiecc/cl_arguments.py +++ b/python/compiler/aiecc/cl_arguments.py @@ -13,6 +13,16 @@ from aie.compiler.aiecc.configure import * +aie_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "..", "..")) +peano_install_dir = "" +# The expected location in an install area +peano_install_dir = os.path.join(aie_dir, "peano") +if(not os.path.exists(peano_install_dir)): + # The expected location in a build area + peano_install_dir = os.path.realpath(os.path.join(aie_dir, "..", "peano")) +if(not os.path.exists(peano_install_dir)): + peano_install_dir = "peano_not_found" + def parse_args(args=None): if (args is None): args = sys.argv[1:] diff --git a/python/compiler/aiecc/main.py b/python/compiler/aiecc/main.py index 257a5c7e7e..444f28ce7a 100644 --- a/python/compiler/aiecc/main.py +++ b/python/compiler/aiecc/main.py @@ -174,6 +174,10 @@ async def prepare_for_chesshack(self, task): async def process_core(self, core): + peano_path = os.path.join(opts.peano_install_dir, 'bin') + peano_clang_path = os.path.join(peano_path, 'clang') + peano_opt_path = os.path.join(peano_path, 'opt') + peano_llc_path = os.path.join(peano_path, 'llc') async with self.limit: if(self.stopall): return @@ -230,7 +234,7 @@ async def process_core(self, core): await self.do_call(task, ['xchesscc_wrapper', self.aie_target.lower(), '+w', os.path.join(self.tmpdirname, 'work'), '-d', '-f', '+P', '4', 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', self.aie_target.lower(), '+w', os.path.join(self.tmpdirname, 'work'), '-c', '-d', '-f', '+P', '4', file_core_llvmir_chesslinked, '-o', file_core_obj]) - await self.do_call(task, ['clang', '-O2', '--target=' + self.aie_peano_target, file_core_obj, *clang_link_args, + await self.do_call(task, [peano_clang_path, '-O2', '--target=' + self.aie_peano_target, file_core_obj, *clang_link_args, '-Wl,-T,'+file_core_ldscript, '-o', file_core_elf]) else: file_core_obj = self.file_obj @@ -238,21 +242,21 @@ async def process_core(self, core): link_with_obj = self.extract_input_files(file_core_bcf) await self.do_call(task, ['xchesscc_wrapper', self.aie_target.lower(), '+w', os.path.join(self.tmpdirname, 'work'), '-d', '-f', file_core_obj, link_with_obj, '+l', file_core_bcf, '-o', file_core_elf]) elif(opts.link): - await self.do_call(task, ['clang', '-O2', '--target=' + self.aie_peano_target, file_core_obj, *clang_link_args, + await self.do_call(task, [peano_clang_path, '-O2', '--target=' + self.aie_peano_target, file_core_obj, *clang_link_args, '-Wl,-T,'+file_core_ldscript, '-o', file_core_elf]) elif(opts.compile): if(not opts.unified): file_core_llvmir_stripped = self.tmpcorefile(core, "stripped.ll") - await self.do_call(task, ['opt', '--passes=default,strip', '-S', file_core_llvmir, '-o', file_core_llvmir_stripped]) - await self.do_call(task, ['llc', file_core_llvmir_stripped, '-O2', '--march=%s' % self.aie_target.lower(), '--function-sections', '--filetype=obj', '-o', file_core_obj]) + await self.do_call(task, [peano_opt_path, '--passes=default,strip', '-S', file_core_llvmir, '-o', file_core_llvmir_stripped]) + await self.do_call(task, [peano_llc_path, file_core_llvmir_stripped, '-O2', '--march=%s' % self.aie_target.lower(), '--function-sections', '--filetype=obj', '-o', file_core_obj]) else: file_core_obj = self.file_obj if(opts.link and opts.xbridge): link_with_obj = self.extract_input_files(file_core_bcf) await self.do_call(task, ['xchesscc_wrapper', self.aie_target.lower(), '+w', os.path.join(self.tmpdirname, 'work'), '-d', '-f', file_core_obj, link_with_obj, '+l', file_core_bcf, '-o', file_core_elf]) elif(opts.link): - await self.do_call(task, ['clang', '-O2', '--target=' + self.aie_peano_target, file_core_obj, *clang_link_args, + await self.do_call(task, [peano_clang_path, '-O2', '--target=' + self.aie_peano_target, file_core_obj, *clang_link_args, '-Wl,-T,'+file_core_ldscript, '-o', file_core_elf]) self.progress_bar.update(self.progress_bar.task_completed,advance=1) @@ -634,6 +638,10 @@ def make_sim_dir(x): print("To run simulation: " + sim_script) async def run_flow(self): + peano_path = os.path.join(opts.peano_install_dir, 'bin') + peano_clang_path = os.path.join(peano_path, 'clang') + peano_opt_path = os.path.join(peano_path, 'opt') + peano_llc_path = os.path.join(peano_path, 'llc') nworkers = int(opts.nthreads) if(nworkers == 0): nworkers = os.cpu_count() @@ -700,9 +708,9 @@ async def run_flow(self): await self.do_call(progress_bar.task, ['xchesscc_wrapper', self.aie_target.lower(), '+w', os.path.join(self.tmpdirname, 'work'), '-c', '-d', '-f', '+P', '4', file_llvmir_hacked, '-o', self.file_obj]) elif(opts.compile): self.file_llvmir_opt= os.path.join(self.tmpdirname, 'input.opt.ll') - await self.do_call(progress_bar.task, ['opt', '--passes=default', '-inline-threshold=10', '-S', self.file_llvmir, '-o', self.file_llvmir_opt]) + await self.do_call(progress_bar.task, [peano_opt_path, '--passes=default', '-inline-threshold=10', '-S', self.file_llvmir, '-o', self.file_llvmir_opt]) - await self.do_call(progress_bar.task, ['llc', self.file_llvmir_opt, '-O2', '--march=%s' % self.aie_target.lower(), '--function-sections', '--filetype=obj', '-o', self.file_obj]) + await self.do_call(progress_bar.task, [peano_llc_path, self.file_llvmir_opt, '-O2', '--march=%s' % self.aie_target.lower(), '--function-sections', '--filetype=obj', '-o', self.file_obj]) progress_bar.update(progress_bar.task,advance=0,visible=False) progress_bar.task_completed = progress_bar.add_task("[green] AIE Compilation:", total=len(cores)+1, command="%d Workers" % nworkers) diff --git a/test/aiecc/simple.mlir b/test/aiecc/simple.mlir index c9aeda3c93..1b5da1dbc1 100644 --- a/test/aiecc/simple.mlir +++ b/test/aiecc/simple.mlir @@ -17,15 +17,15 @@ // Note that llc determines the architecture from the llvm IR. -// XCHESSCC-NOT: {{^llc}} +// XCHESSCC-NOT: {{^[^ ]*llc}} // XCHESSCC: xchesscc_wrapper aie -// XCHESSCC-NOT: {{^llc}} +// XCHESSCC-NOT: {{^[^ ]*llc}} // PEANO-NOT: xchesscc_wrapper -// PEANO: {{^llc}} +// PEANO: {{^[^ ]*llc}} // PEANO-SAME: --march=aie // PEANO-NOT: xchesscc_wrapper // NOCOMPILE-NOT: xchesscc_wrapper -// NOCOMPILE-NOT: {{^llc}} +// NOCOMPILE-NOT: {{^[^ ]*llc}} module { %12 = AIE.tile(1, 2) diff --git a/test/aiecc/simple_aie2.mlir b/test/aiecc/simple_aie2.mlir index 3dd0e74136..adb4386cc8 100644 --- a/test/aiecc/simple_aie2.mlir +++ b/test/aiecc/simple_aie2.mlir @@ -16,15 +16,15 @@ // RUN: %PYTHON aiecc.py --no-unified --no-compile --no-link -nv --sysroot=%VITIS_SYSROOT% --host-target=aarch64-linux-gnu %s -I%host_runtime_lib% %host_runtime_lib%/test_library.cpp %S/test.cpp -o test.elf | FileCheck %s --check-prefix=NOCOMPILE // Note that llc determines the architecture from the llvm IR. -// XCHESSCC-NOT: {{^llc}} +// XCHESSCC-NOT: {{^[^ ]*llc}} // XCHESSCC: xchesscc_wrapper aie2 -// XCHESSCC-NOT: {{^llc}} +// XCHESSCC-NOT: {{^[^ ]*llc}} // PEANO-NOT: xchesscc_wrapper -// PEANO: {{^llc}} +// PEANO: {{^[^ ]*llc}} // PEANO-SAME: --march=aie2 // PEANO-NOT: xchesscc_wrapper // NOCOMPILE-NOT: xchesscc_wrapper -// NOCOMPILE-NOT: {{^llc}} +// NOCOMPILE-NOT: {{^[^ ]*llc}} module { AIE.device(xcve2302) { diff --git a/tools/aiecc/aiecc/configure.py.in b/tools/aiecc/aiecc/configure.py.in index b94b7165a8..ec66aec71a 100644 --- a/tools/aiecc/aiecc/configure.py.in +++ b/tools/aiecc/aiecc/configure.py.in @@ -13,7 +13,6 @@ aie_disable_link = @CONFIG_DISABLE_LINK@ aie_disable_compile = @CONFIG_DISABLE_COMPILE@ aie_unified_compile = True host_disable_compile = @CONFIG_DISABLE_HOST_COMPILE@ -peano_install_dir = "@CONFIG_PEANO_INSTALL_DIR@" host_architecture = "@LLVM_HOST_TRIPLE@" def install_path():