aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.fortran/examples-4/device-1.f90
blob: f7db7bdb505fdbdd0cb3be30b524e1f067521efa (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
! { dg-do run }
! { dg-require-effective-target offload_device_nonshared_as }

program e_57_1
  use omp_lib, only: omp_is_initial_device
  integer :: a, b
  logical :: c, d

  a = 100
  b = 0

  !$omp target map(from: c) if(a > 200 .and. a < 400)
    c = omp_is_initial_device ()
  !$omp end target

  !$omp target data map(to: b) if(a > 200 .and. a < 400)
    !$omp target map(from: b, d)
      b = 100
      d = omp_is_initial_device ()
    !$omp end target
  !$omp end target data

  if (b /= 100 .or. .not. c .or. d) stop 1

  a = a + 200
  b = 0

  !$omp target map(from: c) if(a > 200 .and. a < 400)
    c = omp_is_initial_device ()
  !$omp end target

  !$omp target data map(to: b) if(a > 200 .and. a < 400)
    !$omp target map(from: b, d)
      b = 100
      d = omp_is_initial_device ()
    !$omp end target
  !$omp end target data

  if (b /= 0 .or. c .or. d) stop 2

  a = a + 200
  b = 0

  !$omp target map(from: c) if(a > 200 .and. a < 400)
    c = omp_is_initial_device ()
  !$omp end target

  !$omp target data map(to: b) if(a > 200 .and. a < 400)
    !$omp target map(from: b, d)
      b = 100
      d = omp_is_initial_device ()
    !$omp end target
  !$omp end target data

  if (b /= 100 .or. .not. c .or. d) stop 3
end program