Control Hardware Implementation of the Supported Data Types and Math Operations (-Xsdsp-mode=<option>)
-Xsdsp-mode=
)<option>
The
Intel® oneAPI
allows you to control (at global and local scope) whether the implementation of the
supported data type and math functions uses
DSPs or soft logic using
ALMs. You can find this implementation in the Details pane of the corresponding math instruction nodes in the
System Viewer of the FPGA optimization report (DPC++/C++
Compilerreport.html
).
Global-scope Control
Include the
-Xsdsp-mode=
flag in your
[default|prefer-dsp|prefer-softlogic]
icpx
command to control the hardware implementation of the supported data types and math operations of all kernels in your source code.
Example
icpx -fsycl -fintelfpga –Xshardware -Xsdsp-mode=<option> <source_file>.cpp
where the
is one of the following values:
<option>
Option
| Description
|
---|---|
default | Default option if you do not pass this command-line flag manually. The compiler determines the implementation based on the data type and math operation.
|
prefer-dsp | Prefer math operations to be implemented in DSPs. If a math operation is implemented by DSPs by default, you see no difference in resource utilization or area. Otherwise, you will notice a decrease in the use of soft-logic resources and an increase in the use of DSPs.
|
prefer-softlogic | Prefer math operations to be implemented in soft-logic. If a math operation is implemented without DSPs by default, you see no difference in resource utilization or area. Otherwise, you will notice a decrease in the use of DSPs and an increase in the use of soft-logic resources.
|
Local-scope Control
You can control DSP usage of the supported math operations on a local scope by using the library function
sycl::ext::intel::math_dsp_control(<
defined in the
Preference::<enum>
,
Propagate::<enum>
>)fpga_dsp_control.hpp
header file, which is included in the
fpga_extensions.hpp
header file. This library function provides control at the block level within a single kernel. A reference-capturing lambda expression is passed as the argument to this library function. Inside the lambda expression, the implementation preference of math operations that support DSP control is determined by two template arguments.
The
<
argument takes up an
Preference::<enum>
>enum
data type with one of the following values:
Value
| Description
|
---|---|
sycl::ext::intel::Preference::DSP | Prefer math operations to be implemented in DSPs. Its behavior on a math operation is equivalent to the global control
-Xsdsp-mode=prefer-dsp .
The
sycl::ext::intel::Preference::DSP option is automatically applied if you do not specify the template argument
Preference manually.
|
sycl::ext::intel::Preference::Softlogic | Prefer math operations to be implemented in soft logic. Its behavior on a math operation is equivalent to the global control
-Xsdsp-mode=prefer-softlogic .
|
sycl::ext::intel::Preference::Compiler_default | Compiler determines the implementation based on the data type and math operation. Its behavior on a math operation is equivalent to the global control
-Xsdsp-mode=default .
|
Local control overrides global control on a controlled math operation. For example:
// icpx -fsycl -Xsdsp-mode=prefer-softlogic ...
using namespace sycl;
cgh.single_task<class LocalControl>([=]() {
out_acc[0] = in_acc[0] + inp_acc[1]; // Addition implemented in soft-logic.
ext::intel::math_dsp_control<ext::intel::Preference::DSP>([&] {
out_acc[1] = in_acc[0] + in_acc[1]; // Addition implemented in DSP.
});
});
The
value to function calls in the lambda expression as follows:
<
argument is a boolean value that determines the propagation of the
Propagate::<enum>
>Preference::<enum>
Value
| Description
|
---|---|
sycl::ext::intel::Propagate::On | DSP control recursively applies to controllable math operations in all function calls in the lambda expression function. This value is the default and it is applied if you do not specify the argument
< .
Propagate::<enum> > |
sycl::ext::intel::Propagate::Off | DSP control applies only to the controllable math operations directly inside the lambda expression. Math operations in function calls inside the lambda expression are not affected by this DSP control.
|
Example
sycl::ext::intel::math_dsp_control<sycl::ext::intel::Preference::Softlogic,
sycl::ext::intel::Propagate::On>([&]{
a += 1.23f;
});
A nested
math_dsp_control<>()
call is controlled only by its own
Preference
argument. The
Preference
of the parent
math_dsp_control<>()
function does not affect the nested
math_dsp_control<>()
function, even if the parent has the argument
Propagate::On
. For example:
using namespace sycl;
cgh.single_task<class LocalControl>([=]() {
ext::intel::math_dsp_control<ext::intel::Preference::DSP,
ext::intel::Propagate::On>([&] {
out_acc[0] = in_acc[0] + in_acc[1]; // Addition implemented in DSP.
ext::intel::math_dsp_control<ext::intel::Preference::Softlogic>([&] {
// Addition implemented in soft-logic. Preference::DSP on the parent
// math_dsp_control<>() call does not affect this math_dsp_control<>().
out_acc[1] = in_acc[0] + in_acc[1];
});
});
});
Supported Data Type and Math Operations
Data types
| Math Operations
|
---|---|
float | Addition, subtraction, multiplication by a constant
|
ap_float<8, 23>
| Addition, subtraction, multiplication by a constant
|
int | Multiplication by a constant
|
ac_int
| Multiplication by a constant
|
ac_fixed
| Multiplication by a constant
|