Skip to content

Commit

Permalink
Add aiecc flag for basic_alloc_scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
abisca committed Apr 24, 2024
1 parent 28c0de4 commit 9fd6b84
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 12 deletions.
7 changes: 7 additions & 0 deletions python/compiler/aiecc/cl_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ def parse_args(args=None):
default="0x901",
help="Kernel id in xclbin file",
)
parser.add_argument(
"--basic-alloc-scheme",
dest="basic_alloc_scheme",
default=False,
action="store_const",
help="Use basic memory allocation scheme for AIE buffer address assignment",
)

opts = parser.parse_args(args)
return opts
Expand Down
33 changes: 28 additions & 5 deletions python/compiler/aiecc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from aie.ir import Context, Location, Module
from aie.passmanager import PassManager

INPUT_WITH_ADDRESSES_PIPELINE = (
INPUT_WITH_SWITCHBOXES_PIPELINE = (
Pipeline()
.lower_affine()
.add_pass("aie-canonicalize-device")
Expand All @@ -50,7 +50,6 @@
.add_pass("aie-lower-broadcast-packet")
.add_pass("aie-create-packet-flows")
.add_pass("aie-lower-multicast")
.add_pass("aie-assign-buffer-addresses"),
)
.convert_scf_to_cf()
)
Expand Down Expand Up @@ -986,15 +985,39 @@ async def run_flow(self):
"[green] MLIR compilation:", total=1, command="1 Worker"
)

file_with_addresses = self.prepend_tmp("input_with_addresses.mlir")
pass_pipeline = INPUT_WITH_ADDRESSES_PIPELINE.materialize(module=True)
file_with_switchboxes = self.prepend_tmp("input_with_switchboxes.mlir")
pass_pipeline = INPUT_WITH_SWITCHBOXES_PIPELINE.materialize(module=True)
run_passes(
pass_pipeline,
self.mlir_module_str,
file_with_addresses,
file_with_switchboxes,
self.opts.verbose,
)

file_with_addresses = self.prepend_tmp("input_with_addresses.mlir")
if opts.basic_alloc_scheme:
await self.do_call(
progress_bar.task,
[
"aie-opt",
"--aie-assign-buffer-addresses=basic-alloc",
file_with_switchboxes,
"-o",
file_with_addresses,
],
)
else:
await self.do_call(
progress_bar.task,
[
"aie-opt",
"--aie-assign-buffer-addresses",
file_with_switchboxes,
"-o",
file_with_addresses,
],
)

