1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
! This test doesn't expect any results, the pass condition is running to completion
! without any memory access errors on device or mapping issues from descriptor
! collisions due to local descriptors being placed on device and not being unampped
! before a subsequent local descriptor residing at the same address is mapped to
! device.
! REQUIRES: flang, amdgpu
! RUN: %libomptarget-compile-fortran-run-and-check-generic
module test
contains
subroutine kernel_1d(array)
implicit none
real, dimension(:) :: array
integer :: i
!$omp target enter data map(alloc:array)
!$omp target teams distribute parallel do
do i=1, ubound(array, 1)
array(i) = 42.0
end do
!$omp target update from(array)
end subroutine
subroutine kernel_2d(array)
implicit none
real, dimension(:,:) :: array
integer :: i, j
!$omp target enter data map(alloc:array)
!$omp target teams distribute parallel do collapse(2)
do j=1, ubound(array, 2)
do i=1, ubound(array, 1)
array(i,j) = 42.0
end do
end do
!$omp target update from(array)
end subroutine
subroutine kernel_3d(array)
implicit none
real, dimension(:,:,:) :: array
integer :: i, j, k
!$omp target enter data map(alloc:array)
!$omp target teams distribute parallel do collapse(3)
do k=1, ubound(array, 3)
do j=1, ubound(array, 2)
do i=1, ubound(array, 1)
array(i,j,k) = 42.0
end do
end do
end do
!$omp target update from(array)
end subroutine
subroutine kernel_4d(array)
implicit none
real, dimension(:,:,:,:) :: array
integer :: i, j, k, l
!$omp target enter data map(alloc:array)
!$omp target teams distribute parallel do collapse(4)
do l=1, ubound(array, 4)
do k=1, ubound(array, 3)
do j=1, ubound(array, 2)
do i=1, ubound(array, 1)
array(i,j,k,l) = 42.0
end do
end do
end do
enddo
!$omp target update from(array)
end subroutine
end module
program main
use test
implicit none
integer, parameter :: n = 2
real :: array1(n)
real :: array2(n,n)
real :: array3(n,n,n)
real :: array4(n,n,n,n)
call kernel_1d(array1)
call kernel_2d(array2)
call kernel_3d(array3)
call kernel_4d(array4)
print *, array1
print *, array2
print *, array3
print *, array4
print *, "PASS"
end program
! CHECK: 42. 42.
! CHECK: 42. 42. 42. 42.
! CHECK: 42. 42. 42. 42. 42. 42. 42. 42.
! CHECK: 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42.
! CHECK: PASS
|