diff options
author | Carlo Bertolli <cbertol@us.ibm.com> | 2016-06-24 18:53:35 +0000 |
---|---|---|
committer | Carlo Bertolli <cbertol@us.ibm.com> | 2016-06-24 18:53:35 +0000 |
commit | 396e7147d3c07d993f73a3001cc9f16fa5a4fd2d (patch) | |
tree | 5a0f3d2657447874807bec3b8a97f1e588181936 /test/OpenMP/distribute_parallel_for_proc_bind_messages.cpp | |
parent | 94153940daa554f0c0aff54cf8e6ad9f248a2d3b (diff) |
[OpenMP] Initial implementation of parse and sema for composite pragma 'distribute parallel for'
http://reviews.llvm.org/D21564
This patch is an initial implementation for #distribute parallel for.
The main differences that affect other pragmas are:
The implementation of 'distribute parallel for' requires blocking of the associated loop, where blocks are "distributed" to different teams and iterations within each block are scheduled to parallel threads within each team. To implement blocking, sema creates two additional worksharing directive fields that are used to pass the team assigned block lower and upper bounds through the outlined function resulting from 'parallel'. In this way, scheduling for 'for' to threads can use those bounds.
As a consequence of blocking, the stride of 'distribute' is not 1 but it is equal to the blocking size. This is returned by the runtime and sema prepares a DistIncrExpr variable to hold that value.
As a consequence of blocking, the global upper bound (EnsureUpperBound) expression of the 'for' is not the original loop upper bound (e.g. in for(i = 0 ; i < N; i++) this is 'N') but it is the team-assigned block upper bound. Sema creates a new expression holding the calculation of the actual upper bound for 'for' as UB = min(UB, PrevUB), where UB is the loop upper bound, and PrevUB is the team-assigned block upper bound.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273705 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/OpenMP/distribute_parallel_for_proc_bind_messages.cpp')
-rw-r--r-- | test/OpenMP/distribute_parallel_for_proc_bind_messages.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/test/OpenMP/distribute_parallel_for_proc_bind_messages.cpp b/test/OpenMP/distribute_parallel_for_proc_bind_messages.cpp new file mode 100644 index 0000000000..9898f9dc65 --- /dev/null +++ b/test/OpenMP/distribute_parallel_for_proc_bind_messages.cpp @@ -0,0 +1,101 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s + +void foo(); + +template <class T, typename S, int N> +T tmain(T argc, S **argv) { + T i; +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind // expected-error {{expected '(' after 'proc_bind'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind( // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind() // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind(master // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind(close), proc_bind(spread) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'proc_bind' clause}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind(x) // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} + for (i = 0; i < argc; ++i) + foo(); + +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind(master) + for (i = 0; i < argc; ++i) + foo(); + +#pragma omp parallel proc_bind(close) +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind(spread) + for (i = 0; i < argc; ++i) + foo(); + + return T(); +} + +int main(int argc, char **argv) { + int i; +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind // expected-error {{expected '(' after 'proc_bind'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind( // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind() // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind(master // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind(close), proc_bind(spread) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'proc_bind' clause}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind(x) // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} + for (i = 0; i < argc; ++i) + foo(); + +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind(master) + for (i = 0; i < argc; ++i) + foo(); + +#pragma omp parallel proc_bind(close) +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for proc_bind(spread) + for (i = 0; i < argc; ++i) + foo(); + return tmain<int, char, 3>(argc, argv); +} |