Fix gcc.c-torture/execute/ieee/cdivchkf.c on hpux
[official-gcc.git] / libgomp / testsuite / libgomp.fortran / task-detach-10.f90
blob61f0ea8ba0aa1802b6ae2bfa5b1f749799f107b7
1 ! { dg-do run }
3 ! Test tasks with detach clause on an offload device. Each device
4 ! thread spawns off a chain of tasks in a taskgroup, that can then
5 ! be executed by any available thread.
7 program task_detach_10
8 use omp_lib
10 integer (kind=omp_event_handle_kind) :: detach_event1, detach_event2
11 integer :: x = 0, y = 0, z = 0
12 integer :: thread_count
14 !$omp target map (tofrom: x, y, z) map (from: thread_count)
15 !$omp parallel private (detach_event1, detach_event2)
16 !$omp taskgroup
17 !$omp single
18 thread_count = omp_get_num_threads ()
19 !$omp end single
21 !$omp task detach (detach_event1) untied
22 !$omp atomic update
23 x = x + 1
24 !$omp end task
26 !$omp task detach (detach_event2) untied
27 !$omp atomic update
28 y = y + 1
29 call omp_fulfill_event (detach_event1)
30 !$omp end task
32 !$omp task untied
33 !$omp atomic update
34 z = z + 1
35 call omp_fulfill_event (detach_event2)
36 !$omp end task
37 !$omp end taskgroup
38 !$omp end parallel
39 !$omp end target
41 if (x /= thread_count) stop 1
42 if (y /= thread_count) stop 2
43 if (z /= thread_count) stop 3
44 end program