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

#include <math.h>

#define N 100
#define EPSILON 0.001

#pragma omp declare target
void
f (double a[], double x) {
  int i;

  #pragma omp metadirective \
	when (construct={target}: distribute parallel for) \
	default (parallel for simd)
   for (i = 0; i < N; i++)
     a[i] = x * i;
}
#pragma omp end declare target

int
main (void)
{
  double a[N];
  int i;

  #pragma omp target teams map(from: a[0:N])
    f (a, M_PI);

  for (i = 0; i < N; i++)
    if (fabs (a[i] - (M_PI * i)) > EPSILON)
      return 1;

  f (a, M_E);

  for (i = 0; i < N; i++)
    if (fabs (a[i] - (M_E * i)) > EPSILON)
      return 1;

  return 0;
 }