aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c/examples-4/device-1.c
blob: 46aa1607d47803431f54a9f25eb9df1a97d547e8 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* { dg-do run } */
/* { dg-require-effective-target offload_device_nonshared_as } */

#include <omp.h>
#include <stdlib.h>

int main ()
{
  int a = 100;
  int b = 0;
  int c, d;

  #pragma omp target if(a > 200 && a < 400) map(from: c)
    c = omp_is_initial_device ();

  #pragma omp target data map(to: b) if(a > 200 && a < 400)
    #pragma omp target map(from: b, d)
      {
	b = 100;
	d = omp_is_initial_device ();
      }

  if (b != 100 || !c || d)
    abort ();

  a += 200;
  b = 0;

  #pragma omp target if(a > 200 && a < 400) map(from: c)
    c = omp_is_initial_device ();

  #pragma omp target data map(to: b) if(a > 200 && a < 400)
    #pragma omp target map(from: b, d)
      {
	b = 100;
	d = omp_is_initial_device ();
      }

  if (b != 0 || c || d)
    abort ();

  a += 200;
  b = 0;

  #pragma omp target if(a > 200 && a < 400) map(from: c)
    c = omp_is_initial_device ();

  #pragma omp target data map(to: b) if(a > 200 && a < 400)
    #pragma omp target map(from: b, d)
      {
	b = 100;
	d = omp_is_initial_device ();
      }

  if (b != 100 || !c || d)
    abort ();

  return 0;
}