cores = generate_cores_list(await read_file_async(file_with_addresses))
t = do_run(
[
Expand Down
2 changes: 1 addition & 1 deletion test/benchmarks/01_DDR_SHIM_LM_FillRate/aie.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
//===----------------------------------------------------------------------===//

// RUN: %PYTHON aiecc.py %VitisSysrootFlag% --host-target=%aieHostTargetTriplet% %link_against_hsa% %s -I%host_runtime_lib%/test_lib/include -L%host_runtime_lib%/test_lib/lib -ltest_lib %S/test.cpp -o test.elf
// RUN: %PYTHON aiecc.py %VitisSysrootFlag% --basic-alloc-scheme --host-target=%aieHostTargetTriplet% %link_against_hsa% %s -I%host_runtime_lib%/test_lib/include -L%host_runtime_lib%/test_lib/lib -ltest_lib %S/test.cpp -o test.elf
// RUN: %run_on_board ./test.elf

module @benchmark01_DDR_SHIM_fill_rate {
Expand Down
2 changes: 1 addition & 1 deletion test/benchmarks/02_LM_SHIM_DDR_FillRate/aie.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
//===----------------------------------------------------------------------===//

// RUN: %PYTHON aiecc.py %VitisSysrootFlag% --host-target=%aieHostTargetTriplet% %link_against_hsa% %s -I%host_runtime_lib%/test_lib/include -L%host_runtime_lib%/test_lib/lib -ltest_lib %S/test.cpp -o test.elf
// RUN: %PYTHON aiecc.py %VitisSysrootFlag% --basic-alloc-scheme --host-target=%aieHostTargetTriplet% %link_against_hsa% %s -I%host_runtime_lib%/test_lib/include -L%host_runtime_lib%/test_lib/lib -ltest_lib %S/test.cpp -o test.elf
// RUN: %run_on_board ./test.elf

module @benchmark_02_LM2DDR {
Expand Down
2 changes: 1 addition & 1 deletion test/benchmarks/03_Flood_DDR/aie.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
//===----------------------------------------------------------------------===//

// RUN: %PYTHON aiecc.py %VitisSysrootFlag% --host-target=%aieHostTargetTriplet% %link_against_hsa% %s -I%host_runtime_lib%/test_lib/include -L%host_runtime_lib%/test_lib/lib -ltest_lib %S/test.cpp -o test.elf
// RUN: %PYTHON aiecc.py %VitisSysrootFlag% --basic-alloc-scheme --host-target=%aieHostTargetTriplet% %link_against_hsa% %s -I%host_runtime_lib%/test_lib/include -L%host_runtime_lib%/test_lib/lib -ltest_lib %S/test.cpp -o test.elf
// RUN: %run_on_board ./test.elf

module @benchmark03_Flood_DDR {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// RUN: aie-translate --aie-generate-cdo aie.mlir.prj/input_physical.mlir
// RUN: cp *.elf aie.mlir.prj/
// RUN: cp *.bin aie.mlir.prj/
// RUN: %python aiecc.py --no-aiesim --aie-generate-npu --aie-generate-xclbin --no-compile-host --xclbin-name=aie.xclbin --npu-insts-name=insts.txt %S/aie.mlir
// RUN: %python aiecc.py --no-aiesim --aie-generate-npu --aie-generate-xclbin --no-compile-host --basic-alloc-scheme --xclbin-name=aie.xclbin --npu-insts-name=insts.txt %S/aie.mlir
// RUN: clang %S/test.cpp -o test.exe -std=c++11 -Wall %xrt_flags -lrt -lstdc++
// RUN: %run_on_npu ./test.exe aie.xclbin | FileCheck %s
// CHECK: PASS!
2 changes: 1 addition & 1 deletion test/npu-xrt/add_314_using_dma_op/run.lit
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// RUN: aie-translate --aie-generate-cdo aie.mlir.prj/input_physical.mlir
// RUN: cp *.elf aie.mlir.prj/
// RUN: cp *.bin aie.mlir.prj/
// RUN: %python aiecc.py --no-aiesim --aie-generate-npu --aie-generate-xclbin --no-compile-host --xclbin-name=aie.xclbin --npu-insts-name=insts.txt %S/aie.mlir
// RUN: %python aiecc.py --no-aiesim --aie-generate-npu --aie-generate-xclbin --no-compile-host --basic-alloc-scheme --xclbin-name=aie.xclbin --npu-insts-name=insts.txt %S/aie.mlir
// RUN: clang %S/test.cpp -o test.exe -std=c++11 -Wall %xrt_flags -lrt -lstdc++
// RUN: %run_on_npu ./test.exe aie.xclbin | FileCheck %s
// CHECK: PASS!
Expand Down
2 changes: 1 addition & 1 deletion test/npu-xrt/add_one_using_dma/run.lit
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// REQUIRES: ryzen_ai
//
// RUN: %python aiecc.py --no-aiesim --aie-generate-cdo --aie-generate-npu --no-compile-host --xclbin-name=aie.xclbin --npu-insts-name=insts.txt %S/aie.mlir
// RUN: %python aiecc.py --no-aiesim --aie-generate-cdo --aie-generate-npu --no-compile-host --basic-alloc-scheme --xclbin-name=aie.xclbin --npu-insts-name=insts.txt %S/aie.mlir
// RUN: clang %S/test.cpp -o test.exe -std=c++11 -Wall %xrt_flags -lrt -lstdc++ -lboost_program_options -lboost_filesystem
// RUN: %run_on_npu ./test.exe -x aie.xclbin -k MLIR_AIE -i insts.txt | FileCheck %s
// CHECK: PASS!
Expand Down
2 changes: 1 addition & 1 deletion test/npu-xrt/matrix_multiplication_using_dma/run.lit
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// REQUIRES: ryzen_ai, chess
//
// RUN: xchesscc_wrapper aie2 -I %aietools/include -c %S/mm.cc -o ./mm.o
// RUN: %python aiecc.py --xbridge --aie-generate-cdo --aie-generate-npu --no-compile-host --xclbin-name=aie.xclbin --npu-insts-name=insts.txt %S/aie.mlir
// RUN: %python aiecc.py --xbridge --aie-generate-cdo --aie-generate-npu --no-compile-host --basic-alloc-scheme --xclbin-name=aie.xclbin --npu-insts-name=insts.txt %S/aie.mlir
// RUN: clang %S/test.cpp -o test.exe -std=c++11 -Wall %xrt_flags -lrt -lstdc++ -lboost_program_options -lboost_filesystem
// RUN: %run_on_npu ./test.exe -x aie.xclbin -k MLIR_AIE -i insts.txt | FileCheck %s
// CHECK: PASS!

0 comments on commit 9fd6b84

Please sign in to comment.