Developer Guide

FPGA Optimization Guide for Intel® oneAPI Toolkits

ID 767853
Date 12/16/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Control Hardware Implementation of the Supported Data Types and Math Operations (<span class='codeph'>-Xsdsp-mode=<var><option></var> </span>)

The Intel® oneAPI DPC++/C++ Compiler 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 (report.html).

Global-scope Control

Include the -Xsdsp-mode=[default|prefer-dsp|prefer-softlogic] flag in your 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 <option> is one of the following values:

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(<Preference::<enum>, Propagate::<enum>>) defined in the 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 <Preference::<enum>> argument takes up an 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.
NOTE:

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.
NOTE:

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 <Propagate::<enum>> argument is a boolean value that determines the propagation of the Preference::<enum> value to function calls in the lambda expression as follows:

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;
});
NOTE:

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
NOTE:

For additional information, refer to the FPGA tutorial sample DSP Control listed in the Intel® oneAPI Samples Browser on Linux* or Windows*, or access the code sample in GitHub.