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

<span class='codeph'>task_sequence</span> Use Cases

Using a task_sequence in your kernel enables a variety of design structures that you can implement. Common uses for the task_sequence class include executing multiple loops in parallel, as described in the following section.

Executing Multiple Loops in Parallel

Using the task_sequence class, you can run sequential loops in a pipelined manner within the context of the loop nest.

For example, in the following code sample, the first and second loops cannot be executed in parallel by the same invocation of the kernel they are contained in:

// first loop
for (int i = 0; i < n; i++) {
  // Do something
}
// second loop
for (int i = 0; i < m; i++) { 
  // Do something else
}
// program scope
void firstLoop() {
  for (int i = 0; i < n; i++) {
    // Do something
  }
}
void secondLoop() {
  for (int i = 0; i < m; i++) {
    // Do something else
  }
}

// in kernel code
using namespace sycl::ext::intel::experimental;
task_sequence<firstLoop> firstTask;
task_sequence<secondLoop> secondTask;
firstTask.async();
secondTask.async();
firstTask.get();
secondTask.get();