aboutsummaryrefslogtreecommitdiff
path: root/gcc/sese.h
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-05-25 11:10:41 +0200
committerJakub Jelinek <jakub@redhat.com>2022-05-25 11:10:41 +0200
commitc125f504c43a1d863b040375872b6696a6c2b681 (patch)
treea6072dcca785fe49b7fc4257b604216641b7df1b /gcc/sese.h
parenta1c9f779f75283427316b5c670c1e01ff8ce9ced (diff)
downloadgcc-c125f504c43a1d863b040375872b6696a6c2b681.zip
gcc-c125f504c43a1d863b040375872b6696a6c2b681.tar.gz
gcc-c125f504c43a1d863b040375872b6696a6c2b681.tar.bz2
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.
Diffstat (limited to 'gcc/sese.h')
0 files changed, 0 insertions, 0 deletions