C++: simplify output from suggest_alternatives_for
[official-gcc.git] / libgomp / testsuite / libgomp.c / examples-4 / target-2.c
blob55d667aa77591994f1d05517cd1c44a49e180373
1 /* { dg-do run } */
3 #include <stdlib.h>
5 #define N 100000
7 void init (char *a1, char *a2)
9 char s = -1;
10 int i;
11 for (i = 0; i < N; i++)
13 a1[i] = s;
14 a2[i] = i;
15 s = -s;
19 void check (char *a, char *b)
21 int i;
22 for (i = 0; i < N; i++)
23 if (a[i] != b[i])
24 abort ();
27 void vec_mult_ref (char *p)
29 int i;
30 char v1[N], v2[N];
32 init (v1, v2);
34 for (i = 0; i < N; i++)
35 p[i] = v1[i] * v2[i];
38 void vec_mult (char *p)
40 int i;
41 char v1[N], v2[N];
43 init (v1, v2);
45 #pragma omp target map(from: p[0:N])
46 #pragma omp parallel for
47 for (i = 0; i < N; i++)
48 p[i] = v1[i] * v2[i];
51 int main ()
53 char p1[N], p2[N];
54 char v1[N], v2[N];
56 init (v1, v2);
58 vec_mult_ref (p1);
59 vec_mult (p2);
61 check (p1, p2);
63 return 0;