https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100573

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #3)
> Hmm, I reproduced the problem on the original test-case:
> libgomp.c-c++-common/for-3.c, and minimized from there:
> ...
> $ cat libgomp/testsuite/libgomp.c-c++-common/for-3.c
> /* { dg-additional-options "-std=gnu99" { target c } } */
> 
> #include <stdio.h>
> extern void abort ();
> 
> #define N 1500
> 
> int a[N];
> 
> int
> main (void)
> {
>   int err = 0;
> 
> #pragma omp target map(tofrom: err) map (tofrom: a)
> #pragma omp teams num_teams (15) reduction(|:err)
>   {
>     int i;
> 
>     for (i = 0; i < N; i++)
>       a[i] = 0;

Even this loop is a problem because every initial thread in its team
clears the whole array.
> 
>     do {} while (0);
> 
> #pragma omp distribute
>     for (i = 0; i < N; i++)
>       a[i] += 2;
> 
>     do {} while (0);

And this of course too.
> 
>     for (i = 0; i < N; i++)
>       if (a[i] != 2)
>         err |= 1;
>   }

I think we want to fix both for-3.c and for-9.c similarly to
r11-2571-g916c7a201a9a1dc94f2c056a773826a26d1daca9
i.e.
#define DO_PRAGMA(x) _Pragma (#x)
#define OMPTEAMS DO_PRAGMA (omp target teams)
#define OMPFROM(v) DO_PRAGMA (omp target update from(v))
#define OMPTO(v) DO_PRAGMA (omp target update to(v))
and changing main not to do #pragma omp target teams reduction(|:err)

Reply via email to