Add regression test
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-fortran / data-2.f90
blobec206958e23cf2b798acdccfb039d6404be81905
1 ! { dg-do run }
3 program test
4 use openacc
5 integer, parameter :: N = 8
6 real, allocatable :: a(:,:), b(:,:)
7 real, allocatable :: c(:), d(:)
8 integer i, j
10 i = 0
11 j = 0
13 allocate (a(N,N))
14 allocate (b(N,N))
16 a(:,:) = 3.0
17 b(:,:) = 0.0
19 !$acc enter data copyin (a(1:N,1:N), b(1:N,1:N))
21 !$acc parallel
22 do i = 1, n
23 do j = 1, n
24 b(j,i) = a (j,i)
25 end do
26 end do
27 !$acc end parallel
29 !$acc exit data copyout (a(1:N,1:N), b(1:N,1:N))
31 do i = 1, n
32 do j = 1, n
33 if (a(j,i) .ne. 3.0) STOP 1
34 if (b(j,i) .ne. 3.0) STOP 2
35 end do
36 end do
38 allocate (c(N))
39 allocate (d(N))
41 c(:) = 3.0
42 d(:) = 0.0
44 !$acc enter data copyin (c(1:N)) create (d(1:N)) async
45 !$acc wait
47 !$acc parallel
48 do i = 1, N
49 d(i) = c(i) + 1
50 end do
51 !$acc end parallel
53 !$acc exit data copyout (c(1:N), d(1:N)) async
54 !$acc wait
56 do i = 1, N
57 if (d(i) .ne. 4.0) STOP 3
58 end do
60 c(:) = 3.0
61 d(:) = 0.0
63 !$acc enter data copyin (c(1:N)) async
64 !$acc enter data create (d(1:N)) wait
65 !$acc wait
67 !$acc parallel
68 do i = 1, N
69 d(i) = c(i) + 1
70 end do
71 !$acc end parallel
73 !$acc exit data copyout (d(1:N)) async
74 !$acc exit data async
75 !$acc wait
77 do i = 1, N
78 if (d(i) .ne. 4.0) STOP 4
79 end do
81 end program test