Skip to content

Commit 7fd6cb2

Browse files
committed
[Flang][OpenMP] Derived type member map fortran offload runtime tests
This is a large series of runtime tests that help to add coverage for the specific cases intended to be supported by the PR stack that extends derived type map support in Flang+OpenMP. Primarily this will add functionality coverage, there's cases where things may work, but not optimally (or at least similarly to the status quo in Clang), addiitonal IR tests are added in the relevant segments of the related PRs to test for breakages like that. Pull Request: #82850
1 parent d009bd7 commit 7fd6cb2

File tree

30 files changed

+1306
-5
lines changed

30 files changed

+1306
-5
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
! Offloading test checking interaction of an
2+
! explicit derived type mapping when mapped
3+
! to target and assinging one derived type
4+
! to another
5+
! REQUIRES: flang, amdgcn-amd-amdhsa
6+
! UNSUPPORTED: nvptx64-nvidia-cuda
7+
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
8+
! UNSUPPORTED: aarch64-unknown-linux-gnu
9+
! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
10+
! UNSUPPORTED: x86_64-pc-linux-gnu
11+
! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
12+
13+
! RUN: %libomptarget-compile-fortran-run-and-check-generic
14+
program main
15+
type :: scalar
16+
integer(4) :: ix = 0
17+
real(4) :: rx = 0.0
18+
complex(4) :: zx = (0,0)
19+
end type scalar
20+
21+
type(scalar) :: in
22+
type(scalar) :: out
23+
in%ix = 10
24+
in%rx = 2.0
25+
in%zx = (2, 10)
26+
27+
!$omp target map(from:out) map(to:in)
28+
out = in
29+
!$omp end target
30+
31+
print*, in%ix
32+
print*, in%rx
33+
write (*,*) in%zx
34+
35+
print*, out%ix
36+
print*, out%rx
37+
write (*,*) out%zx
38+
end program main
39+
40+
!CHECK: 10
41+
!CHECK: 2.
42+
!CHECK: (2.,10.)
43+
!CHECK: 10
44+
!CHECK: 2.
45+
!CHECK: (2.,10.)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
! Offloading test checking interaction of an
2+
! explicit derived type mapping when mapped to
3+
! target and assigning to individual members
4+
! REQUIRES: flang, amdgcn-amd-amdhsa
5+
! UNSUPPORTED: nvptx64-nvidia-cuda
6+
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
7+
! UNSUPPORTED: aarch64-unknown-linux-gnu
8+
! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
9+
! UNSUPPORTED: x86_64-pc-linux-gnu
10+
! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
11+
12+
! RUN: %libomptarget-compile-fortran-run-and-check-generic
13+
program main
14+
type :: scalar
15+
integer(4) :: ix = 0
16+
real(4) :: rx = 0.0
17+
complex(4) :: zx = (0,0)
18+
integer(4) :: array(5)
19+
end type scalar
20+
21+
type(scalar) :: out
22+
type(scalar) :: in
23+
24+
in%ix = 10
25+
in%rx = 2.0
26+
in%zx = (2, 10)
27+
28+
do i = 1, 5
29+
in%array(i) = i
30+
end do
31+
32+
!$omp target map(from:out) map(to:in)
33+
out%ix = in%ix
34+
out%rx = in%rx
35+
out%zx = in%zx
36+
37+
do i = 1, 5
38+
out%array(i) = in%array(i)
39+
end do
40+
!$omp end target
41+
42+
print*, in%ix
43+
print*, in%rx
44+
print*, in%array
45+
write (*,*) in%zx
46+
47+
print*, out%ix
48+
print*, out%rx
49+
print*, out%array
50+
write (*,*) out%zx
51+
end program main
52+
53+
!CHECK: 10
54+
!CHECK: 2.
55+
!CHECK: 1 2 3 4 5
56+
!CHECK: (2.,10.)
57+
!CHECK: 10
58+
!CHECK: 2.
59+
!CHECK: 1 2 3 4 5
60+
!CHECK: (2.,10.)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
! Offloading test checking interaction of an
2+
! implicit derived type mapping when mapped
3+
! to target and assinging one derived type
4+
! to another
5+
! REQUIRES: flang, amdgcn-amd-amdhsa
6+
! UNSUPPORTED: nvptx64-nvidia-cuda
7+
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
8+
! UNSUPPORTED: aarch64-unknown-linux-gnu
9+
! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
10+
! UNSUPPORTED: x86_64-pc-linux-gnu
11+
! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
12+
13+
! RUN: %libomptarget-compile-fortran-run-and-check-generic
14+
program main
15+
type :: scalar
16+
integer(4) :: ix = 0
17+
real(4) :: rx = 0.0
18+
complex(4) :: zx = (0,0)
19+
end type scalar
20+
21+
type(scalar) :: in
22+
type(scalar) :: out
23+
in%ix = 10
24+
in%rx = 2.0
25+
in%zx = (2, 10)
26+
27+
!$omp target map(from:out)
28+
out = in
29+
!$omp end target
30+
31+
print*, in%ix
32+
print*, in%rx
33+
write (*,*) in%zx
34+
35+
print*, out%ix
36+
print*, out%rx
37+
write (*,*) out%zx
38+
end program main
39+
40+
!CHECK: 10
41+
!CHECK: 2.
42+
!CHECK: (2.,10.)
43+
!CHECK: 10
44+
!CHECK: 2.
45+
!CHECK: (2.,10.)
46+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
! Offloading test checking interaction of an
2+
! explicit derived type mapping when mapped
3+
! to target and assinging one derived type
4+
! to another
5+
! REQUIRES: flang, amdgcn-amd-amdhsa
6+
! UNSUPPORTED: nvptx64-nvidia-cuda
7+
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
8+
! UNSUPPORTED: aarch64-unknown-linux-gnu
9+
! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
10+
! UNSUPPORTED: x86_64-pc-linux-gnu
11+
! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
12+
13+
! RUN: %libomptarget-compile-fortran-run-and-check-generic
14+
program main
15+
type :: scalar
16+
integer(4) :: ix = 0
17+
real(4) :: rx = 0.0
18+
complex(4) :: zx = (0,0)
19+
integer(4) :: array(5)
20+
end type scalar
21+
22+
type(scalar) :: out
23+
type(scalar) :: in
24+
25+
in%ix = 10
26+
in%rx = 2.0
27+
in%zx = (2, 10)
28+
29+
do i = 1, 5
30+
in%array(i) = i
31+
end do
32+
33+
!$omp target
34+
out%ix = in%ix
35+
out%rx = in%rx
36+
out%zx = in%zx
37+
38+
do i = 1, 5
39+
out%array(i) = in%array(i)
40+
end do
41+
!$omp end target
42+
43+
print*, in%ix
44+
print*, in%rx
45+
print*, in%array
46+
write (*,*) in%zx
47+
48+
print*, out%ix
49+
print*, out%rx
50+
print*, out%array
51+
write (*,*) out%zx
52+
end program main
53+
54+
!CHECK: 10
55+
!CHECK: 2.
56+
!CHECK: 1 2 3 4 5
57+
!CHECK: (2.,10.)
58+
!CHECK: 10
59+
!CHECK: 2.
60+
!CHECK: 1 2 3 4 5
61+
!CHECK: (2.,10.)
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
! Offloading test checking interaction of an
2+
! explicit member map from two large nested
3+
! derived types
4+
! REQUIRES: flang, amdgcn-amd-amdhsa
5+
! UNSUPPORTED: nvptx64-nvidia-cuda
6+
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
7+
! UNSUPPORTED: aarch64-unknown-linux-gnu
8+
! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
9+
! UNSUPPORTED: x86_64-pc-linux-gnu
10+
! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
11+
12+
! RUN: %libomptarget-compile-fortran-run-and-check-generic
13+
program main
14+
type :: bottom_layer1
15+
real(4) :: i4
16+
real(4) :: j4
17+
real(4) :: k4
18+
end type bottom_layer1
19+
20+
type :: bottom_layer2
21+
integer(4) :: i3
22+
integer(4) :: j3
23+
integer(4) :: k3
24+
end type bottom_layer2
25+
26+
type :: middle_layer
27+
real(4) :: array_i2(10)
28+
real(4) :: i2
29+
real(4) :: array_j2(10)
30+
type(bottom_layer1) :: nest
31+
type(bottom_layer2) :: nest2
32+
end type middle_layer
33+
34+
type :: top_layer
35+
real(4) :: i
36+
integer(4) :: array_i(10)
37+
real(4) :: j
38+
integer, allocatable :: array_j(:)
39+
integer(4) :: k
40+
type(middle_layer) :: nested
41+
end type top_layer
42+
43+
type(top_layer) :: top_dtype
44+
type(top_layer) :: top_dtype2
45+
46+
top_dtype2%nested%nest%i4 = 10
47+
top_dtype2%nested%nest%j4 = 12
48+
top_dtype2%nested%nest%k4 = 54
49+
50+
top_dtype2%nested%nest2%i3 = 20
51+
top_dtype2%nested%nest2%j3 = 40
52+
top_dtype2%nested%nest2%k3 = 60
53+
54+
top_dtype2%nested%i2 = 200
55+
56+
do i = 1, 10
57+
top_dtype2%array_i(i) = i
58+
end do
59+
60+
!$omp target map(from: top_dtype%nested%nest%j4, top_dtype%nested%nest%i4, top_dtype%nested%nest%k4) &
61+
!$omp map(from: top_dtype%array_i, top_dtype%nested%nest2%i3, top_dtype%nested%i2) &
62+
!$omp map(from: top_dtype%nested%nest2%k3, top_dtype%nested%nest2%j3) &
63+
!$omp map(to: top_dtype2%nested%nest%j4, top_dtype2%nested%nest%i4, top_dtype2%nested%nest%k4) &
64+
!$omp map(to: top_dtype2%array_i, top_dtype2%nested%nest2%i3, top_dtype2%nested%i2) &
65+
!$omp map(to: top_dtype2%nested%nest2%k3, top_dtype2%nested%nest2%j3)
66+
top_dtype%nested%nest%i4 = top_dtype2%nested%nest%i4
67+
top_dtype%nested%nest%j4 = top_dtype2%nested%nest%j4
68+
top_dtype%nested%nest%k4 = top_dtype2%nested%nest%k4
69+
70+
top_dtype%nested%nest2%i3 = top_dtype2%nested%nest2%i3
71+
top_dtype%nested%nest2%j3 = top_dtype2%nested%nest2%j3
72+
top_dtype%nested%nest2%k3 = top_dtype2%nested%nest2%k3
73+
74+
top_dtype%nested%i2 = top_dtype2%nested%i2
75+
76+
do i = 1, 10
77+
top_dtype%array_i(i) = top_dtype2%array_i(i)
78+
end do
79+
!$omp end target
80+
81+
print *, top_dtype%nested%nest%i4
82+
print *, top_dtype%nested%nest%j4
83+
print *, top_dtype%nested%nest%k4
84+
85+
print *, top_dtype%nested%nest2%i3
86+
print *, top_dtype%nested%nest2%j3
87+
print *, top_dtype%nested%nest2%k3
88+
89+
print *, top_dtype%nested%i2
90+
91+
print *, top_dtype%array_i
92+
end program main
93+
94+
!CHECK: 10.
95+
!CHECK: 12.
96+
!CHECK: 54.
97+
!CHECK: 20
98+
!CHECK: 40
99+
!CHECK: 60
100+
!CHECK: 200.
101+
!CHECK: 1 2 3 4 5 6 7 8 9 10
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
! Offloading test checking interaction of two
2+
! explicit arrau member maps with bounds from
3+
! two nested derived types
4+
! REQUIRES: flang, amdgcn-amd-amdhsa
5+
! UNSUPPORTED: nvptx64-nvidia-cuda
6+
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
7+
! UNSUPPORTED: aarch64-unknown-linux-gnu
8+
! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
9+
! UNSUPPORTED: x86_64-pc-linux-gnu
10+
! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
11+
12+
! RUN: %libomptarget-compile-fortran-run-and-check-generic
13+
program main
14+
type :: bottom_layer
15+
real(8) :: i2
16+
real(4) :: array_i2(10)
17+
real(4) :: array_j2(10)
18+
end type bottom_layer
19+
20+
type :: top_layer
21+
real(4) :: i
22+
integer(4) :: array_i(10)
23+
real(4) :: j
24+
type(bottom_layer) :: nested
25+
integer, allocatable :: array_j(:)
26+
integer(4) :: k
27+
end type top_layer
28+
29+
type(top_layer) :: top_dtype
30+
type(top_layer) :: top_dtype2
31+
32+
!$omp target map(tofrom: top_dtype%nested%array_i2(4:8), top_dtype2%nested%array_j2(4:8))
33+
do i = 4, 8
34+
top_dtype%nested%array_i2(i) = i * 2
35+
end do
36+
37+
do i = 4, 8
38+
top_dtype2%nested%array_j2(i) = i * 2
39+
end do
40+
!$omp end target
41+
42+
print *, top_dtype%nested%array_i2
43+
print *, top_dtype2%nested%array_j2
44+
end program main
45+
46+
!CHECK: 0. 0. 0. 8. 10. 12. 14. 16. 0. 0.
47+
!CHECK: 0. 0. 0. 8. 10. 12. 14. 16. 0. 0.

0 commit comments

Comments
 (0)