Skip various cmp-mem-const tests on lp64 hppa*-*-*
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / task-detach-9.c
blob5316ca545b528045b20f661df21571830c0dcbc0
1 /* { dg-do run } */
3 #include <omp.h>
4 #include <assert.h>
6 /* Test tasks with detach clause. Each thread spawns off a chain of tasks
7 in a taskgroup, that can then be executed by any available thread. */
9 int main (void)
11 int x = 0, y = 0, z = 0;
12 int thread_count;
13 omp_event_handle_t detach_event1, detach_event2;
15 #pragma omp parallel private (detach_event1, detach_event2)
16 #pragma omp taskgroup
18 #pragma omp single
19 thread_count = omp_get_num_threads ();
21 #pragma omp task detach (detach_event1) untied
22 #pragma omp atomic update
23 x++;
25 #pragma omp task detach (detach_event2) untied
27 #pragma omp atomic update
28 y++;
29 omp_fulfill_event (detach_event1);
32 #pragma omp task untied
34 #pragma omp atomic update
35 z++;
36 omp_fulfill_event (detach_event2);
40 assert (x == thread_count);
41 assert (y == thread_count);
42 assert (z == thread_count);