Skip to content

Commit 00f82a3

Browse files
committed
oneAPI BSP support.
1 parent 97c187d commit 00f82a3

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

hls4ml/backends/oneapi/oneapi_backend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ def create_initial_config(self, part='Arria10', clock_period=5, io_type='io_para
153153
# TODO: add namespace
154154
'WriteTar': write_tar,
155155
}
156-
157-
if 'use_bsp' in _:
158-
config['IS_BSP'] = True
156+
# Target oneAPI Board Support Package (BSP).
157+
if "use_oneapi_bsp" in _:
158+
config['UseOneAPIBSP'] = _["use_oneapi_bsp"]
159159

160160
return config
161161

hls4ml/templates/oneapi/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@ set(LIBRARY_NAME myproject-${LIB_STAMP})
3939
# specific part number (E.g. "10AS066N3F40E2SG") to generate a standalone IP.
4040
if(NOT DEFINED FPGA_DEVICE)
4141
set(FPGA_DEVICE "Agilex7")
42+
set(BSP_FLAG "")
4243
endif()
4344

45+
# Set the target to a BSP if we target an actual accelerator board.
46+
# hls-fpga-machine-learning insert oneapi_bsp_cmake_flag
47+
4448
# Use cmake -DUSER_FPGA_FLAGS=<flags> to set extra flags for FPGA backend
4549
# compilation.
4650
# -Xsoptimize=latency Turns off the hyper-optimized handshake
4751
set(USER_FPGA_FLAGS -Wno-unused-label;${USER_FPGA_FLAGS};-Xsoptimize=latency)
4852

4953
# Use cmake -DUSER_FLAGS=<flags> to set extra flags for general compilation.
50-
set(USER_FLAGS -Wno-unused-label -fconstexpr-steps=134217728 ${USER_FLAGS})
54+
set(USER_FLAGS -Wno-unused-label -fconstexpr-steps=134217728 ${USER_FLAGS} ${BSP_FLAG})
5155

5256
# Use cmake -DUSER_INCLUDE_PATHS=<paths> to set extra paths for general
5357
# compilation.

hls4ml/templates/oneapi/firmware/myproject.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using PipeProps = decltype(sycl::ext::oneapi::experimental::properties(sycl::ext
1111
// Pipe properties for host pipes. Host pipes connect to the data source DMA and sink DMA.
1212
// They are connected to the first and the last layer to stream data into and out from the kernel.
1313
using HostPipePropertiesT = decltype(sycl::ext::oneapi::experimental::properties(
14-
sycl::ext::intel::experimental::ready_latency<0>, sycl::ext::intel::experimental::bits_per_symbol<8>,
14+
sycl::ext::intel::experimental::ready_latency<0>, sycl::ext::intel::experimental::bits_per_symbol<16>,
1515
sycl::ext::intel::experimental::uses_valid<true>, sycl::ext::intel::experimental::first_symbol_in_high_order_bits<true>,
1616
sycl::ext::intel::experimental::protocol_avalon_streaming_uses_ready));
1717

@@ -127,12 +127,15 @@ template <class src_pipe, class dst_T> struct DMA_convert_data_back {
127127
class MyProjectID;
128128

129129
struct MyProject {
130-
130+
#ifndef IS_BSP
131131
// kernel property method to config invocation interface
132132
auto get(sycl::ext::oneapi::experimental::properties_tag) {
133133
return sycl::ext::oneapi::experimental::properties{sycl::ext::intel::experimental::streaming_interface<>,
134134
sycl::ext::intel::experimental::pipelined<>};
135135
}
136+
#else
137+
// kernel properties and pipelining is not supported in BSP.
138+
#endif
136139

137140
SYCL_EXTERNAL void operator()() const;
138141
};

hls4ml/writer/oneapi_writer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,10 @@ def write_build_script(self, model):
557557
if 'set(FPGA_DEVICE' in line:
558558
line = f' set(FPGA_DEVICE "{device}")\n'
559559

560+
if model.config.get_config_value('UseOneAPIBSP'):
561+
if 'hls-fpga-machine-learning insert oneapi_bsp_cmake_flag' in line:
562+
line = f'set(BSP_FLAG "-DIS_BSP")'
563+
560564
fout.write(line)
561565

562566
def write_nnet_utils(self, model):

0 commit comments

Comments
 (0)