Files
llvm-project/clang/test/OpenMP/distribute_parallel_for_copyin_messages.cpp
Carlo Bertolli 9925f15661 Resubmission of http://reviews.llvm.org/D21564 after fixes.
[OpenMP] Initial implementation of parse and sema for composite pragma 'distribute parallel for'

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.

llvm-svn: 273884
2016-06-27 14:55:37 +00:00

191 lines
5.6 KiB
C++

// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s
void foo() {
}
bool foobool(int argc) {
return argc;
}
struct S1; // expected-note 2 {{declared here}}
class S2 {
mutable int a;
public:
S2() : a(0) {}
S2 &operator=(S2 &s2) { return *this; }
};
class S3 {
int a;
public:
S3() : a(0) {}
S3 &operator=(S3 &s3) { return *this; }
};
class S4 {
int a;
S4();
S4 &operator=(const S4 &s4); // expected-note 3 {{implicitly declared private here}}
public:
S4(int v) : a(v) {}
};
class S5 {
int a;
S5() : a(0) {}
S5 &operator=(const S5 &s5) { return *this; } // expected-note 3 {{implicitly declared private here}}
public:
S5(int v) : a(v) {}
};
template <class T>
class ST {
public:
static T s;
};
S2 k;
S3 h;
S4 l(3);
S5 m(4);
#pragma omp threadprivate(h, k, l, m)
namespace A {
double x;
#pragma omp threadprivate(x)
}
namespace B {
using A::x;
}
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 copyin // expected-error {{expected '(' after 'copyin'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin( // expected-error {{expected expression}} 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 copyin() // expected-error {{expected expression}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(k // 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 copyin(h, // expected-error {{expected expression}} 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 copyin(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(l) // expected-error 2 {{'operator=' is a private member of 'S4'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(S1) // expected-error {{'S1' does not refer to a value}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(argv[1]) // expected-error {{expected variable name}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(i) // expected-error {{copyin variable must be threadprivate}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(m) // expected-error 2 {{'operator=' is a private member of 'S5'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(ST<int>::s, B::x) // expected-error {{copyin variable must be threadprivate}}
for (i = 0; i < argc; ++i)
foo();
}
int main(int argc, char **argv) {
int i;
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin // expected-error {{expected '(' after 'copyin'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin( // expected-error {{expected expression}} 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 copyin() // expected-error {{expected expression}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(k // 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 copyin(h, // expected-error {{expected expression}} 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 copyin(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(l) // expected-error {{'operator=' is a private member of 'S4'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(S1) // expected-error {{'S1' does not refer to a value}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(argv[1]) // expected-error {{expected variable name}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(i) // expected-error {{copyin variable must be threadprivate}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(m) // expected-error {{'operator=' is a private member of 'S5'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for copyin(ST<int>::s, B::x) // expected-error {{copyin variable must be threadprivate}}
for (i = 0; i < argc; ++i)
foo();
return tmain<int, char, 3>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 3>' requested here}}
}