2016-03-03 13:21:39 +08:00
|
|
|
// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
|
2017-12-30 02:07:07 +08:00
|
|
|
|
|
|
|
// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
|
2016-03-03 13:21:39 +08:00
|
|
|
// expected-no-diagnostics
|
|
|
|
|
|
|
|
#ifndef HEADER
|
|
|
|
#define HEADER
|
|
|
|
|
2018-09-13 00:31:59 +08:00
|
|
|
template <typename T>
|
|
|
|
void bar(T &x, T &y) { x.a += y.a; }
|
|
|
|
|
|
|
|
namespace N1
|
|
|
|
{
|
|
|
|
struct A { int a; A() : a(0) {} };
|
|
|
|
#pragma omp declare reduction(+: A : bar(omp_out, omp_in))
|
|
|
|
};
|
|
|
|
|
2016-03-03 13:21:39 +08:00
|
|
|
#pragma omp declare reduction(+ : int, char : omp_out *= omp_in)
|
2018-02-15 01:38:47 +08:00
|
|
|
// CHECK: #pragma omp declare reduction (+ : int : omp_out *= omp_in){{$}}
|
2016-03-03 13:21:39 +08:00
|
|
|
// CHECK-NEXT: #pragma omp declare reduction (+ : char : omp_out *= omp_in)
|
|
|
|
|
2020-01-08 22:39:44 +08:00
|
|
|
|
2016-03-03 13:21:39 +08:00
|
|
|
template <class T>
|
|
|
|
class SSS {
|
|
|
|
public:
|
|
|
|
#pragma omp declare reduction(fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
|
2020-01-08 22:39:44 +08:00
|
|
|
#pragma omp declare reduction(fun1 : T : omp_out=1, omp_out=foo(omp_in)) initializer(omp_priv = omp_orig + 14)
|
|
|
|
static T foo(T &);
|
2016-03-03 13:21:39 +08:00
|
|
|
};
|
|
|
|
|
2020-01-08 22:39:44 +08:00
|
|
|
// CHECK: template <class T> class SSS {
|
|
|
|
// CHECK: #pragma omp declare reduction (fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
|
|
|
|
// CHECK: #pragma omp declare reduction (fun1 : T : omp_out = 1 , omp_out = foo(omp_in)) initializer(omp_priv = omp_orig + 14)
|
|
|
|
// CHECK: };
|
|
|
|
// CHECK: template<> class SSS<int> {
|
|
|
|
// CHECK: #pragma omp declare reduction (fun : int : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
|
|
|
|
// CHECK: #pragma omp declare reduction (fun1 : int : omp_out = 1 , omp_out = foo(omp_in)) initializer(omp_priv = omp_orig + 14)
|
|
|
|
// CHECK: };
|
|
|
|
|
2016-03-03 13:21:39 +08:00
|
|
|
SSS<int> d;
|
|
|
|
|
|
|
|
void init(SSS<int> &lhs, SSS<int> rhs);
|
|
|
|
|
|
|
|
#pragma omp declare reduction(fun : SSS < int > : omp_out = omp_in) initializer(init(omp_priv, omp_orig))
|
|
|
|
// CHECK: #pragma omp declare reduction (fun : SSS<int> : omp_out = omp_in) initializer(init(omp_priv, omp_orig))
|
|
|
|
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: template <typename T> T foo(T a) {
|
|
|
|
// CHECK: #pragma omp declare reduction (fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15);
|
2016-03-03 13:21:39 +08:00
|
|
|
// CHECK: {
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: #pragma omp declare reduction (fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15);
|
2016-03-03 13:21:39 +08:00
|
|
|
// CHECK: }
|
|
|
|
// CHECK: return a;
|
|
|
|
// CHECK: }
|
|
|
|
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: template<> int foo<int>(int a) {
|
|
|
|
// CHECK: #pragma omp declare reduction (fun : int : omp_out += omp_in) initializer(omp_priv = omp_orig + 15);
|
2016-03-03 13:21:39 +08:00
|
|
|
// CHECK: {
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: #pragma omp declare reduction (fun : int : omp_out += omp_in) initializer(omp_priv = omp_orig + 15);
|
2016-03-03 13:21:39 +08:00
|
|
|
// CHECK: }
|
|
|
|
// CHECK: return a;
|
|
|
|
// CHECK: }
|
|
|
|
template <typename T>
|
|
|
|
T foo(T a) {
|
|
|
|
#pragma omp declare reduction(fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
|
|
|
|
{
|
|
|
|
#pragma omp declare reduction(fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
|
|
|
|
}
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
int i = 0;
|
|
|
|
SSS<int> sss;
|
|
|
|
// TODO: Add support for scoped reduction identifiers
|
|
|
|
// #pragma omp parallel reduction(SSS<int>::fun : i)
|
|
|
|
// TODO-CHECK: #pragma omp parallel reduction(SSS<int>::fun: i)
|
|
|
|
{
|
|
|
|
i += 1;
|
|
|
|
}
|
|
|
|
// #pragma omp parallel reduction(::fun:sss)
|
|
|
|
// TODO-CHECK: #pragma omp parallel reduction(::fun: sss)
|
|
|
|
{
|
|
|
|
}
|
2018-09-13 00:31:59 +08:00
|
|
|
N1::A a;
|
|
|
|
// CHECK: #pragma omp parallel reduction(+: a)
|
|
|
|
#pragma omp parallel reduction(+: a)
|
|
|
|
{
|
|
|
|
}
|
2016-03-03 13:21:39 +08:00
|
|
|
return foo(15);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|