Intel® High Level Synthesis Compiler Pro Edition: Reference Manual

ID 683349
Date 3/28/2022
Public

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

Document Table of Contents

13.13. Intel® HLS Compiler Pro Edition Systems of Tasks API

Table 49.   Intel® HLS Compiler System of Tasks Summary
Function Description
ihc::launch Marks a function as an Intel® HLS Compiler task for hardware generation, and launches the task function asynchronously.
ihc::collect Synchronizes the completion of the specified task function in the component.
ihc::stream Allows streaming communication between different task functions.
ihc::launch_always_run Launches a task function at component power-on or reset and continuously executes the function.
Recommendation: Use the ihc_hls_set_component_wait_cycle with this function to keep your component and always-run task functions correctly coordinated.

ihc::launch Function

Syntax
ihc::launch<function[, capacity]>(fuction_argument_list)
Where the function parameters are defined as follows:
  • function

    The name of the function that you are calling as an Intel® HLS Compiler task in your component.

  • capacity

    An optional value that, when set, results in a FIFO buffer of depth capacity inserted between the function that launches the task and the task function.

    Set the capacity parameter when you observe stall patterns that indicate an imbalance between any backpressure introduced by the called task function (function) and how often the caller launches this task function.

  • fuction_argument_list

    The list of arguments to pass to the task function.

    This list must match the arguments (in names and types) that the task function expects.

Description
The ihc::launch API function identifies a function as Intel® HLS Compiler task for hardware generation. Calling this function starts the task function asynchronously.

If the task function cannot accept a new thread, the ihc::launch function can block the function that calls the ihc::launch function.

The list of arguments that supply the ihc::launch API function must match (in names and types) the list of arguments expected by the task function.

ihc::collect Function

Syntax
ihc::collect<function[, capacity]>()
Where the function parameters are defined as follows:
  • function

    The name of the Intel® HLS Compiler task function to synchronize the completion of.

    Set the capacity parameter when you observe stall patterns that indicate that the task function (function) produces data at a different cadence from the reading cadence of the caller.

  • capacity

    An optional value that, when set, results in a FIFO buffer of size capacity inserted between the task function and the function that collects the task.

Description
The ihc::collect API function synchronizes the completion of the specified task function in the component.

For a non-void task function, the ihc::collect API function collects the result from the specified task function.

For a void task function, the ihc::collect API function synchronizes against the done signal of the task function.

The number of ihc::collect calls for a task function must match the number of ihc::launch calls for the same task function to flush all of the calls to the task.

Special Case: If you do not use ihc::collect at all, the compiler optimizes and ties-off the return stream of the task to be stall free and ignores any data on the return stream. Other streaming interfaces can still back-pressure the task function. Additionally, the caller might finish before the task function.

ihc::launch_always_run Function

Syntax
ihc::launch_always_run<function>()
Where the function parameters are defined as follows:
  • <function>

    The name of the function that you are calling as a continuously-executing Intel® HLS Compiler task in your component.

Description

Use the ihc::launch_always_run API function to continuously execute a task function, much like an invoking a component with the hls_always_run_component invocation interface argument.

The task launches at the power-on or the reset of the component instead of at a specific point in the datapath.

The task function that you provide to this API must match this prototype:
void function(void)

Your task function must be have no function arguments and no return value. You should communicate with your task function through global streams or by using compile-time constant template parameters.

Use the ihc_hls_set_component_wait_cycle API function when using the ihc::launch_always_run API function because the top level component can finish before all of the always-run task functions are done processing the work allotted to them.

Example
The following example shows a simple use of the ihc::launch_always_run function.
ihc::stream<int> in_stream, out_stream;

template <ihc::stream<int> &inStream,
          ihc::stream<int> &outStream>

void my_task()
{
  int x = inStream.read();
  x *= 2;
  outStream.write(x);
}

component void foo()
{
  ihc::launch_always_run<my_task<in_stream, out_stream>>();
}

Intel® HLS Compiler System of Tasks Code Example

The following code example illustrates how you can use the systems of tasks API.
int mul(int a, int b)
{
	return a * b;
}

Template<typename T>
T add(T a, T b)
{
	return a + b;
}

component int foo(int a, int b)
{
	ihc::launch<mul>(a,b);
	ihc::launch<add<int>>(a,b);
	int prod = ihc::collect<mul>();
	int sum = ihc::collect<add<int>>();
	return sum + prod;
}