Consider the following code which may be executed by a serial team:
int dep; #pragma omp target nowait depend(out: dep) { sleep(1); } #pragma omp task depend(in: dep) { #pragma omp target nowait { sleep(1); } }
Here the explicit task may not be freed until the nested proxy task has
finished. The current code hasn't considered this and called __kmp_free_task
anyway which triggered an assert because of remaining incomplete children:
KMP_DEBUG_ASSERT( TCR_4(taskdata->td_incomplete_child_tasks) == 0 );
This change breaks the following code:
The problem is that for a serial task its parent task is most likely still running and thus cannot be freed prematurely.
To me, the correct fix would be to remember the status of initial task at the beginning of the routine, e.g.
then in the loop check this condition:
I think checking task_serial flag here is better than team_serial or tasking_serial (as was done before the change), because a task can be serialized even if team is active and tasking is active (e.g. no room in thread's task queue).