| 1 |
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s -Wno-openmp-mapping | 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 -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45 |
| 4 |
// RUN: %clang_cc1 -verify -fopenmp -ast-print %s -Wno-openmp-mapping -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 -verify %s -ast-print -Wno-openmp-mapping -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50 |
| 7 |
|
| 8 |
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=60 -ast-print %s -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51 |
| 9 |
// RUN: %clang_cc1 -fopenmp -fopenmp-version=60 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP51 |
| 10 |
// RUN: %clang_cc1 -fopenmp -fopenmp-version=60 -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51 |
| 11 |
|
| 12 |
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -ast-print %s -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51 |
| 13 |
// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP51 |
| 14 |
// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51 |
| 15 |
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=52 -ast-print %s -Wno-openmp-mapping -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52 |
| 16 |
// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP52 |
| 17 |
// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52 |
| 18 |
|
| 19 |
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45 |
| 20 |
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s |
| 21 |
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45 |
| 22 |
// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -Wno-openmp-mapping -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50 |
| 23 |
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5 |
| 24 |
// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50 |
| 25 |
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -ast-print %s -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51 |
| 26 |
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP51 |
| 27 |
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51 |
| 28 |
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=60 -ast-print %s -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51 |
| 29 |
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=60 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP51 |
| 30 |
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=60 -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51 |
| 31 |
// expected-no-diagnostics |
| 32 |
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -ast-print %s -Wno-openmp-mapping -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52 |
| 33 |
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP52 |
| 34 |
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -std=c++11 -include-pch %t -verify %s -ast-print -Wno-openmp-mapping -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52 |
| 35 |
// expected-no-diagnostics |
| 36 |
|
| 37 |
#ifndef HEADER |
| 38 |
#define HEADER |
| 39 |
|
| 40 |
struct S { |
| 41 |
S(): a(0) {} |
| 42 |
S(int v) : a(v) {} |
| 43 |
int a; |
| 44 |
typedef int type; |
| 45 |
}; |
| 46 |
|
| 47 |
template <typename T> |
| 48 |
class S7 : public T { |
| 49 |
protected: |
| 50 |
T a; |
| 51 |
S7() : a(0) {} |
| 52 |
|
| 53 |
public: |
| 54 |
S7(typename T::type v) : a(v) { |
| 55 |
#pragma omp target |
| 56 |
#pragma omp teams |
| 57 |
#pragma omp distribute simd private(a) private(this->a) private(T::a) allocate(T::a) |
| 58 |
for (int k = 0; k < a.a; ++k) |
| 59 |
++this->a.a; |
| 60 |
} |
| 61 |
S7 &operator=(S7 &s) { |
| 62 |
#pragma omp target |
| 63 |
#pragma omp teams |
| 64 |
#pragma omp distribute simd allocate(a) private(a) private(this->a) |
| 65 |
for (int k = 0; k < s.a.a; ++k) |
| 66 |
++s.a.a; |
| 67 |
return *this; |
| 68 |
} |
| 69 |
}; |
| 70 |
|
| 71 |
// CHECK: #pragma omp distribute simd private(this->a) private(this->a) private(T::a) allocate(T::a){{$}} |
| 72 |
// CHECK: #pragma omp distribute simd allocate(this->a) private(this->a) private(this->a) |
| 73 |
// CHECK: #pragma omp distribute simd private(this->a) private(this->a) private(this->S::a) allocate(this->S::a) |
| 74 |
|
| 75 |
class S8 : public S7<S> { |
| 76 |
S8() {} |
| 77 |
|
| 78 |
public: |
| 79 |
S8(int v) : S7<S>(v){ |
| 80 |
#pragma omp target |
| 81 |
#pragma omp teams |
| 82 |
#pragma omp distribute simd private(a) private(this->a) private(S7<S>::a) |
| 83 |
for (int k = 0; k < a.a; ++k) |
| 84 |
++this->a.a; |
| 85 |
} |
| 86 |
S8 &operator=(S8 &s) { |
| 87 |
#pragma omp target |
| 88 |
#pragma omp teams |
| 89 |
#pragma omp distribute simd private(a) private(this->a) |
| 90 |
for (int k = 0; k < s.a.a; ++k) |
| 91 |
++s.a.a; |
| 92 |
return *this; |
| 93 |
} |
| 94 |
}; |
| 95 |
|
| 96 |
// CHECK: #pragma omp distribute simd private(this->a) private(this->a) private(this->S7<S>::a) |
| 97 |
// CHECK: #pragma omp distribute simd private(this->a) private(this->a) |
| 98 |
|
| 99 |
template <class T, int N> |
| 100 |
T tmain(T argc) { |
| 101 |
T b = argc, c, d, e, f, h; |
| 102 |
static T a; |
| 103 |
// CHECK: static T a; |
| 104 |
static T g; |
| 105 |
#pragma omp threadprivate(g) |
| 106 |
|
| 107 |
#pragma omp target |
| 108 |
#pragma omp teams |
| 109 |
#pragma omp distribute simd dist_schedule(static, a) firstprivate(a) |
| 110 |
for (int i = 0; i < 2; ++i) |
| 111 |
a = 2; |
| 112 |
// CHECK: #pragma omp distribute simd dist_schedule(static, a) firstprivate(a) |
| 113 |
// CHECK-NEXT: for (int i = 0; i < 2; ++i) |
| 114 |
// CHECK-NEXT: a = 2; |
| 115 |
|
| 116 |
#pragma omp target |
| 117 |
#pragma omp teams |
| 118 |
#pragma omp distribute simd private(argc, b), firstprivate(c, d), lastprivate(f) collapse(N) reduction(+ : h) dist_schedule(static,N) |
| 119 |
for (int i = 0; i < 2; ++i) |
| 120 |
for (int j = 0; j < 2; ++j) |
| 121 |
for (int k = 0; k < 10; ++k) |
| 122 |
for (int m = 0; m < 10; ++m) |
| 123 |
for (int n = 0; n < 10; ++n) |
| 124 |
a++; |
| 125 |
// CHECK: #pragma omp distribute simd private(argc,b) firstprivate(c,d) lastprivate(f) collapse(N) reduction(+: h) dist_schedule(static, N) |
| 126 |
// CHECK-NEXT: for (int i = 0; i < 2; ++i) |
| 127 |
// CHECK-NEXT: for (int j = 0; j < 2; ++j) |
| 128 |
// CHECK-NEXT: for (int k = 0; k < 10; ++k) |
| 129 |
// CHECK-NEXT: for (int m = 0; m < 10; ++m) |
| 130 |
// CHECK-NEXT: for (int n = 0; n < 10; ++n) |
| 131 |
// CHECK-NEXT: a++; |
| 132 |
return T(); |
| 133 |
} |
| 134 |
|
| 135 |
int main(int argc, char **argv) { |
| 136 |
int b = argc, c, d, e, f, h; |
| 137 |
int x[200]; |
| 138 |
static int a; |
| 139 |
// CHECK: static int a; |
| 140 |
static float g; |
| 141 |
#pragma omp threadprivate(g) |
| 142 |
|
| 143 |
#pragma omp target |
| 144 |
#pragma omp teams |
| 145 |
#pragma omp distribute simd dist_schedule(static, a) private(a) |
| 146 |
for (int i = 0; i < 2; ++i) |
| 147 |
a = 2; |
| 148 |
// CHECK: #pragma omp distribute simd dist_schedule(static, a) private(a) |
| 149 |
// CHECK-NEXT: for (int i = 0; i < 2; ++i) |
| 150 |
// CHECK-NEXT: a = 2; |
| 151 |
|
| 152 |
#pragma omp target |
| 153 |
#pragma omp teams |
| 154 |
#ifdef OMP5 |
| 155 |
#pragma omp distribute simd private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) reduction(+ : h) dist_schedule(static, b) if(simd:argc) |
| 156 |
#else |
| 157 |
#pragma omp distribute simd private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) reduction(+ : h) dist_schedule(static, b) |
| 158 |
#endif // OMP5 |
| 159 |
for (int i = 0; i < 10; ++i) |
| 160 |
for (int j = 0; j < 10; ++j) |
| 161 |
a++; |
| 162 |
// OMP45: #pragma omp distribute simd private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) reduction(+: h) dist_schedule(static, b) |
| 163 |
// OMP50: #pragma omp distribute simd private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) reduction(+: h) dist_schedule(static, b) if(simd: argc) |
| 164 |
// OMP51: #pragma omp distribute simd private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) reduction(+: h) dist_schedule(static, b) |
| 165 |
// OMP52: #pragma omp distribute simd private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) reduction(+: h) dist_schedule(static, b) |
| 166 |
// CHECK-NEXT: for (int i = 0; i < 10; ++i) |
| 167 |
// CHECK-NEXT: for (int j = 0; j < 10; ++j) |
| 168 |
// CHECK-NEXT: a++; |
| 169 |
|
| 170 |
int i; |
| 171 |
#pragma omp target |
| 172 |
#pragma omp teams |
| 173 |
#ifdef OMP52 |
| 174 |
#pragma omp distribute simd aligned(x:8) linear(i: step(2)) safelen(8) simdlen(8) if(argc) nontemporal(argc, c, d) order(reproducible:concurrent) |
| 175 |
#elif OMP51 |
| 176 |
#pragma omp distribute simd aligned(x:8) linear(i:2) safelen(8) simdlen(8) if(argc) nontemporal(argc, c, d) order(reproducible:concurrent) |
| 177 |
#elif OMP5 |
| 178 |
#pragma omp distribute simd aligned(x:8) linear(i:2) safelen(8) simdlen(8) if(argc) nontemporal(argc, c, d) order(concurrent) |
| 179 |
#else |
| 180 |
#pragma omp distribute simd aligned(x:8) linear(i:2) safelen(8) simdlen(8) |
| 181 |
#endif // OMP51 |
| 182 |
for (i = 0; i < 100; i++) |
| 183 |
for (int j = 0; j < 200; j++) |
| 184 |
a += h + x[j]; |
| 185 |
// OMP45: #pragma omp distribute simd aligned(x: 8) linear(i: step(2)) safelen(8) simdlen(8) |
| 186 |
// OMP50: #pragma omp distribute simd aligned(x: 8) linear(i: step(2)) safelen(8) simdlen(8) if(argc) nontemporal(argc,c,d) order(concurrent) |
| 187 |
// OMP51: #pragma omp distribute simd aligned(x: 8) linear(i: step(2)) safelen(8) simdlen(8) if(argc) nontemporal(argc,c,d) order(reproducible: concurrent) |
| 188 |
// OMP52: #pragma omp distribute simd aligned(x: 8) linear(i: step(2)) safelen(8) simdlen(8) if(argc) nontemporal(argc,c,d) order(reproducible: concurrent) |
| 189 |
// CHECK-NEXT: for (i = 0; i < 100; i++) |
| 190 |
// CHECK-NEXT: for (int j = 0; j < 200; j++) |
| 191 |
// CHECK-NEXT: a += h + x[j]; |
| 192 |
|
| 193 |
return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0])); |
| 194 |
} |
| 195 |
|
| 196 |
#endif |