Skip gnat.dg/prot7.adb on hppa.
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / task-detach-6.c
blobe5c2291e6ff0c0070d874cd593143ef65076e9e6
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. */
10 int main (void)
12 int x = 0, y = 0, z = 0;
13 int thread_count;
14 omp_event_handle_t detach_event1, detach_event2;
16 #pragma omp target map (tofrom: x, y, z) map (from: thread_count)
17 #pragma omp parallel private (detach_event1, detach_event2)
19 #pragma omp single
20 thread_count = omp_get_num_threads ();
22 #pragma omp task detach(detach_event1) untied
23 #pragma omp atomic update
24 x++;
26 #pragma omp task detach(detach_event2) untied
28 #pragma omp atomic update
29 y++;
30 omp_fulfill_event (detach_event1);
33 #pragma omp task untied
35 #pragma omp atomic update
36 z++;
37 omp_fulfill_event (detach_event2);
41 assert (x == thread_count);
42 assert (y == thread_count);
43 assert (z == thread_count);