CodeGen for undeferred detachable tasks with out-dependencies is invalid
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
In the following code, the last task needs to wait for the `omp_fulfill_event` call from the first task. The codeGen for `if(0)` tasks is invalid and effectively drops the out dependence from the detachable task.
```C
#include
#include
#include
#include
#include
int main(int argc, char **argv) {
atomic_int res = 0;
#pragma omp parallel
{
#pragma omp single
{
omp_event_handle_t event;
#pragma omp task shared(event)
{
usleep(100000);
res += 1;
omp_fulfill_event(event);
printf("Completing task 1\n");
}
#pragma omp task if (0) detach(event) depend(out : res)
{
res += 1;
printf("Completing task 2\n");
}
printf("Completed task 2\n");
#pragma omp task if (0) depend(in : res)
{
printf("This task was preceded by %i tasks.\n", res);
assert(res == 2);
}
} // single
} // parallel
}
```
The Codegen effectively transforms the code for the detachable task to:
```C
#pragma omp taskwait depend(out : res)
#pragma omp task if (0) detach(event)
```
The detachable task doesn't get the information about the out dependence.
From my perspective, the generated code should be pretty much the same as without if clause, but dependent on the if condition, the `task_serial` bit for the task should be set. As I understand `__kmpc_omp_task_with_deps`, the function would at the moment also ignore the dependencies for serial execution, so the runtime function would also need some modifications.
Contributor guide
Assessment
This issue has not been assessed yet.