gcc.c-torture/execute/builtins/fputs.c: fputs_unlocked prototype
[official-gcc.git] / libgomp / testsuite / libgomp.c / target-link-1.c
blob681677cc2aa90e48ca30adace57333c144140862
1 struct S { int s, t; };
3 int a = 1, b = 1;
4 double c[27];
5 struct S d = { 8888, 8888 };
6 #pragma omp declare target link (a) to (b) link (c, d)
8 int
9 foo (void)
11 return a++ + b++;
14 int
15 bar (int n)
17 int *p1 = &a;
18 int *p2 = &b;
19 c[n] += 2.0;
20 d.s -= 2;
21 d.t -= 2;
22 return *p1 + *p2 + d.s + d.t;
25 #pragma omp declare target (foo, bar)
27 int
28 main ()
30 a = b = 2;
31 d.s = 17;
32 d.t = 18;
34 int res, n = 10;
35 #pragma omp target map (to: a, b, c, d) map (from: res)
37 res = foo () + foo ();
38 c[n] = 3.0;
39 res += bar (n);
42 int shared_mem = 0;
43 #pragma omp target map (alloc: shared_mem)
44 shared_mem = 1;
46 if ((shared_mem && res != (2 + 2) + (3 + 3) + (4 + 4 + 15 + 16))
47 || (!shared_mem && res != (2 + 1) + (3 + 2) + (4 + 3 + 15 + 16)))
48 __builtin_abort ();
50 #pragma omp target enter data map (to: c)
51 #pragma omp target update from (c)
52 res = (int) (c[n] + 0.5);
53 if ((shared_mem && res != 5) || (!shared_mem && res != 0))
54 __builtin_abort ();
56 #pragma omp target map (to: a, b) map (from: res)
57 res = foo ();
59 if ((shared_mem && res != 4 + 4) || (!shared_mem && res != 2 + 3))
60 __builtin_abort ();
62 return 0;