[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / loop_bind_messages.cpp
blobbecd1f40c0c0474ca1ea014af38cfe7280334024
1 #ifndef HEADER
2 #define HEADER
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -verify %s
5 #define NNN 50
6 int aaa[NNN];
7 int aaa2[NNN][NNN];
9 void parallel_loop() {
10 #pragma omp parallel
12 #pragma omp loop
13 for (int j = 0 ; j < NNN ; j++) {
14 aaa[j] = j*NNN;
18 #pragma omp parallel for
19 for (int i = 0 ; i < NNN ; i++) {
20 #pragma omp loop bind(parallel) // expected-error{{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp loop' directive into a parallel region?}}
21 for (int j = 0 ; j < NNN ; j++) {
22 aaa2[i][j] = i+j;
26 #pragma omp parallel
27 #pragma omp for nowait
28 for (int i = 0 ; i < NNN ; i++) {
29 #pragma omp loop bind(parallel) // expected-error{{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp loop' directive into a parallel region?}}
30 for (int j = 0 ; j < NNN ; j++) {
31 aaa2[i][j] = i+j;
35 #pragma omp parallel for
36 for (int i = 0 ; i < NNN ; i++) {
37 #pragma omp nothing
38 #pragma omp loop
39 for (int j = 0 ; j < NNN ; j++) {
40 aaa2[i][j] = i+j;
44 #pragma omp target teams distribute parallel for
45 for (int i = 0 ; i < NNN ; i++) {
46 #pragma omp loop bind(parallel) // expected-error{{region cannot be closely nested inside 'target teams distribute parallel for' region; perhaps you forget to enclose 'omp loop' directive into a parallel region?}}
47 for (int j = 0 ; j < NNN ; j++) {
48 aaa2[i][j] = i+j;
52 #pragma omp target parallel
53 for (int i = 0 ; i < NNN ; i++) {
54 #pragma omp loop bind(parallel)
55 for (int j = 0 ; j < NNN ; j++) {
56 aaa2[i][j] = i+j;
60 #pragma omp parallel for
61 for (int i = 0; i < 100; ++i) {
62 #pragma omp loop bind(parallel) // expected-error{{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp loop' directive into a parallel region?}}
63 for (int i = 0 ; i < NNN ; i++) {
64 #pragma omp loop bind(parallel) // expected-error{{region cannot be closely nested inside 'loop' region; perhaps you forget to enclose 'omp loop' directive into a parallel region?}}
65 for (int j = 0 ; j < NNN ; j++) {
66 aaa[j] = j*NNN;
71 #pragma omp parallel
73 #pragma omp sections
75 for (int i = 0 ; i < NNN ; i++) {
76 #pragma omp loop bind(parallel) // expected-error{{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp loop' directive into a parallel region?}}
77 for (int j = 0 ; j < NNN ; j++) {
78 aaa2[i][j] = i+j;
82 #pragma omp section
84 aaa[NNN-1] = NNN;
90 void teams_loop() {
91 int var1;
92 int total = 0;
94 #pragma omp teams
96 #pragma omp loop bind(teams)
97 for (int j = 0 ; j < NNN ; j++) {
98 aaa[j] = j*NNN;
101 #pragma omp loop bind(teams) collapse(2) private(var1)
102 for (int i = 0 ; i < 3 ; i++) {
103 for (int j = 0 ; j < NNN ; j++) {
104 var1 += aaa[j];
109 #pragma omp target teams
110 for (int i = 0 ; i < NNN ; i++) {
111 #pragma omp loop bind(teams)
112 for (int j = 0 ; j < NNN ; j++) {
113 aaa2[i][j] = i+j;
117 #pragma omp target teams distribute parallel for
118 for (int i = 0 ; i < NNN ; i++) {
119 #pragma omp loop bind(teams) // expected-error{{region cannot be closely nested inside 'target teams distribute parallel for' region; perhaps you forget to enclose 'omp loop' directive into a teams region?}}
120 for (int j = 0 ; j < NNN ; j++) {
121 aaa2[i][j] = i+j;
125 #pragma omp teams
127 #pragma omp loop bind(teams)
128 for (int j = 0 ; j < NNN ; j++) {
129 aaa[j] = j*NNN;
132 #pragma omp loop bind(teams) reduction(+:total) // expected-error{{'reduction' clause not allowed with '#pragma omp loop bind(teams)'}}
133 for (int j = 0 ; j < NNN ; j++) {
134 total+=aaa[j];
138 #pragma omp teams num_teams(8) thread_limit(256)
139 #pragma omp distribute parallel for dist_schedule(static, 1024) \
140 schedule(static, 64)
141 for (int i = 0; i < NNN; i++) {
142 #pragma omp loop bind(teams) // expected-error{{'distribute parallel for' region; perhaps you forget to enclose 'omp loop' directive into a teams region?}}
143 for (int j = 0; j < NNN; j++) {
144 aaa2[i][j] = i+j;
148 #pragma omp teams
149 for (int i = 0; i < NNN; i++) {
150 #pragma omp loop bind(thread)
151 for (int j = 0 ; j < NNN ; j++) {
152 aaa[i] = i+i*NNN;
156 #pragma omp teams loop
157 for (int i = 0; i < NNN; i++) {
158 #pragma omp loop
159 for (int j = 0 ; j < NNN ; j++) {
160 aaa[i] = i+i*NNN;
164 #pragma omp teams loop
165 for (int i = 0; i < NNN; i++) {
166 #pragma omp loop bind(teams) // expected-error{{region cannot be closely nested inside 'teams loop' region; perhaps you forget to enclose 'omp loop' directive into a teams region?}}
167 for (int j = 0 ; j < NNN ; j++) {
168 aaa[i] = i+i*NNN;
173 void thread_loop() {
174 #pragma omp parallel
175 for (int i = 0; i < NNN; i++) {
176 #pragma omp loop bind(thread)
177 for (int j = 0 ; j < NNN ; j++) {
178 aaa[i] = i+i*NNN;
182 #pragma omp teams
183 for (int i = 0; i < NNN; i++) {
184 #pragma omp loop bind(thread)
185 for (int j = 0 ; j < NNN ; j++) {
186 aaa[i] = i+i*NNN;
191 void parallel_for_with_loop_teams_bind(){
192 #pragma omp parallel for
193 for (int i = 0; i < NNN; i++) {
194 #pragma omp loop bind(teams) // expected-error{{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp loop' directive into a teams region?}}
195 for (int j = 0 ; j < NNN ; j++) {
196 aaa[i] = i+i*NNN;
201 void orphan_loops() {
202 #pragma omp loop // expected-error{{expected 'bind' clause for 'loop' construct without an enclosing OpenMP construct}}
203 for (int j = 0 ; j < NNN ; j++) {
204 aaa[j] = j*NNN;
207 #pragma omp loop bind(parallel)
208 for (int j = 0 ; j < NNN ; j++) {
209 aaa[j] = j*NNN;
212 #pragma omp loop bind(teams)
213 for (int i = 0; i < NNN; i++) {
214 aaa[i] = i+i*NNN;
217 #pragma omp loop bind(thread)
218 for (int i = 0; i < NNN; i++) {
219 aaa[i] = i+i*NNN;
223 int main(int argc, char *argv[]) {
224 parallel_loop();
225 teams_loop();
226 thread_loop();
227 parallel_for_with_loop_teams_bind();
228 orphan_loops();
231 #endif