Skip to content

Commit cc98140

Browse files
authored
Update xdna-driver/xrt (#2452)
1 parent b2b5eb4 commit cc98140

8 files changed

Lines changed: 31 additions & 61 deletions

File tree

programming_examples/basic/row_wise_bias_add/Makefile

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,17 @@ srcdir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
1212

1313
include ${srcdir}/../../makefile-common
1414

15-
# ---
16-
17-
# The following environment variables that point to the Xilinx runtime (XRT)
18-
# should be set up by an environment setup script already.
19-
XILINX_XRT?=/opt/xilinx/xrt
20-
21-
# ---
22-
15+
XILINX_XRT=/opt/xilinx/xrt/
2316
XILINX_XRT_INCLUDE?=${XILINX_XRT}/include
2417
XILINX_XRT_LIB?=${XILINX_XRT}/lib
2518

2619
XRT_FLAGS=-I${XILINX_XRT_INCLUDE} -L${XILINX_XRT_LIB}
2720
XRT_LIBS=-lxrt_coreutil
28-
CXX=g++-13 -ggdb
21+
CXX=g++-13 -ggdb
22+
23+
UTILS_INCLUDE := -I$(srcdir)/../../../runtime_lib/test_lib/
24+
UTILS_LIB=$(srcdir)/../../../runtime_lib/test_lib/test_utils.cpp
25+
2926

3027
mlir_target?=build/aie.mlir
3128
xclbin_target?=build/final.xclbin
@@ -68,17 +65,12 @@ ${xclbin_target}: ${mlir_target} build/kernel.o
6865

6966
${host_target}: ${srcdir}/test.cpp ${xclbin_target}
7067
mkdir -p ${@D}
71-
${CXX} ${XRT_FLAGS} -DM=$M -DN=$N -o $@ $< ${XRT_LIBS}
68+
${CXX} ${XRT_FLAGS} ${UTILS_INCLUDE} ${UTILS_LIB} -DSIZE_M=$M -DSIZE_N=$N -o $@ $< ${XRT_LIBS}
7269

7370
.PHONY: run
7471
run: ${host_target}
7572
./${host_target}
7673

77-
xclbin_sign=${XILINX_XRT}/amdxdna/setup_xclbin_firmware.sh
78-
.PHONY: sign
79-
sign: ${xclbin_target}
80-
${xclbin_sign} -dev Phoenix -xclbin $<
81-
8274
.PHONY: clean
8375
clean:
8476
-rm -r build

programming_examples/basic/row_wise_bias_add/test.cpp

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "xrt/xrt_device.h"
1414
#include "xrt/xrt_kernel.h"
1515

16+
#include "test_utils.h"
17+
1618
#ifndef XCLBIN
1719
#define XCLBIN "build/final.xclbin"
1820
#endif
@@ -25,9 +27,9 @@
2527
#define KERNEL_NAME "MLIR_AIE"
2628
#endif
2729

28-
#define IN_SIZE (M * N * sizeof(float)) // in bytes
29-
#define BIAS_SIZE (N * sizeof(float)) // in bytes
30-
#define OUT_SIZE (M * N * sizeof(float)) // in bytes
30+
#define IN_SIZE (SIZE_M * SIZE_N * sizeof(float)) // in bytes
31+
#define BIAS_SIZE (SIZE_N * sizeof(float)) // in bytes
32+
#define OUT_SIZE (SIZE_M * SIZE_N * sizeof(float)) // in bytes
3133

3234
void print_matrix(float *buf, int n_rows, int n_cols) {
3335
for (int row = 0; row < n_rows; row++) {
@@ -38,34 +40,9 @@ void print_matrix(float *buf, int n_rows, int n_cols) {
3840
}
3941
}
4042

41-
std::vector<uint32_t> load_instr_binary(std::string instr_path) {
42-
// Open file in binary mode
43-
std::ifstream instr_file(instr_path, std::ios::binary);
44-
if (!instr_file.is_open()) {
45-
throw std::runtime_error("Unable to open instruction file\n");
46-
}
47-
48-
// Get the size of the file
49-
instr_file.seekg(0, std::ios::end);
50-
std::streamsize size = instr_file.tellg();
51-
instr_file.seekg(0, std::ios::beg);
52-
53-
// Check that the file size is a multiple of 4 bytes (size of uint32_t)
54-
if (size % 4 != 0) {
55-
throw std::runtime_error("File size is not a multiple of 4 bytes\n");
56-
}
57-
58-
// Allocate vector and read the binary data
59-
std::vector<uint32_t> instr_v(size / 4);
60-
if (!instr_file.read(reinterpret_cast<char *>(instr_v.data()), size)) {
61-
throw std::runtime_error("Failed to read instruction file\n");
62-
}
63-
return instr_v;
64-
}
65-
6643
int main(int argc, const char *argv[]) {
6744

68-
std::vector<uint32_t> instr_v = load_instr_binary(INSTS_BIN);
45+
std::vector<uint32_t> instr_v = test_utils::load_instr_binary(INSTS_BIN);
6946
assert(instr_v.size() > 0);
7047

7148
// Get a device handle
@@ -131,22 +108,22 @@ int main(int argc, const char *argv[]) {
131108

132109
bo_out.sync(XCL_BO_SYNC_BO_FROM_DEVICE);
133110

134-
float ref[M * N] = {};
135-
for (int i = 0; i < M; i++) {
136-
for (int j = 0; j < N; j++) {
137-
ref[i * N + j] = buf_in[i * N + j] + buf_bias[j];
111+
float ref[SIZE_M * SIZE_N] = {};
112+
for (int i = 0; i < SIZE_M; i++) {
113+
for (int j = 0; j < SIZE_N; j++) {
114+
ref[i * SIZE_N + j] = buf_in[i * SIZE_N + j] + buf_bias[j];
138115
}
139116
}
140117

141-
if (M <= 64 && N <= 64) {
118+
if (SIZE_M <= 64 && SIZE_N <= 64) {
142119
std::cout << "Input:" << std::endl;
143-
print_matrix(buf_in, M, N);
120+
print_matrix(buf_in, SIZE_M, SIZE_N);
144121
std::cout << "Bias:" << std::endl;
145-
print_matrix(buf_bias, 1, N);
122+
print_matrix(buf_bias, 1, SIZE_N);
146123
std::cout << "Expected:" << std::endl;
147-
print_matrix(ref, M, N);
124+
print_matrix(ref, SIZE_M, SIZE_N);
148125
std::cout << "Output:" << std::endl;
149-
print_matrix(buf_out, M, N);
126+
print_matrix(buf_out, SIZE_M, SIZE_N);
150127
}
151128

152129
if (memcmp(ref, buf_out, sizeof(ref)) == 0) {

programming_examples/basic/vector_scalar_add_runlist/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <string>
1717
#include <vector>
1818

19-
#include "experimental/xrt_kernel.h" // for xrt::runlist
19+
#include "xrt/experimental/xrt_kernel.h" // for xrt::runlist
2020
#include "xrt/xrt_aie.h"
2121
#include "xrt/xrt_bo.h"
2222
#include "xrt/xrt_device.h"

test/npu-xrt/add_one_two_txn/test.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
#include <string>
1616
#include <vector>
1717

18-
#include "cxxopts.hpp"
19-
#include "experimental/xrt_kernel.h"
20-
#include "test_utils.h"
18+
#include "xrt/experimental/xrt_kernel.h"
2119
#include "xrt/xrt_bo.h"
2220
#include "xrt/xrt_device.h"
2321
#include "xrt/xrt_kernel.h"
2422

23+
#include "cxxopts.hpp"
24+
#include "test_utils.h"
25+
2526
constexpr int IN_SIZE = 64;
2627
constexpr int OUT_SIZE = 64;
2728

test/npu-xrt/ctrl_packet_reconfig/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <string>
1616
#include <vector>
1717

18-
#include "experimental/xrt_kernel.h"
18+
#include "xrt/experimental/xrt_kernel.h"
1919
#include "xrt/xrt_bo.h"
2020
#include "xrt/xrt_device.h"
2121
#include "xrt/xrt_kernel.h"

test/npu-xrt/ctrl_packet_reconfig_1x4_cores/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <string>
1414
#include <vector>
1515

16-
#include "experimental/xrt_kernel.h"
16+
#include "xrt/experimental/xrt_kernel.h"
1717
#include "xrt/xrt_bo.h"
1818
#include "xrt/xrt_device.h"
1919
#include "xrt/xrt_kernel.h"

test/npu-xrt/ctrl_packet_reconfig_4x1_cores/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <string>
1414
#include <vector>
1515

16-
#include "experimental/xrt_kernel.h"
16+
#include "xrt/experimental/xrt_kernel.h"
1717
#include "xrt/xrt_bo.h"
1818
#include "xrt/xrt_device.h"
1919
#include "xrt/xrt_kernel.h"

utils/build_drivers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fi
3131

3232
echo "Cloning the XDNA driver repository..."
3333
# Clone the XDNA driver repository and initialize submodules
34-
XDNA_SHA=0e6d303b2cc2b3fe1cf10aba0acbf57a422588fb
34+
XDNA_SHA=e9d2788a884784e3531e95d65b923c2252a1132e
3535
git clone https://github.com/amd/xdna-driver.git
3636
export XDNA_SRC_DIR=$(realpath xdna-driver)
3737
cd xdna-driver

0 commit comments

Comments
 (0)