summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.fortran/is_device_ptr-1.f90
blob: 30a927a19ba199e312acf9a115d821aa27a1d400 (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
! { dg-additional-options "-fdump-tree-original" }

! PR fortran/98476

program abc
  implicit none
  integer a, b

  a = 83
  b = 73
  call test(a, b)

contains
  subroutine test(aa, bb)
    use iso_c_binding, only: c_ptr, c_loc, c_f_pointer
    integer :: aa, bb
    integer, target :: cc, dd
    type(c_ptr) :: pcc, pdd
    cc = 131
    dd = 484

    !$omp target enter data map(to: aa, bb, cc, dd)

    !$omp target data use_device_ptr(aa, cc) use_device_addr(bb, dd)
      pcc = c_loc(cc)
      pdd = c_loc(dd)

      ! TODO: has_device_addr(cc, dd)
      !$omp target is_device_ptr(aa, bb)
        if (aa /= 83 .or. bb /= 73) stop 1
        aa = 42
        bb = 43
        block
          integer, pointer :: c2, d2
          call c_f_pointer(pcc, c2)
          call c_f_pointer(pdd, d2)
          if (c2 /= 131 .or. d2 /= 484) stop 2
          c2 = 44
          d2 = 45
        end block
      !$omp end target
    !$omp end target data

    !$omp target exit data map(from:aa, bb, cc, dd)

    if (aa /= 42 .or. bb /= 43) stop 3
    if (cc /= 44 .or. dd /= 45) stop 5
  endsubroutine
end program

! { dg-final { scan-tree-dump-times "omp target data .*use_device_addr\\(aa\\)" 1 "original" } }
! { dg-final { scan-tree-dump-times "omp target data .*use_device_addr\\(bb\\)" 1 "original" } }
! { dg-final { scan-tree-dump-times "omp target data .*use_device_addr\\(cc\\)" 1 "original" } }
! { dg-final { scan-tree-dump-times "omp target data .*use_device_addr\\(dd\\)" 1 "original" } }