Debian Codegraph @

libgomp/testsuite/libgomp.fortran/alloc-comp-4.f90

raw
1 !
2 ! Check that mapping with map(var%tiles(1)) works.
3 !
4 ! This uses deep mapping to handle the allocatable
5 ! derived-type components
6 !
7 ! The tricky part is that GCC generates intermittently
8 ! an SSA_NAME that needs to be resolved.
9 !
10 module m
11 type t
12 integer, allocatable :: den1(:,:), den2(:,:)
13 end type t
14
15 type t2
16 type(t), allocatable :: tiles(:)
17 end type t2
18 end
19
20 use m
21 use iso_c_binding
22 implicit none (type, external)
23 type(t2), target :: var
24 logical :: is_self_map
25 type(C_ptr) :: pden1, pden2, ptiles, ptiles1
26
27 allocate(var%tiles(1))
28 var%tiles(1)%den1 = reshape([1,2,3,4],[2,2])
29 var%tiles(1)%den2 = reshape([11,22,33,44],[2,2])
30
31 ptiles = c_loc(var%tiles)
32 ptiles1 = c_loc(var%tiles(1))
33 pden1 = c_loc(var%tiles(1)%den1)
34 pden2 = c_loc(var%tiles(1)%den2)
35
36
37 is_self_map = .false.
38 !$omp target map(to: is_self_map)
39 is_self_map = .true.
40 !$omp end target
41
42 !$omp target enter data map(var%tiles(1))
43
44 !$omp target firstprivate(ptiles, ptiles1, pden1, pden2)
45 if (any (var%tiles(1)%den1 /= reshape([1,2,3,4],[2,2]))) stop 1
46 if (any (var%tiles(1)%den2 /= reshape([11,22,33,44],[2,2]))) stop 2
47 var%tiles(1)%den1 = var%tiles(1)%den1 + 5
48 var%tiles(1)%den2 = var%tiles(1)%den2 + 7
49
50 if (is_self_map) then
51 if (.not. c_associated (ptiles, c_loc(var%tiles))) stop 3
52 if (.not. c_associated (ptiles1, c_loc(var%tiles(1)))) stop 4
53 if (.not. c_associated (pden1, c_loc(var%tiles(1)%den1))) stop 5
54 if (.not. c_associated (pden2, c_loc(var%tiles(1)%den2))) stop 6
55 else
56 if (c_associated (ptiles, c_loc(var%tiles))) stop 3
57 if (c_associated (ptiles1, c_loc(var%tiles(1)))) stop 4
58 if (c_associated (pden1, c_loc(var%tiles(1)%den1))) stop 5
59 if (c_associated (pden2, c_loc(var%tiles(1)%den2))) stop 6
60 endif
61 !$omp end target
62
63 if (is_self_map) then
64 if (any (var%tiles(1)%den1 /= 5 + reshape([1,2,3,4],[2,2]))) stop 7
65 if (any (var%tiles(1)%den2 /= 7 + reshape([11,22,33,44],[2,2]))) stop 8
66 else
67 if (any (var%tiles(1)%den1 /= reshape([1,2,3,4],[2,2]))) stop 7
68 if (any (var%tiles(1)%den2 /= reshape([11,22,33,44],[2,2]))) stop 8
69 endif
70
71 !$omp target exit data map(var%tiles(1))
72
73 if (any (var%tiles(1)%den1 /= 5 + reshape([1,2,3,4],[2,2]))) stop 7
74 if (any (var%tiles(1)%den2 /= 7 + reshape([11,22,33,44],[2,2]))) stop 8
75 end