Debian Codegraph @

libgomp/testsuite/libgomp.fortran/task-detach-6.f90

raw
1 ! { dg-do run }
2
3 ! Test tasks with detach clause on an offload device. Each device
4 ! thread spawns off a chain of tasks, that can then be executed by
5 ! any available thread.
6
7 program task_detach_6
8 use omp_lib
9
10 integer (kind=omp_event_handle_kind) :: detach_event1, detach_event2
11 integer :: x = 0, y = 0, z = 0
12 integer :: thread_count
13
14 !$omp target map (tofrom: x, y, z) map (from: thread_count)
15 !$omp parallel private (detach_event1, detach_event2)
16 !$omp single
17 thread_count = omp_get_num_threads ()
18 !$omp end single
19
20 !$omp task detach (detach_event1) untied
21 !$omp atomic update
22 x = x + 1
23 !$omp end task
24
25 !$omp task detach (detach_event2) untied
26 !$omp atomic update
27 y = y + 1
28 call omp_fulfill_event (detach_event1)
29 !$omp end task
30
31 !$omp task untied
32 !$omp atomic update
33 z = z + 1
34 call omp_fulfill_event (detach_event2)
35 !$omp end task
36 !$omp end parallel
37 !$omp end target
38
39 if (x /= thread_count) stop 1
40 if (y /= thread_count) stop 2
41 if (z /= thread_count) stop 3
42 end program