Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
! test helps to check that we can replace the constants
! within the kernel with instructions and then replace
! these instructions with the kernel parameters.
! REQUIRES: flang
! UNSUPPORTED: nvptx64-nvidia-cuda
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
! UNSUPPORTED: aarch64-unknown-linux-gnu
! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
! UNSUPPORTED: x86_64-unknown-linux-gnu
! UNSUPPORTED: x86_64-unknown-linux-gnu-LTO
! REQUIRES: flang, amdgpu

! RUN: %libomptarget-compile-fortran-run-and-check-generic
module test_0
Expand Down
110 changes: 110 additions & 0 deletions offload/test/offloading/fortran/dtype-member-map-syntax-1.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
! This test checks a number of more complex derived type
! member mapping syntaxes utilising a non-allocatable parent
! derived type.

! REQUIRES: flang, amdgpu

! RUN: %libomptarget-compile-fortran-run-and-check-generic
program main
type dtype2
integer int
real float
real float_elements(10)
end type dtype2

type dtype1
character (LEN=30) characters
character (LEN=1) character
type(dtype2) number
end type dtype1

type nonallocatabledtype
integer elements(20)
type(dtype1) num_chars
integer value
type(dtype2) internal_dtypes(5)
end type nonallocatabledtype

type (nonallocatabledtype) array_dtype(5)

!$omp target map(tofrom: array_dtype(5))
do i = 1, 20
array_dtype(5)%elements(i) = 20 + i
end do

array_dtype(5)%num_chars%number%float_elements(5) = 10
array_dtype(5)%value = 40
!$omp end target

print *, array_dtype(5)%elements
print *, array_dtype(5)%num_chars%number%float_elements(5)
print *, array_dtype(5)%value

!$omp target map(tofrom: array_dtype(4)%elements(3))
array_dtype(4)%elements(3) = 74
!$omp end target

print *, array_dtype(4)%elements(3)

!$omp target map(tofrom: array_dtype(5)%elements(3:5))
do i = 3, 5
array_dtype(5)%elements(i) = i + 1
end do
!$omp end target

do i = 3, 5
print *, array_dtype(5)%elements(i)
end do

!$omp target map(tofrom: array_dtype(3:5))
do i = 3, 5
array_dtype(i)%value = i + 2
end do
!$omp end target

do i = 3, 5
print *, array_dtype(i)%value
end do

!$omp target map(tofrom: array_dtype(4)%num_chars%number%float_elements(8))
array_dtype(4)%num_chars%number%float_elements(8) = 250
!$omp end target

print *, array_dtype(4)%num_chars%number%float_elements(8)

!$omp target map(tofrom: array_dtype(4)%num_chars%number%float_elements(5:10))
do i = 5, 10
array_dtype(4)%num_chars%number%float_elements(i) = i + 3
end do
!$omp end target

do i = 5, 10
print *, array_dtype(4)%num_chars%number%float_elements(i)
end do

!$omp target map(tofrom: array_dtype(4)%internal_dtypes(3)%float_elements(4))
array_dtype(4)%internal_dtypes(3)%float_elements(4) = 200
!$omp end target

print *, array_dtype(4)%internal_dtypes(3)%float_elements(4)

end program main

! CHECK: 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
! CHECK: 10.
! CHECK: 40
! CHECK: 74
! CHECK: 4
! CHECK: 5
! CHECK: 6
! CHECK: 5
! CHECK: 6
! CHECK: 7
! CHECK: 250.
! CHECK: 8.
! CHECK: 9.
! CHECK: 10.
! CHECK: 11.
! CHECK: 12.
! CHECK: 13.
! CHECK: 200
176 changes: 176 additions & 0 deletions offload/test/offloading/fortran/dtype-member-map-syntax-2.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
! This test checks a number of more complex derived type
! member mapping syntaxes utilising an allocatable parent
! derived type and mixed allocatable members.

! REQUIRES: flang, amdgpu

! RUN: %libomptarget-compile-fortran-run-and-check-generic
program main
implicit none

integer :: i
integer :: N1, N2

type :: vertexes
integer :: test
integer :: testarray(10)
integer(4), allocatable :: vertexx(:)
integer(4), allocatable :: vertexy(:)
end type vertexes

type testing_tile_type
TYPE(vertexes) :: field
end type testing_tile_type

type :: dtype
real(4) :: i
type(vertexes), allocatable :: vertexes(:)
TYPE(testing_tile_type), DIMENSION(:), allocatable :: test_tile
integer(4) :: array_i(10)
real(4) :: j
integer, allocatable :: array_j(:)
integer(4) :: k
end type dtype

