Visible to Intel only — GUID: GUID-3A377FE5-55D9-4ACB-9A52-74A492FC9DDB
Visible to Intel only — GUID: GUID-3A377FE5-55D9-4ACB-9A52-74A492FC9DDB
task_sequence 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();
For additional information, refer to the Parallel Loops sample on GitHub.