<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/94260>94260</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[OpenMP] Debug assert hit with nesting parallels
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mikaoP
</td>
</tr>
</table>
<pre>
```cpp
// This is a simplification of task_teams_stress_test.cpp test
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <omp.h>
// The number of times to run each test
#define NTIMES 2
// Every thread creates a single "increment" task
void test_tasks() {
for (int i = 0; i < 100; ++i)
#pragma omp task
{
int tid = omp_get_thread_num();
}
}
// Testing single level of parallelism with increment tasks
void test_base(int nthreads) {
#ifdef VERBOSE
#pragma omp master
printf(" test_base(%d)\n", nthreads);
#endif
#pragma omp parallel num_threads(nthreads)
{ test_tasks(); }
}
// Testing nested parallel with increment tasks
// first = nthreads of outer parallel
// second = nthreads of nested parallel
void test_nest(int first, int second) {
#ifdef VERBOSE
#pragma omp master
printf(" test_nest(%d, %d)\n", first, second);
#endif
#pragma omp parallel num_threads(first)
{
for (int i = 0; i < 100; ++i)
#pragma omp task
{
int tid = omp_get_thread_num();
}
test_base(second);
}
}
template <typename... Args>
void run_ntimes(int n, void (*func)(Args...), Args... args) {
for (int i = 0; i < n; ++i) {
func(args...);
}
}
int main() {
omp_set_max_active_levels(5);
run_ntimes(NTIMES, test_nest, 4, 3);
run_ntimes(NTIMES, test_nest, 2, 1);
printf("PASS\n");
return EXIT_SUCCESS;
}
```
`Assertion failure at kmp_tasking.cpp(3238): victim_tid < task_team->tt.tt_nproc.`
`clang++ -fopenmp t1.cpp -o t1 && while taskset -c 0-1 env KMP_USE_YIELD=0 ./t1 || break; do date; done`
Aparently it is necessary `KMP_USE_YIELD=0`. I've not managed how to reproduce it with 1 or 2. Also less cpus than threads is needed.
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