C++: simplify output from suggest_alternatives_for
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / routine-4.c
blobd6ff44df5a1107b8ded158b2f98db08f7ab23810
1 #include <stdlib.h>
2 #include <stdio.h>
4 #define M 8
5 #define N 32
7 #pragma acc routine vector
8 void
9 vector (int *a)
11 int i;
13 #pragma acc loop vector
14 for (i = 0; i < N; i++)
15 a[i] -= a[i];
18 #pragma acc routine worker
19 void
20 worker (int *b)
22 int i, j;
24 #pragma acc loop worker
25 for (i = 0; i < N; i++)
27 #pragma acc loop vector
28 for (j = 0; j < M; j++)
29 b[i * M + j] += b[i * M + j];
33 #pragma acc routine gang
34 void
35 gang (int *a)
37 int i;
39 #pragma acc loop gang worker vector
40 for (i = 0; i < N; i++)
41 a[i] -= i;
44 #pragma acc routine seq
45 void
46 seq (int *a)
48 int i;
50 for (i = 0; i < N; i++)
51 a[i] += 1;
54 int
55 main(int argc, char **argv)
57 int i;
58 int a[N];
59 int b[M * N];
61 i = 0;
63 for (i = 0; i < N; i++)
64 a[i] = 0;
66 #pragma acc parallel copy (a[0:N])
68 #pragma acc loop seq
69 for (i = 0; i < N; i++)
70 seq (&a[0]);
73 for (i = 0; i < N; i++)
75 if (a[i] != N)
76 abort ();
79 #pragma acc parallel copy (a[0:N])
81 #pragma acc loop seq
82 for (i = 0; i < N; i++)
83 gang (&a[0]);
86 for (i = 0; i < N; i++)
88 if (a[i] != N + (N * (-1 * i)))
89 abort ();
92 for (i = 0; i < N; i++)
93 a[i] = i;
95 #pragma acc parallel copy (b[0:M*N])
97 worker (&b[0]);
100 for (i = 0; i < N; i++)
102 if (a[i] != i)
103 abort ();
106 for (i = 0; i < N; i++)
107 a[i] = i;
109 #pragma acc parallel copy (a[0:N])
111 #pragma acc loop
112 for (i = 0; i < N; i++)
113 vector (&a[0]);
116 for (i = 0; i < N; i++)
118 if (a[i] != 0)
119 abort ();
122 return 0;