@@ -263,9 +263,13 @@ extern char *goacc_device_type;
enum gomp_task_kind
{
+ /* Thread not directly created by user. For instance, when creating
+ a team of threads or an ICV. */
GOMP_TASK_IMPLICIT,
GOMP_TASK_IFFALSE,
+ /* Task created by GOMP_task and waiting to be run. */
GOMP_TASK_WAITING,
+ /* Task currently scheduled and about to execute. */
GOMP_TASK_TIED
};
@@ -313,8 +317,11 @@ struct gomp_task
struct gomp_task *prev_child;
struct gomp_task *next_queue;
struct gomp_task *prev_queue;
+ /* Next task in the current taskgroup. */
struct gomp_task *next_taskgroup;
+ /* Previous task in the current taskgroup. */
struct gomp_task *prev_taskgroup;
+ /* Taskgroup this task belongs in. */
struct gomp_taskgroup *taskgroup;
struct gomp_dependers_vec *dependers;
struct htab *depend_hash;
@@ -388,6 +388,7 @@ GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
parent->children = task;
if (taskgroup)
{
+ /* If applicable, place task into its taskgroup. */
if (taskgroup->children)
{
task->next_taskgroup = taskgroup->children;
@@ -451,7 +452,14 @@ gomp_task_run_pre (struct gomp_task *child_task, struct gomp_task *parent,
{
if (parent)
{
- /* Remove child_task from parent. */
+ /* Adjust children such that it will point to a next child,
+ while the current one is scheduled to be executed. This way,
+ GOMP_taskwait (and others) can schedule a next task while
+ waiting.
+
+ Do not remove it entirely from the circular list, as it is
+ still a child, though not one we should consider first (say
+ by GOMP_taskwait). */
if (parent->children == child_task)
parent->children = child_task->next_child;
@@ -465,10 +473,14 @@ gomp_task_run_pre (struct gomp_task *child_task, struct gomp_task *parent,
parent->taskwait->last_parent_depends_on = NULL;
}
}
- /* Remove child_task from taskgroup. */
+
+ /* Adjust taskgroup to point to the next taskgroup. See note above
+ regarding adjustment of children as to why the child_task is not
+ removed entirely from the circular list. */
if (taskgroup && taskgroup->children == child_task)
taskgroup->children = child_task->next_taskgroup;
+ /* Remove child_task from the task_queue. */
child_task->prev_queue->next_queue = child_task->next_queue;
child_task->next_queue->prev_queue = child_task->prev_queue;
if (team->task_queue == child_task)
@@ -479,6 +491,7 @@ gomp_task_run_pre (struct gomp_task *child_task, struct gomp_task *parent,
team->task_queue = NULL;
}
child_task->kind = GOMP_TASK_TIED;
+
if (--team->task_queued_count == 0)
gomp_team_barrier_clear_task_pending (&team->barrier);
if ((gomp_team_barrier_cancelled (&team->barrier)