gcc/libgomp
Jakub Jelinek c125f504c4 libgomp: Fix occassional hangs with taskwait nowait depend
Richi reported occassional hangs with taskwait-depend-nowait-1.*
tests and I've finally manged to reproduce.  The problem is if
taskwait depend without nowait is encountered soon after
taskwait depend nowait and the former depends on the latter and there
is no other work to do, the taskwait depend without nowait is put
to sleep, but the empty_task optimization in
gomp_task_run_post_handle_dependers wouldn't wake it up in that
case.  gomp_task_run_post_handle_dependers normally does some wakeups
because it schedules more work (another task), which is not the
case of empty_task, but we need to do the wakeups that would be done
upon task completion so that we awake sleeping threads when the
last child is done.
So, the taskwait-depend-nowait-1.* testcase is fixed with the
else if (__builtin_expect (task->parent_depends_on, 0) part of
the patch.
The new testcase can hang on another problem, if the empty task
is the last task of a taskgroup, we need to use atomic store
like elsewhere to decrease the counter to 0, and wake up taskgroup
end if needed.
Yet another spot which can sleep is normal taskwait (without depend),
but I believe nothing needs to be done for that - in that case we
await solely until the children's queue has no tasks, tasks still
waiting for dependencies aren't accounted in that, but the reason
is that if taskwait should wait for something, there needs to be at least
one active child doing something (in the children queue), which then
possibly awakes some of its siblings when the dependencies are met,
or in the empty task case awakes further dependencies, but in any
case the child that finished is still handled as active child and
will awake taskwait at the end if there is nothing further to
do.
Last sleeping case are barriers, but that is handled by ++ret and
awaking the barrier.

2022-05-25  Jakub Jelinek  <jakub@redhat.com>

	* task.c (gomp_task_run_post_handle_dependers): If empty_task
	is the last task taskwait depend depends on, wake it up.
	Similarly if it is the last child of a taskgroup, use atomic
	store instead of decrement and awak taskgroup wait if any.
	* testsuite/libgomp.c-c++-common/taskwait-depend-nowait-2.c: New test.
2022-05-25 11:10:41 +02:00
..
config openmp: Fix up gomp_affinity_init_numa_domains 2022-03-18 11:02:13 +01:00
plugin amdgcn: Add gfx90a support 2022-05-24 16:18:14 +01:00
testsuite libgomp: Fix occassional hangs with taskwait nowait depend 2022-05-25 11:10:41 +02:00
.gitattributes
acc_prof.h
acinclude.m4 Add mold detection for libs. 2022-01-31 09:46:44 +01:00
aclocal.m4
affinity-fmt.c
affinity.c
alloc.c
allocator.c
atomic.c
barrier.c
ChangeLog Daily bump. 2022-05-25 00:17:06 +00:00
ChangeLog.graphite
config.h.in Refactor '-ldl' handling for libgomp proper and plugins 2022-05-12 15:11:30 +02:00
configure Refactor '-ldl' handling for libgomp proper and plugins 2022-05-12 15:11:30 +02:00
configure.ac make -Werror optional in libatomic/libbacktrace/libgomp/libitm/libsanitizer 2022-02-03 16:10:18 +01:00
configure.tgt LoongArch Port: libgomp 2022-03-29 17:43:35 +08:00
critical.c
env.c
error.c
fortran.c OpenMP, Fortran: Bugfix for omp_set_num_teams. 2022-03-16 07:38:54 -07:00
hashtab.h
icv-device.c
icv.c
iter_ull.c
iter.c
libgomp_f.h.in
libgomp_g.h openmp: Add taskwait nowait depend support [PR105378] 2022-05-24 09:12:44 +02:00
libgomp-plugin.c
libgomp-plugin.h
libgomp.h openmp: Add support for inoutset depend-kind 2022-05-17 15:40:27 +02:00
libgomp.map openmp: Add taskwait nowait depend support [PR105378] 2022-05-24 09:12:44 +02:00
libgomp.spec.in
libgomp.texi OpenMP: Support nowait with Fortran [PR105378] 2022-05-24 10:45:26 +02:00
lock.c
loop_ull.c libgomp: Fix up two non-GOMP_USE_ALIGNED_WORK_SHARES related issues [PR105358] 2022-04-26 08:57:17 +02:00
loop.c libgomp: Fix up two non-GOMP_USE_ALIGNED_WORK_SHARES related issues [PR105358] 2022-04-26 08:57:17 +02:00
Makefile.am Refactor '-ldl' handling for libgomp proper and plugins 2022-05-12 15:11:30 +02:00
Makefile.in libgomp nvptx plugin: Only consider '--with-cuda-driver=[...]' when applicable 2022-05-13 14:01:01 +02:00
oacc-async.c
oacc-cuda.c
oacc-host.c
oacc-init.c
oacc-int.h
oacc-mem.c
oacc-parallel.c
oacc-plugin.c
oacc-plugin.h
oacc-profiling.c
oacc-target.c
omp_lib.f90.in libgomp: Add new runtime routines omp_target_memcpy_async and omp_target_memcpy_rect_async 2022-05-20 02:29:32 -07:00
omp_lib.h.in libgomp: Add new runtime routines omp_target_memcpy_async and omp_target_memcpy_rect_async 2022-05-20 02:29:32 -07:00
omp.h.in libgomp: Add new runtime routines omp_target_memcpy_async and omp_target_memcpy_rect_async 2022-05-20 02:29:32 -07:00
openacc_lib.h
openacc.f90
openacc.h
ordered.c
parallel.c
priority_queue.c
priority_queue.h
scope.c
sections.c libgomp: Fix up two non-GOMP_USE_ALIGNED_WORK_SHARES related issues [PR105358] 2022-04-26 08:57:17 +02:00
secure_getenv.h
single.c
splay-tree.c
splay-tree.h
target.c OpenMP: Handle descriptors in target's firstprivate [PR104949] 2022-05-23 10:54:32 +02:00
task.c libgomp: Fix occassional hangs with taskwait nowait depend 2022-05-25 11:10:41 +02:00
taskloop.c
team.c
teams.c
work.c libgomp: Fix up two non-GOMP_USE_ALIGNED_WORK_SHARES related issues [PR105358] 2022-04-26 08:57:17 +02:00