summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/gomp/declare-target-4.f90
blob: 4f5de4bd8c7e226dab9b23974d246658e4be4229 (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
83
84
85
86
! { dg-do compile }
! { dg-additional-options "-fdump-tree-original" }

subroutine f1
  !$omp declare target device_type (any)  ! { dg-warning "OMP DECLARE TARGET directive at .1. with only DEVICE_TYPE clause is ignored" }
end subroutine

subroutine f2
  !$omp declare target to (f2) device_type (any)
end subroutine

subroutine f3
  !$omp declare target device_type (any) to (f3)
end subroutine

subroutine f4
  !$omp declare target device_type (host) to (f4)
end subroutine

subroutine f5
  !$omp declare target device_type (nohost) to (f5)
end subroutine

subroutine f6
  !$omp declare target enter (f6) device_type (any)
end subroutine

module mymod
  ! device_type is ignored for variables in OpenMP 5.0
  ! but TR8 and later apply those rules to variables as well
  implicit none
  integer :: a, b(4), c, d
  integer :: e, f, g
  integer :: m, n, o, p, q, r, s, t, u, v, w, x
  common /block1/ m, n
  common /block2/ o, p
  common /block3/ q, r
  common /block4/ s, t
  common /block5/ u, v
  common /block6/ w, x

  !$omp declare target to(a) device_type(nohost)
  !$omp declare target to(b) device_type(host)
  !$omp declare target to(c) device_type(any)
 ! Fails in ME with "Error: wrong number of arguments specified for 'omp declare target link' attribute"
 ! !$omp declare target link(e) device_type(nohost)
 ! !$omp declare target link(f) device_type(host)
 ! !$omp declare target link(g) device_type(any)

  !$omp declare target to(/block1/) device_type(nohost)
  !$omp declare target to(/block2/) device_type(host)
  !$omp declare target to(/block3/) device_type(any)
  !$omp declare target link(/block4/) device_type(nohost)
  !$omp declare target link(/block5/) device_type(host)
  !$omp declare target link(/block6/) device_type(any)
contains
  subroutine s1
    !$omp declare target to (s1) device_type (any)
  end
  subroutine s2
    !$omp declare target to (s2) device_type (nohost)
  end
  subroutine s3
    !$omp declare target to (s3) device_type (host)
  end
end module

module m2
  use mymod
  implicit none
  public
  private :: s1, s2, s3, a, b, c, d, e, f, g
  public :: m, n, o, p, q, r, s, t, u, v, w, x
end module m2

! { dg-final { scan-tree-dump-times "omp declare target" 8 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(" 8 "original" } }
! { dg-final { scan-tree-dump-not "__attribute__\\(\\(omp declare target \[^\n\r\]*\[\n\r\]void f1" "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(any\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r]void f2" 1 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(any\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r\]void f3" 1 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(host\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r\]void f4" 1 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(nohost\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r\]void f5" 1 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(any\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r]void f6" 1 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(any\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r\]void s1" 1 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(nohost\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r\]void s2" 1 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(host\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r\]void s3" 1 "original" } }