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
|
! { dg-do run }
program test
implicit none
integer, parameter :: N = 100
integer :: x(N), y(N), z(N)
integer :: i
do i = 1, N
x(i) = i;
y(i) = -i;
end do
call f (x, y, z)
do i = 1, N
if (z(i) .ne. x(i) * y(i)) stop 1
end do
! -----
do i = 1, N
x(i) = i;
y(i) = -i;
end do
call g (x, y, z)
do i = 1, N
if (z(i) .ne. x(i) * y(i)) stop 1
end do
contains
subroutine f (x, y, z)
integer :: x(N), y(N), z(N)
!$omp target map (to: x, y) map(from: z)
block
!$omp metadirective &
!$omp& when(device={arch("nvptx")}: teams loop) &
!$omp& default(parallel loop)
do i = 1, N
z(i) = x(i) * y(i)
enddo
end block
end subroutine
subroutine g (x, y, z)
integer :: x(N), y(N), z(N)
!$omp target map (to: x, y) map(from: z)
block
!$omp metadirective &
!$omp& when(device={arch("nvptx")}: teams loop) &
!$omp& default(parallel loop)
do i = 1, N
z(i) = x(i) * y(i)
enddo
end block
!$omp end target
end subroutine
end program
|