Skip to content

Commit

Permalink
[ASPLOS] Rename directories (#1196)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeff Fifield <jeff.fifield@amd.com>
Co-authored-by: AndraBisca <andrab@amd.com>
Co-authored-by: Jack Lo <36210336+jackl-xilinx@users.noreply.github.com>
  • Loading branch information
4 people authored Apr 9, 2024
1 parent c0c1aee commit a9a71b4
Show file tree
Hide file tree
Showing 17 changed files with 18 additions and 71 deletions.
Empty file added aie_kernels/aie1/.gitkeep
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
68 changes: 7 additions & 61 deletions mlir_tutorials/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
# Copyright (C) 2022, Advanced Micro Devices, Inc.

import os
import platform
import re
import shutil
import subprocess
import tempfile

import lit.formats
import lit.util
Expand All @@ -19,9 +21,12 @@
# Configuration file for the 'lit' test runner.

# name: The name of this test suite.
config.name = "AIE_REFERENCE_DESIGNS"
config.name = "AIE_TUTORIALS"

config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
config.environment["PYTHONPATH"] = "{}".format(
os.path.join(config.aie_obj_root, "python")
)

# suffixes: A list of file extensions to treat as test files.
config.suffixes = [".mlir"]
Expand All @@ -42,67 +47,13 @@
# for xchesscc_wrapper
llvm_config.with_environment("AIETOOLS", config.vitis_aietools_dir)

# for python
llvm_config.with_environment("PYTHONPATH", os.path.join(config.aie_obj_root, "python"))

if config.enable_board_tests:
config.substitutions.append(
("%run_on_board", "echo %T >> /home/xilinx/testlog | sync | sudo")
)
else:
config.substitutions.append(("%run_on_board", "echo"))

run_on_ipu = "echo"
xrt_flags = ""
if config.xrt_lib_dir:
print("xrt found at", os.path.dirname(config.xrt_lib_dir))
xrt_flags = "-I{} -L{} -luuid -lxrt_coreutil".format(
config.xrt_include_dir, config.xrt_lib_dir
)
try:
xbutil = os.path.join(config.xrt_bin_dir, "xbutil")
result = subprocess.run(
[xbutil, "examine"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
result = result.stdout.decode("utf-8").split("\n")
# Starting with Linux 6.8 the format is like "[0000:66:00.1] : RyzenAI-npu1"
p = re.compile("\[.+:.+:.+\].+(Phoenix|RyzenAI-(npu\d))")
for l in result:
m = p.match(l)
if m:
print("Found Ryzen AI device:", m.group().split()[0])
if len(m.groups()) == 2:
# Prepare the future
aie_model = m.group(2)
print("\tmodel:", aie_model)
config.available_features.add("ryzen_ai")
run_on_ipu = (
f"flock /tmp/ipu.lock {config.aie_src_root}/utils/run_on_ipu.sh"
)
except:
print("Failed to run xbutil")
pass
else:
print("xrt not found")

config.substitutions.append(("%run_on_ipu", run_on_ipu))
config.substitutions.append(("%xrt_flags", xrt_flags))
config.substitutions.append(("%XRT_DIR", config.xrt_dir))

opencv_flags = ""
if config.opencv_include_dir and config.opencv_libs:
print("opencv found")
config.available_features.add("opencv")
opencv_flags = opencv_flags + " -I" + config.opencv_include_dir
if config.opencv_lib_dir:
opencv_flags = opencv_flags + " -L" + config.opencv_lib_dir
libs = config.opencv_libs.split(";")
opencv_flags = opencv_flags + " " + " ".join(["-l" + l for l in libs])
else:
print("opencv not found")
opencv_flags = ""
config.substitutions.append(("%opencv_flags", opencv_flags))

VitisSysrootFlag = ""
if config.aieHostTarget == "x86_64":
config.substitutions.append(("%aieHostTargetTriplet%", "x86_64-unknown-linux-gnu"))
Expand All @@ -127,7 +78,6 @@
"README.txt",
"LICENSE.txt",
"aie.mlir.prj",
"lit.cfg.py",
]

config.aie_tools_dir = os.path.join(config.aie_obj_root, "bin")
Expand Down Expand Up @@ -206,11 +156,7 @@ def prepend_path(path):
print(
"WARNING: no valid xchess license that is required by some of the lit tests"
)
elif os.getenv("XILINXD_LICENSE_FILE") is not None:
print("Chess license found")
llvm_config.with_environment(
"XILINXD_LICENSE_FILE", os.getenv("XILINXD_LICENSE_FILE")
)

else:
print("Chess not found")

Expand Down
5 changes: 3 additions & 2 deletions programming_examples/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
//
//===----------------------------------------------------------------------===//-->

# <ins>Core Programming Examples</ins>
# <ins>Basic Programming Examples</ins>

These programming examples provide a good starting point to illustrate how to build commonly used compute kernels (both single core and multicore data processing pipelines). They serve to highlight how designs can be described in python and lowered through the mlir-aie tool flow to an executable that runs on the IPU.

* [Add One (with ObjectFIFOs)](./add_one_objFifo) - Single tile performs a very simple `+` operation where the kernel loads data from local memory, increments the value by `1` and stores it back.
* [Vector Bias Add](./vector_bias_add) - Single tile performs a very simple `+` operation where the kernel loads data from local memory, increments the value by `1` and stores it back.
* [Hello World (Log version)](./log_hello_world) - Single tile performs a self-query and `printf` function where printed data is moved from local buffers to external memory to be read by the host processor.
* [Matrix Multiplication](./matrix_multiplication) - Single tile performs a `matrix * matrix` multiply on int16 data type where `MxKxN` is `128x128x128`. The kernel itself computes `64x32x64 (MxKxN)` so it is invoked multiple times to complete the full matmul compute.
* [Vector Scalar](./vector_scalar) - Single tile performs `vector * scalar` of size `4096`. The kernel does a `1024` vector multiply and is invoked multiple times to complete the full vector*scalar compute.
* [Vision Pipelines](./vision_pipelines) - More extensive vision processing pipeline designs such as Edge Detect and Color Thresholding are found here.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ insts_target?=build/insts_${M}x${K}x${N}.txt

runargs?=-v 1 --warmup 10 --iters 10

kernels_dir=../../../../aie_kernels/iron
kernels_dir=../../../../aie_kernels/aie2

.PHONY: all
all: ${xclbin_target} ${insts_target} ${targetname}.exe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// REQUIRES: ryzen_ai, chess
//
// RUN: xchesscc_wrapper aie2 -I %aietools/include -c %S/../../../../aie_kernels/iron/mv.cc -o ./mv.o
// RUN: xchesscc_wrapper aie2 -I %aietools/include -c %S/../../../../aie_kernels/aie2/mv.cc -o ./mv.o
// RUN: %python %S/aie2.py -M 288 -K 288 -N 1 > ./aie.mlir
// RUN: %python aiecc.py --aie-generate-cdo --aie-generate-ipu --no-compile-host --xclbin-name=aie.xclbin --ipu-insts-name=insts.txt ./aie.mlir
// RUN: g++-13 %S/test.cpp -o test.exe -std=c++23 -Wall %xrt_flags -lrt -lstdc++ -lboost_program_options -lboost_filesystem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// REQUIRES: ryzen_ai, chess
//
// RUN: xchesscc_wrapper aie2 -I %aietools/include -c %S/../../../../aie_kernels/iron/mm.cc -o ./mm.o
// RUN: xchesscc_wrapper aie2 -I %aietools/include -c %S/../../../../aie_kernels/aie2/mm.cc -o ./mm.o
// RUN: %python %S/aie2.py -M 256 -K 128 -N 128 > ./aie.mlir
// RUN: %python aiecc.py --xbridge --aie-generate-cdo --aie-generate-ipu --no-compile-host --xclbin-name=aie.xclbin --ipu-insts-name=insts.txt ./aie.mlir
// RUN: g++-13 %S/test.cpp -o test.exe -std=c++23 -Wall %xrt_flags -lrt -lstdc++ -lboost_program_options -lboost_filesystem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// REQUIRES: ryzen_ai, chess
//
// RUN: xchesscc_wrapper aie2 -I %aietools/include -c %S/../../../../aie_kernels/iron/mm.cc -o ./mm.o
// RUN: xchesscc_wrapper aie2 -I %aietools/include -c %S/../../../../aie_kernels/aie2/mm.cc -o ./mm.o
// RUN: %python %S/aie2.py -M 256 -K 256 -N 256 > ./aie.mlir
// RUN: %python aiecc.py --xbridge --aie-generate-cdo --aie-generate-ipu --no-compile-host --xclbin-name=aie.xclbin --ipu-insts-name=insts.txt ./aie.mlir
// RUN: g++-13 %S/test.cpp -o test.exe -std=c++23 -Wall %xrt_flags -lrt -lstdc++ -lboost_program_options -lboost_filesystem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// REQUIRES: ryzen_ai, chess
//
// RUN: xchesscc_wrapper aie2 -I %aietools/include -c %S/../../../../aie_kernels/iron/mm.cc -o ./mm.o
// RUN: xchesscc_wrapper aie2 -I %aietools/include -c %S/../../../../aie_kernels/aie2/mm.cc -o ./mm.o
// RUN: %python %S/aie2.py -M 512 -K 512 -N 512 > ./aie.mlir
// RUN: %python aiecc.py --xbridge --aie-generate-cdo --aie-generate-ipu --no-compile-host --xclbin-name=aie.xclbin --ipu-insts-name=insts.txt ./aie.mlir
// RUN: g++-13 %S/test.cpp -o test.exe -std=c++23 -Wall %xrt_flags -lrt -lstdc++ -lboost_program_options -lboost_filesystem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include ../makefile-common

all: build/final.xclbin

targetname = addOneObjfifo
targetname = vectorBiasAdd

build/aie.mlir: aie2.py
mkdir -p ${@D}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from aie.extras.context import mlir_mod_ctx


def my_add_one_objFifo():
def my_vector_bias_add():
with mlir_mod_ctx() as ctx:

@device(AIEDevice.ipu)
Expand Down Expand Up @@ -72,4 +72,4 @@ def sequence(inTensor, notUsed, outTensor):
print(ctx.module)


my_add_one_objFifo()
my_vector_bias_add()

0 comments on commit a9a71b4

Please sign in to comment.