<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63394>63394</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[OpenMP] no async tasks when there is 1 thread only
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ye-luo
</td>
</tr>
</table>
<pre>
This is a libomp implementation issue not an OpenMP spec one.
The async tasking behavior should be respected even when there is no parallel region and there is only a single implicit thread.
I wrote this reproducer as a proxy for the issue of target tasks which should be asynchronous but not due to the limitation of the libomp behavior.
code
```
#include <iostream>
void run()
{
#pragma omp task
std::cout << "running task 1" << std::endl;
#pragma omp task
std::cout << "running task 2" << std::endl;
std::cout << "task 1 & 2 launched" << std::endl;
#pragma omp taskwait
std::cout << "taskwait completed!" << std::endl;
}
int main()
{
std::cout << "run without parallel" << std::endl;
run();
std::cout << "\nrun with parallel but 1 thread" << std::endl;
#pragma omp parallel num_threads(1)
run();
std::cout << "\nrun with parallel but 2 thread" << std::endl;
#pragma omp parallel num_threads(2)
run();
}
```
```
$ clang++ -fopenmp test_task.cpp && ./a.out
run without parallel
running task 1
running task 2
task 1 & 2 launched # no asynchronicity, both tasks are treated as included tasks and execute immediately.
taskwait completed!
run with parallel but 1 thread
running task 1
running task 2
task 1 & 2 launched # no asynchronicity, both tasks are treated as included tasks and execute immediately.
taskwait completed!
run with parallel but 2 thread
task 1 & 2 launched # both tasks are async
running task 2
running task 1
taskwait completed!
running task 1
running task 2
task 1 & 2 launched
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVs1u6zYTfRpqM4ghUbJsLbRI4s_Atyjaxd1fUORYYkuRAn_i67cvSEu2m-vELZpVAcM2OeLMOYczo2HOyV4jtmT9Qta7jAU_GNue8EkFk3VGnNpvg3QgHTBQsjPjBHKcFI6oPfPSaJDOBQRtPDANv06of_kN3IQc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