Skip to content

Commit 754ead3

Browse files
build dir name + versal packaging + ultraclean
1 parent 9c6e5cd commit 754ead3

File tree

4 files changed

+44
-19
lines changed

4 files changed

+44
-19
lines changed

hls4ml/backends/vitis_accelerator/supported_boards.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"memory": {"type": "ddr", "channels": 4, "capacity": 64}
1919
},
2020
"vck5000": {
21-
"board_type": "versal",
21+
"board_type": "alveo-versal",
2222
"part": "xcvc1902-2msevsvd1760",
2323
"platform": "xilinx_vck5000_gen4x8_qdma_2_202220_1",
2424
"memory":{"type": "ddr", "channels": 3, "capacity": 12}

hls4ml/backends/vitis_accelerator/vitis_accelerator_backend.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def create_initial_config(
4444
config['AcceleratorConfig']['Batchsize'] = batchsize
4545
return config
4646

47-
def build(self, model, reset=False, synth=True, vsynth=True):
47+
def build(self, model, reset=False, synth=True, vsynth=True, csim=False, cosim=False, debug=False, **kwargs):
4848
if 'linux' in sys.platform:
4949
if 'XILINX_VITIS' not in os.environ:
5050
raise Exception("XILINX_VITIS environmental variable missing. Please install XRT and Vitis, and run the setup scripts before building")
@@ -65,13 +65,22 @@ def build(self, model, reset=False, synth=True, vsynth=True):
6565

6666
if vsynth:
6767
if synth:
68-
target = "all"
68+
target = "all "
6969
else:
70-
target = "xclbin"
70+
target = "xclbin "
7171
elif synth:
72-
target = "hls"
72+
target = "hls "
7373
else:
74-
target = "host"
74+
target = "host "
75+
76+
if cosim:
77+
target += "TARGET=hw_emu "
78+
elif csim:
79+
target += "TARGET=sw_emu "
80+
81+
if debug:
82+
target += "DEBUG"
83+
7584
command = "make " + target
7685

7786
# Pre-loading libudev

hls4ml/templates/vitis_accelerator/Makefile

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,22 @@ CARD_CFG ?= accelerator_card.cfg
3131
# Platform (currently extracted from accelerator_card.cfg if not already set)
3232
PLATFORM ?= $(shell awk -F '=' '/platform=/ {print $$2}' $(CARD_CFG))
3333

34-
# kernel name
34+
# Board Type (determines whether design will go through packaging step)
35+
BOARD_TYPE :=
36+
37+
# Kernel name
3538
KERNEL_NAME := myproject
3639

3740
# Wrapper name
3841
WRAPPER_NAME := kernel_wrapper
3942

4043
# Top level build directory
4144
BUILD_DIR := ./build_$(TARGET)
45+
ifdef DEBUG
46+
BUILD_DIR += _deb
47+
else
48+
BUILD_DIR += _rel
49+
endif
4250

4351
# Directories for kernel synthesis
4452
XO_DIR := $(BUILD_DIR)/xo
@@ -78,27 +86,27 @@ hls: $(BUILD_DIR)/$(KERNEL_NAME)_kernel.xo
7886

7987
# Kernel linking & packaging ##################################################
8088

89+
ifeq ($(BOARD_TYPE),alveo)
8190
# For Standard Alveo, a single step is required for linking and packaging
82-
ifeq (,$(findstring vck5000,$(PLATFORM)))
8391
# This is standard Alveo linking and packaging
84-
8592
$(BUILD_DIR)/$(WRAPPER_NAME).xclbin: $(BUILD_DIR)/$(KERNEL_NAME)_kernel.xo
8693
mkdir -p $(XCLBIN_DIR)
8794
v++ -l $(XOLDFLAGS) --temp_dir $(XCLBIN_DIR) --log_dir $(XCLBIN_DIR) -o $@ $^
8895

89-
else
90-
# For VCK5000, linking and packaging are separate steps
91-
96+
else ifeq ($(BOARD_TYPE),alveo-versal) || ($(BOARD_TYPE),versal)
97+
# For Versal architecture, linking and packaging are separate steps
9298
$(BUILD_DIR)/$(WRAPPER_NAME).xsa: $(BUILD_DIR)/$(KERNEL_NAME)_kernel.xo
9399
mkdir -p $(XCLBIN_DIR)
94100
v++ -l $(XOLDFLAGS) --temp_dir $(XCLBIN_DIR) --log_dir $(XCLBIN_DIR) -o $@ $^
95101

96-
XOCCPFLAGS := -t $(TARGET) -f $(PLATFORM) --package.boot_mode=ospi --messageDb=$(BUILD_DIR)/kernel_wrapper.mdb
97-
98102
# VCK5000 specific packaging
103+
XOCCPFLAGS := -t $(TARGET) -f $(PLATFORM) --package.boot_mode=ospi --messageDb=$(BUILD_DIR)/kernel_wrapper.mdb
99104
$(BUILD_DIR)/$(WRAPPER_NAME).xclbin: $(BUILD_DIR)/$(WRAPPER_NAME).xsa
100105
v++ -p $(XOCCPFLAGS) --temp_dir $(XCLBIN_DIR) --log_dir $(XCLBIN_DIR) -o $@ $^
101106

107+
else
108+
@echo "$(BOARD_TYPE) board type is currently unsupported"
109+
102110
endif
103111

104112
xclbin: $(BUILD_DIR)/$(WRAPPER_NAME).xclbin
@@ -114,14 +122,19 @@ host: $(KERNEL_NAME)_host_cl.cpp libs/xcl2.cpp
114122
# Cleanup #####################################################################
115123

116124
cleanxclbin:
117-
rm -rf host tb_data/hw_results.dat
125+
rm -rf host tb_data/hw_results.dat tb_data/tb_input_features.dat
118126
rm -rf *$(WRAPPER_NAME)*.log
119-
rm -rf $(BUILD_DIR)/$(WRAPPER_NAME).xclbin* $(BUILD_DIR)/$(WRAPPER_NAME).xsa* $(BUILD_DIR)/$(WRAPPER_NAME).ltx $(BUILD_DIR)/$(WRAPPER_NAME).mdb
120-
rm -rf $(BUILD_DIR)/xclbincleanhls
127+
rm -rf $(BUILD_DIR)/$(WRAPPER_NAME).xclbin.* $(BUILD_DIR)/$(WRAPPER_NAME).xsa* $(BUILD_DIR)/$(WRAPPER_NAME).ltx $(BUILD_DIR)/$(WRAPPER_NAME).mdb
128+
rm -rf $(XCLBIN_DIR)
121129

122130
cleanhls:
123-
rm -rf $(BUILD_DIR)/$(KERNEL_NAME)_kernel.xo*
124-
rm -rf $(BUILD_DIR)/xo
125131
rm -rf *$(KERNEL_NAME)_kernel*.log
132+
rm -rf $(BUILD_DIR)/$(KERNEL_NAME)_kernel.xo.*
133+
rm -rf $(XO_DIR)
126134

127135
clean: cleanxclbin cleanhls
136+
137+
ultraclean:
138+
rm -rf host tb_data/hw_results.dat tb_data/tb_input_features.dat *.log
139+
rm -rf $(BUILD_DIR)
140+

hls4ml/writer/vitis_accelerator_writer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ def write_makefile(self, model):
184184
for line in f.readlines():
185185
if 'myproject' in line:
186186
newline = line.replace('myproject', project_name)
187+
if 'BOARD_TYPE :=' in line:
188+
newline = line
189+
newline += board_type
187190
else:
188191
newline = line
189192
fout.write(newline)

0 commit comments

Comments
 (0)