• 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 
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 
foo()13 void foo() {}
14 
15 template <class T, int N>
tmain(T argc)16 T tmain(T argc) {
17   T b = argc, c, d, e, f, g;
18   static T a;
19 // CHECK: static T a;
20 #pragma omp taskgroup allocate(d) task_reduction(+: d)
21 #pragma omp master taskloop if(taskloop: argc > N) default(shared) untied priority(N) grainsize(N) reduction(+:g) in_reduction(+: d) allocate(d)
22   // CHECK-NEXT: #pragma omp taskgroup allocate(d) task_reduction(+: d)
23   // CHECK-NEXT: #pragma omp master taskloop if(taskloop: argc > N) default(shared) untied priority(N) grainsize(N) reduction(+: g) in_reduction(+: d) allocate(d){{$}}
24   for (int i = 0; i < 2; ++i)
25     a = 2;
26 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
27 // CHECK-NEXT: a = 2;
28 #pragma omp parallel
29 #pragma omp master taskloop private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) shared(g) if (c) final(d) mergeable priority(f) nogroup num_tasks(N)
30   for (int i = 0; i < 2; ++i)
31     for (int j = 0; j < 2; ++j)
32       for (int j = 0; j < 2; ++j)
33         for (int j = 0; j < 2; ++j)
34           for (int j = 0; j < 2; ++j)
35   for (int i = 0; i < 2; ++i)
36     for (int j = 0; j < 2; ++j)
37       for (int j = 0; j < 2; ++j)
38         for (int j = 0; j < 2; ++j)
39           for (int j = 0; j < 2; ++j) {
40 #pragma omp cancel taskgroup
41 #pragma omp cancellation point taskgroup
42             foo();
43           }
44   // CHECK-NEXT: #pragma omp parallel
45   // CHECK-NEXT: #pragma omp master taskloop private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) shared(g) if(c) final(d) mergeable priority(f) nogroup num_tasks(N)
46   // CHECK-NEXT: for (int i = 0; i < 2; ++i)
47   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
48   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
49   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
50   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
51   // CHECK-NEXT: for (int i = 0; i < 2; ++i)
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 j = 0; j < 2; ++j) {
56   // CHECK-NEXT: #pragma omp cancel taskgroup
57   // CHECK-NEXT: #pragma omp cancellation point taskgroup
58   // CHECK-NEXT: foo();
59   return T();
60 }
61 
62 // CHECK-LABEL: int main(int argc, char **argv) {
main(int argc,char ** argv)63 int main(int argc, char **argv) {
64   int b = argc, c, d, e, f, g;
65   static int a;
66 // CHECK: static int a;
67 #pragma omp taskgroup task_reduction(+: d)
68 #pragma omp master taskloop if(taskloop: a) default(none) shared(a) final(b) priority(5) num_tasks(argc) reduction(*: g) in_reduction(+:d)
69   // CHECK-NEXT: #pragma omp taskgroup task_reduction(+: d)
70   // CHECK-NEXT: #pragma omp master taskloop if(taskloop: a) default(none) shared(a) final(b) priority(5) num_tasks(argc) reduction(*: g) in_reduction(+: d)
71   for (int i = 0; i < 2; ++i)
72     a = 2;
73 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
74 // CHECK-NEXT: a = 2;
75 #pragma omp parallel
76 #pragma omp master taskloop private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) shared(g) if(argc) mergeable priority(argc) grainsize(argc) reduction(max: a, e)
77   for (int i = 0; i < 10; ++i)
78     for (int j = 0; j < 10; ++j) {
79 #pragma omp cancel taskgroup
80 #pragma omp cancellation point taskgroup
81       foo();
82     }
83   // CHECK-NEXT: #pragma omp parallel
84   // CHECK-NEXT: #pragma omp master taskloop private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) shared(g) if(argc) mergeable priority(argc) grainsize(argc) reduction(max: a,e)
85   // CHECK-NEXT: for (int i = 0; i < 10; ++i)
86   // CHECK-NEXT: for (int j = 0; j < 10; ++j) {
87   // CHECK-NEXT: #pragma omp cancel taskgroup
88   // CHECK-NEXT: #pragma omp cancellation point taskgroup
89   // CHECK-NEXT: foo();
90   return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
91 }
92 
93 #endif
94