Debian Codegraph @

libgomp/testsuite/libgomp.fortran/declare-target-indirect-2.f90

raw
1 ! { dg-do run }
2
3 module m
4 contains
5 integer function foo ()
6 !$omp declare target to (foo) indirect
7 foo = 5
8 end function
9
10 integer function bar ()
11 !$omp declare target to (bar) indirect
12 bar = 8
13 end function
14
15 integer function baz ()
16 !$omp declare target to (baz) indirect
17 baz = 11
18 end function
19 end module
20
21 program main
22 use m
23 implicit none
24
25 type fp
26 procedure (foo), pointer, nopass :: f => null ()
27 end type
28
29 integer, parameter :: N = 256
30 integer :: i, x = 0, expected = 0;
31 type (fp) :: fn_ptr (N)
32
33 do i = 1, N
34 select case (mod (i, 3))
35 case (0)
36 fn_ptr (i)%f => foo
37 case (1)
38 fn_ptr (i)%f => bar
39 case (2)
40 fn_ptr (i)%f => baz
41 end select
42 expected = expected + fn_ptr (i)%f ()
43 end do
44
45 !$omp target teams distribute parallel do &
46 !$omp & reduction(+: x) map (to: fn_ptr) map (tofrom: x)
47 do i = 1, N
48 x = x + fn_ptr (i)%f ()
49 end do
50 !$omp end target teams distribute parallel do
51
52 stop x - expected
53 end program