• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP45
2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP45
4 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
5 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5
6 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
7 
8 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP45
9 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
10 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP45
11 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
12 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5
13 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
14 // expected-no-diagnostics
15 
16 #ifndef HEADER
17 #define HEADER
18 
foo()19 void foo() {}
20 
21 template <class T, int N>
tmain(T argc)22 T tmain(T argc) {
23   T b = argc, c, d, e, f, g;
24   T *ptr;
25   static T a;
26 // CHECK: static T a;
27 #pragma omp taskgroup task_reduction(+: d) allocate(d)
28 #pragma omp master taskloop simd allocate(d) if(taskloop: argc > N) default(shared) untied priority(N) safelen(N) linear(c) aligned(ptr) grainsize(N) reduction(+:g) in_reduction(+: d)
29   // CHECK-NEXT: #pragma omp taskgroup task_reduction(+: d) allocate(d)
30   // CHECK-NEXT: #pragma omp master taskloop simd allocate(d) if(taskloop: argc > N) default(shared) untied priority(N) safelen(N) linear(c) aligned(ptr) grainsize(N) reduction(+: g) in_reduction(+: d){{$}}
31   for (int i = 0; i < 2; ++i)
32     a = 2;
33 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
34 // CHECK-NEXT: a = 2;
35 #pragma omp parallel
36 #pragma omp master taskloop simd private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) shared(g) if (c) final(d) mergeable priority(f) simdlen(N) nogroup num_tasks(N)
37   for (int i = 0; i < 2; ++i)
38     for (int j = 0; j < 2; ++j)
39       for (int j = 0; j < 2; ++j)
40         for (int j = 0; j < 2; ++j)
41           for (int j = 0; j < 2; ++j)
42   for (int i = 0; i < 2; ++i)
43     for (int j = 0; j < 2; ++j)
44       for (int j = 0; j < 2; ++j)
45         for (int j = 0; j < 2; ++j)
46           for (int j = 0; j < 2; ++j)
47             foo();
48   // CHECK-NEXT: #pragma omp parallel
49   // CHECK-NEXT: #pragma omp master taskloop simd private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) shared(g) if(c) final(d) mergeable priority(f) simdlen(N) nogroup num_tasks(N)
50   // CHECK-NEXT: for (int i = 0; i < 2; ++i)
51   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
52   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
53   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
54   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
55   // CHECK-NEXT: for (int i = 0; i < 2; ++i)
56   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
57   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
58   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
59   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
60   // CHECK-NEXT: foo();
61   return T();
62 }
63 
64 // CHECK-LABEL: int main(int argc, char **argv) {
main(int argc,char ** argv)65 int main(int argc, char **argv) {
66   int b = argc, c, d, e, f, g, h;
67   static int a;
68 // CHECK: static int a;
69 #pragma omp taskgroup task_reduction(+: d)
70 #pragma omp master taskloop simd if(taskloop: a) default(none) shared(a) final(b) priority(5) safelen(8) linear(b), aligned(argv) num_tasks(argc) reduction(*: g) in_reduction(+: d)
71   // CHECK-NEXT: #pragma omp taskgroup task_reduction(+: d)
72   // CHECK-NEXT: #pragma omp master taskloop simd if(taskloop: a) default(none) shared(a) final(b) priority(5) safelen(8) linear(b) aligned(argv) num_tasks(argc) reduction(*: g) in_reduction(+: d)
73   for (int i = 0; i < 2; ++i)
74     a = 2;
75 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
76 // CHECK-NEXT: a = 2;
77 #pragma omp parallel
78 #ifdef OMP5
79 #pragma omp master taskloop simd private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) shared(g) if(simd:argc) mergeable priority(argc) simdlen(16) grainsize(argc) reduction(max: a, e) nontemporal(argc, c, d) order(concurrent)
80 #else
81 #pragma omp master taskloop simd private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) shared(g) if(argc) mergeable priority(argc) simdlen(16) grainsize(argc) reduction(max: a, e)
82 #endif // OMP5
83   for (int i = 0; i < 10; ++i)
84     for (int j = 0; j < 10; ++j)
85       foo();
86   // CHECK-NEXT: #pragma omp parallel
87   // OMP50-NEXT: #pragma omp master taskloop simd private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) shared(g) if(simd: argc) mergeable priority(argc) simdlen(16) grainsize(argc) reduction(max: a,e) nontemporal(argc,c,d) order(concurrent)
88   // OMP45-NEXT: #pragma omp master taskloop simd private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) shared(g) if(argc) mergeable priority(argc) simdlen(16) grainsize(argc) reduction(max: a,e)
89   // CHECK-NEXT: for (int i = 0; i < 10; ++i)
90   // CHECK-NEXT: for (int j = 0; j < 10; ++j)
91   // CHECK-NEXT: foo();
92   return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
93 }
94 
95 #endif
96