gcc/libgomp/testsuite
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 Update copyright years. 2022-01-03 10:42:10 +01:00
lib libgomp testsuite: Don't amend 'LD_LIBRARY_PATH' for system-provided HSA Runtime library 2022-05-11 14:24:21 +02:00
libgomp.c [nvptx] Add warp sync at simt exit 2022-03-22 14:35:34 +01:00
libgomp.c++ OpenMP, C++: Add template support for the has_device_addr clause. 2022-05-16 01:02:50 -07:00
libgomp.c-c++-common libgomp: Fix occassional hangs with taskwait nowait depend 2022-05-25 11:10:41 +02:00
libgomp.fortran OpenMP: Support nowait with Fortran [PR105378] 2022-05-24 10:45:26 +02:00
libgomp.graphite Update copyright years. 2022-01-03 10:42:10 +01:00
libgomp.oacc-c
libgomp.oacc-c++ nvptx: update fix for -Wformat-diag 2022-01-19 08:27:00 +01:00
libgomp.oacc-c-c++-common [libgomp, testsuite, nvptx] Fix dg-output test in vector-length-128-7.c 2022-04-01 13:22:07 +02:00
libgomp.oacc-fortran Fix up 'libgomp.oacc-fortran/print-1.f90' GCN offloading compilation [PR104717] 2022-04-28 15:15:29 +02:00
Makefile.am
Makefile.in Refactor '-ldl' handling for libgomp proper and plugins 2022-05-12 15:11:30 +02:00
libgomp-site-extra.exp.in
libgomp-test-support.exp.in libgomp testsuite: Don't amend 'LD_LIBRARY_PATH' for system-provided HSA Runtime library 2022-05-11 14:24:21 +02:00