xfail scan-tree-dump-not throw in g++.dg/pr99966.C on hppa*64*-*-*
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / task-detach-10.c
blob10d6746f61a0ef128ab5c01e4135a57ec6747243
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 in a taskgroup, that can then
8 be executed by 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)
18 #pragma omp taskgroup
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);
42 assert (x == thread_count);
43 assert (y == thread_count);
44 assert (z == thread_count);