S/390: Deprecate g5 and g6 CPU levels
[official-gcc.git] / gcc / testsuite / g++.dg / gomp / target-teams-1.C
blob0a97de0ec30e9c836341156eeeab3c3ddd2bf415
1 // { dg-do compile }
2 // { dg-options "-fopenmp -fdump-tree-gimple" }
4 int v = 6;
5 void bar (int);
6 void bar2 (int, long *, long *);
7 int baz (void);
8 #pragma omp declare target to (bar, baz, v)
10 template <int N>
11 void
12 foo (int a, int b, long c, long d)
14   /* The OpenMP 4.5 spec says that these expressions are evaluated before
15      target region on combined target teams, so those cases are always
16      fine.  */
17   #pragma omp target
18   bar (0);
19   #pragma omp target
20   #pragma omp teams
21   bar (1);
22   #pragma omp target teams
23   bar (2);
24   #pragma omp target
25   #pragma omp teams num_teams (4)
26   bar (3);
27   #pragma omp target teams num_teams (4)
28   bar (4);
29   #pragma omp target
30   #pragma omp teams thread_limit (7)
31   bar (5);
32   #pragma omp target teams thread_limit (7)
33   bar (6);
34   #pragma omp target
35   #pragma omp teams num_teams (4) thread_limit (8)
36   {
37     {
38       bar (7);
39     }
40   }
41   #pragma omp target teams num_teams (4) thread_limit (8)
42   bar (8);
43   #pragma omp target
44   #pragma omp teams num_teams (a) thread_limit (b)
45   bar (9);
46   #pragma omp target teams num_teams (a) thread_limit (b)
47   bar (10);
48   #pragma omp target
49   #pragma omp teams num_teams (c + 1) thread_limit (d - 1)
50   bar (11);
51   #pragma omp target teams num_teams (c + 1) thread_limit (d - 1)
52   bar (12);
53   #pragma omp target map (always, to: c, d)
54   #pragma omp teams num_teams (c + 1) thread_limit (d - 1)
55   bar (13);
56   #pragma omp target data map (to: c, d)
57   {
58     #pragma omp target defaultmap (tofrom: scalar)
59     bar2 (14, &c, &d);
60     /* This is one of the cases which can't be generally optimized,
61        the c and d are (or could be) already mapped and whether
62        their device and original values match is unclear.  */
63     #pragma omp target map (to: c, d)
64     #pragma omp teams num_teams (c + 1) thread_limit (d - 1)
65     bar (15);
66   }
67   /* This can't be optimized, there are function calls inside of
68      target involved.  */
69   #pragma omp target
70   #pragma omp teams num_teams (baz () + 1) thread_limit (baz () - 1)
71   bar (16);
72   #pragma omp target teams num_teams (baz () + 1) thread_limit (baz () - 1)
73   bar (17);
74   /* This one can't be optimized, as v might have different value between
75      host and target.  */
76   #pragma omp target
77   #pragma omp teams num_teams (v + 1) thread_limit (v - 1)
78   bar (18);
81 void
82 foo (int a, int b, long c, long d)
84   foo<0> (a, b, c, d);
87 /* { dg-final { scan-tree-dump-times "num_teams\\(-1\\)" 3 "gimple" } } */
88 /* { dg-final { scan-tree-dump-times "thread_limit\\(-1\\)" 3 "gimple" } } */
89 /* { dg-final { scan-tree-dump-times "num_teams\\(0\\)" 4 "gimple" } } */
90 /* { dg-final { scan-tree-dump-times "thread_limit\\(0\\)" 6 "gimple" } } */
91 /* { dg-final { scan-tree-dump-times "num_teams\\(1\\)" 2 "gimple" } } */
92 /* { dg-final { scan-tree-dump-times "thread_limit\\(1\\)" 0 "gimple" } } */