| Issue |
61499
|
| Summary |
OpenMP untied tasks + stack management
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
rpereira-dev
|
Tested on LLVM release 15.x
Using C99 Variable Length Array (VLA) within OpenMP untied tasks crashes.
Using `alloca` within OpenMP untied tasks can lead to unexpected behaviour at run-time.
I believe these issues are tightly linked to the `untied` implementation, which as far as I understand it:
- A single task descriptor `kmp_task_t` is built by the compiler/runtime (`__kmpc_omp_task_alloc`)
- Clang creates continuations on each explicit scheduling point of the task scope, privatizing tasks local variables that would be pushed on the thread's
- Each continuations are sent to the runtime and scheduled as 'normal tasks'
Here are a few code examples illustrating what's going on:
Snippet 1: crashed at compile-time
```C
void toto(int n) {
# pragma omp task untied
{
int x[n];
x[0] = 42;
# pragma omp taskyield
assert(x[0] == 42);
}
}
int main(void) {
# pragma omp parallel
{
# pragma omp single
{
toto(1);
}
}
return 0;
}
```
Snippet 2: no crashes, no continuations are generated (but task cannot change thread on the yield)
```C
void toto(int n) {
int x[n];
x[0] = 42;
# pragma omp taskyield
assert(x[0] == 42);
}
int main(void) {
# pragma omp parallel
{
# pragma omp single
{
# pragma omp task untied
toto(1);
}
}
return 0;
}
```
Snippet 3: may crash at run-time (the pointer 'x' is privatized, not the 'n' pointed bytes)
```C
void toto(int n) {
# pragma omp task untied
{
int * x = alloca(n);
x[0] = 42;
# pragma omp taskyield
assert(x[0] == 42);
}
}
int main(void) {
# pragma omp parallel
{
# pragma omp single
{
toto(1);
}
}
return 0;
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs