Debian Codegraph @

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

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