c125f504c4
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. |
||
---|---|---|
.. | ||
config | ||
plugin | ||
testsuite | ||
.gitattributes | ||
acc_prof.h | ||
acinclude.m4 | ||
aclocal.m4 | ||
affinity-fmt.c | ||
affinity.c | ||
alloc.c | ||
allocator.c | ||
atomic.c | ||
barrier.c | ||
ChangeLog | ||
ChangeLog.graphite | ||
config.h.in | ||
configure | ||
configure.ac | ||
configure.tgt | ||
critical.c | ||
env.c | ||
error.c | ||
fortran.c | ||
hashtab.h | ||
icv-device.c | ||
icv.c | ||
iter_ull.c | ||
iter.c | ||
libgomp_f.h.in | ||
libgomp_g.h | ||
libgomp-plugin.c | ||
libgomp-plugin.h | ||
libgomp.h | ||
libgomp.map | ||
libgomp.spec.in | ||
libgomp.texi | ||
lock.c | ||
loop_ull.c | ||
loop.c | ||
Makefile.am | ||
Makefile.in | ||
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 | ||
omp_lib.h.in | ||
omp.h.in | ||
openacc_lib.h | ||
openacc.f90 | ||
openacc.h | ||
ordered.c | ||
parallel.c | ||
priority_queue.c | ||
priority_queue.h | ||
scope.c | ||
sections.c | ||
secure_getenv.h | ||
single.c | ||
splay-tree.c | ||
splay-tree.h | ||
target.c | ||
task.c | ||
taskloop.c | ||
team.c | ||
teams.c | ||
work.c |