type(dtype) :: alloca_dtype
type(dtype), DIMENSION(:), allocatable :: alloca_dtype_arr

allocate(alloca_dtype%vertexes(4))
allocate(alloca_dtype%vertexes(1)%vertexx(10))
allocate(alloca_dtype%vertexes(1)%vertexy(10))
allocate(alloca_dtype%vertexes(2)%vertexx(10))
allocate(alloca_dtype%vertexes(2)%vertexy(10))
allocate(alloca_dtype%vertexes(3)%vertexx(10))
allocate(alloca_dtype%vertexes(3)%vertexy(10))
allocate(alloca_dtype%vertexes(4)%vertexx(10))
allocate(alloca_dtype%vertexes(4)%vertexy(10))
allocate(alloca_dtype%test_tile(4))
allocate(alloca_dtype%test_tile(1)%field%vertexx(10))
allocate(alloca_dtype%test_tile(1)%field%vertexy(10))
allocate(alloca_dtype%test_tile(2)%field%vertexx(10))
allocate(alloca_dtype%test_tile(2)%field%vertexy(10))
allocate(alloca_dtype%test_tile(3)%field%vertexx(10))
allocate(alloca_dtype%test_tile(3)%field%vertexy(10))
allocate(alloca_dtype%test_tile(4)%field%vertexx(10))
allocate(alloca_dtype%test_tile(4)%field%vertexy(10))

allocate(alloca_dtype_arr(3))

N1 = 1
N2 = 2

!$omp target map(tofrom: alloca_dtype%vertexes(N1)%test)
alloca_dtype%vertexes(N1)%test = 3
!$omp end target

print *, alloca_dtype%vertexes(N1)%test

!$omp target map(tofrom: alloca_dtype%vertexes(N1)%test, alloca_dtype%vertexes(N2)%test)
alloca_dtype%vertexes(N1)%test = 5
alloca_dtype%vertexes(N2)%test = 10
!$omp end target

print *, alloca_dtype%vertexes(N1)%test
print *, alloca_dtype%vertexes(N2)%test

!$omp target map(tofrom: alloca_dtype%test_tile(N1)%field%vertexx, &
!$omp alloca_dtype%test_tile(N1)%field%vertexy)
do i = 1, 10
alloca_dtype%test_tile(N1)%field%vertexx(i) = i + 4
alloca_dtype%test_tile(N1)%field%vertexy(i) = i + 4
end do
!$omp end target

print *, alloca_dtype%test_tile(N1)%field%vertexx
print *, alloca_dtype%test_tile(N1)%field%vertexy

!$omp target map(tofrom: alloca_dtype%test_tile(N1)%field%test, &
!$omp alloca_dtype%test_tile(N2)%field%test, &
!$omp alloca_dtype%test_tile(N1)%field%vertexy, &
!$omp alloca_dtype%test_tile(N2)%field%vertexy)
alloca_dtype%test_tile(N2)%field%test = 9999
alloca_dtype%test_tile(N2)%field%vertexy(2) = 9998
alloca_dtype%test_tile(N1)%field%test = 9997
alloca_dtype%test_tile(N1)%field%vertexy(2) = 9996
!$omp end target

print *, alloca_dtype%test_tile(N1)%field%test
print *, alloca_dtype%test_tile(N2)%field%test
print *, alloca_dtype%test_tile(N1)%field%vertexy(2)
print *, alloca_dtype%test_tile(N2)%field%vertexy(2)

!$omp target map(tofrom: alloca_dtype%test_tile(N2)%field%vertexy)
alloca_dtype%test_tile(N2)%field%vertexy(2) = 2000
!$omp end target

!$omp target map(tofrom: alloca_dtype%vertexes(N1)%vertexx, &
!$omp alloca_dtype%vertexes(N1)%vertexy, &
!$omp alloca_dtype%vertexes(N2)%vertexx, &
!$omp alloca_dtype%vertexes(N2)%vertexy)
do i = 1, 10
alloca_dtype%vertexes(N1)%vertexx(i) = i * 2
alloca_dtype%vertexes(N1)%vertexy(i) = i * 2
alloca_dtype%vertexes(N2)%vertexx(i) = i * 2
alloca_dtype%vertexes(N2)%vertexy(i) = i * 2
end do
!$omp end target

print *, alloca_dtype%vertexes(N1)%vertexx
print *, alloca_dtype%vertexes(N1)%vertexy
print *, alloca_dtype%vertexes(N2)%vertexx
print *, alloca_dtype%vertexes(N2)%vertexy

