Set num_threads to 50 on 32-bit hppa in two libgomp loop tests
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / task-detach-8.c
blob6f77f1263ab9c5a86e4a4e00f4049b7e1eea08ac
1 /* { dg-do run } */
3 #include <omp.h>
4 #include <assert.h>
6 /* Test tasks with detach clause on an offload device. Each device
7 thread spawns off a chain of tasks, that can then be executed by
8 any available thread. Each thread uses taskwait to wait for the
9 child tasks to complete. */
11 int main (void)
13 int x = 0, y = 0, z = 0;
14 int thread_count;
15 omp_event_handle_t detach_event1, detach_event2;
17 #pragma omp target map (tofrom: x, y, z) map (from: thread_count)
18 #pragma omp parallel private (detach_event1, detach_event2)
20 #pragma omp single
21 thread_count = omp_get_num_threads ();
23 #pragma omp task detach (detach_event1) untied
24 #pragma omp atomic update
25 x++;
27 #pragma omp task detach (detach_event2) untied
29 #pragma omp atomic update
30 y++;
31 omp_fulfill_event (detach_event1);
34 #pragma omp task untied
36 #pragma omp atomic update
37 z++;
38 omp_fulfill_event (detach_event2);
41 #pragma omp taskwait
44 assert (x == thread_count);
45 assert (y == thread_count);
46 assert (z == thread_count);