diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2016-04-12 11:02:11 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2016-04-12 11:02:11 +0000 |
commit | ecba70f194b556ca03df28bfc943878611f12e7a (patch) | |
tree | e3cc5ced73eb7acd5a5b6824d3594e7a5c1095bc /clang/test | |
parent | 703c864fe3a15c5d35c5f09b78a152f9809b833e (diff) | |
download | bcm5719-llvm-ecba70f194b556ca03df28bfc943878611f12e7a.tar.gz bcm5719-llvm-ecba70f194b556ca03df28bfc943878611f12e7a.zip |
[OPENMP 4.0] Support for 'linear' clause in 'declare simd' directive.
The linear clause declares one or more list items to be private to a SIMD lane and to have a linear relationship with respect to the iteration space of a loop.
'linear' '(' <linear-list> [ ':' <linear-step> ] ')'
When a linear-step expression is specified in a linear clause it must be
either a constant integer expression or an integer-typed parameter that is specified in a uniform clause on the directive.
The special this pointer can be used as if was one of the arguments to the function in any of the linear, aligned, or uniform clauses.
llvm-svn: 266056
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/OpenMP/declare_simd_ast_print.c | 16 | ||||
-rw-r--r-- | clang/test/OpenMP/declare_simd_ast_print.cpp | 38 | ||||
-rw-r--r-- | clang/test/OpenMP/declare_simd_messages.cpp | 56 |
3 files changed, 82 insertions, 28 deletions
diff --git a/clang/test/OpenMP/declare_simd_ast_print.c b/clang/test/OpenMP/declare_simd_ast_print.c index 5cb24084e53..04fd73f272d 100644 --- a/clang/test/OpenMP/declare_simd_ast_print.c +++ b/clang/test/OpenMP/declare_simd_ast_print.c @@ -7,15 +7,15 @@ #define HEADER #pragma omp declare simd aligned(b : 64) -#pragma omp declare simd simdlen(32) aligned(d, s1) -#pragma omp declare simd inbranch, uniform(d) -#pragma omp declare simd notinbranch simdlen(2), uniform(s1, s2) -void add_1(float *d, float *s1, float *s2, double b[]) __attribute__((cold)); +#pragma omp declare simd simdlen(32) aligned(d, b) +#pragma omp declare simd inbranch, uniform(d) linear(val(s1, s2) : 32) +#pragma omp declare simd notinbranch simdlen(2), uniform(s1, s2) linear(d: s1) +void add_1(float *d, int s1, float *s2, double b[]) __attribute__((cold)); -// CHECK: #pragma omp declare simd notinbranch simdlen(2) uniform(s1, s2) -// CHECK-NEXT: #pragma omp declare simd inbranch uniform(d) -// CHECK-NEXT: #pragma omp declare simd simdlen(32) aligned(d) aligned(s1) +// CHECK: #pragma omp declare simd notinbranch simdlen(2) uniform(s1, s2) linear(val(d): s1) +// CHECK-NEXT: #pragma omp declare simd inbranch uniform(d) linear(val(s1): 32) linear(val(s2): 32) +// CHECK-NEXT: #pragma omp declare simd simdlen(32) aligned(d) aligned(b) // CHECK-NEXT: #pragma omp declare simd aligned(b: 64) -// CHECK-NEXT: void add_1(float *d, float *s1, float *s2, double b[]) __attribute__((cold)) +// CHECK-NEXT: void add_1(float *d, int s1, float *s2, double b[]) __attribute__((cold)) #endif diff --git a/clang/test/OpenMP/declare_simd_ast_print.cpp b/clang/test/OpenMP/declare_simd_ast_print.cpp index 56008b53967..5a32e61d992 100644 --- a/clang/test/OpenMP/declare_simd_ast_print.cpp +++ b/clang/test/OpenMP/declare_simd_ast_print.cpp @@ -6,14 +6,14 @@ #ifndef HEADER #define HEADER -#pragma omp declare simd +#pragma omp declare simd linear(d: 8) #pragma omp declare simd inbranch simdlen(32) #pragma omp declare simd notinbranch void add_1(float *d) __attribute__((cold)); // CHECK: #pragma omp declare simd notinbranch // CHECK-NEXT: #pragma omp declare simd inbranch simdlen(32) -// CHECK-NEXT: #pragma omp declare simd +// CHECK-NEXT: #pragma omp declare simd linear(val(d): 8) // CHECK-NEXT: void add_1(float *d) __attribute__((cold)); // @@ -48,28 +48,28 @@ void h(int *hp, int *hp2, int *hq, int *lin) } class VV { - // CHECK: #pragma omp declare simd uniform(this, a) + // CHECK: #pragma omp declare simd uniform(this, a) linear(val(b): a) // CHECK-NEXT: int add(int a, int b) __attribute__((cold)) { // CHECK-NEXT: return a + b; // CHECK-NEXT: } - #pragma omp declare simd uniform(this, a) + #pragma omp declare simd uniform(this, a) linear(val(b): a) int add(int a, int b) __attribute__((cold)) { return a + b; } - // CHECK: #pragma omp declare simd aligned(b: 4) aligned(a) + // CHECK: #pragma omp declare simd aligned(b: 4) aligned(a) linear(ref(b): 4) linear(val(this)) linear(val(a)) // CHECK-NEXT: float taddpf(float *a, float *&b) { // CHECK-NEXT: return *a + *b; // CHECK-NEXT: } - #pragma omp declare simd aligned (b: 4) aligned(a) + #pragma omp declare simd aligned (b: 4) aligned(a) linear(ref(b): 4) linear(this, a) float taddpf(float *a, float *&b) { return *a + *b; } // CHECK: #pragma omp declare simd aligned(b: 8) -// CHECK-NEXT: #pragma omp declare simd -// CHECK-NEXT: int tadd(int (&b)[]) { +// CHECK-NEXT: #pragma omp declare simd linear(uval(c): 8) +// CHECK-NEXT: int tadd(int (&b)[], int &c) { // CHECK-NEXT: return this->x[b[0]] + b[0]; // CHECK-NEXT: } - #pragma omp declare simd + #pragma omp declare simd linear(uval(c): 8) #pragma omp declare simd aligned(b : 8) - int tadd(int (&b)[]) { return x[b[0]] + b[0]; } + int tadd(int (&b)[], int &c) { return x[b[0]] + b[0]; } private: int x[10]; @@ -78,7 +78,7 @@ private: // CHECK: template <int X = 16, typename T = float> class TVV { // CHECK: #pragma omp declare simd // CHECK-NEXT: int tadd(int a, int b); -// CHECK: #pragma omp declare simd aligned(a: 16 * 2) aligned(b) +// CHECK: #pragma omp declare simd aligned(a: 16 * 2) aligned(b) linear(ref(b): 16) // CHECK-NEXT: float taddpf(float *a, float *&b) { // CHECK-NEXT: return *a + *b; // CHECK-NEXT: } @@ -100,7 +100,7 @@ public: // CHECK-NEXT: return a + b; // CHECK-NEXT: } - #pragma omp declare simd aligned(a : X * 2) aligned(b) + #pragma omp declare simd aligned(a : X * 2) aligned(b) linear(ref(b): X) float taddpf(float *a, T *&b) { return *a + *b; } // CHECK: #pragma omp declare simd aligned(a: X * 2) aligned(b) @@ -123,13 +123,13 @@ private: }; // CHECK: }; -// CHECK: #pragma omp declare simd simdlen(64) aligned(b: 64 * 2) -// CHECK: template <int N = 64> void foo(int (&b)[64]) -// CHECK: #pragma omp declare simd simdlen(N) aligned(b: N * 2) -// CHECK: template <int N> void foo(int (&b)[N]) -#pragma omp declare simd simdlen(N) aligned(b : N * 2) +// CHECK: #pragma omp declare simd simdlen(64) aligned(b: 64 * 2) linear(uval(c): 64) +// CHECK: template <int N = 64> void foo(int (&b)[64], float *&c) +// CHECK: #pragma omp declare simd simdlen(N) aligned(b: N * 2) linear(uval(c): N) +// CHECK: template <int N> void foo(int (&b)[N], float *&c) +#pragma omp declare simd simdlen(N) aligned(b : N * 2) linear(uval(c): N) template <int N> -void foo(int (&b)[N]); +void foo(int (&b)[N], float *&c); // CHECK: TVV<16, float> t16; TVV<16, float> t16; @@ -140,7 +140,7 @@ void f() { float r = t16.taddpf(&a, p); int res = t16.tadd(b); int c[64]; - foo(c); + foo(c, p); } #endif diff --git a/clang/test/OpenMP/declare_simd_messages.cpp b/clang/test/OpenMP/declare_simd_messages.cpp index e1745aaa116..15971eb14de 100644 --- a/clang/test/OpenMP/declare_simd_messages.cpp +++ b/clang/test/OpenMP/declare_simd_messages.cpp @@ -144,6 +144,57 @@ void test() { #pragma omp declare simd aligned(b: -1) // expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}} #pragma omp declare simd aligned(b: 3) +// expected-error@+1 {{expected '(' after 'linear'}} +#pragma omp declare simd linear +// expected-note@+3 {{to match this '('}} +// expected-error@+2 {{expected ')'}} +// expected-error@+1 {{expected expression}} +#pragma omp declare simd linear( +// expected-error@+1 {{expected expression}} +#pragma omp declare simd linear() +// expected-note@+3 {{to match this '('}} +// expected-error@+2 {{expected ')'}} +// expected-error@+1 {{expected expression}} +#pragma omp declare simd linear(a: +// expected-error@+1 {{expected expression}} +#pragma omp declare simd linear(a:) +// expected-warning@+2 {{extra tokens at the end of '#pragma omp declare simd' are ignored}} +// expected-error@+1 {{expected '(' after 'linear'}} +#pragma omp declare simd linear :) +// expected-note@+3 {{to match this '('}} +// expected-error@+2 {{expected ')'}} +// expected-error@+1 {{invalid use of 'this' outside of a non-static member function}} +#pragma omp declare simd linear(this +// expected-note@+3 {{to match this '('}} +// expected-error@+2 {{expected ')'}} +// expected-error@+1 {{invalid use of 'this' outside of a non-static member function}} +#pragma omp declare simd linear(this,b +// expected-error@+1 {{expected expression}} +#pragma omp declare simd linear(, b) +// expected-note@+4 {{defined as linear}} +// expected-error@+3 {{linear variable cannot be linear}} +// expected-error@+2 {{expected expression}} +// expected-error@+1 {{expected ',' or ')' in 'linear' clause}} +#pragma omp declare simd linear(b) linear(b ; 64) +// expected-note@+2 {{defined as linear}} +// expected-error@+1 {{linear variable cannot be linear}} +#pragma omp declare simd linear(b) linear(b: 64) +#pragma omp declare simd linear(b: -1) +#pragma omp declare simd linear(b: 3) +// expected-error@+1 {{expected a reference to a parameter specified in a 'uniform' clause}} +#pragma omp declare simd linear(b: a) +// expected-note@+2 {{defined as uniform}} +// expected-error@+1 {{linear variable cannot be uniform}} +#pragma omp declare simd uniform(a), linear(a: 4) +// expected-note@+2 {{defined as uniform}} +// expected-error@+1 {{linear variable cannot be uniform}} +#pragma omp declare simd linear(a: 4) uniform(a) +// expected-error@+1 {{variable of non-reference type 'int *' can be used only with 'val' modifier, but used with 'uval'}} +#pragma omp declare simd linear(uval(b)) +// expected-error@+1 {{variable of non-reference type 'int *' can be used only with 'val' modifier, but used with 'ref'}} +#pragma omp declare simd linear(ref(b)) +// expected-error@+1 {{expected one of 'ref', val' or 'uval' modifiers}} +#pragma omp declare simd linear(uref(b)) void bar(int a, int *b); template <class T> @@ -152,11 +203,14 @@ struct St { #pragma init_seg(compiler) #pragma omp declare simd #pragma init_seg(compiler) +// expected-note@+7 {{defined as uniform}} +// expected-error@+6 {{expected a reference to a parameter specified in a 'uniform' clause}} +// expected-error@+5 {{linear variable cannot be uniform}} // expected-note@+4 {{defined as aligned}} // expected-error@+3 {{argument to 'aligned' clause must be a strictly positive integer value}} // expected-error@+2 {{'this' cannot appear in more than one aligned clause}} // expected-error@+1 {{use of undeclared identifier 't'}} -#pragma omp declare simd uniform(this, t) aligned(this: 4) aligned(this: -4) +#pragma omp declare simd uniform(this, t) aligned(this: 4) aligned(this: -4) linear(this: hp) void h(T *hp) { // expected-error@+1 {{unexpected OpenMP directive '#pragma omp declare simd'}} #pragma omp declare simd |