!$omp target map(tofrom: alloca_dtype%vertexes(N1)%vertexx, &
!$omp alloca_dtype%vertexes(N1)%vertexy, &
!$omp alloca_dtype%vertexes(4)%vertexy, &
!$omp alloca_dtype%vertexes(4)%vertexx, &
!$omp alloca_dtype%vertexes(N2)%vertexx, &
!$omp alloca_dtype%vertexes(N2)%vertexy)
do i = 1, 10
alloca_dtype%vertexes(N1)%vertexx(i) = i * 3
alloca_dtype%vertexes(N1)%vertexy(i) = i * 3
alloca_dtype%vertexes(4)%vertexx(i) = i * 3
alloca_dtype%vertexes(4)%vertexy(i) = i * 3
alloca_dtype%vertexes(N2)%vertexx(i) = i * 3
alloca_dtype%vertexes(N2)%vertexy(i) = i * 3
end do
!$omp end target


print *, alloca_dtype%vertexes(1)%vertexx
print *, alloca_dtype%vertexes(1)%vertexy
print *, alloca_dtype%vertexes(4)%vertexx
print *, alloca_dtype%vertexes(4)%vertexy
print *, alloca_dtype%vertexes(2)%vertexx
print *, alloca_dtype%vertexes(2)%vertexy

!$omp target map(tofrom: alloca_dtype_arr(N2)%array_i)
do i = 1, 10
alloca_dtype_arr(N2)%array_i(i) = i + 2
end do
!$omp end target

print *, alloca_dtype_arr(N2)%array_i

end program main

! CHECK: 3
! CHECK: 5
! CHECK: 10
! CHECK: 5 6 7 8 9 10 11 12 13 14
! CHECK: 5 6 7 8 9 10 11 12 13 14
! CHECK: 9997
! CHECK: 9999
! CHECK: 9996
! CHECK: 9998
! CHECK: 2 4 6 8 10 12 14 16 18 20
! CHECK: 2 4 6 8 10 12 14 16 18 20
! CHECK: 2 4 6 8 10 12 14 16 18 20
! CHECK: 2 4 6 8 10 12 14 16 18 20
! CHECK: 3 6 9 12 15 18 21 24 27 30
! CHECK: 3 6 9 12 15 18 21 24 27 30
! CHECK: 3 6 9 12 15 18 21 24 27 30
! CHECK: 3 6 9 12 15 18 21 24 27 30
! CHECK: 3 6 9 12 15 18 21 24 27 30
! CHECK: 3 6 9 12 15 18 21 24 27 30
! CHECK: 3 4 5 6 7 8 9 10 11 12
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
! Offloading test checking interaction of explicit
! member mapping of an allocatable array of derived
! types contained within an allocatable derived type
! REQUIRES: flang, amdgpu

! RUN: %libomptarget-compile-fortran-run-and-check-generic
program main
type :: nested_dtype
real(4) :: i
real(4) :: j
integer(4) :: array_i(10)
integer(4) :: k
end type nested_dtype

type :: dtype
real(4) :: i
integer(4) :: array_i(10)
real(4) :: j
type(nested_dtype), allocatable :: array_dtype(:)
integer(4) :: k
end type dtype

type(dtype), allocatable :: dtyped
allocate(dtyped)
allocate(dtyped%array_dtype(10))

!$omp target map(tofrom: dtyped%array_dtype)
do i = 1, 10
dtyped%array_dtype(i)%k = i
end do
!$omp end target

print *, dtyped%array_dtype%k
end program main

!CHECK: 1 2 3 4 5 6 7 8 9 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
! Offload test that checks an allocatable array within an
! allocatable derived type can be mapped explicitly using
! member mapping.
! REQUIRES: flang, amdgpu

! RUN: %libomptarget-compile-fortran-run-and-check-generic
program main
type :: dtype
real(4) :: i
integer(4) :: array_i(10)
real(4) :: j
integer, allocatable :: array_j(:)
integer(4) :: k
end type dtype

type(dtype), allocatable :: alloca_dtype
allocate(alloca_dtype)
allocate(alloca_dtype%array_j(10))

!$omp target map(tofrom: alloca_dtype%array_j)
do i = 1, 10
alloca_dtype%array_j(i) = i
end do
!$omp end target

print *, alloca_dtype%array_j

end program main

!CHECK: 1 2 3 4 5 6 7 8 9 10
Loading
Loading