Debian Codegraph @

libgomp/testsuite/libgomp.c-c++-common/metadirective-late-1.c

raw
1 /* { dg-do run } */
2 /* { dg-additional-options -O0 } */
3
4 /* Test late resolution of metadirectives with dynamic selectors
5 in "declare simd" functions. All the variants do the same thing;
6 the purpose of this test is to ensure that the "condition" predicates
7 are all called, and in the correct order. */
8
9 static int pcount = 0;
10
11 static int __attribute__ ((noinline))
12 ptrue (int n)
13 {
14 pcount++;
15 if (pcount != n)
16 __builtin_abort ();
17 return 1;
18 }
19
20 static int __attribute__ ((noinline))
21 pfalse (int n)
22 {
23 pcount++;
24 if (pcount != n)
25 __builtin_abort ();
26 return 0;
27 }
28
29 #define N 256
30
31 #pragma omp declare simd
32 void
33 f (int a[])
34 {
35 int i;
36
37 #pragma omp metadirective \
38 when (construct={simd}: \
39 nothing) \
40 when (user={condition(score (100): pfalse (1))}: \
41 nothing) \
42 when (user={condition(score (90): pfalse (2))}: \
43 nothing) \
44 when (user={condition(score (70): (ptrue (5) && pfalse (6)))}: \
45 nothing) \
46 when (user={condition(score (80): (pfalse (3) || pfalse (4)))}: \
47 nothing) \
48 when (user={condition(score (60): \
49 (ptrue (7) ? pfalse (8) : ptrue (8)))}: \
50 nothing) \
51 otherwise (nothing)
52 for (i = 0; i < N; i++)
53 a[i] += i;
54 }
55
56 int a[N];
57
58 int
59 main (void)
60 {
61 f (a);
62 for (int i = 0; i < N; i++)
63 if (a[i] != i)
64 return 1;
65 return 0;
66 }