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

            Bug ID: 121416
           Summary: [gcn][MI300][CDNA3]
                    libgomp.oacc-c-c++-common/reduction-cplx-dbl.c
                    produces wrong gang-reduction result
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: openacc, wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: ams at gcc dot gnu.org
  Target Milestone: ---
            Target: gcn

For all optimization levels:
  libgomp.oacc-c-c++-common/reduction-cplx-dbl.c
produces the wrong result for 'gang', only:

Expected (approx):
  sum   104.833984 + 109.667969 i
  prod  698317287061244416.0 - 950434920224383616.0 i

Actual result (varies):
  tsum   33.609375 +  35.218750 i
  tpod                 676.427908 +           228.939762 i


That's for:

typedef double _Complex Type;

...
gang (Type ary[N], Type sum, Type prod)
{
  Type tsum = 0, tprod = 1;

#pragma acc parallel num_gangs (32) copyin(ary[0:N])
  {
#pragma acc loop gang reduction(+:tsum) reduction (*:tprod)
    for (int ix = 0; ix < N; ix++)
      {
        tsum += ary[ix];
        tprod *= ary[ix];
      }
...

Reply via email to