-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fifield-patch-version
- Loading branch information
Showing
44 changed files
with
320 additions
and
2,012 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
reference_designs/ipu-xrt/matrix_multiplication/makefile-common
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
##===- 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 | ||
# | ||
##===----------------------------------------------------------------------===## | ||
|
||
# This file is to be included from one of the subdirectories, e.g. | ||
# /matrix_vector/, after defining at least the targetname and kernels variable. | ||
# | ||
# The build steps for these matrix and matrix-vector multiplication designs all | ||
# look the same. We need to build: | ||
# - A common host test code, | ||
# - a kernel implemented in C using AIE intrinsics, | ||
# - the actual design implemented in MLIR. | ||
# There are also targets for signing the resulting xclbin, extracting traces | ||
# and cleaning everything. | ||
# | ||
# Since the targets are all the same for all designs, they are defined here. | ||
# Subdirectories need only include this makefile-common after defining the | ||
# following variables: | ||
# - subdir -- subdirectory you are including this from | ||
# - targetname -- resulting test host code will be named targetname.exe | ||
# - kernels -- which kernels in kernels folder to compile and link in | ||
# (without file extension) | ||
# - M, K, N -- (optional) dimensions of matrices, may be used by design; | ||
# N=1 for matrix-vector | ||
|
||
include ../../makefile-common | ||
|
||
# defaults; overwrite if needed | ||
M?=512 | ||
K?=512 | ||
N?=512 | ||
|
||
mlir_target?=build/aie_${M}x${K}x${N}.mlir | ||
xclbin_target?=build/final_${M}x${K}x${N}.xclbin | ||
insts_target?=build/insts_${M}x${K}x${N}.txt | ||
|
||
runargs?=-v 1 --warmup 10 --iters 10 | ||
|
||
kernels_dir=../../../../aie_kernels/iron | ||
|
||
.PHONY: all | ||
all: ${xclbin_target} ${insts_target} ${targetname}.exe | ||
|
||
build/%.o: ${kernels_dir}/%.cc | ||
mkdir -p ${@D} | ||
cd ${@D} && xchesscc_wrapper ${CHESSCCWRAP2_FLAGS} -DBIT_WIDTH=8 -c $(<:%=../%) -o ${@F} | ||
|
||
${mlir_target}: aie2.py | ||
mkdir -p ${@D} | ||
python3 $< -M $M -K $K -N $N > $@ | ||
|
||
${xclbin_target}: ${mlir_target} ${kernels:%=build/%.o} | ||
mkdir -p ${@D} | ||
cd ${@D} && aiecc.py --aie-generate-cdo --no-compile-host --xclbin-name=${@F} \ | ||
--aie-generate-ipu --ipu-insts-name=${insts_target:build/%=%} $(<:%=../%) | ||
|
||
${targetname}.exe: test.cpp ../test.cpp ../common.h | ||
rm -rf _build | ||
mkdir -p _build | ||
cd _build && ${powershell} cmake -E env CXXFLAGS="-std=c++23 -ggdb" cmake ../.. -D CMAKE_C_COMPILER=gcc-13 -D CMAKE_CXX_COMPILER=g++-13 -DTARGET_NAME=${targetname} -Dsubdir=${subdir} | ||
cd _build && ${powershell} cmake --build . --config Release | ||
ifeq "${powershell}" "powershell.exe" | ||
cp _build/${targetname}.exe $@ | ||
else | ||
cp _build/${targetname} $@ | ||
endif | ||
|
||
xclbin_sign=/opt/xilinx/xrt/amdxdna/setup_xclbin_firmware.sh | ||
.PHONY: sign | ||
sign: ${xclbin_target} | ||
${xclbin_sign} -dev Phoenix -xclbin $< | ||
|
||
.PHONY: run | ||
run: ${targetname}.exe ${xclbin_target} ${insts_target} #sign | ||
export XRT_HACK_UNSECURE_LOADING_XCLBIN=1 && \ | ||
${powershell} ./$< -x ${xclbin_target} -i ${insts_target} -k MLIR_AIE -M $M -K $K -N $N ${runargs} | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf build _build ${targetname}.exe | ||
|
||
.PHONY: parse_trace | ||
parse_trace: | ||
../../../utils/parse_eventIR.py --filename trace.txt --mlir ./build/aie.mlir --colshift 1 > trace_eventIR.json | ||
|
||
.PHONY: clean_trace | ||
clean_trace: | ||
rm -rf tmpTrace trace_eventIR.json |
19 changes: 19 additions & 0 deletions
19
reference_designs/ipu-xrt/matrix_multiplication/matrix_vector/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
##===- 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 | ||
# | ||
##===----------------------------------------------------------------------===## | ||
|
||
subdir=matrix_vector | ||
targetname=matrixVectorMultiplication | ||
kernels=mv | ||
|
||
# Currently does not accept reconfiguring size via these variables; must change | ||
# in source at aie2.py as well as here | ||
M=288 | ||
K=288 | ||
N=1 | ||
|
||
include ../makefile-common |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
reference_designs/ipu-xrt/matrix_multiplication/matrix_vector/test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//===- test.cpp -------------------------------------------000---*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
// Copyright (C) 2023, Advanced Micro Devices, Inc. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <stdfloat> | ||
|
||
#define DATATYPES_USING_DEFINED | ||
using A_DATATYPE = std::bfloat16_t; | ||
using B_DATATYPE = std::bfloat16_t; | ||
using C_DATATYPE = float; | ||
|
||
#include "../test.cpp" |
File renamed without changes.
19 changes: 19 additions & 0 deletions
19
reference_designs/ipu-xrt/matrix_multiplication/single_column/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
##===- 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 | ||
# | ||
##===----------------------------------------------------------------------===## | ||
|
||
subdir=single_column | ||
targetname=matrixMultiplication | ||
kernels=mm | ||
|
||
# Currently does not accept reconfiguring size via these variables; must change | ||
# in source at aie2.py as well as here | ||
M=256 | ||
K=128 | ||
N=128 | ||
|
||
include ../makefile-common |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
reference_designs/ipu-xrt/matrix_multiplication/single_column/test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//===- test.cpp -------------------------------------------000---*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
// Copyright (C) 2023, Advanced Micro Devices, Inc. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <stdfloat> | ||
|
||
#define DATATYPES_USING_DEFINED | ||
using A_DATATYPE = std::bfloat16_t; | ||
using B_DATATYPE = std::bfloat16_t; | ||
using C_DATATYPE = float; | ||
|
||
#include "../test.cpp" |
Oops, something went wrong.