aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.oacc-fortran/lib-14.f90
blob: bf35631c96bc00cf4f05c2648a030324fed62ba8 (plain)
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
! Exercise the data movement runtime library functions on non-shared memory
! targets.

! { dg-do run { target openacc_nvidia_accel_selected } }

program main
  use openacc
  implicit none

  integer, parameter :: N = 256
  integer, allocatable :: h(:)
  integer :: i

  allocate (h(N))

  do i = 1, N
    h(i) = i
  end do 

  call acc_present_or_copyin (h)

  if (acc_is_present (h) .neqv. .TRUE.) stop 1

  call acc_copyout (h)

  if (acc_is_present (h) .neqv. .FALSE.) stop 1

  do i = 1, N
    if (h(i) /= i) stop 1
  end do

  do i = 1, N
    h(i) = i + i
  end do 

  call acc_pcopyin (h, sizeof (h))

  if (acc_is_present (h) .neqv. .TRUE.) stop 1

  call acc_copyout (h)

  if (acc_is_present (h) .neqv. .FALSE.) stop 1

  do i = 1, N
    if (h(i) /= i + i) stop 1
  end do

  call acc_create (h)

  if (acc_is_present (h) .neqv. .TRUE.) stop 1

  !$acc parallel loop
    do i = 1, N
      h(i) = i
    end do
  !$end acc parallel

  call acc_copyout (h)

  if (acc_is_present (h) .neqv. .FALSE.) stop 1

  do i = 1, N
    if (h(i) /= i) stop 1
  end do

  call acc_present_or_create (h, sizeof (h))

  if (acc_is_present (h) .neqv. .TRUE.) stop 1

  call acc_delete (h)

  if (acc_is_present (h) .neqv. .FALSE.) stop 1

  call acc_pcreate (h)

  if (acc_is_present (h) .neqv. .TRUE.) stop 1

  call acc_delete (h)

  if (acc_is_present (h) .neqv. .FALSE.) stop 1

end program