• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
4 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 -ast-print %s | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5
5 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s
6 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5
7 
8 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
9 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
10 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
11 // expected-no-diagnostics
12 
13 #ifndef HEADER
14 #define HEADER
15 
foo()16 void foo() {}
17 
18 template <class T>
19 struct S {
operator TS20   operator T() {return T();}
21   static T TS;
22   #pragma omp threadprivate(TS)
23 };
24 
25 // CHECK:      template <class T> struct S {
26 // CHECK:        static T TS;
27 // CHECK-NEXT:   #pragma omp threadprivate(S::TS)
28 // CHECK:      };
29 // CHECK:      template<> struct S<int> {
30 // CHECK:        static int TS;
31 // CHECK-NEXT:   #pragma omp threadprivate(S<int>::TS)
32 // CHECK-NEXT: }
33 // CHECK:      template<> struct S<long> {
34 // CHECK:        static long TS;
35 // CHECK-NEXT:   #pragma omp threadprivate(S<long>::TS)
36 // CHECK-NEXT: }
37 
38 template <typename T, int C>
tmain(T argc,T * argv)39 T tmain(T argc, T *argv) {
40   T b = argc, c, d, e, f, g;
41   static T a;
42   S<T> s;
43 #ifdef OMP5
44 #pragma omp teams
45   a=2;
46 #endif // OMP5
47 #pragma omp target
48 #pragma omp teams
49   a=2;
50 #pragma omp target
51 #pragma omp teams default(none), private(argc,b) firstprivate(argv) shared (d) reduction(+:c) reduction(max:e) num_teams(C) thread_limit(d*C)
52   foo();
53 #pragma omp target
54 #pragma omp teams reduction(^:e, f) reduction(&& : g)
55   foo();
56   return 0;
57 }
58 
59 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
60 // CHECK-NEXT: T b = argc, c, d, e, f, g;
61 // CHECK-NEXT: static T a;
62 // CHECK-NEXT: S<T> s;
63 // OMP5-NEXT:  #pragma omp teams
64 // OMP5-NEXT:  a = 2;
65 // CHECK-NEXT: #pragma omp target
66 // CHECK-NEXT: #pragma omp teams{{$}}
67 // CHECK-NEXT: a = 2;
68 // CHECK-NEXT: #pragma omp target
69 // CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(C) thread_limit(d * C)
70 // CHECK-NEXT: foo()
71 // CHECK-NEXT: #pragma omp target
72 // CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g)
73 // CHECK-NEXT: foo()
74 // CHECK: template<> int tmain<int, 5>(int argc, int *argv) {
75 // CHECK-NEXT: int b = argc, c, d, e, f, g;
76 // CHECK-NEXT: static int a;
77 // CHECK-NEXT: S<int> s;
78 // OMP5-NEXT:  #pragma omp teams
79 // OMP5-NEXT:  a = 2;
80 // CHECK-NEXT: #pragma omp target
81 // CHECK-NEXT: #pragma omp teams
82 // CHECK-NEXT: a = 2;
83 // CHECK-NEXT: #pragma omp target
84 // CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(5) thread_limit(d * 5)
85 // CHECK-NEXT: foo()
86 // CHECK-NEXT: #pragma omp target
87 // CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g)
88 // CHECK-NEXT: foo()
89 // CHECK: template<> long tmain<long, 1>(long argc, long *argv) {
90 // CHECK-NEXT: long b = argc, c, d, e, f, g;
91 // CHECK-NEXT: static long a;
92 // CHECK-NEXT: S<long> s;
93 // OMP5-NEXT:  #pragma omp teams
94 // OMP5-NEXT:  a = 2;
95 // CHECK-NEXT: #pragma omp target
96 // CHECK-NEXT: #pragma omp teams
97 // CHECK-NEXT: a = 2;
98 // CHECK-NEXT: #pragma omp target
99 // CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(1) thread_limit(d * 1)
100 // CHECK-NEXT: foo()
101 // CHECK-NEXT: #pragma omp target
102 // CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g)
103 // CHECK-NEXT: foo()
104 
105 enum Enum { };
106 
main(int argc,char ** argv)107 int main (int argc, char **argv) {
108   long x;
109   int b = argc, c, d, e, f, g;
110   static int a;
111   #pragma omp threadprivate(a)
112   Enum ee;
113 // CHECK: Enum ee;
114 #pragma omp target
115 #pragma omp teams
116 // CHECK-NEXT: #pragma omp target
117 // CHECK-NEXT: #pragma omp teams
118   a=2;
119 // CHECK-NEXT: a = 2;
120 #pragma omp target
121 #pragma omp teams default(none), private(argc,b) num_teams(f) firstprivate(argv) reduction(| : c, d) reduction(* : e) thread_limit(f+g)
122 // CHECK-NEXT: #pragma omp target
123 // CHECK-NEXT: #pragma omp teams default(none) private(argc,b) num_teams(f) firstprivate(argv) reduction(|: c,d) reduction(*: e) thread_limit(f + g)
124   foo();
125 // CHECK-NEXT: foo();
126   return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x);
127 }
128 
129 extern template int S<int>::TS;
130 extern template long S<long>::TS;
131 #endif
132