]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgomp/testsuite/libgomp.c/target-15.c
gcc/
[thirdparty/gcc.git] / libgomp / testsuite / libgomp.c / target-15.c
1 extern void abort (void);
2
3 void
4 foo (int *x)
5 {
6 int a[10], b[15], err, i;
7 for (i = 0; i < 10; i++)
8 a[i] = 7 * i;
9 for (i = 0; i < 15; i++)
10 b[i] = 8 * i;
11 #pragma omp target map(to:x[5:10], a[0:10], b[5:10]) map(from:err)
12 {
13 err = 0;
14 for (i = 0; i < 10; i++)
15 if (x[5 + i] != 20 + 4 * i
16 || a[i] != 7 * i
17 || b[5 + i] != 40 + 8 * i)
18 err = 1;
19 }
20 if (err)
21 abort ();
22 }
23
24 void
25 bar (int n, int v)
26 {
27 int a[n], b[n], c[n], d[n], e[n], err, i;
28 int (*x)[n] = &c;
29 for (i = 0; i < n; i++)
30 {
31 (*x)[i] = 4 * i;
32 a[i] = 7 * i;
33 b[i] = 8 * i;
34 }
35 #pragma omp target map(to:x[0][5:10], a[0:10], b[5:10]) map(from:err)
36 {
37 err = 0;
38 for (i = 0; i < 10; i++)
39 if ((*x)[5 + i] != 20 + 4 * i
40 || a[i] != 7 * i
41 || b[5 + i] != 40 + 8 * i)
42 err = 1;
43 }
44 if (err)
45 abort ();
46 for (i = 0; i < n; i++)
47 {
48 (*x)[i] = 9 * i;
49 a[i] = 12 * i;
50 b[i] = 13 * i;
51 }
52 #pragma omp target map(to:x[0][v:v+5], a[v-5:v+5], b[v:v+5]) map(from:err)
53 {
54 err = 0;
55 for (i = 0; i < 10; i++)
56 if ((*x)[5 + i] != 45 + 9 * i
57 || a[i] != 12 * i
58 || b[5 + i] != 65 + 13 * i)
59 err = 1;
60 }
61 if (err)
62 abort ();
63 }
64
65 int
66 main ()
67 {
68 int x[15], i;
69 for (i = 0; i < 15; i++)
70 x[i] = 4 * i;
71 foo (x);
72 bar (15, 5);
73 return 0;
74 }