[Bug libgomp/80394] New: Empty OpenMP task is wrongly removed when optimizing
sergi.mateo at bsc dot es
gcc-bugzilla@gcc.gnu.org
Tue Apr 11 12:24:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80394
Bug ID: 80394
Summary: Empty OpenMP task is wrongly removed when optimizing
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgomp
Assignee: unassigned at gcc dot gnu.org
Reporter: sergi.mateo at bsc dot es
CC: jakub at gcc dot gnu.org
Target Milestone: ---
Hi,
In the following code:
#include<unistd.h>
#include<stdio.h>
void foo(int foo_id) {
int x = 0;
for (int i = 0; i < 5; ++i)
{
#pragma omp task depend(inout: x) shared(x)
{
printf("%d -> hola : %d\n", foo_id, i);
usleep(1000000);
x++;
}
}
#pragma omp task if(0) depend(inout: x)
{
//printf("if\n");
}
}
int main() {
#pragma omp parallel
#pragma omp single
{
foo(0);
foo(1);
}
}
GCC wrongly removes the empty second task when optimizing (-O2 or higher).
Then, tasks created by the first call to 'foo' may be executed concurrently
with the tasks created by the second call, which is wrong: when a thread
reaches the empty task, the current task region should be suspended until all
the predecessor tasks of that task are executed.
Uncommenting the 'printf(...);' statement or compiling with a lower
optimization level make it work.
Thanks!,
Sergi
More information about the Gcc-bugs
mailing list