pr70688.c 479 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/* Verify that reduction variables can appear in data clause.  */

#include <assert.h>

const int n = 100;

int
main ()
{
  int s = 0;
  int array[n];

  for (int i = 0; i < n; i++)
    array[i] = i+1;

#pragma acc parallel loop num_gangs (10) copy (s) reduction (+:s)
  for (int i = 0; i < n; i++)
    s += array[i];

#pragma acc parallel loop num_gangs (10) reduction (+:s) copy (s)
  for (int i = 0; i < n; i++)
    s += array[i];

  assert (s == n * (n + 1));

  return 0;
}