| 1 |
// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -std=c++11 -ferror-limit 200 -o - %s |
| 2 |
// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -std=c++11 -ferror-limit 200 -o - %s |
| 3 |
// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp -fopenmp-version=51 -std=c++11 -ferror-limit 200 -o - %s |
| 4 |
// RUN: %clang_cc1 -verify=expected -DOMP60 -fopenmp -fopenmp-version=60 -std=c++11 -ferror-limit 200 -o - %s |
| 5 |
|
| 6 |
// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -std=c++11 -ferror-limit 200 -o - %s |
| 7 |
// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 -std=c++11 -ferror-limit 200 -o - %s |
| 8 |
// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-simd -fopenmp-version=51 -std=c++11 -ferror-limit 200 -o - %s |
| 9 |
// RUN: %clang_cc1 -verify=expected -DOMP60 -fopenmp-simd -fopenmp-version=60 -std=c++11 -ferror-limit 200 -o - %s |
| 10 |
|
| 11 |
#ifdef OMP60 |
| 12 |
struct ComplexStruct { |
| 13 |
int data[10]; |
| 14 |
struct InnerStruct { |
| 15 |
float value; |
| 16 |
} inner; |
| 17 |
}; |
| 18 |
|
| 19 |
// Template class with member functions using 'threadset'. |
| 20 |
template <typename T> |
| 21 |
class TemplateClass { |
| 22 |
public: |
| 23 |
void foo() { |
| 24 |
#pragma omp task threadset(omp_pool) |
| 25 |
{ |
| 26 |
T temp; |
| 27 |
} |
| 28 |
} |
| 29 |
void bar() { |
| 30 |
#pragma omp taskloop threadset(omp_team) |
| 31 |
for (int i = 0; i < 10; ++i) {} |
| 32 |
} |
| 33 |
}; |
| 34 |
|
| 35 |
// Valid uses of 'threadset' with 'omp_pool' and 'omp_team' in task directive. |
| 36 |
void test_task_threadset_valid() { |
| 37 |
int a; |
| 38 |
#pragma omp task threadset(omp_pool) |
| 39 |
#pragma omp task threadset(omp_team) |
| 40 |
#pragma omp task threadset(omp_pool) if(1) |
| 41 |
#pragma omp task threadset(omp_team) priority(5) |
| 42 |
#pragma omp task threadset(omp_pool) depend(out: a) |
| 43 |
#pragma omp parallel |
| 44 |
{ |
| 45 |
#pragma omp task threadset(omp_pool) |
| 46 |
{ |
| 47 |
#pragma omp taskloop threadset(omp_team) |
| 48 |
for (int i = 0; i < 5; ++i) {} |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
TemplateClass<int> obj; |
| 53 |
obj.foo(); |
| 54 |
obj.bar(); |
| 55 |
} |
| 56 |
|
| 57 |
// Invalid uses of 'threadset' with incorrect arguments in task directive. |
| 58 |
void test_task_threadset_invalid_args() { |
| 59 |
#pragma omp task threadset(invalid_arg) // expected-error {{expected 'omp_pool' or 'omp_team' in OpenMP clause 'threadset'}} |
| 60 |
#pragma omp task threadset(123) // expected-error {{expected 'omp_pool' or 'omp_team' in OpenMP clause 'threadset'}} |
| 61 |
#pragma omp task threadset(omp_pool, omp_team) // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 62 |
#pragma omp task threadset() // expected-error {{expected 'omp_pool' or 'omp_team' in OpenMP clause 'threadset'}} |
| 63 |
{} |
| 64 |
} |
| 65 |
|
| 66 |
// Valid uses of 'threadset' with 'omp_pool' and 'omp_team' in taskloop directive. |
| 67 |
void test_taskloop_threadset_valid() { |
| 68 |
#pragma omp taskloop threadset(omp_pool) |
| 69 |
for (int i = 0; i < 10; ++i) {} |
| 70 |
#pragma omp taskloop threadset(omp_team) |
| 71 |
for (int i = 0; i < 10; ++i) {} |
| 72 |
#pragma omp taskloop threadset(omp_pool) grainsize(5) |
| 73 |
for (int i = 0; i < 10; ++i) {} |
| 74 |
#pragma omp taskloop threadset(omp_team) num_tasks(2) |
| 75 |
for (int i = 0; i < 10; ++i) {} |
| 76 |
} |
| 77 |
|
| 78 |
// Invalid uses of 'threadset' with incorrect arguments in taskloop directive. |
| 79 |
void test_taskloop_threadset_invalid_args() { |
| 80 |
#pragma omp taskloop threadset(invalid_arg) // expected-error {{expected 'omp_pool' or 'omp_team' in OpenMP clause 'threadset'}} |
| 81 |
for (int i = 0; i < 10; ++i) {} |
| 82 |
#pragma omp taskloop threadset(123) // expected-error {{expected 'omp_pool' or 'omp_team' in OpenMP clause 'threadset'}} |
| 83 |
for (int i = 0; i < 10; ++i) {} |
| 84 |
#pragma omp taskloop threadset(omp_pool, omp_team) // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 85 |
for (int i = 0; i < 10; ++i) {} |
| 86 |
#pragma omp taskloop threadset() // expected-error {{expected 'omp_pool' or 'omp_team' in OpenMP clause 'threadset'}} |
| 87 |
for (int i = 0; i < 10; ++i) {} |
| 88 |
} |
| 89 |
|
| 90 |
#else |
| 91 |
void test_threadset_not_supported() { |
| 92 |
#pragma omp task threadset(omp_pool) // omp45-error {{unexpected OpenMP clause 'threadset' in directive '#pragma omp task'}} omp50-error {{unexpected OpenMP clause 'threadset' in directive '#pragma omp task'}} omp51-error {{unexpected OpenMP clause 'threadset' in directive '#pragma omp task'}} |
| 93 |
#pragma omp task threadset(omp_team) // omp45-error {{unexpected OpenMP clause 'threadset' in directive '#pragma omp task'}} omp50-error {{unexpected OpenMP clause 'threadset' in directive '#pragma omp task'}} omp51-error {{unexpected OpenMP clause 'threadset' in directive '#pragma omp task'}} |
| 94 |
#pragma omp taskloop threadset(omp_team) // omp45-error {{unexpected OpenMP clause 'threadset' in directive '#pragma omp taskloop'}} omp50-error {{unexpected OpenMP clause 'threadset' in directive '#pragma omp taskloop'}} omp51-error {{unexpected OpenMP clause 'threadset' in directive '#pragma omp taskloop'}} |
| 95 |
for (int i = 0; i < 10; ++i) {} |
| 96 |
#pragma omp taskloop threadset(omp_pool) // omp45-error {{unexpected OpenMP clause 'threadset' in directive '#pragma omp taskloop'}} omp50-error {{unexpected OpenMP clause 'threadset' in directive '#pragma omp taskloop'}} omp51-error {{unexpected OpenMP clause 'threadset' in directive '#pragma omp taskloop'}} |
| 97 |
for (int i = 0; i < 10; ++i) {} |
| 98 |
} |
| 99 |
#endif |