2020-03-24 05:30:38 +08:00
|
|
|
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
|
2017-12-30 02:07:07 +08:00
|
|
|
|
2020-03-24 05:30:38 +08:00
|
|
|
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -ast-print %s | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
|
2013-07-19 11:13:43 +08:00
|
|
|
// expected-no-diagnostics
|
|
|
|
|
|
|
|
#ifndef HEADER
|
|
|
|
#define HEADER
|
|
|
|
|
|
|
|
void foo() {}
|
|
|
|
|
2016-01-20 17:07:54 +08:00
|
|
|
struct S1 {
|
|
|
|
S1(): a(0) {}
|
|
|
|
S1(int v) : a(v) {}
|
|
|
|
int a;
|
|
|
|
typedef int type;
|
2016-02-29 13:54:20 +08:00
|
|
|
S1& operator +(const S1&);
|
|
|
|
S1& operator *(const S1&);
|
|
|
|
S1& operator &&(const S1&);
|
|
|
|
S1& operator ^(const S1&);
|
2016-01-20 17:07:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
class S7 : public T {
|
|
|
|
protected:
|
|
|
|
T a;
|
2016-02-29 13:54:20 +08:00
|
|
|
T b[100];
|
2016-01-20 17:07:54 +08:00
|
|
|
S7() : a(0) {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
S7(typename T::type v) : a(v) {
|
|
|
|
#pragma omp parallel private(a) private(this->a) private(T::a)
|
|
|
|
for (int k = 0; k < a.a; ++k)
|
|
|
|
++this->a.a;
|
2016-02-10 19:29:16 +08:00
|
|
|
#pragma omp parallel firstprivate(a) firstprivate(this->a) firstprivate(T::a)
|
|
|
|
for (int k = 0; k < a.a; ++k)
|
|
|
|
++this->a.a;
|
2016-02-25 11:59:29 +08:00
|
|
|
#pragma omp parallel shared(a) shared(this->a) shared(T::a)
|
|
|
|
for (int k = 0; k < a.a; ++k)
|
|
|
|
++this->a.a;
|
2016-02-29 13:54:20 +08:00
|
|
|
#pragma omp parallel reduction(+ : a) reduction(*: b[:])
|
|
|
|
for (int k = 0; k < a.a; ++k)
|
|
|
|
++this->a.a;
|
2016-01-20 17:07:54 +08:00
|
|
|
}
|
|
|
|
S7 &operator=(S7 &s) {
|
|
|
|
#pragma omp parallel private(a) private(this->a)
|
|
|
|
for (int k = 0; k < s.a.a; ++k)
|
|
|
|
++s.a.a;
|
2016-02-10 19:29:16 +08:00
|
|
|
#pragma omp parallel firstprivate(a) firstprivate(this->a)
|
|
|
|
for (int k = 0; k < s.a.a; ++k)
|
|
|
|
++s.a.a;
|
2016-02-25 11:59:29 +08:00
|
|
|
#pragma omp parallel shared(a) shared(this->a)
|
|
|
|
for (int k = 0; k < s.a.a; ++k)
|
|
|
|
++s.a.a;
|
2016-02-29 13:54:20 +08:00
|
|
|
#pragma omp parallel reduction(&& : this->a) reduction(^: b[s.a.a])
|
|
|
|
for (int k = 0; k < s.a.a; ++k)
|
|
|
|
++s.a.a;
|
2016-01-20 17:07:54 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK: #pragma omp parallel private(this->a) private(this->a) private(T::a)
|
2016-02-10 19:29:16 +08:00
|
|
|
// CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a) firstprivate(T::a)
|
2016-02-25 11:59:29 +08:00
|
|
|
// CHECK: #pragma omp parallel shared(this->a) shared(this->a) shared(T::a)
|
2016-02-29 13:54:20 +08:00
|
|
|
// CHECK: #pragma omp parallel reduction(+: this->a) reduction(*: this->b[:])
|
2016-01-20 17:07:54 +08:00
|
|
|
// CHECK: #pragma omp parallel private(this->a) private(this->a)
|
2016-02-10 19:29:16 +08:00
|
|
|
// CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a)
|
2016-02-25 11:59:29 +08:00
|
|
|
// CHECK: #pragma omp parallel shared(this->a) shared(this->a)
|
2016-02-29 13:54:20 +08:00
|
|
|
// CHECK: #pragma omp parallel reduction(&&: this->a) reduction(^: this->b[s.a.a])
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: #pragma omp parallel private(this->a) private(this->a) private(this->S1::a)
|
|
|
|
// CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a) firstprivate(this->S1::a)
|
|
|
|
// CHECK: #pragma omp parallel shared(this->a) shared(this->a) shared(this->S1::a)
|
|
|
|
// CHECK: #pragma omp parallel reduction(+: this->a) reduction(*: this->b[:])
|
2016-01-20 17:07:54 +08:00
|
|
|
|
|
|
|
class S8 : public S7<S1> {
|
|
|
|
S8() {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
S8(int v) : S7<S1>(v){
|
2016-02-25 11:59:29 +08:00
|
|
|
#pragma omp parallel private(a) private(this->a) private(S7 < S1 > ::a)
|
2016-01-20 17:07:54 +08:00
|
|
|
for (int k = 0; k < a.a; ++k)
|
|
|
|
++this->a.a;
|
2016-02-25 11:59:29 +08:00
|
|
|
#pragma omp parallel firstprivate(a) firstprivate(this->a) firstprivate(S7 < S1 > ::a)
|
|
|
|
for (int k = 0; k < a.a; ++k)
|
|
|
|
++this->a.a;
|
|
|
|
#pragma omp parallel shared(a) shared(this->a) shared(S7 < S1 > ::a)
|
2016-02-10 19:29:16 +08:00
|
|
|
for (int k = 0; k < a.a; ++k)
|
|
|
|
++this->a.a;
|
2020-03-24 05:30:38 +08:00
|
|
|
#pragma omp parallel reduction(default, ^ : S7 < S1 > ::a) reduction(+ : S7 < S1 > ::b[ : S7 < S1 > ::a.a])
|
2016-02-29 13:54:20 +08:00
|
|
|
for (int k = 0; k < a.a; ++k)
|
|
|
|
++this->a.a;
|
2016-01-20 17:07:54 +08:00
|
|
|
}
|
|
|
|
S8 &operator=(S8 &s) {
|
|
|
|
#pragma omp parallel private(a) private(this->a)
|
|
|
|
for (int k = 0; k < s.a.a; ++k)
|
|
|
|
++s.a.a;
|
2016-02-10 19:29:16 +08:00
|
|
|
#pragma omp parallel firstprivate(a) firstprivate(this->a)
|
|
|
|
for (int k = 0; k < s.a.a; ++k)
|
|
|
|
++s.a.a;
|
2016-02-25 11:59:29 +08:00
|
|
|
#pragma omp parallel shared(a) shared(this->a)
|
|
|
|
for (int k = 0; k < s.a.a; ++k)
|
|
|
|
++s.a.a;
|
2016-02-29 13:54:20 +08:00
|
|
|
#pragma omp parallel reduction(* : this->a) reduction(&&:this->b[a.a:])
|
|
|
|
for (int k = 0; k < s.a.a; ++k)
|
|
|
|
++s.a.a;
|
2016-01-20 17:07:54 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK: #pragma omp parallel private(this->a) private(this->a) private(this->S7<S1>::a)
|
2016-02-10 19:29:16 +08:00
|
|
|
// CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a) firstprivate(this->S7<S1>::a)
|
2016-02-25 11:59:29 +08:00
|
|
|
// CHECK: #pragma omp parallel shared(this->a) shared(this->a) shared(this->S7<S1>::a)
|
2020-03-24 05:30:38 +08:00
|
|
|
// CHECK: #pragma omp parallel reduction(default, ^: this->S7<S1>::a) reduction(+: this->S7<S1>::b[:this->S7<S1>::a.a])
|
2016-01-20 17:07:54 +08:00
|
|
|
// CHECK: #pragma omp parallel private(this->a) private(this->a)
|
2016-02-10 19:29:16 +08:00
|
|
|
// CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a)
|
2016-02-25 11:59:29 +08:00
|
|
|
// CHECK: #pragma omp parallel shared(this->a) shared(this->a)
|
2016-02-29 13:54:20 +08:00
|
|
|
// CHECK: #pragma omp parallel reduction(*: this->a) reduction(&&: this->b[this->a.a:])
|
2016-01-20 17:07:54 +08:00
|
|
|
|
2014-03-06 14:15:19 +08:00
|
|
|
template <class T>
|
|
|
|
struct S {
|
|
|
|
operator T() {return T();}
|
2014-03-31 11:36:38 +08:00
|
|
|
static T TS;
|
|
|
|
#pragma omp threadprivate(TS)
|
2014-03-06 14:15:19 +08:00
|
|
|
};
|
2013-10-01 13:32:34 +08:00
|
|
|
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: template <class T> struct S {
|
|
|
|
// CHECK: static T TS;
|
|
|
|
// CHECK-NEXT: #pragma omp threadprivate(S::TS)
|
|
|
|
// CHECK: };
|
|
|
|
// CHECK: template<> struct S<int> {
|
2014-03-31 11:36:38 +08:00
|
|
|
// CHECK: static int TS;
|
|
|
|
// CHECK-NEXT: #pragma omp threadprivate(S<int>::TS)
|
|
|
|
// CHECK-NEXT: }
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: template<> struct S<long> {
|
2014-03-31 11:36:38 +08:00
|
|
|
// CHECK: static long TS;
|
|
|
|
// CHECK-NEXT: #pragma omp threadprivate(S<long>::TS)
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
|
2017-11-15 05:01:01 +08:00
|
|
|
int thrp;
|
|
|
|
#pragma omp threadprivate(thrp)
|
|
|
|
|
2014-03-05 14:45:14 +08:00
|
|
|
template <typename T, int C>
|
2013-10-01 13:32:34 +08:00
|
|
|
T tmain(T argc, T *argv) {
|
|
|
|
T b = argc, c, d, e, f, g;
|
|
|
|
static T a;
|
2014-03-06 14:15:19 +08:00
|
|
|
S<T> s;
|
2015-09-30 17:22:36 +08:00
|
|
|
T arr[C][10], arr1[C];
|
2013-10-01 13:32:34 +08:00
|
|
|
#pragma omp parallel
|
|
|
|
a=2;
|
2017-11-15 05:01:01 +08:00
|
|
|
#pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared (d) if (parallel:argc > 0) num_threads(C) copyin(S<T>::TS, thrp) proc_bind(master) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10])
|
2013-10-01 13:32:34 +08:00
|
|
|
foo();
|
2020-04-22 20:14:39 +08:00
|
|
|
#pragma omp parallel if (C) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:C][:argc]) reduction(default, && : g) reduction(task,+:argc)
|
2014-03-05 14:45:14 +08:00
|
|
|
foo();
|
2013-10-01 13:32:34 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-03-31 11:36:38 +08:00
|
|
|
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
|
|
|
|
// CHECK-NEXT: T b = argc, c, d, e, f, g;
|
|
|
|
// CHECK-NEXT: static T a;
|
|
|
|
// CHECK-NEXT: S<T> s;
|
|
|
|
// CHECK-NEXT: T arr[C][10], arr1[C];
|
2018-02-15 01:38:47 +08:00
|
|
|
// CHECK-NEXT: #pragma omp parallel{{$}}
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK-NEXT: a = 2;
|
2017-11-15 05:01:01 +08:00
|
|
|
// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) copyin(S<T>::TS,thrp) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:C][0:10])
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK-NEXT: foo()
|
2020-04-22 20:14:39 +08:00
|
|
|
// CHECK-NEXT: #pragma omp parallel if(C) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:C][:argc]) reduction(default, &&: g) reduction(task, +: argc)
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK-NEXT: foo()
|
|
|
|
// CHECK: template<> int tmain<int, 5>(int argc, int *argv) {
|
2013-10-01 13:32:34 +08:00
|
|
|
// CHECK-NEXT: int b = argc, c, d, e, f, g;
|
|
|
|
// CHECK-NEXT: static int a;
|
2014-03-06 14:15:19 +08:00
|
|
|
// CHECK-NEXT: S<int> s;
|
2015-09-30 17:22:36 +08:00
|
|
|
// CHECK-NEXT: int arr[5][10], arr1[5];
|
2013-10-01 13:32:34 +08:00
|
|
|
// CHECK-NEXT: #pragma omp parallel
|
|
|
|
// CHECK-NEXT: a = 2;
|
2017-11-15 05:01:01 +08:00
|
|
|
// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) copyin(S<int>::TS,thrp) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:5][0:10])
|
2013-10-01 13:32:34 +08:00
|
|
|
// CHECK-NEXT: foo()
|
2020-04-22 20:14:39 +08:00
|
|
|
// CHECK-NEXT: #pragma omp parallel if(5) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:5][:argc]) reduction(default, &&: g) reduction(task, +: argc)
|
2014-03-05 14:45:14 +08:00
|
|
|
// CHECK-NEXT: foo()
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: template<> long tmain<long, 1>(long argc, long *argv) {
|
2014-03-06 14:15:19 +08:00
|
|
|
// CHECK-NEXT: long b = argc, c, d, e, f, g;
|
|
|
|
// CHECK-NEXT: static long a;
|
|
|
|
// CHECK-NEXT: S<long> s;
|
2015-09-30 17:22:36 +08:00
|
|
|
// CHECK-NEXT: long arr[1][10], arr1[1];
|
2013-10-01 13:32:34 +08:00
|
|
|
// CHECK-NEXT: #pragma omp parallel
|
|
|
|
// CHECK-NEXT: a = 2;
|
2017-11-15 05:01:01 +08:00
|
|
|
// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) copyin(S<long>::TS,thrp) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:1][0:10])
|
2013-10-01 13:32:34 +08:00
|
|
|
// CHECK-NEXT: foo()
|
2020-04-22 20:14:39 +08:00
|
|
|
// CHECK-NEXT: #pragma omp parallel if(1) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:1][:argc]) reduction(default, &&: g) reduction(task, +: argc)
|
2014-03-05 14:45:14 +08:00
|
|
|
// CHECK-NEXT: foo()
|
2013-10-01 13:32:34 +08:00
|
|
|
|
2014-03-06 14:15:19 +08:00
|
|
|
enum Enum { };
|
|
|
|
|
2013-07-19 11:13:43 +08:00
|
|
|
int main (int argc, char **argv) {
|
2014-03-06 14:15:19 +08:00
|
|
|
long x;
|
2013-07-19 11:13:43 +08:00
|
|
|
int b = argc, c, d, e, f, g;
|
|
|
|
static int a;
|
2014-03-31 11:36:38 +08:00
|
|
|
#pragma omp threadprivate(a)
|
2015-09-30 17:22:36 +08:00
|
|
|
int arr[10][argc], arr1[2];
|
2014-03-06 14:15:19 +08:00
|
|
|
Enum ee;
|
|
|
|
// CHECK: Enum ee;
|
2013-07-19 11:13:43 +08:00
|
|
|
#pragma omp parallel
|
|
|
|
// CHECK-NEXT: #pragma omp parallel
|
|
|
|
a=2;
|
|
|
|
// CHECK-NEXT: a = 2;
|
2019-03-27 22:14:31 +08:00
|
|
|
#pragma omp parallel default(none), private(argc,b) firstprivate(argv) if (parallel: argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(| : c, d, arr1[argc]) reduction(* : e, arr[:10][0:argc]) allocate(e)
|
|
|
|
// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) if(parallel: argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(|: c,d,arr1[argc]) reduction(*: e,arr[:10][0:argc]) allocate(e)
|
2013-07-19 11:13:43 +08:00
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
2019-03-27 22:14:31 +08:00
|
|
|
// CHECK-NEXT: #pragma omp parallel allocate(e) if(b) num_threads(c) proc_bind(close) reduction(^: e,f) reduction(&&: g,arr[0:argc][:10])
|
2015-09-03 16:45:56 +08:00
|
|
|
// CHECK-NEXT: foo()
|
2019-03-27 22:14:31 +08:00
|
|
|
#pragma omp parallel allocate(e) if (b) num_threads(c) proc_bind(close) reduction(^:e, f) reduction(&& : g, arr[0:argc][:10])
|
2015-09-03 16:45:56 +08:00
|
|
|
foo();
|
2014-03-06 14:15:19 +08:00
|
|
|
return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x);
|
2013-07-19 11:13:43 +08:00
|
|
|
}
|
|
|
|
|
2015-12-17 14:55:08 +08:00
|
|
|
template <class T>
|
|
|
|
struct Foo {
|
|
|
|
int foo;
|
|
|
|
};
|
|
|
|
|
|
|
|
void foo(const Foo<int> &arg) {
|
|
|
|
// CHECK: #pragma omp parallel
|
|
|
|
#pragma omp parallel
|
|
|
|
{
|
|
|
|
// CHECK: #pragma omp for schedule(static)
|
|
|
|
#pragma omp for schedule(static)
|
|
|
|
for (int idx = 0; idx < 1234; ++idx) {
|
|
|
|
//arg.foo = idx;
|
|
|
|
idx = arg.foo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-19 14:19:52 +08:00
|
|
|
template<typename T>
|
|
|
|
T S<T>::TS = 0;
|
|
|
|
|
2013-07-19 11:13:43 +08:00
|
|
|
#endif
|