Task reductions defined over undeferred tasks are not working properly
The following code is not working properly:
#include<omp.h>
#include<stdio.h>
#include<assert.h>
int main() {
int v[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8 , 9};
int x = 0;
for(int i = 0; i < 10; ++i) {
#pragma omp task if(0) reduction(+: x) shared(v)
{
x += v[i];
printf("val: %d, thread: %d\n", x, omp_get_thread_num());
}
}
#pragma omp taskwait
printf("%d\n", x);
assert(x == 45);
}
If you link against the Nanos++ debug library you will see the following error message:
what(): ASSERT failed: [0] !depObj.waits():Commutative & concurrent should not wait (../../../nanox/src/plugins/deps/plain_deps.cpp:137)
Note that removing the 'if(0)' clause make it work.
Reported by @jbellon