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 | |
5 | // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s |
6 | // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s |
7 | // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s |
8 | // expected-no-diagnostics |
9 | |
10 | #ifndef HEADER |
11 | #define HEADER |
12 | |
13 | void foo() {} |
14 | |
15 | template <class T> |
16 | struct S { |
17 | operator T() {return T();} |
18 | static T TS; |
19 | #pragma omp threadprivate(TS) |
20 | }; |
21 | |
22 | // CHECK: template <class T> struct S { |
23 | // CHECK: static T TS; |
24 | // CHECK-NEXT: #pragma omp threadprivate(S::TS) |
25 | // CHECK: }; |
26 | // CHECK: template<> struct S<int> { |
27 | // CHECK: static int TS; |
28 | // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS) |
29 | // CHECK-NEXT: } |
30 | // CHECK: template<> struct S<long> { |
31 | // CHECK: static long TS; |
32 | // CHECK-NEXT: #pragma omp threadprivate(S<long>::TS) |
33 | // CHECK-NEXT: } |
34 | |
35 | template <typename T, int C> |
36 | T tmain(T argc, T *argv) { |
37 | T b = argc, c, d, e, f, g; |
38 | static T a; |
39 | S<T> s; |
40 | #pragma omp target teams |
41 | a=2; |
42 | #pragma omp target teams default(none), private(argc,b) firstprivate(argv) shared (d) reduction(+:c) reduction(max:e) num_teams(C) thread_limit(d*C) allocate(argv) |
43 | foo(); |
44 | #pragma omp target teams allocate(f) reduction(^:e, f) reduction(&& : g) |
45 | foo(); |
46 | return 0; |
47 | } |
48 | |
49 | // CHECK: template <typename T, int C> T tmain(T argc, T *argv) { |
50 | // CHECK-NEXT: T b = argc, c, d, e, f, g; |
51 | // CHECK-NEXT: static T a; |
52 | // CHECK-NEXT: S<T> s; |
53 | // CHECK-NEXT: #pragma omp target teams{{$}} |
54 | // CHECK-NEXT: a = 2; |
55 | // CHECK-NEXT: #pragma omp target teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(C) thread_limit(d * C) allocate(argv) |
56 | // CHECK-NEXT: foo() |
57 | // CHECK-NEXT: #pragma omp target teams allocate(f) reduction(^: e,f) reduction(&&: g) |
58 | // CHECK-NEXT: foo() |
59 | // CHECK: template<> int tmain<int, 5>(int argc, int *argv) { |
60 | // CHECK-NEXT: int b = argc, c, d, e, f, g; |
61 | // CHECK-NEXT: static int a; |
62 | // CHECK-NEXT: S<int> s; |
63 | // CHECK-NEXT: #pragma omp target teams |
64 | // CHECK-NEXT: a = 2; |
65 | // CHECK-NEXT: #pragma omp target teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(5) thread_limit(d * 5) allocate(argv) |
66 | // CHECK-NEXT: foo() |
67 | // CHECK-NEXT: #pragma omp target teams allocate(f) reduction(^: e,f) reduction(&&: g) |
68 | // CHECK-NEXT: foo() |
69 | // CHECK: template<> long tmain<long, 1>(long argc, long *argv) { |
70 | // CHECK-NEXT: long b = argc, c, d, e, f, g; |
71 | // CHECK-NEXT: static long a; |
72 | // CHECK-NEXT: S<long> s; |
73 | // CHECK-NEXT: #pragma omp target teams |
74 | // CHECK-NEXT: a = 2; |
75 | // CHECK-NEXT: #pragma omp target teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(1) thread_limit(d * 1) allocate(argv) |
76 | // CHECK-NEXT: foo() |
77 | // CHECK-NEXT: #pragma omp target teams allocate(f) reduction(^: e,f) reduction(&&: g) |
78 | // CHECK-NEXT: foo() |
79 | |
80 | enum Enum { }; |
81 | |
82 | int main (int argc, char **argv) { |
83 | long x; |
84 | int b = argc, c, d, e, f, g; |
85 | static int a; |
86 | #pragma omp threadprivate(a) |
87 | Enum ee; |
88 | // CHECK: Enum ee; |
89 | #pragma omp target teams |
90 | // CHECK-NEXT: #pragma omp target teams |
91 | a=2; |
92 | // CHECK-NEXT: a = 2; |
93 | #pragma omp target teams default(none), private(argc,b) num_teams(f) firstprivate(argv) reduction(| : c, d) reduction(* : e) thread_limit(f+g) |
94 | // CHECK-NEXT: #pragma omp target teams default(none) private(argc,b) num_teams(f) firstprivate(argv) reduction(|: c,d) reduction(*: e) thread_limit(f + g) |
95 | foo(); |
96 | // CHECK-NEXT: foo(); |
97 | return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x); |
98 | } |
99 | |
100 | extern template int S<int>::TS; |
101 | extern template long S<long>::TS; |
102 | #endif |
103 | |