- Code: Select all
#pragma omp parallel
{
// Task 1
#pragma omp task
{
// Task 2
#pragma omp task
{
doSomething();
}
// Taskwait 1
#pragma omp taskwait
doSomethingElse();
}
// Task 3
#pragma omp task if(1 == 0)
{
// Task 4
#pragma omp task
{
doAnotherThing();
}
// Taskwait 2
#pragma omp taskwait
doSomethingMore();
}
}
Each thread decides to execute Task 1 when it is created but then decides to continue with Task 1 when Task 2 is created. When they reach Taskwait 1 each thread then decides to continue executing its implicit task. When each thread creates its Task 3 it must execute it immediately because of task scheduling constraint 1 in the API. Then the threads must create Task 4 and reach Taskwait 2. Each thread is now stuck: Task 1 and Task 3 are stuck at Taskwait 1 and Taskwait 2 respectively, Task 2 and Task 4 cannot be execute because of task scheduling constraint 2 in the API (Task 2 is not descended from Task 3 and Task 4 is not descended from Task 1).
Each of the scheduling decisions described above appear to be valid according to the API and the source code also appears to be valid. Have I misinterpreted the API or is this conforming behaviour?
