Taskiter Construct

October 22, 2025 ยท View on GitHub

Given an iterative application with loops presenting an identifiable task directed-acyclic graph (DAG) that repeats itself at each iteration, the taskiter construct optimizes their execution as follows:

  1. The first iteration of the loop is executed, and its generated DAG is recorded.
  2. The recorded DAG is transformed to generate a directed cyclic task graph (DCTG).
  3. The generated DCTG is automatically optimized and utilized to execute the remaining iterations.

The following code, extracted from tests/correctness/taskiter/taskiter-unroll.cpp, shows an example usage of the taskiter clause:

    #pragma oss taskiter shared(A) unroll(UNROLL)
    for (int i = 0; i < NUM_ITERS; ++i) {
        for (int j = 0; j < tilesize; ++j) {
            #pragma oss task shared(A) firstprivate(j) inout(A[j])
            {
                A[j]++;
            }

            #pragma oss task shared(A) firstprivate(j) inout(A[j])
            {
                A[j]++;
            }
        }
    }

    #pragma oss taskwait

More information about the taskiter construct and its benefits can be found in its original paper.