/
Makefile
198 lines (168 loc) · 6.83 KB
/
Makefile
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
.PHONY: help
help::
$(ECHO) "Makefile Usage:"
$(ECHO) " make all TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86> SYSROOT=<sysroot_path>"
$(ECHO) " Command to generate the design for specified Target and Shell."
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH and SYSROOT is required for SoC shells"
$(ECHO) ""
$(ECHO) " make clean "
$(ECHO) " Command to remove the generated non-hardware files."
$(ECHO) ""
$(ECHO) " make cleanall"
$(ECHO) " Command to remove all the generated files."
$(ECHO) ""
$(ECHO) " make test DEVICE=<FPGA platform>"
$(ECHO) " Command to run the application. This is same as 'check' target but does not have any makefile dependency."
$(ECHO) ""
$(ECHO) " make sd_card TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86> SYSROOT=<sysroot_path>"
$(ECHO) " Command to prepare sd_card files."
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH and SYSROOT is required for SoC shells"
$(ECHO) ""
$(ECHO) " make check TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86> SYSROOT=<sysroot_path>"
$(ECHO) " Command to run application in emulation."
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH and SYSROOT is required for SoC shells"
$(ECHO) ""
$(ECHO) " make build TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86> SYSROOT=<sysroot_path>"
$(ECHO) " Command to build xclbin application."
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH and SYSROOT is required for SoC shells"
$(ECHO) ""
# Points to top directory of Git repository
COMMON_REPO = .
PWD = $(shell readlink -f .)
ABS_COMMON_REPO = $(shell readlink -f $(COMMON_REPO))
SEQINCLUDE := -Iseqan
TARGET := hw
HOST_ARCH := x86
SYSROOT :=
#DEVICE := /opt/xilinx/platforms/xilinx_u200_xdma_201830_2/xilinx_u200_xdma_201830_2.xpfm
DEVICE := /opt/xilinx/platforms//xilinx_u280_xdma_201920_1/xilinx_u280_xdma_201920_1.xpfm
include ./utils.mk
XSA := $(call device2xsa, $(DEVICE))
TEMP_DIR := ./_x.$(TARGET).$(XSA)
BUILD_DIR := ./build_dir.$(TARGET).$(XSA)
VPP := v++
SDCARD := sd_card
#Include Libraries
include $(ABS_COMMON_REPO)/common/includes/opencl/opencl.mk
include $(ABS_COMMON_REPO)/common/includes/xcl2/xcl2.mk
CXXFLAGS += $(xcl2_CXXFLAGS)
LDFLAGS += $(xcl2_LDFLAGS)
HOST_SRCS += $(xcl2_SRCS)
CXXFLAGS += $(opencl_CXXFLAGS) $(SEQINCLUDE) -Wall -O0 -g -std=c++14 -fopenmp
LDFLAGS += $(opencl_LDFLAGS)
HOST_SRCS += src/host.cpp
# Host compiler global settings
CXXFLAGS += -fmessage-length=0
LDFLAGS += -lrt -lstdc++
ifneq ($(HOST_ARCH), x86)
LDFLAGS += --sysroot=$(SYSROOT)
endif
# Kernel compiler global settings
CLFLAGS += -t $(TARGET) --platform $(DEVICE) --save-temps
ifneq ($(TARGET), hw)
CLFLAGS += -g
endif
# Adding config files to linker
LDCLFLAGS += --config xdrop.ini
EXECUTABLE = host
CMD_ARGS = $(BUILD_DIR)/xdrop.xclbin
EMCONFIG_DIR = $(TEMP_DIR)
EMU_DIR = $(SDCARD)/data/emulation
BINARY_CONTAINERS += $(BUILD_DIR)/xdrop.xclbin
BINARY_CONTAINER_xdrop_OBJS += $(TEMP_DIR)/xdrop.xo
# Setting higher frequency to achieve higher bandwidth
CLFLAGS+=--kernel_frequency 400
CP = cp -rf
.PHONY: all clean cleanall docs emconfig
all: check-devices $(EXECUTABLE) $(BINARY_CONTAINERS) emconfig sd_card
.PHONY: exe
exe: $(EXECUTABLE)
.PHONY: build
build: $(BINARY_CONTAINERS)
# Building kernel
$(TEMP_DIR)/xdrop.xo: src/xdrop.cpp
mkdir -p $(TEMP_DIR)
$(VPP) $(CLFLAGS) --temp_dir $(TEMP_DIR) -c -k xdrop -I'$(<D)' -o'$@' '$<'
$(BUILD_DIR)/xdrop.xclbin: $(BINARY_CONTAINER_xdrop_OBJS)
mkdir -p $(BUILD_DIR)
$(VPP) $(CLFLAGS) --temp_dir $(BUILD_DIR) -l $(LDCLFLAGS) -o'$@' $(+)
# Building Host
$(EXECUTABLE): check-xrt $(HOST_SRCS) $(HOST_HDRS)
$(CXX) $(CXXFLAGS) $(HOST_SRCS) $(HOST_HDRS) -o '$@' $(LDFLAGS)
emconfig:$(EMCONFIG_DIR)/emconfig.json
$(EMCONFIG_DIR)/emconfig.json:
emconfigutil --platform $(DEVICE) --od $(EMCONFIG_DIR)
check: all
ifeq ($(findstring zc, $(DEVICE)), zc)
$(error This kernel is not supported for $(DEVICE))
endif
ifeq ($(findstring vck, $(DEVICE)), vck)
$(error This kernel is not supported for $(DEVICE))
endif
ifeq ($(findstring u250, $(DEVICE)), u250)
$(error This kernel is not supported for $(DEVICE))
endif
ifeq ($(findstring aws, $(DEVICE)), aws)
$(error This kernel is not supported for $(DEVICE))
endif
ifeq ($(findstring samsung, $(DEVICE)), samsung)
$(error This kernel is not supported for $(DEVICE))
endif
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
ifeq ($(HOST_ARCH), x86)
$(CP) $(EMCONFIG_DIR)/emconfig.json .
XCL_EMULATION_MODE=$(TARGET) ./$(EXECUTABLE) $(BUILD_DIR)/xdrop.xclbin
else
mkdir -p $(EMU_DIR)
$(CP) $(XILINX_VITIS)/data/emulation/unified $(EMU_DIR)
mkfatimg $(SDCARD) $(SDCARD).img 500000
launch_emulator -no-reboot -runtime ocl -t $(TARGET) -sd-card-image $(SDCARD).img -device-family $(DEV_FAM)
endif
else
ifeq ($(HOST_ARCH), x86)
./$(EXECUTABLE) $(BUILD_DIR)/xdrop.xclbin
endif
endif
.PHONY: test
test: $(EXECUTABLE)
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
ifeq ($(HOST_ARCH), x86)
XCL_EMULATION_MODE=$(TARGET) ./$(EXECUTABLE) $(BUILD_DIR)/xdrop.xclbin
else
mkdir -p $(EMU_DIR)
$(CP) $(XILINX_VITIS)/data/emulation/unified $(EMU_DIR)
mkfatimg $(SDCARD) $(SDCARD).img 500000
launch_emulator -no-reboot -runtime ocl -t $(TARGET) -sd-card-image $(SDCARD).img -device-family $(DEV_FAM)
endif
else
ifeq ($(HOST_ARCH), x86)
./$(EXECUTABLE) $(BUILD_DIR)/xdrop.xclbin
else
$(ECHO) "Please copy the content of sd_card folder and data to an SD Card and run on the board"
endif
endif
sd_card: $(EXECUTABLE) $(BINARY_CONTAINERS) emconfig
ifneq ($(HOST_ARCH), x86)
mkdir -p $(SDCARD)/$(BUILD_DIR)
$(CP) $(B_NAME)/sw/$(XSA)/boot/generic.readme $(B_NAME)/sw/$(XSA)/xrt/image/* xrt.ini $(EXECUTABLE) $(SDCARD)
$(CP) $(BUILD_DIR)/*.xclbin $(SDCARD)/$(BUILD_DIR)/
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
$(ECHO) 'cd /mnt/' >> $(SDCARD)/init.sh
$(ECHO) 'export XILINX_VITIS=$$PWD' >> $(SDCARD)/init.sh
$(ECHO) 'export XCL_EMULATION_MODE=$(TARGET)' >> $(SDCARD)/init.sh
$(ECHO) './$(EXECUTABLE) $(CMD_ARGS)' >> $(SDCARD)/init.sh
$(ECHO) 'reboot' >> $(SDCARD)/init.sh
else
[ -f $(SDCARD)/BOOT.BIN ] && echo "INFO: BOOT.BIN already exists" || $(CP) $(BUILD_DIR)/sd_card/BOOT.BIN $(SDCARD)/
$(ECHO) 'cd /mnt/' >> $(SDCARD)/init.sh
$(ECHO) './$(EXECUTABLE) $(CMD_ARGS)' >> $(SDCARD)/init.sh
endif
endif
# Cleaning stuff
clean:
-$(RMDIR) $(EXECUTABLE) $(XCLBIN)/{*sw_emu*,*hw_emu*}
-$(RMDIR) profile_* TempConfig system_estimate.xtxt *.rpt *.csv
-$(RMDIR) src/*.ll *v++* .Xil emconfig.json dltmp* xmltmp* *.log *.jou *.wcfg *.wdb
cleanall: clean
-$(RMDIR) build_dir* sd_card*
-$(RMDIR) _x.* *xclbin.run_summary qemu-memory-_* emulation/ _vimage/ pl* start_simulation.sh *.xclbin