Skip to content

Commit 5be9569

Browse files
author
Quentin Berthet
committed
Update bulild():
- use backend specific target parameter - remove environnement checks that are also performed in the makefile
1 parent 5376926 commit 5be9569

File tree

2 files changed

+13
-46
lines changed

2 files changed

+13
-46
lines changed

docs/backend/accelerator.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,17 @@ Build workflow
116116

117117
At the call of the ``build`` method, the following option affect the build process:
118118

119-
* ``reset``: If True, clears files generated during previous build processes (STILL BEING TESTED).
120-
* ``csim``: If True, builds the project for Vitis' software emulation validation flow (STILL BEING TESTED)
121-
* ``synth``: If True, runs `make hls`, building object files for the kernel (STILL BEING TESTED)
122-
* ``cosim``: If True, builds the project for Vitis' hardware emulation validation flow (STILL BEING TESTED)
123-
* ``vsynth``: If True, runs `make xclbin`, building the .xclbin binary executable for the kernel (STILL BEING TESTED)
124-
* ``debug``: If True, compiles the c++ host code and the HLS in debug mode (STILL BEING TESTED)
119+
* ``reset``: If True, clears files generated during previous build processes (Equivalent to ``make clean`` in build folder).
120+
* ``target``: Can be one of ``hw``, ``hw_emu``, ``sw_emu``, to define which build target to use (Default is ``hw``).
121+
* ``debug``: If True, compiles the c++ host code and the HLS in debug mode.
125122

126123
Once the project is generated, it possible to run manually the build steps by using one of the following ``make`` targets in the generated project directory:
127124

128125
* ``host``: Compiles the host application.
129126
* ``hls``: Produces only the kernel's object file.
130127
* ``xclbin``: Produces only the kernel's .xclbin file.
128+
* ``clean``: Removes all generated files.
129+
* ``run``: Run the host application using the .xclbin file and the input data present in ``tb_data/tb_input_features.dat``.
131130

132131
It is also possible to run the full build process by calling ``make`` without any target. Modifications to the ``accelerator_card.cfg`` file can be done manually before running the build process (e.g., to change the clock period, or add addition ``.xo`` kernel to the build).
133132

hls4ml/backends/vitis_accelerator/vitis_accelerator_backend.py

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -57,60 +57,28 @@ def build(
5757
self,
5858
model,
5959
reset=False,
60-
synth=True,
61-
vsynth=True,
62-
csim=False,
63-
cosim=False,
60+
target="hw",
6461
debug=False,
6562
**kwargs,
6663
):
64+
if target not in ["hw", "hw_emu", "sw_emu"]:
65+
raise Exception("Invalid target, must be one of 'hw', 'hw_emu' or 'sw_emu'")
66+
6767
if "linux" in sys.platform:
68-
if "XILINX_VITIS" not in os.environ:
69-
raise Exception(
70-
"XILINX_VITIS environmental variable missing."
71-
" Please install XRT and Vitis, and run the setup scripts before building"
72-
)
73-
if "XILINX_XRT" not in os.environ:
74-
raise Exception(
75-
"XILINX_XRT environmental variable missing."
76-
" Please install XRT and Vitis, and run the setup scripts before building"
77-
)
78-
if "XILINX_VIVADO" not in os.environ:
79-
raise Exception(
80-
"XILINX_VIVADO environmental variable missing."
81-
" Please install XRT and Vitis, and run the setup scripts before building"
82-
)
8368

8469
curr_dir = os.getcwd()
8570
os.chdir(model.config.get_output_dir())
8671

87-
if cosim:
88-
target = "TARGET=hw_emu "
89-
elif csim:
90-
target = "TARGET=sw_emu "
72+
command = f"TARGET={target} "
9173

9274
if debug:
93-
target += "DEBUG"
94-
95-
if vsynth:
96-
if synth:
97-
process = "all "
98-
else:
99-
process = "xclbin "
100-
elif synth:
101-
process = "hls "
102-
else:
103-
process = "host "
75+
command += "DEBUG=1 "
10476

105-
command = "make " + process + target
77+
command += " make all"
10678

10779
# Cleaning
10880
if reset:
109-
if vsynth:
110-
os.system("make cleanxclbin " + target)
111-
if synth:
112-
os.system("make cleanhls " + target)
113-
os.system("rm -rf host")
81+
os.system(f"TARGET={target} make clean")
11482

11583
# Pre-loading libudev
11684
ldconfig_output = subprocess.check_output(["ldconfig", "-p"]).decode("utf-8")

0 commit comments

Comments
 (0)