Skip to content

Commit 6277698

Browse files
committed
[𝘀𝗽𝗿] changes to main this commit is based on
Created using spr 1.3.4 [skip ci]
1 parent f873fc3 commit 6277698

28 files changed

+1322
-8
lines changed

offload/test/offloading/fortran/dtype-array-constant-index-map.f90

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
! test helps to check that we can replace the constants
66
! within the kernel with instructions and then replace
77
! these instructions with the kernel parameters.
8-
! REQUIRES: flang
9-
! UNSUPPORTED: nvptx64-nvidia-cuda
10-
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
11-
! UNSUPPORTED: aarch64-unknown-linux-gnu
12-
! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
13-
! UNSUPPORTED: x86_64-unknown-linux-gnu
14-
! UNSUPPORTED: x86_64-unknown-linux-gnu-LTO
8+
! REQUIRES: flang, amdgpu
159

1610
! RUN: %libomptarget-compile-fortran-run-and-check-generic
1711
module test_0
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
! This test checks a number of more complex derived type
2+
! member mapping syntaxes utilising a non-allocatable parent
3+
! derived type.
4+
5+
! REQUIRES: flang, amdgpu
6+
7+
! RUN: %libomptarget-compile-fortran-run-and-check-generic
8+
program main
9+
type dtype2
10+
integer int
11+
real float
12+
real float_elements(10)
13+
end type dtype2
14+
15+
type dtype1
16+
character (LEN=30) characters
17+
character (LEN=1) character
18+
type(dtype2) number
19+
end type dtype1
20+
21+
type nonallocatabledtype
22+
integer elements(20)
23+
type(dtype1) num_chars
24+
integer value
25+
type(dtype2) internal_dtypes(5)
26+
end type nonallocatabledtype
27+
28+
type (nonallocatabledtype) array_dtype(5)
29+
30+
!$omp target map(tofrom: array_dtype(5))
31+
do i = 1, 20
32+
array_dtype(5)%elements(i) = 20 + i
33+
end do
34+
35+
array_dtype(5)%num_chars%number%float_elements(5) = 10
36+
array_dtype(5)%value = 40
37+
!$omp end target
38+
39+
print *, array_dtype(5)%elements
40+
print *, array_dtype(5)%num_chars%number%float_elements(5)
41+
print *, array_dtype(5)%value
42+
43+
!$omp target map(tofrom: array_dtype(4)%elements(3))
44+
array_dtype(4)%elements(3) = 74
45+
!$omp end target
46+
47+
print *, array_dtype(4)%elements(3)
48+
49+
!$omp target map(tofrom: array_dtype(5)%elements(3:5))
50+
do i = 3, 5
51+
array_dtype(5)%elements(i) = i + 1
52+
end do
53+
!$omp end target
54+
55+
do i = 3, 5
56+
print *, array_dtype(5)%elements(i)
57+
end do
58+
59+
!$omp target map(tofrom: array_dtype(3:5))
60+
do i = 3, 5
61+
array_dtype(i)%value = i + 2
62+
end do
63+
!$omp end target
64+
65+
do i = 3, 5
66+
print *, array_dtype(i)%value
67+
end do
68+
69+
!$omp target map(tofrom: array_dtype(4)%num_chars%number%float_elements(8))
70+
array_dtype(4)%num_chars%number%float_elements(8) = 250
71+
!$omp end target
72+
73+
print *, array_dtype(4)%num_chars%number%float_elements(8)
74+
75+
!$omp target map(tofrom: array_dtype(4)%num_chars%number%float_elements(5:10))
76+
do i = 5, 10
77+
array_dtype(4)%num_chars%number%float_elements(i) = i + 3
78+
end do
79+
!$omp end target
80+
81+
do i = 5, 10
82+
print *, array_dtype(4)%num_chars%number%float_elements(i)
83+
end do
84+
85+
!$omp target map(tofrom: array_dtype(4)%internal_dtypes(3)%float_elements(4))
86+
array_dtype(4)%internal_dtypes(3)%float_elements(4) = 200
87+
!$omp end target
88+
89+
print *, array_dtype(4)%internal_dtypes(3)%float_elements(4)
90+
91+
end program main
92+
93+
! CHECK: 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
94+
! CHECK: 10.
95+
! CHECK: 40
96+
! CHECK: 74
97+
! CHECK: 4
98+
! CHECK: 5
99+
! CHECK: 6
100+
! CHECK: 5
101+
! CHECK: 6
102+
! CHECK: 7
103+
! CHECK: 250.
104+
! CHECK: 8.
105+
! CHECK: 9.
106+
! CHECK: 10.
107+
! CHECK: 11.
108+
! CHECK: 12.
109+
! CHECK: 13.
110+
! CHECK: 200
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
! This test checks a number of more complex derived type
2+
! member mapping syntaxes utilising an allocatable parent
3+
! derived type and mixed allocatable members.
4+
5+
! REQUIRES: flang, amdgpu
6+
7+
! RUN: %libomptarget-compile-fortran-run-and-check-generic
8+
program main
9+
implicit none
10+
11+
integer :: i
12+
integer :: N1, N2
13+
14+
type :: vertexes
15+
integer :: test
16+
integer :: testarray(10)
17+
integer(4), allocatable :: vertexx(:)
18+
integer(4), allocatable :: vertexy(:)
19+
end type vertexes
20+
21+
type testing_tile_type
22+
TYPE(vertexes) :: field
23+
end type testing_tile_type
24+
25+
type :: dtype
26+
real(4) :: i
27+
type(vertexes), allocatable :: vertexes(:)
28+
TYPE(testing_tile_type), DIMENSION(:), allocatable :: test_tile
29+
integer(4) :: array_i(10)
30+
real(4) :: j
31+
integer, allocatable :: array_j(:)
32+
integer(4) :: k
33+
end type dtype
34+
35+
type(dtype) :: alloca_dtype
36+
type(dtype), DIMENSION(:), allocatable :: alloca_dtype_arr
37+
38+
allocate(alloca_dtype%vertexes(4))
39+
allocate(alloca_dtype%vertexes(1)%vertexx(10))
40+
allocate(alloca_dtype%vertexes(1)%vertexy(10))
41+
allocate(alloca_dtype%vertexes(2)%vertexx(10))
42+
allocate(alloca_dtype%vertexes(2)%vertexy(10))
43+
allocate(alloca_dtype%vertexes(3)%vertexx(10))
44+
allocate(alloca_dtype%vertexes(3)%vertexy(10))
45+
allocate(alloca_dtype%vertexes(4)%vertexx(10))
46+
allocate(alloca_dtype%vertexes(4)%vertexy(10))
47+
allocate(alloca_dtype%test_tile(4))
48+
allocate(alloca_dtype%test_tile(1)%field%vertexx(10))
49+
allocate(alloca_dtype%test_tile(1)%field%vertexy(10))
50+
allocate(alloca_dtype%test_tile(2)%field%vertexx(10))
51+
allocate(alloca_dtype%test_tile(2)%field%vertexy(10))
52+
allocate(alloca_dtype%test_tile(3)%field%vertexx(10))
53+
allocate(alloca_dtype%test_tile(3)%field%vertexy(10))
54+
allocate(alloca_dtype%test_tile(4)%field%vertexx(10))
55+
allocate(alloca_dtype%test_tile(4)%field%vertexy(10))
56+
57+
allocate(alloca_dtype_arr(3))
58+
59+
N1 = 1
60+
N2 = 2
61+
62+
!$omp target map(tofrom: alloca_dtype%vertexes(N1)%test)
63+
alloca_dtype%vertexes(N1)%test = 3
64+
!$omp end target
65+
66+
print *, alloca_dtype%vertexes(N1)%test
67+
68+
!$omp target map(tofrom: alloca_dtype%vertexes(N1)%test, alloca_dtype%vertexes(N2)%test)
69+
alloca_dtype%vertexes(N1)%test = 5
70+
alloca_dtype%vertexes(N2)%test = 10
71+
!$omp end target
72+
73+
print *, alloca_dtype%vertexes(N1)%test
74+
print *, alloca_dtype%vertexes(N2)%test
75+
76+
!$omp target map(tofrom: alloca_dtype%test_tile(N1)%field%vertexx, &
77+
!$omp alloca_dtype%test_tile(N1)%field%vertexy)
78+
do i = 1, 10
79+
alloca_dtype%test_tile(N1)%field%vertexx(i) = i + 4
80+
alloca_dtype%test_tile(N1)%field%vertexy(i) = i + 4
81+
end do
82+
!$omp end target
83+
84+
print *, alloca_dtype%test_tile(N1)%field%vertexx
85+
print *, alloca_dtype%test_tile(N1)%field%vertexy
86+
87+
!$omp target map(tofrom: alloca_dtype%test_tile(N1)%field%test, &
88+
!$omp alloca_dtype%test_tile(N2)%field%test, &
89+
!$omp alloca_dtype%test_tile(N1)%field%vertexy, &
90+
!$omp alloca_dtype%test_tile(N2)%field%vertexy)
91+
alloca_dtype%test_tile(N2)%field%test = 9999
92+
alloca_dtype%test_tile(N2)%field%vertexy(2) = 9998
93+
alloca_dtype%test_tile(N1)%field%test = 9997
94+
alloca_dtype%test_tile(N1)%field%vertexy(2) = 9996
95+
!$omp end target
96+
97+
print *, alloca_dtype%test_tile(N1)%field%test
98+
print *, alloca_dtype%test_tile(N2)%field%test
99+
print *, alloca_dtype%test_tile(N1)%field%vertexy(2)
100+
print *, alloca_dtype%test_tile(N2)%field%vertexy(2)
101+
102+
!$omp target map(tofrom: alloca_dtype%test_tile(N2)%field%vertexy)
103+
alloca_dtype%test_tile(N2)%field%vertexy(2) = 2000
104+
!$omp end target
105+
106+
!$omp target map(tofrom: alloca_dtype%vertexes(N1)%vertexx, &
107+
!$omp alloca_dtype%vertexes(N1)%vertexy, &
108+
!$omp alloca_dtype%vertexes(N2)%vertexx, &
109+
!$omp alloca_dtype%vertexes(N2)%vertexy)
110+
do i = 1, 10
111+
alloca_dtype%vertexes(N1)%vertexx(i) = i * 2
112+
alloca_dtype%vertexes(N1)%vertexy(i) = i * 2
113+
alloca_dtype%vertexes(N2)%vertexx(i) = i * 2
114+
alloca_dtype%vertexes(N2)%vertexy(i) = i * 2
115+
end do
116+
!$omp end target
117+
118+
print *, alloca_dtype%vertexes(N1)%vertexx
119+
print *, alloca_dtype%vertexes(N1)%vertexy
120+
print *, alloca_dtype%vertexes(N2)%vertexx
121+
print *, alloca_dtype%vertexes(N2)%vertexy
122+
123+
!$omp target map(tofrom: alloca_dtype%vertexes(N1)%vertexx, &
124+
!$omp alloca_dtype%vertexes(N1)%vertexy, &
125+
!$omp alloca_dtype%vertexes(4)%vertexy, &
126+
!$omp alloca_dtype%vertexes(4)%vertexx, &
127+
!$omp alloca_dtype%vertexes(N2)%vertexx, &
128+
!$omp alloca_dtype%vertexes(N2)%vertexy)
129+
do i = 1, 10
130+
alloca_dtype%vertexes(N1)%vertexx(i) = i * 3
131+
alloca_dtype%vertexes(N1)%vertexy(i) = i * 3
132+
alloca_dtype%vertexes(4)%vertexx(i) = i * 3
133+
alloca_dtype%vertexes(4)%vertexy(i) = i * 3
134+
alloca_dtype%vertexes(N2)%vertexx(i) = i * 3
135+
alloca_dtype%vertexes(N2)%vertexy(i) = i * 3
136+
end do
137+
!$omp end target
138+
139+
140+
print *, alloca_dtype%vertexes(1)%vertexx
141+
print *, alloca_dtype%vertexes(1)%vertexy
142+
print *, alloca_dtype%vertexes(4)%vertexx
143+
print *, alloca_dtype%vertexes(4)%vertexy
144+
print *, alloca_dtype%vertexes(2)%vertexx
145+
print *, alloca_dtype%vertexes(2)%vertexy
146+
147+
!$omp target map(tofrom: alloca_dtype_arr(N2)%array_i)
148+
do i = 1, 10
149+
alloca_dtype_arr(N2)%array_i(i) = i + 2
150+
end do
151+
!$omp end target
152+
153+
print *, alloca_dtype_arr(N2)%array_i
154+
155+
end program main
156+
157+
! CHECK: 3
158+
! CHECK: 5
159+
! CHECK: 10
160+
! CHECK: 5 6 7 8 9 10 11 12 13 14
161+
! CHECK: 5 6 7 8 9 10 11 12 13 14
162+
! CHECK: 9997
163+
! CHECK: 9999
164+
! CHECK: 9996
165+
! CHECK: 9998
166+
! CHECK: 2 4 6 8 10 12 14 16 18 20
167+
! CHECK: 2 4 6 8 10 12 14 16 18 20
168+
! CHECK: 2 4 6 8 10 12 14 16 18 20
169+
! CHECK: 2 4 6 8 10 12 14 16 18 20
170+
! CHECK: 3 6 9 12 15 18 21 24 27 30
171+
! CHECK: 3 6 9 12 15 18 21 24 27 30
172+
! CHECK: 3 6 9 12 15 18 21 24 27 30
173+
! CHECK: 3 6 9 12 15 18 21 24 27 30
174+
! CHECK: 3 6 9 12 15 18 21 24 27 30
175+
! CHECK: 3 6 9 12 15 18 21 24 27 30
176+
! CHECK: 3 4 5 6 7 8 9 10 11 12
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
! Offloading test checking interaction of explicit
2+
! member mapping of an allocatable array of derived
3+
! types contained within an allocatable derived type
4+
! REQUIRES: flang, amdgpu
5+
6+
! RUN: %libomptarget-compile-fortran-run-and-check-generic
7+
program main
8+
type :: nested_dtype
9+
real(4) :: i
10+
real(4) :: j
11+
integer(4) :: array_i(10)
12+
integer(4) :: k
13+
end type nested_dtype
14+
15+
type :: dtype
16+
real(4) :: i
17+
integer(4) :: array_i(10)
18+
real(4) :: j
19+
type(nested_dtype), allocatable :: array_dtype(:)
20+
integer(4) :: k
21+
end type dtype
22+
23+
type(dtype), allocatable :: dtyped
24+
allocate(dtyped)
25+
allocate(dtyped%array_dtype(10))
26+
27+
!$omp target map(tofrom: dtyped%array_dtype)
28+
do i = 1, 10
29+
dtyped%array_dtype(i)%k = i
30+
end do
31+
!$omp end target
32+
33+
print *, dtyped%array_dtype%k
34+
end program main
35+
36+
!CHECK: 1 2 3 4 5 6 7 8 9 10
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
! Offload test that checks an allocatable array within an
2+
! allocatable derived type can be mapped explicitly using
3+
! member mapping.
4+
! REQUIRES: flang, amdgpu
5+
6+
! RUN: %libomptarget-compile-fortran-run-and-check-generic
7+
program main
8+
type :: dtype
9+
real(4) :: i
10+
integer(4) :: array_i(10)
11+
real(4) :: j
12+
integer, allocatable :: array_j(:)
13+
integer(4) :: k
14+
end type dtype
15+
16+
type(dtype), allocatable :: alloca_dtype
17+
allocate(alloca_dtype)
18+
allocate(alloca_dtype%array_j(10))
19+
20+
!$omp target map(tofrom: alloca_dtype%array_j)
21+
do i = 1, 10
22+
alloca_dtype%array_j(i) = i
23+
end do
24+
!$omp end target
25+
26+
print *, alloca_dtype%array_j
27+
28+
end program main
29+
30+
!CHECK: 1 2 3 4 5 6 7 8 9 10

0 commit comments

Comments
 (0)