Debian Codegraph @

libgomp/testsuite/libgomp.fortran/self_maps.f90

raw
1 ! Basic test whether self_maps work
2
3 module m
4 !$omp requires self_maps
5 implicit none (type, external)
6 type t
7 integer :: val
8 type(t), pointer :: next
9 end type t
10 contains
11 subroutine init(p)
12 integer :: i
13 type(t), pointer :: p, x
14 allocate(x)
15 p => x
16 do i = 1, 5
17 x%val = i
18 if (i < 5) then
19 allocate(x%next)
20 x => x%next
21 end if
22 end do
23 end subroutine
24
25 subroutine check(p)
26 !$omp declare target enter(check)
27 integer :: i
28 type(t), pointer :: p, x
29 x => p
30 do i = 1, 5
31 if (x%val /= i) stop 1
32 x => x%next
33 end do
34 end subroutine
35 end module
36
37 use omp_lib
38 use m
39 implicit none (type, external)
40 type(t), pointer :: linked
41 integer :: i
42
43 call init(linked)
44 do i = 0, omp_get_num_devices()
45 !$omp target device(i)
46 call check(linked)
47 !$omp end target
48 end do
49 end