[OPENMP 4.5] Allow 'ordered' clause on 'loop simd' constructs.

OpenMP 4.5 allows to use 'ordered' clause without parameter on 'loop simd' constructs.

llvm-svn: 256639
This commit is contained in:
Alexey Bataev 2015-12-30 12:06:23 +00:00
parent 57286644f7
commit 113438cd5c
10 changed files with 61 additions and 12 deletions

View File

@ -7969,6 +7969,8 @@ def err_omp_schedule_nonmonotonic_static : Error<
"'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind">;
def err_omp_schedule_nonmonotonic_ordered : Error<
"'schedule' clause with 'nonmonotonic' modifier cannot be specified if an 'ordered' clause is specified">;
def err_omp_ordered_simd : Error<
"'ordered' clause with a parameter can not be specified in '#pragma omp %0' directive">;
} // end of OpenMP category
let CategoryName = "Related Result Type Issue" in {

View File

@ -220,6 +220,7 @@ OPENMP_FOR_SIMD_CLAUSE(safelen)
OPENMP_FOR_SIMD_CLAUSE(simdlen)
OPENMP_FOR_SIMD_CLAUSE(linear)
OPENMP_FOR_SIMD_CLAUSE(aligned)
OPENMP_FOR_SIMD_CLAUSE(ordered)
// Clauses allowed for OpenMP directive 'omp sections'.
OPENMP_SECTIONS_CLAUSE(private)
@ -303,6 +304,7 @@ OPENMP_PARALLEL_FOR_SIMD_CLAUSE(safelen)
OPENMP_PARALLEL_FOR_SIMD_CLAUSE(simdlen)
OPENMP_PARALLEL_FOR_SIMD_CLAUSE(linear)
OPENMP_PARALLEL_FOR_SIMD_CLAUSE(aligned)
OPENMP_PARALLEL_FOR_SIMD_CLAUSE(ordered)
// Clauses allowed for OpenMP directive 'parallel sections'.
OPENMP_PARALLEL_SECTIONS_CLAUSE(if)

View File

@ -1680,6 +1680,13 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S,
}
ErrorFound = true;
}
if (isOpenMPWorksharingDirective(DSAStack->getCurrentDirective()) &&
isOpenMPSimdDirective(DSAStack->getCurrentDirective()) && OC &&
OC->getNumForLoops()) {
Diag(OC->getLocStart(), diag::err_omp_ordered_simd)
<< getOpenMPDirectiveName(DSAStack->getCurrentDirective());
ErrorFound = true;
}
if (ErrorFound) {
ActOnCapturedRegionError();
return StmtError();

View File

@ -14,8 +14,8 @@ template<class T, class N> T reduct(T* arr, N num) {
N myind;
T sum = (T)0;
// CHECK: T sum = (T)0;
#pragma omp for simd private(myind, g_ind), linear(ind), aligned(arr)
// CHECK-NEXT: #pragma omp for simd private(myind,g_ind) linear(ind) aligned(arr)
#pragma omp for simd private(myind, g_ind), linear(ind), aligned(arr) ordered
// CHECK-NEXT: #pragma omp for simd private(myind,g_ind) linear(ind) aligned(arr) ordered
for (i = 0; i < num; ++i) {
myind = ind;
T cur = arr[myind];
@ -92,8 +92,8 @@ int main (int argc, char **argv) {
int k1=0,k2=0;
static int *a;
// CHECK: static int *a;
#pragma omp for simd
// CHECK-NEXT: #pragma omp for simd
#pragma omp for simd ordered
// CHECK-NEXT: #pragma omp for simd ordered
for (int i=0; i < 2; ++i)*a=2;
// CHECK-NEXT: for (int i = 0; i < 2; ++i)
// CHECK-NEXT: *a = 2;

View File

@ -719,10 +719,18 @@ void test_loop_firstprivate_lastprivate() {
void test_ordered() {
#pragma omp parallel
// expected-error@+1 2 {{unexpected OpenMP clause 'ordered' in directive '#pragma omp for simd'}}
#pragma omp for simd ordered ordered // expected-error {{directive '#pragma omp for simd' cannot contain more than one 'ordered' clause}}
for (int i = 0; i < 16; ++i)
;
#pragma omp parallel
#pragma omp for simd ordered
for (int i = 0; i < 16; ++i)
;
#pragma omp parallel
// expected-error@+1 {{'ordered' clause with a parameter can not be specified in '#pragma omp for simd' directive}}
#pragma omp for simd ordered(1)
for (int i = 0; i < 16; ++i)
;
}
void test_nowait() {

View File

@ -2060,7 +2060,7 @@ void foo() {
}
#pragma omp ordered
{
#pragma omp parallel for simd ordered //expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp parallel for simd'}}
#pragma omp parallel for simd ordered
for (int j = 0; j < 10; ++j) {
#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
{
@ -2070,6 +2070,16 @@ void foo() {
}
#pragma omp ordered
{
#pragma omp parallel for simd ordered
for (int j = 0; j < 10; ++j) {
#pragma omp ordered simd
{
bar();
}
}
}
#pragma omp ordered
{
#pragma omp parallel for
for (int i = 0; i < 10; ++i)
;

View File

@ -221,6 +221,14 @@ void foo_simd(int low, int up) {
#pragma omp simd
for (int i = low; i < up; ++i) {
f[i] = 0.0;
#pragma omp ordered simd
f[i] = 1.0;
}
// CHECK: store float 0.000000e+00, float* %{{.+}}, align {{[0-9]+}}, !llvm.mem.parallel_loop_access !
// CHECK-NEXT: call void [[CAP_FUNC:@.+]](i32* %{{.+}}) #{{[0-9]+}}, !llvm.mem.parallel_loop_access !
#pragma omp for simd ordered
for (int i = low; i < up; ++i) {
f[i] = 0.0;
#pragma omp ordered simd
f[i] = 1.0;
}

View File

@ -44,8 +44,8 @@ template<class T> struct S {
}
const T clen = 3;
// CHECK: T clen = 3;
#pragma omp parallel for simd safelen(clen-1) simdlen(clen-1)
// CHECK-NEXT: #pragma omp parallel for simd safelen(clen - 1) simdlen(clen - 1)
#pragma omp parallel for simd safelen(clen-1) simdlen(clen-1) ordered
// CHECK-NEXT: #pragma omp parallel for simd safelen(clen - 1) simdlen(clen - 1) ordered
for(T i = clen+2; i < 20; ++i) {
// CHECK-NEXT: for (T i = clen + 2; i < 20; ++i) {
v[i] = v[v-clen] + 1;
@ -92,8 +92,8 @@ int main (int argc, char **argv) {
int k1=0,k2=0;
static int *a;
// CHECK: static int *a;
#pragma omp parallel for simd if(parallel :b)
// CHECK-NEXT: #pragma omp parallel for simd if(parallel: b)
#pragma omp parallel for simd if(parallel :b) ordered
// CHECK-NEXT: #pragma omp parallel for simd if(parallel: b) ordered
for (int i=0; i < 2; ++i)*a=2;
// CHECK-NEXT: for (int i = 0; i < 2; ++i)
// CHECK-NEXT: *a = 2;

View File

@ -628,10 +628,16 @@ void test_loop_firstprivate_lastprivate() {
}
void test_ordered() {
// expected-error@+1 2 {{unexpected OpenMP clause 'ordered' in directive '#pragma omp parallel for simd'}}
#pragma omp parallel for simd ordered ordered // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'ordered' clause}}
for (int i = 0; i < 16; ++i)
;
#pragma omp parallel for simd ordered
for (int i = 0; i < 16; ++i)
;
//expected-error@+1 {{'ordered' clause with a parameter can not be specified in '#pragma omp parallel for simd' directive}}
#pragma omp parallel for simd ordered(1)
for (int i = 0; i < 16; ++i)
;
}
void test_nowait() {

View File

@ -79,9 +79,15 @@ L1:
}
void test_ordered() {
// expected-error@+1 2 {{unexpected OpenMP clause 'ordered' in directive '#pragma omp parallel for simd'}}
#pragma omp parallel for simd ordered ordered // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'ordered' clause}}
for (int i = 0; i < 16; ++i)
;
#pragma omp parallel for simd ordered
for (int i = 0; i < 16; ++i)
;
// expected-error@+1 {{'ordered' clause with a parameter can not be specified in '#pragma omp parallel for simd' directive}}
#pragma omp parallel for simd ordered(1)
for (int i = 0; i < 16; ++i)
;
}