aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c-c++-common/metadirective-1.c
blob: a57d6fd56714ed5b80fc5cfee9520b32f0e302ed (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
/* { dg-do run } */

#define N 100

void
f (int x[], int y[], int z[])
{
  int i;

  #pragma omp target map(to: x[0:N], y[0:N]) map(from: z[0:N])
    #pragma omp metadirective \
	when (device={arch("nvptx")}: teams loop) \
	default (parallel loop)
      for (i = 0; i < N; i++)
	z[i] = x[i] * y[i];
}

int
main (void)
{
  int x[N], y[N], z[N];
  int i;

  for (i = 0; i < N; i++)
    {
      x[i] = i;
      y[i] = -i;
    }

  f (x, y, z);

  for (i = 0; i < N; i++)
    if (z[i] != x[i] * y[i])
      return 1;

  return 0;
}