On Wed, Jan 13, 2016 at 09:05:47PM +0300, Alexander Monakov wrote:
> I'm testing 'target teams' implementation for gomp-nvptx branch, and I'm
> seeing test failures that, I think, are caused by faulty tests (unlike NVPTX,
> MIC offloading uses 1 team similar to native execution, so the issues are not
> exposed there).
> 
> First, there's libgomp.c/target-31.c where the following triggers:
> 
> 39  if (c != 3 || d != 4 || g[0] != 9 || g[1] != 10 || h[0] != 11 || h[1] != 
> 12 || k != 14 || m[0] != 17 || m[1] != 18)
> 40    #pragma omp atomic write
> 41      err = 1;
> 
> The first failing clause is 'g[0] != 9'; g[0] is actually 11 after being
> incremented at line 57 in another team.
> 
> If I remove ' || g[0] != 9 || g[1] != 10' from line 39 the test passes.

That is weird, because c is also a firstprivate var in target and
(implicitly) shared in teams, so if omp lowering/expansion is not buggy,
you should see the exactly same problem with that.
Wonder if we use GOMP_MAP_FIRSTPRIVATE_INT when we shouldn't (the var really
should be addressable because of the atomics and atomics would be the only
way to observe some changes on it (or teams reduction?)).

That said, for the testcase, as it is num_teams(4), I think I'd prefer
#pragma omp atomic read c, g[0] and g[1] into temporaries and verify if they
are one of the possible values.  There is already
      int v1, v2, v3;
      #pragma omp atomic read
        v1 = c;
      #pragma omp atomic read
        v2 = g[0];
      #pragma omp atomic read
        v3 = g[1];
far later, so use something similar, but include the test in the region.

> Second, there are failures on libgomp.c/examples-4/teams-{3,4}.c and their
> Fortran counterparts.  The issue is that 'sum' is not reduced across all
> teams, but only across loop iterations within each team.  I'm using the
> following patch to add the missing reduction.  Is that correct?

Yes, but we need to report it upstream, the bug is on the OpenMP Examples side.
Let me do it now.

> --- a/libgomp/testsuite/libgomp.fortran/examples-4/teams-3.f90
> +++ b/libgomp/testsuite/libgomp.fortran/examples-4/teams-3.f90
> @@ -14,7 +14,7 @@ function dotprod (B, C, N) result(sum)
>    real :: B(N), C(N), sum
>    integer :: N, i
>    sum = 0.0e0
> -  !$omp target teams map(to: B, C)
> +  !$omp target teams map(to: B, C) reduction(+:sum)

When touching the Fortran tests, I'd prefer to add also map(tofrom: sum),
which will make it also valid for OpenMP 4.5, not just 4.0.

        Jakub

Reply via email to