aboutsummaryrefslogtreecommitdiff
path: root/libgomp/libgomp.h
diff options
context:
space:
mode:
authorKwok Cheung Yeung <kcy@codesourcery.com>2021-01-21 05:38:47 -0800
committerKwok Cheung Yeung <kcy@codesourcery.com>2021-02-25 14:47:11 -0800
commitd656bfda2d8316627d0bbb18b10954e6aaf3c88c (patch)
tree9054f33271d1e28f4bb63a203980b5ca35fd7df6 /libgomp/libgomp.h
parent7fb9a1e929db520fd741e60d84ec1a58581a8299 (diff)
downloadgcc-d656bfda2d8316627d0bbb18b10954e6aaf3c88c.zip
gcc-d656bfda2d8316627d0bbb18b10954e6aaf3c88c.tar.gz
gcc-d656bfda2d8316627d0bbb18b10954e6aaf3c88c.tar.bz2
openmp: Fix intermittent hanging of task-detach-6 libgomp tests [PR98738]
This adds support for the task detach clause to taskwait and taskgroup, and simplifies the handling of the detach clause by moving most of the extra handling required for detach tasks to omp_fulfill_event. 2021-02-25 Kwok Cheung Yeung <kcy@codesourcery.com> Jakub Jelinek <jakub@redhat.com> libgomp/ PR libgomp/98738 * libgomp.h (enum gomp_task_kind): Add GOMP_TASK_DETACHED. (struct gomp_task): Replace detach and completion_sem fields with union containing completion_sem and detach_team. Add deferred_p field. (struct gomp_team): Remove task_detach_queue. * task.c: Include assert.h. (gomp_init_task): Initialize deferred_p and completion_sem fields. Rearrange initialization order of fields. (task_fulfilled_p): Delete. (GOMP_task): Use address of task as the event handle. Remove initialization of detach field. Initialize deferred_p field. Use automatic local for completion_sem. Initialize detach_team field for deferred tasks. (gomp_barrier_handle_tasks): Remove handling of task_detach_queue. Set kind of suspended detach task to GOMP_TASK_DETACHED and decrement task_running_count. Move finish_cancelled block out of else branch. Relocate call to gomp_team_barrier_done. (GOMP_taskwait): Handle tasks with completion events that have not been fulfilled. (GOMP_taskgroup_end): Likewise. (omp_fulfill_event): Use address of task as event handle. Post to completion_sem for undeferred tasks. Clear detach_team if task has not finished. For finished tasks, handle post-execution tasks, call gomp_team_barrier_wake if necessary, and free task. * team.c (gomp_new_team): Remove initialization of task_detach_queue. (free_team): Remove free of task_detach_queue. * testsuite/libgomp.c-c++-common/task-detach-1.c: Fix formatting. * testsuite/libgomp.c-c++-common/task-detach-2.c: Fix formatting. * testsuite/libgomp.c-c++-common/task-detach-3.c: Fix formatting. * testsuite/libgomp.c-c++-common/task-detach-4.c: Fix formatting. * testsuite/libgomp.c-c++-common/task-detach-5.c: Fix formatting. Change data-sharing of detach events on enclosing parallel to private. * testsuite/libgomp.c-c++-common/task-detach-6.c: Likewise. Remove taskwait directive. * testsuite/libgomp.c-c++-common/task-detach-7.c: New. * testsuite/libgomp.c-c++-common/task-detach-8.c: New. * testsuite/libgomp.c-c++-common/task-detach-9.c: New. * testsuite/libgomp.c-c++-common/task-detach-10.c: New. * testsuite/libgomp.c-c++-common/task-detach-11.c: New. * testsuite/libgomp.fortran/task-detach-1.f90: Fix formatting. * testsuite/libgomp.fortran/task-detach-2.f90: Fix formatting. * testsuite/libgomp.fortran/task-detach-3.f90: Fix formatting. * testsuite/libgomp.fortran/task-detach-4.f90: Fix formatting. * testsuite/libgomp.fortran/task-detach-5.f90: Fix formatting. Change data-sharing of detach events on enclosing parallel to private. * testsuite/libgomp.fortran/task-detach-6.f90: Likewise. Remove taskwait directive. * testsuite/libgomp.fortran/task-detach-7.f90: New. * testsuite/libgomp.fortran/task-detach-8.f90: New. * testsuite/libgomp.fortran/task-detach-9.f90: New. * testsuite/libgomp.fortran/task-detach-10.f90: New. * testsuite/libgomp.fortran/task-detach-11.f90: New.
Diffstat (limited to 'libgomp/libgomp.h')
-rw-r--r--libgomp/libgomp.h21
1 files changed, 15 insertions, 6 deletions
diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h
index b4d0c93..ef1bb49 100644
--- a/libgomp/libgomp.h
+++ b/libgomp/libgomp.h
@@ -481,7 +481,10 @@ enum gomp_task_kind
but not yet completed. Once that completes, they will be readded
into the queues as GOMP_TASK_WAITING in order to perform the var
unmapping. */
- GOMP_TASK_ASYNC_RUNNING
+ GOMP_TASK_ASYNC_RUNNING,
+ /* Task that has finished executing but is waiting for its
+ completion event to be fulfilled. */
+ GOMP_TASK_DETACHED
};
struct gomp_task_depend_entry
@@ -537,6 +540,16 @@ struct gomp_task
into the various queues to be scheduled. */
size_t num_dependees;
+ union {
+ /* Valid only if deferred_p is false. */
+ gomp_sem_t *completion_sem;
+ /* Valid only if deferred_p is true. Set to the team that executes the
+ task if the task is detached and the completion event has yet to be
+ fulfilled. */
+ struct gomp_team *detach_team;
+ };
+ bool deferred_p;
+
/* Priority of this task. */
int priority;
/* The priority node for this task in each of the different queues.
@@ -545,9 +558,6 @@ struct gomp_task
entries and the gomp_task in which they reside. */
struct priority_node pnode[3];
- bool detach;
- gomp_sem_t completion_sem;
-
struct gomp_task_icv icv;
void (*fn) (void *);
void *fn_data;
@@ -688,8 +698,7 @@ struct gomp_team
int work_share_cancelled;
int team_cancelled;
- /* Tasks waiting for their completion event to be fulfilled. */
- struct priority_queue task_detach_queue;
+ /* Number of tasks waiting for their completion event to be fulfilled. */
unsigned int task_detach_count;
/* This array contains structures for implicit tasks. */