Set num_threads to 50 on 32-bit hppa in two libgomp loop tests
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / acc_prof-dispatch-1.c
blobd929bfd80a4fb380b9489e79e68c328a4349c859
1 /* Test dispatch of events to callbacks. */
3 #undef NDEBUG
4 #include <assert.h>
6 #include <acc_prof.h>
9 /* Use explicit 'copyin' clauses, to work around "'firstprivate'
10 optimizations", which will cause the value at the point of call to be used
11 (*before* any potential modifications done in callbacks), as opposed to its
12 address being taken, which then later gets dereferenced (*after* any
13 modifications done in callbacks). */
14 #define COPYIN(...) copyin(__VA_ARGS__)
17 #define DEBUG_printf(...) //__builtin_printf (__VA_ARGS__)
20 static int state = -1;
22 #define STATE_OP(state, op) \
23 do \
24 { \
25 typeof (state) state_o = (state); \
26 (void) state_o; \
27 (state)op; \
28 DEBUG_printf("state: %d -> %d\n", state_o, (state)); \
29 } \
30 while (0)
33 static void cb_compute_construct_start_1 (acc_prof_info *prof_info, acc_event_info *event_info, acc_api_info *api_info)
35 DEBUG_printf ("%s\n", __FUNCTION__);
37 assert (state == 0
38 || state == 10
39 || state == 30
40 || state == 41
41 || state == 51
42 || state == 91
43 || state == 101
44 || state == 151);
45 STATE_OP (state, ++);
48 static void cb_compute_construct_start_2 (acc_prof_info *prof_info, acc_event_info *event_info, acc_api_info *api_info)
50 DEBUG_printf ("%s\n", __FUNCTION__);
52 assert (state == 1
53 || state == 11
54 || state == 40
55 || state == 50
56 || state == 90
57 || state == 100
58 || state == 150);
59 STATE_OP (state, ++);
62 static void cb_compute_construct_end_1 (acc_prof_info *prof_info, acc_event_info *event_info, acc_api_info *api_info)
64 DEBUG_printf ("%s\n", __FUNCTION__);
66 assert (state == 14
67 || state == 21
68 || state == 32
69 || state == 42
70 || state == 80
71 || state == 103
72 || state == 152);
73 STATE_OP (state, ++);
76 static void cb_compute_construct_end_2 (acc_prof_info *prof_info, acc_event_info *event_info, acc_api_info *api_info)
78 DEBUG_printf ("%s\n", __FUNCTION__);
80 assert (state == 13
81 || state == 43
82 || state == 102
83 || state == 154);
84 STATE_OP (state, ++);
87 static void cb_compute_construct_end_3 (acc_prof_info *prof_info, acc_event_info *event_info, acc_api_info *api_info)
89 DEBUG_printf ("%s\n", __FUNCTION__);
91 assert (state == 12
92 || state == 20
93 || state == 31
94 || state == 44
95 || state == 81
96 || state == 104
97 || state == 153);
98 STATE_OP (state, ++);
102 static acc_prof_reg reg;
103 static acc_prof_reg unreg;
104 static acc_prof_lookup_func lookup;
105 void acc_register_library (acc_prof_reg reg_, acc_prof_reg unreg_, acc_prof_lookup_func lookup_)
107 DEBUG_printf ("%s\n", __FUNCTION__);
109 reg = reg_;
110 unreg = unreg_;
111 lookup = lookup_;
115 int main()
117 acc_register_library (acc_prof_register, acc_prof_unregister, acc_prof_lookup);
119 STATE_OP (state, = 0);
120 reg (acc_ev_compute_construct_start, cb_compute_construct_start_1, acc_reg);
121 reg (acc_ev_compute_construct_start, cb_compute_construct_start_1, acc_reg);
122 reg (acc_ev_compute_construct_start, cb_compute_construct_start_2, acc_reg);
124 int state_init;
125 #pragma acc parallel COPYIN(state) copyout(state_init)
127 state_init = state;
129 assert (state_init == 2);
131 assert (state == 2);
133 STATE_OP (state, = 10);
134 reg (acc_ev_compute_construct_end, cb_compute_construct_end_1, acc_reg);
135 reg (acc_ev_compute_construct_end, cb_compute_construct_end_2, acc_reg);
136 reg (acc_ev_compute_construct_end, cb_compute_construct_end_3, acc_reg);
137 reg (acc_ev_compute_construct_end, cb_compute_construct_end_2, acc_reg);
138 reg (acc_ev_compute_construct_end, cb_compute_construct_end_3, acc_reg);
139 reg (acc_ev_compute_construct_end, cb_compute_construct_end_3, acc_reg);
141 int state_init;
142 #pragma acc parallel COPYIN(state) copyout(state_init)
144 state_init = state;
146 assert (state_init == 12);
148 assert (state == 15);
150 STATE_OP (state, = 20);
151 unreg (acc_ev_compute_construct_start, cb_compute_construct_start_1, acc_toggle);
152 unreg (acc_ev_compute_construct_start, cb_compute_construct_start_2, acc_toggle);
153 unreg (acc_ev_compute_construct_start, cb_compute_construct_start_1, acc_reg);
154 unreg (acc_ev_compute_construct_start, cb_compute_construct_start_2, acc_reg);
155 unreg (acc_ev_compute_construct_end, cb_compute_construct_end_1, acc_toggle);
156 unreg (acc_ev_compute_construct_end, cb_compute_construct_end_2, acc_toggle);
157 unreg (acc_ev_compute_construct_end, cb_compute_construct_end_3, acc_toggle);
158 unreg (acc_ev_compute_construct_end, cb_compute_construct_end_2, acc_reg);
159 unreg (acc_ev_compute_construct_end, cb_compute_construct_end_2, acc_reg);
160 unreg (acc_ev_compute_construct_end, cb_compute_construct_end_2, acc_toggle);
161 reg (acc_ev_compute_construct_end, cb_compute_construct_end_2, acc_toggle);
163 int state_init;
164 #pragma acc parallel COPYIN(state) copyout(state_init)
166 state_init = state;
168 assert (state_init == 20);
170 assert (state == 20);
172 STATE_OP (state, = 30);
173 reg (acc_ev_compute_construct_start, cb_compute_construct_start_1, acc_toggle);
174 reg (acc_ev_compute_construct_start, cb_compute_construct_start_2, acc_toggle);
175 reg (acc_ev_compute_construct_end, cb_compute_construct_end_1, acc_toggle);
176 reg (acc_ev_compute_construct_end, cb_compute_construct_end_2, acc_toggle);
177 reg (acc_ev_compute_construct_end, cb_compute_construct_end_3, acc_toggle);
179 int state_init;
180 #pragma acc parallel COPYIN(state) copyout(state_init)
182 state_init = state;
184 assert (state_init == 31);
186 assert (state == 33);
188 STATE_OP (state, = 40);
189 reg (acc_ev_compute_construct_start, cb_compute_construct_start_2, acc_reg);
190 unreg (acc_ev_compute_construct_start, cb_compute_construct_start_1, acc_reg);
191 reg (acc_ev_compute_construct_start, cb_compute_construct_start_1, acc_reg);
192 unreg (acc_ev_compute_construct_end, cb_compute_construct_end_3, acc_reg);
193 unreg (acc_ev_compute_construct_end, cb_compute_construct_end_3, acc_reg);
194 reg (acc_ev_compute_construct_end, cb_compute_construct_end_2, acc_reg);
195 unreg (acc_ev_compute_construct_end, cb_compute_construct_end_1, acc_reg);
196 reg (acc_ev_compute_construct_end, cb_compute_construct_end_1, acc_reg);
198 int state_init;
199 #pragma acc parallel COPYIN(state) copyout(state_init)
201 state_init = state;
203 assert (state_init == 42);
205 assert (state == 45);
207 STATE_OP (state, = 50);
208 unreg (acc_ev_compute_construct_end, NULL, acc_toggle);
210 int state_init;
211 #pragma acc parallel COPYIN(state) copyout(state_init)
213 state_init = state;
215 assert (state_init == 52);
217 assert (state == 52);
219 STATE_OP (state, = 60);
220 unreg (acc_ev_compute_construct_end, NULL, acc_toggle);
221 unreg (/* TODO */ (acc_event_t) 0, NULL, acc_toggle_per_thread);
222 unreg (/* TODO */ (acc_event_t) 0, NULL, acc_toggle_per_thread);
224 int state_init;
225 #pragma acc parallel COPYIN(state) copyout(state_init)
227 state_init = state;
229 assert (state_init == 60);
231 assert (state == 60);
233 STATE_OP (state, = 70);
234 unreg (acc_ev_compute_construct_start, NULL, acc_toggle);
235 reg (/* TODO */ (acc_event_t) 0, NULL, acc_toggle_per_thread);
237 int state_init;
238 #pragma acc parallel COPYIN(state) copyout(state_init)
240 state_init = state;
242 assert (state_init == 70);
244 assert (state == 70);
246 STATE_OP (state, = 80);
247 unreg (acc_ev_compute_construct_end, cb_compute_construct_end_2, acc_reg);
248 reg (acc_ev_compute_construct_end, NULL, acc_toggle);
249 reg (/* TODO */ (acc_event_t) 0, NULL, acc_toggle_per_thread);
251 int state_init;
252 #pragma acc parallel COPYIN(state) copyout(state_init)
254 state_init = state;
256 assert (state_init == 80);
258 assert (state == 82);
260 STATE_OP (state, = 90);
261 reg (acc_ev_compute_construct_start, NULL, acc_toggle);
262 unreg (acc_ev_compute_construct_end, NULL, acc_toggle);
263 reg (acc_ev_compute_construct_end, cb_compute_construct_end_2, acc_reg);
265 int state_init;
266 #pragma acc parallel COPYIN(state) copyout(state_init)
268 state_init = state;
270 assert (state_init == 92);
272 assert (state == 92);
274 STATE_OP (state, = 100);
275 reg (acc_ev_compute_construct_end, NULL, acc_toggle);
277 int state_init;
278 #pragma acc parallel COPYIN(state) copyout(state_init)
280 state_init = state;
282 assert (state_init == 102);
284 assert (state == 105);
286 STATE_OP (state, = 110);
287 unreg (/* TODO */ (acc_event_t) 0, NULL, acc_toggle);
288 unreg (/* TODO */ (acc_event_t) 0, NULL, acc_toggle);
290 int state_init;
291 #pragma acc parallel COPYIN(state) copyout(state_init)
293 state_init = state;
295 assert (state_init == 110);
297 assert (state == 110);
299 STATE_OP (state, = 120);
300 unreg (/* TODO */ (acc_event_t) 0, NULL, acc_toggle_per_thread);
302 int state_init;
303 #pragma acc parallel COPYIN(state) copyout(state_init)
305 state_init = state;
307 assert (state_init == 120);
309 assert (state == 120);
311 STATE_OP (state, = 130);
312 unreg (acc_ev_compute_construct_end, cb_compute_construct_end_3, acc_reg);
313 reg (acc_ev_compute_construct_end, cb_compute_construct_end_3, acc_reg);
314 reg (/* TODO */ (acc_event_t) 0, NULL, acc_toggle);
316 int state_init;
317 #pragma acc parallel COPYIN(state) copyout(state_init)
319 state_init = state;
321 assert (state_init == 130);
323 assert (state == 130);
325 STATE_OP (state, = 140);
326 unreg (acc_ev_compute_construct_start, cb_compute_construct_start_1, acc_reg);
327 reg (acc_ev_compute_construct_start, cb_compute_construct_start_1, acc_reg);
328 unreg (acc_ev_compute_construct_end, cb_compute_construct_end_1, acc_reg);
329 reg (acc_ev_compute_construct_end, cb_compute_construct_end_1, acc_reg);
331 int state_init;
332 #pragma acc parallel COPYIN(state) copyout(state_init)
334 state_init = state;
336 assert (state_init == 140);
338 assert (state == 140);
340 STATE_OP (state, = 150);
341 reg (/* TODO */ (acc_event_t) 0, NULL, acc_toggle_per_thread);
343 int state_init;
344 #pragma acc parallel COPYIN(state) copyout(state_init)
346 state_init = state;
348 assert (state_init == 152);
350 assert (state == 155);
352 return 0;