aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/gomp/metadirective-2.c
blob: 4b05cb96ab2bffbc476e31cece74b8e0fba7406e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* { dg-do compile } */

#define N 100

int
main (void)
{
  int x = 0;
  int y = 0;

  /* Test implicit default (nothing).  */
  #pragma omp metadirective \
      when (device={arch("nvptx")}: barrier)
    x = 1;

  /* Test with multiple standalone directives.  */
  #pragma omp metadirective \
      when (device={arch("nvptx")}: barrier) \
      default (flush)
    x = 1;

  /* Test combining a standalone directive with one that takes a statement
     body.  */
  #pragma omp metadirective \
      when (device={arch("nvptx")}: parallel) \
      default (barrier)
    x = 1;

  /* Test combining a standalone directive with one that takes a for loop.  */
  #pragma omp metadirective \
      when (device={arch("nvptx")}: parallel for) \
      default (barrier)
    for (int i = 0; i < N; i++)
      x += i;

  /* Test combining a directive that takes a for loop with one that takes
     a regular statement body.  */
  #pragma omp metadirective \
      when (device={arch("nvptx")}: parallel for) \
      default (parallel)
    for (int i = 0; i < N; i++)
      x += i;

  /* Test labels inside statement body.  */
  #pragma omp metadirective \
    when (device={arch("nvptx")}: teams num_teams(512)) \
    when (device={arch("gcn")}: teams num_teams(256)) \
    default (teams num_teams(4))
  {
    if (x)
      goto l1;
    else
      goto l2;
  l1: ;
  l2: ;
  }

  /* Test local labels inside statement body.  */
  #pragma omp metadirective \
    when (device={arch("nvptx")}: teams num_teams(512)) \
    when (device={arch("gcn")}: teams num_teams(256)) \
    default (teams num_teams(4))
  {
    //__label__ l1, l2;

    if (x)
      goto l1;
    else
      goto l2;
  l1: ;
  l2: ;
  }

  return 0;
}