Intel® High Level Synthesis Compiler Pro Edition: Reference Manual

ID 683349
Date 6/02/2023
Public

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

Document Table of Contents

13.8. Intel® HLS Compiler Pro Edition Scope Pragmas

Use the Intel® HLS Compiler scope pragmas to influence the rounding of floating-point operations and the ordering of arithmetic operations in your component at finer grain than the i++ command options.

Table 44.   Intel® HLS Compiler Pro Edition Scoped Pragmas Summary
Pragma Description
fp contract Controls the removal of intermediate rounding and conversion when possible within the code block that this pragma is applied to.
fp reassociate Controls the relaxing of the order of floating point arithmetic operations within the code block that this pragma is applied to.

fp contract Scoped Pragma

Syntax
#pragma clang fp contract(state)
Description
For double-precision data types, this pragma controls whether the compiler can contract floating-point multiply and add or subtract operations into a single fused multiply-add (FMA), and controls whether the compiler skips intermediate rounding and conversions.

This pragma has no effect on operations that involve single-precision data types.

If multiple occurrences of this pragma affect the same scope, the pragma with the narrowest scope takes precedence.

The state parameter can be one of the following values:
  • off

    Turns off any permissions to fuse instructions into FMAs.

    The effect of the -ffp-contract=fast i++ command flag is suppressed for instructions within the scope of the pragma.

  • on

    Allows the fusing of mult andadd instructions into an FMA only when they are in one line of code, but might violate the language standard.

    For instructions within the scope of this pragma, the same optimizations as -ffp-contract=on i++ command flag are enabled.

    The effect of the -ffp-contract=fast i++ command flag are overridden for instructions within the scope of the pragma. That is, operations in code scoped with #pragma clang fp contract(on) can be fused only when they are in one line of code but not multiple lines of code.

  • fast

    Allows the fusing of mult andadd instructions into an FMA across multiple lines of code, but might violate the language standard.

    For instructions within the scope of this pragma, the same optimizations as -ffp-contract=fast i++ command flag are enabled.

For example, in the following code, #pragma clang fp contract(on) and #pragma clang fp contract(fast) would have the same effect:
double res = a * b + c;
However, in the following code, #pragma clang fp contract(on) and #pragma clang fp contract(fast) would have the different effects:
double temp = a * b;
double res = temp + c;

fp reassociate Scoped Pragma

Syntax
#pragma clang fp reassociate(state)
Description
This pragma controls whether the compiler can relax the order of floating point operations requested by the source code. With some reordering, the compiler can optimize the hardware structure which improves the performance of your component.

If multiple occurrences of this pragma affect the same scope, the pragma with the narrowest scope takes precedence.

The state parameter can be one of the following values:
  • on

    Enables the effect of the -ffp-reassociate i++ command flag for instructions within the scope of the pragma.

  • off

    The effect of the -ffp-reassociate i++ command flag is suppressed for instructions within the scope of the pragma.