Skip to content

Commit 03953ad

Browse files
Change default part to agilex 7, turn of hyper-optimized handshaking (#1304)
Co-authored-by: Jan-Frederik Schulte <jschulte@cern.ch>
1 parent 50381da commit 03953ad

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

hls4ml/backends/oneapi/oneapi_backend.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,15 @@ def get_default_flow(self):
130130
def get_writer_flow(self):
131131
return self._writer_flow
132132

133-
def create_initial_config(self, part='Arria10', clock_period=5, io_type='io_parallel', write_tar=False, **_):
133+
def create_initial_config(
134+
self, part='Agilex7', clock_period=5, hyperopt_handshake=False, io_type='io_parallel', write_tar=False, **_
135+
):
134136
"""Create initial configuration of the oneAPI backend.
135137
136138
Args:
137-
part (str, optional): The FPGA part to be used. Defaults to 'Arria10'.
138-
clock_period (int, optional): The clock period. Defaults to 5.
139+
part (str, optional): The FPGA part to be used. Defaults to 'Agilex7'.
140+
clock_period (int, optional): The clock period in ns. Defaults to 5.
141+
hyperopt_handshake (bool, optional): Should hyper-optimized handshaking be used? Defaults to False
139142
io_type (str, optional): Type of implementation used. One of
140143
'io_parallel' or 'io_stream'. Defaults to 'io_parallel'.
141144
write_tar (bool, optional): If True, compresses the output directory into a .tar.gz file. Defaults to False.
@@ -146,8 +149,9 @@ def create_initial_config(self, part='Arria10', clock_period=5, io_type='io_para
146149

147150
config = {}
148151

149-
config['Part'] = part if part is not None else 'Arria10'
152+
config['Part'] = part if part is not None else 'Agilex7'
150153
config['ClockPeriod'] = clock_period
154+
config['HyperoptHandshake'] = hyperopt_handshake
151155
config['IOType'] = io_type
152156
config['HLSConfig'] = {}
153157
config['WriterConfig'] = {
@@ -167,7 +171,7 @@ def compile(self, model):
167171
Exception: If the project failed to compile
168172
169173
Returns:
170-
string: Returns the name of the compiled library.
174+
Path: Returns the name of the compiled library.
171175
"""
172176
outdir = Path(Path.cwd(), model.config.get_output_dir())
173177
builddir = outdir / 'build'

hls4ml/templates/oneapi/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ set(LIBRARY_NAME myproject-${LIB_STAMP})
3535
# path to the board support package (BSP), this usually is in your install
3636
# folder.
3737
#
38-
# You can also specify a device family (E.g. "Arria10" or "Stratix10") or a
38+
# You can also specify a device family (E.g. "Agilex7" or "Stratix10") or a
3939
# specific part number (E.g. "10AS066N3F40E2SG") to generate a standalone IP.
4040
if(NOT DEFINED FPGA_DEVICE)
41-
set(FPGA_DEVICE "Arria10")
41+
set(FPGA_DEVICE "Agilex7")
4242
endif()
4343

4444
# Use cmake -DUSER_FPGA_FLAGS=<flags> to set extra flags for FPGA backend
4545
# compilation.
46-
set(USER_FPGA_FLAGS -Wno-unused-label ${USER_FPGA_FLAGS})
46+
set(USER_FPGA_FLAGS -Wno-unused-label;${USER_FPGA_FLAGS})
4747

4848
# Use cmake -DUSER_FLAGS=<flags> to set extra flags for general compilation.
4949
set(USER_FLAGS -Wno-unused-label -fconstexpr-steps=134217728 ${USER_FLAGS})

hls4ml/writer/oneapi_writer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,8 @@ def write_build_script(self, model):
517517
# Makefile
518518
filedir = os.path.dirname(os.path.abspath(__file__))
519519
device = model.config.get_config_value('Part')
520+
period = model.config.get_config_value('ClockPeriod')
521+
hyper = model.config.get_config_value('HyperoptHandshake')
520522
with (
521523
open(os.path.join(filedir, '../templates/oneapi/CMakeLists.txt')) as f,
522524
open(f'{model.config.get_output_dir()}/CMakeLists.txt', 'w') as fout,
@@ -528,6 +530,11 @@ def write_build_script(self, model):
528530
if 'set(FPGA_DEVICE' in line:
529531
line = f' set(FPGA_DEVICE "{device}")\n'
530532

533+
if 'set(USER_FPGA_FLAGS' in line:
534+
line += f'set(USER_FPGA_FLAGS -Xsclock={period}ns; ${{USER_FPGA_FLAGS}})\n'
535+
if not hyper:
536+
line += 'set(USER_FPGA_FLAGS -Xsoptimize=latency; ${USER_FPGA_FLAGS})\n'
537+
531538
fout.write(line)
532539

533540
def write_nnet_utils(self, model):

0 commit comments

Comments
 (0)