[OPENMP] Tests for nesting of regions for 'atomic' directive.

llvm-svn: 213648
This commit is contained in:
Alexey Bataev 2014-07-22 12:35:18 +00:00
parent 8ca8651171
commit 823d3c24d7
1 changed files with 340 additions and 4 deletions

View File

@ -4,6 +4,7 @@ void bar();
template <class T>
void foo() {
T a = T();
// PARALLEL DIRECTIVE
#pragma omp parallel
#pragma omp for
@ -76,6 +77,11 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp parallel
{
#pragma omp atomic
++a;
}
// SIMD DIRECTIVE
#pragma omp simd
@ -176,6 +182,11 @@ void foo() {
#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
bar();
}
#pragma omp simd
for (int i = 0; i < 10; ++i) {
#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
// FOR DIRECTIVE
#pragma omp for
@ -227,7 +238,7 @@ void foo() {
}
#pragma omp for
for (int i = 0; i < 10; ++i) {
#pragma omp critical
#pragma omp critical
{
bar();
}
@ -299,6 +310,11 @@ void foo() {
#pragma omp ordered // OK
bar();
}
#pragma omp for
for (int i = 0; i < 10; ++i) {
#pragma omp atomic
++a;
}
// SECTIONS DIRECTIVE
#pragma omp sections
@ -429,6 +445,11 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp sections
{
#pragma omp atomic
++a;
}
// SECTION DIRECTIVE
#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
@ -583,6 +604,12 @@ void foo() {
bar();
}
}
#pragma omp sections
{
#pragma omp section
#pragma omp atomic
++a;
}
// SINGLE DIRECTIVE
#pragma omp single
@ -693,6 +720,11 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp single
{
#pragma omp atomic
++a;
}
// MASTER DIRECTIVE
#pragma omp master
@ -803,6 +835,11 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp master
{
#pragma omp atomic
++a;
}
// CRITICAL DIRECTIVE
#pragma omp critical
@ -908,7 +945,7 @@ void foo() {
#pragma omp critical(grelka)
bar();
}
#pragma omp critical(Belka)// expected-note {{previous 'critical' region starts here}}
#pragma omp critical(Belka) // expected-note {{previous 'critical' region starts here}}
{
#pragma omp critical(Belka) // expected-error {{cannot nest 'critical' regions having the same name 'Belka'}}
{
@ -927,6 +964,11 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp critical
{
#pragma omp atomic
++a;
}
// PARALLEL FOR DIRECTIVE
#pragma omp parallel for
@ -1052,6 +1094,11 @@ void foo() {
#pragma omp ordered // OK
bar();
}
#pragma omp parallel for
for (int i = 0; i < 10; ++i) {
#pragma omp atomic
++a;
}
// PARALLEL SECTIONS DIRECTIVE
#pragma omp parallel sections
@ -1168,6 +1215,11 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp parallel sections
{
#pragma omp atomic
++a;
}
// TASK DIRECTIVE
#pragma omp task
@ -1237,6 +1289,11 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp task
{
#pragma omp atomic
++a;
}
// ORDERED DIRECTIVE
#pragma omp ordered
@ -1340,9 +1397,120 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp ordered
{
#pragma omp atomic
++a;
}
// ATOMIC DIRECTIVE
#pragma omp atomic
{
#pragma omp for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
for (int i = 0; i < 10; ++i)
;
}
#pragma omp atomic
{
#pragma omp simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
for (int i = 0; i < 10; ++i)
;
}
#pragma omp atomic
{
#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
for (int i = 0; i < 10; ++i)
;
}
#pragma omp atomic
{
#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp section // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp single // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp master // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
for (int i = 0; i < 10; ++i)
;
}
#pragma omp atomic
{
#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp task // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
bar();
}
#pragma omp atomic
{
#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
bar();
}
#pragma omp atomic
{
#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
bar();
}
#pragma omp atomic
{
#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
bar();
}
#pragma omp atomic
{
#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
bar();
}
#pragma omp atomic
{
#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
++a;
}
}
void foo() {
int a = 0;
// PARALLEL DIRECTIVE
#pragma omp parallel
#pragma omp for
@ -1415,6 +1583,11 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp parallel
{
#pragma omp atomic
++a;
}
// SIMD DIRECTIVE
#pragma omp simd
@ -1508,6 +1681,11 @@ void foo() {
#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
bar();
}
#pragma omp simd
for (int i = 0; i < 10; ++i) {
#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
// FOR DIRECTIVE
#pragma omp for
@ -1618,6 +1796,11 @@ void foo() {
#pragma omp ordered // OK
bar();
}
#pragma omp for
for (int i = 0; i < 10; ++i) {
#pragma omp atomic
++a;
}
// SECTIONS DIRECTIVE
#pragma omp sections
@ -1720,6 +1903,11 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp sections
{
#pragma omp atomic
++a;
}
// SECTION DIRECTIVE
#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
@ -1874,6 +2062,14 @@ void foo() {
bar();
}
}
#pragma omp sections
{
#pragma omp section
{
#pragma omp atomic
++a;
}
}
// SINGLE DIRECTIVE
#pragma omp single
@ -1974,6 +2170,11 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp single
{
#pragma omp atomic
++a;
}
// MASTER DIRECTIVE
#pragma omp master
@ -2084,6 +2285,11 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp master
{
#pragma omp atomic
++a;
}
// CRITICAL DIRECTIVE
#pragma omp critical
@ -2189,7 +2395,7 @@ void foo() {
#pragma omp critical(Strelka)
bar();
}
#pragma omp critical(Tuzik)// expected-note {{previous 'critical' region starts here}}
#pragma omp critical(Tuzik) // expected-note {{previous 'critical' region starts here}}
{
#pragma omp critical(grelka) // expected-note {{previous 'critical' region starts here}}
{
@ -2205,9 +2411,19 @@ void foo() {
}
#pragma omp critical
{
#pragma omp flush
bar();
}
#pragma omp critical
{
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp critical
{
#pragma omp atomic
++a;
}
// PARALLEL FOR DIRECTIVE
#pragma omp parallel for
@ -2329,9 +2545,14 @@ void foo() {
}
#pragma omp parallel for ordered
for (int i = 0; i < 10; ++i) {
#pragma omp ordered // OK
#pragma omp ordered // OK
bar();
}
#pragma omp parallel for
for (int i = 0; i < 10; ++i) {
#pragma omp atomic
++a;
}
// PARALLEL SECTIONS DIRECTIVE
#pragma omp parallel sections
@ -2444,6 +2665,11 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp parallel sections
{
#pragma omp atomic
++a;
}
// TASK DIRECTIVE
#pragma omp task
@ -2512,6 +2738,116 @@ void foo() {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
#pragma omp task
{
#pragma omp atomic
++a;
}
// ATOMIC DIRECTIVE
#pragma omp atomic
{
#pragma omp for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
for (int i = 0; i < 10; ++i)
;
}
#pragma omp atomic
{
#pragma omp simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
for (int i = 0; i < 10; ++i)
;
}
#pragma omp atomic
{
#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
for (int i = 0; i < 10; ++i)
;
}
#pragma omp atomic
{
#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp section // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp single // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp master // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
for (int i = 0; i < 10; ++i)
;
}
#pragma omp atomic
{
#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp task // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
}
}
#pragma omp atomic
{
#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
bar();
}
#pragma omp atomic
{
#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
bar();
}
#pragma omp atomic
{
#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
bar();
}
#pragma omp atomic
{
#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
bar();
}
#pragma omp atomic
{
#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
bar();
}
#pragma omp atomic
{
#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
++a;
}
return foo<int>();
}