Skip to content

Commit e637d44

Browse files
build() signature alignment + xcl update + write_host() overwrite
1 parent e2cfc84 commit e637d44

File tree

9 files changed

+264
-166870
lines changed

9 files changed

+264
-166870
lines changed

hls4ml/backends/vitis_accelerator/vitis_accelerator_backend.py

Lines changed: 20 additions & 4 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, target="all"):
47+
def build(self, model, reset=False, synth=True, vsynth=True):
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")
@@ -53,19 +53,35 @@ def build(self, model, target="all"):
5353
if 'XILINX_VIVADO' not in os.environ:
5454
raise Exception("XILINX_VIVADO environmental variable missing. Please install XRT and Vitis, and run the setup scripts before building")
5555

56-
if target not in ["all", "host", "hls", "xclbin"]:
57-
raise Exception("Invalid build target")
58-
5956
curr_dir = os.getcwd()
6057
os.chdir(model.config.get_output_dir())
58+
59+
if reset:
60+
if vsynth:
61+
os.system("make cleanxclbin")
62+
if synth:
63+
os.system("make cleanhls")
64+
os.system("rm -rf host")
65+
66+
if vsynth:
67+
if synth:
68+
target = "all"
69+
else:
70+
target = "xclbin"
71+
elif synth:
72+
target = "hls"
73+
else:
74+
target = "host"
6175
command = "make " + target
76+
6277
# Pre-loading libudev
6378
ldconfig_output = subprocess.check_output(["ldconfig", "-p"]).decode("utf-8")
6479
for line in ldconfig_output.split("\n"):
6580
if "libudev.so" in line and "x86" in line:
6681
command = "LD_PRELOAD=" + line.split("=>")[1].strip() + " " + command
6782
break
6883
os.system(command)
84+
6985
os.chdir(curr_dir)
7086
else:
7187
raise Exception("Currently untested on non-Linux OS")

hls4ml/templates/vitis_accelerator/Makefile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ endif
2525
KERN_LIBRARIES += -I./ -I./firmware/ -I./firmware/weights -I./firmware/nnet_utils/
2626

2727
.PHONY: all
28-
all: host xclbin
28+
all: hls xclbin
2929

3030
# Building kernel
3131
./build/myproject_kernel.xo: kernel_wrapper.cpp
@@ -47,12 +47,16 @@ host: myproject_host_cl.cpp libs/xcl2.cpp
4747
hls: ./build/myproject_kernel.xo
4848

4949
.PHONY: xclbin
50-
xclbin: ./build/kernel_wrapper.xclbin
50+
xclbin: ./build/kernel_wrapper.xclbin host
5151

5252
# Cleaning stuff
53-
.PHONY: clean
54-
clean:
55-
-rm -rf host
56-
-rm -rf *.xclbin*
57-
-rm -rf build*
58-
-rm -rf *.log *.jou *.rpt *.csv *.mdb *.ltx
53+
.PHONY: cleanxclbin
54+
-rm -rf host tb_data/hw_results.dat
55+
-rm -rf *kernel_wrapper*.log
56+
-rm -rf build/kernel_wrapper.xclbin* build/kernel_wrapper.xsa* build/kernel_wrapper.ltx build/kernel_wrapper.mdb
57+
-rm -rf build/xclbin
58+
59+
.PHONY: cleanhls
60+
-rm -rf build/myproject_kernel.xo*
61+
-rm -rf build/xo
62+
-rm -rf *myproject_kernel*.log

0 commit comments

Comments
 (0)