[Bug target/100321] [OpenMP][nvptx, SIMT] (Con't) Reduction fails with optimization and 'loop'/'for simd' but not with 'for'

vries at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Apr 29 15:09:57 GMT 2021


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

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
C example:
...
/* { dg-additional-options "-foffload=-latomic" } */

#include <stdio.h>

struct s
{
  int i;
};

#pragma omp declare reduction(+: struct s: omp_out.i += omp_in.i)

int
main (void)
{
  const int N0 = 32768;

  printf ("Expected: %d\n", N0);

  struct s counter_N0 = { 0 };
#pragma omp target
#pragma omp for simd reduction(+: counter_N0)
  for (int i0 = 0 ; i0 < N0 ; i0++ )
    counter_N0.i += 1;
  printf ("Got     : %d\n", counter_N0.i);

  return 0;
}
...


More information about the Gcc-bugs mailing list