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

            Bug ID: 85445
           Summary: [nvptx, openacc] Calls to worker and vector routine
                    broken
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

og7 test-case ref-1.C fails in execution when run with trunk:
...
/* { dg-do run } */

extern "C" int printf (char const *, ...);

#pragma acc routine vector
void Vector (int *ptr,int n,const int &inc)
{
  #pragma acc loop vector
  for (unsigned ix = 0; ix < n; ix++)
    ptr[ix] += inc;
}

#pragma acc routine worker
void Worker (int *ptr, int m, int n, const int &inc)
{
  #pragma acc loop worker
  for (unsigned ix = 0; ix < m; ix++)
    Vector(ptr + ix * n, n, inc);
}

int main ()
{
  const int n = 32, m=32;

  int ary[m][n];
  unsigned ix,  iy;

  for (ix = m; ix--;)
    for (iy = n; iy--;)
      ary[ix][iy] = (ix << 8) + iy;

#pragma acc parallel copy(ary)
  {
    Worker (&ary[0][0], m, n, 1<<16);
  }

  int err = 0;

  for (ix = m; ix--;)
    for (iy = n; iy--;)
      if (ary[ix][iy] != ((1 << 16) + (ix << 8) + iy))
        {
          printf ("ary[%u][%u] = %x expected %x\n",
                  ix, iy, ary[ix][iy], ((1 << 16) + (ix << 8) + iy));
          err++;
        }

  if (err)
    {
      printf ("%d failed\n", err);
      return 1;
     }

#pragma acc parallel copy(ary)
  {
    Vector (&ary[0][0], m * n, (1<<24) - (1<<16));
  }

  for (ix = m; ix--;)
    for (iy = n; iy--;)
      if (ary[ix][iy] != ((1 << 24) + (ix << 8) + iy))
        {
          printf ("ary[%u][%u] = %x expected %x\n",
                  ix, iy, ary[ix][iy], ((1 << 24) + (ix << 8) + iy));
          err++;
        }

  if (err)
    {
      printf ("%d failed\n", err);
      return 1;
     }

  return 0;
}
...

og7 fix was submitted here (
https://gcc.gnu.org/ml/gcc-patches/2016-08/msg01730.html ) and committed as
r239736.

Reply via email to