-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (70 loc) · 2.52 KB
/
Copy pathMakefile
File metadata and controls
85 lines (70 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
##===- Makefile -----------------------------------------------------------===##
#
# This file 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
#
# Copyright (C) 2025, Advanced Micro Devices, Inc.
#
##===----------------------------------------------------------------------===##
srcdir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
include ${srcdir}/../../makefile-common
aie2_runtime_dir = ${MLIR_AIE_DIR}/aie_runtime_lib/AIE2
devicename ?= $(if $(filter 1,$(NPU2)),npu2,npu)
targetname = silu
length ?= 16384
cols ?= 4
chans ?= 2
ifeq ($(devicename),npu2)
VPATH :=${srcdir}/../../../aie_kernels/aie2p
else
VPATH :=${srcdir}/../../../aie_kernels/aie2
endif
aie_py_src=silu.py
.PHONY all: build/${targetname}.mlir build/final.xclbin
ifeq ($(devicename),npu)
build/lut_based_ops.o: ${aie2_runtime_dir}/lut_based_ops.cpp
mkdir -p ${@D}
cd ${@D} && ${PEANO_INSTALL_DIR}/bin/clang++ ${PEANOWRAP2_FLAGS} -I. -c $< -o ${@F}
endif
build/%.cc.o: %.cc
mkdir -p ${@D}
ifeq ($(devicename),npu)
cd ${@D} && ${PEANO_INSTALL_DIR}/bin/clang++ ${PEANOWRAP2_FLAGS} -I. -I${aie2_runtime_dir} -c $< -o ${@F}
else ifeq ($(devicename),npu2)
cd ${@D} && ${PEANO_INSTALL_DIR}/bin/clang++ ${PEANOWRAP2P_FLAGS} -c $< -o ${@F}
else
echo "Device type not supported"
endif
ifeq ($(devicename),npu)
build/kernels.a: build/${targetname}.cc.o build/lut_based_ops.o
ar rvs $@ $+
else ifeq ($(devicename),npu2)
build/kernels.a: build/${targetname}.cc.o
ar rvs $@ $+
else
echo "Device type not supported"
endif
build/${targetname}.mlir: ${srcdir}/${aie_py_src}
mkdir -p ${@D}
python3 $< -d ${devicename} -l ${length} -co ${cols} -ch ${chans} > $@
build/final.xclbin: build/${targetname}.mlir build/kernels.a
mkdir -p ${@D}
cd ${@D} && aiecc --aie-generate-xclbin --aie-generate-npu-insts --no-compile-host \
--xclbin-name=${@F} \
--no-xchesscc --no-xbridge \
--npu-insts-name=insts.bin $(<:%=../%)
${targetname}.exe: ${srcdir}/test.cpp
rm -rf _build
mkdir -p _build
cd _build && ${powershell} cmake ${srcdir} -DTARGET_NAME=${targetname}
cd _build && ${powershell} cmake --build . --config Release
ifeq "${powershell}" "powershell.exe"
cp _build/${targetname}.exe $@
else
cp _build/${targetname} $@
endif
run: ${targetname}.exe build/final.xclbin
${powershell} ./$< -x build/final.xclbin -i build/insts.bin -k MLIR_AIE -l ${length}
clean:
rm -rf build _build inst aie.mlir.prj core_* test.elf ${targetname}.exe