Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Dependencies for undeferred detached tasks are missing #45155

Open Quuxplusone opened 4 years ago

Quuxplusone commented 4 years ago
Bugzilla Link PR46185
Status NEW
Importance P normal
Reported by Joachim Protze (protze@itc.rwth-aachen.de)
Reported on 2020-06-03 12:20:30 -0700
Last modified on 2020-06-11 12:38:07 -0700
Version unspecified
Hardware PC Linux
CC a.bataev@hotmail.com, jdoerfert@anl.gov, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments task_late_fulfill.c (992 bytes, text/x-csrc)
task_late_fulfill.c (4608 bytes, text/x-csrc)
Blocks
Blocked by
See also
Created attachment 23570
reproducer

Without detached tasks, any outgoing dependencies for undeferred tasks (if(0))
could be ignored.
For detached tasks, tracking this dependency is necessary.

As I understand the generated code, the dependencies are not passed to the
task, but rather  __kmpc_omp_wait_deps blocks for the incoming dependencies.

  call void @__kmpc_omp_wait_deps ...
  call void @__kmpc_omp_task_begin_if0 ...

Therefore, the second task in the attached code does not wait for the
completion of the first task, which would be the call to omp_event_fulfill at
the end.
Quuxplusone commented 4 years ago

Attached task_late_fulfill.c (992 bytes, text/x-csrc): reproducer

Quuxplusone commented 4 years ago

Attached task_late_fulfill.c (4608 bytes, text/x-csrc): openmp/runtime/test/ompt/tasks/task_late_fulfill.c

Quuxplusone commented 4 years ago
I think, similar as in bug 46193, we should emit code as for normal tasks, but
set the bit to mark the task as undeferred/included task. This will tell the
runtime to not put the task into some queue, but execute before returning.

The task_serial bit in the kmp_tasking_flags_t flag argument of
__kmp_task_alloc should provide the right thing.
I submitted a patch for review (https://reviews.llvm.org/D81497) to pass the
flag to the allocated task.
Quuxplusone commented 4 years ago

Andrey suggested to use the merge_if0 flag (0x4) for the serialized (if0) task:

https://reviews.llvm.org/D81497