Debian Codegraph @

gcc/testsuite/c-c++-common/gomp/attrs-metadirective-2.c

raw
1 /* { dg-do compile { target { c || c++11 } } } */
2 /* { dg-options "-fopenmp -std=c23" { target { c } } } */
3
4 #define N 100
5
6 int
7 main (void)
8 {
9 int x = 0;
10 int y = 0;
11
12 /* Test implicit default (nothing). */
13 [[omp::directive (metadirective,
14 when (device={arch("nvptx")}: barrier))]]
15 x = 1;
16
17 /* Test with multiple standalone directives. */
18 [[omp::directive (metadirective,
19 when (device={arch("nvptx")}: barrier),
20 default (flush))]]
21 x = 1;
22
23 /* Test combining a standalone directive with one that takes a statement
24 body. */
25 [[omp::directive (metadirective,
26 when (device={arch("nvptx")}: parallel),
27 default (barrier))]]
28 x = 1;
29
30 /* Test combining a standalone directive with one that takes a for loop. */
31 [[omp::directive (metadirective,
32 when (device={arch("nvptx")}: parallel for),
33 default (barrier))]]
34 for (int i = 0; i < N; i++)
35 x += i;
36
37 /* Test combining a directive that takes a for loop with one that takes
38 a regular statement body. */
39 [[omp::directive (metadirective,
40 when (device={arch("nvptx")}: parallel for),
41 default (parallel))]]
42 for (int i = 0; i < N; i++)
43 x += i;
44
45 /* Test labels inside statement body. */
46 [[omp::directive (metadirective,
47 when (device={arch("nvptx")}: teams num_teams(512)),
48 when (device={arch("gcn")}: teams num_teams(256)),
49 default (teams num_teams(4)))]]
50 {
51 if (x)
52 goto l1;
53 else
54 goto l2;
55 l1: ;
56 l2: ;
57 }
58
59 /* Test local labels inside statement body. */
60 [[omp::directive (metadirective,
61 when (device={arch("nvptx")}: teams num_teams(512)),
62 when (device={arch("gcn")}: teams num_teams(256)),
63 default (teams num_teams(4)))]]
64 {
65 //__label__ l1, l2;
66
67 if (x)
68 goto l1;
69 else
70 goto l2;
71 l1: ;
72 l2: ;
73 }
74
75 return 0;
76 }