aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.oacc-c-c++-common/pr88288.c
blob: d13e3359a3ec41c2d2bf48640e5aa513c57b38f4 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Test present data clauses in acc offloaded regions when the
   subarray inside the present clause does not have the same base
   offset value as the subarray in the enclosing acc data or acc enter
   data variable.  */

#include <assert.h>

void
offset (int *data, int n)
{
  int i;

#pragma acc parallel loop present (data[0:n])
  for (i = 0; i < n; i++)
    data[i] = n;
}

int
main ()
{
  const int n = 30;
  int data[n], i;

  for (i = 0; i < n; i++)
    data[i] = -1;

#pragma acc data copy(data[0:n])
  {
    offset (data + 10, 10);
  }

  for (i = 0; i < n; i++)
    {
      if (i < 10 || i >= 20)
	assert (data[i] == -1);
      else
	assert (data[i] == 10);
    }

  return 0;
}