| 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 -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 -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, int N> |
| 16 |
T tmain(T argc) { |
| 17 |
T b = argc, c, d, e, f, g; |
| 18 |
int tid = 0; |
| 19 |
static T a; |
| 20 |
// CHECK: static T a; |
| 21 |
#pragma omp taskgroup allocate(d) task_reduction(+: d) |
| 22 |
#pragma omp masked taskloop if(taskloop: argc > N) default(shared) untied priority(N) grainsize(N) reduction(+:g) in_reduction(+: d) filter(tid) allocate(d) |
| 23 |
// CHECK-NEXT: #pragma omp taskgroup allocate(d) task_reduction(+: d) |
| 24 |
// CHECK-NEXT: #pragma omp masked taskloop if(taskloop: argc > N) default(shared) untied priority(N) grainsize(N) reduction(+: g) in_reduction(+: d) filter(tid) allocate(d){{$}} |
| 25 |
for (int i = 0; i < 2; ++i) |
| 26 |
a = 2; |
| 27 |
// CHECK-NEXT: for (int i = 0; i < 2; ++i) |
| 28 |
// CHECK-NEXT: a = 2; |
| 29 |
#pragma omp parallel |
| 30 |
#pragma omp masked 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) |
| 31 |
for (int i = 0; i < 2; ++i) |
| 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 j = 0; j < 2; ++j) |
| 36 |
for (int i = 0; i < 2; ++i) |
| 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 |
for (int j = 0; j < 2; ++j) { |
| 41 |
#pragma omp cancel taskgroup |
| 42 |
#pragma omp cancellation point taskgroup |
| 43 |
foo(); |
| 44 |
} |
| 45 |
// CHECK-NEXT: #pragma omp parallel |
| 46 |
// CHECK-NEXT: #pragma omp masked 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) |
| 47 |
// CHECK-NEXT: for (int i = 0; i < 2; ++i) |
| 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 j = 0; j < 2; ++j) |
| 52 |
// CHECK-NEXT: for (int i = 0; i < 2; ++i) |
| 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: for (int j = 0; j < 2; ++j) { |
| 57 |
// CHECK-NEXT: #pragma omp cancel taskgroup |
| 58 |
// CHECK-NEXT: #pragma omp cancellation point taskgroup |
| 59 |
// CHECK-NEXT: foo(); |
| 60 |
return T(); |
| 61 |
} |
| 62 |
|
| 63 |
// CHECK-LABEL: int main(int argc, char **argv) { |
| 64 |
int main(int argc, char **argv) { |
| 65 |
int b = argc, c, d, e, f, g; |
| 66 |
int tid = 0; |
| 67 |
static int a; |
| 68 |
// CHECK: static int a; |
| 69 |
#pragma omp taskgroup task_reduction(+: d) |
| 70 |
#pragma omp masked taskloop if(taskloop: a) default(none) shared(a) final(b) priority(5) num_tasks(argc) reduction(*: g) in_reduction(+:d) |
| 71 |
// CHECK-NEXT: #pragma omp taskgroup task_reduction(+: d) |
| 72 |
// CHECK-NEXT: #pragma omp masked taskloop if(taskloop: a) default(none) shared(a) final(b) priority(5) 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 |
#pragma omp masked 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) filter(tid) |
| 79 |
for (int i = 0; i < 10; ++i) |
| 80 |
for (int j = 0; j < 10; ++j) { |
| 81 |
#pragma omp cancel taskgroup |
| 82 |
#pragma omp cancellation point taskgroup |
| 83 |
foo(); |
| 84 |
} |
| 85 |
// CHECK-NEXT: #pragma omp parallel |
| 86 |
// CHECK-NEXT: #pragma omp masked 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) filter(tid) |
| 87 |
// CHECK-NEXT: for (int i = 0; i < 10; ++i) |
| 88 |
// CHECK-NEXT: for (int j = 0; j < 10; ++j) { |
| 89 |
// CHECK-NEXT: #pragma omp cancel taskgroup |
| 90 |
// CHECK-NEXT: #pragma omp cancellation point taskgroup |
| 91 |
// CHECK-NEXT: foo(); |
| 92 |
return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0])); |
| 93 |
} |
| 94 |
|
| 95 |
#endif |