File: loop-5.f90

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (84 lines) | stat: -rw-r--r-- 2,545 bytes parent folder | download
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
! { dg-additional-options "-fdump-tree-original" }
!
! PR fortran/108512

! The problem was that the context wasn't reset for the 'LOOP'
! such that the clauses of the loops weren't seen when adding
! PRIVATE clauses.
!
! In the following, only the loop variable of the non-OpenMP loop
! in 'subroutine four' should get a front-end addded PRIVATE clause

implicit none
integer :: x, a(10), b(10), n
    n = 10
    a = -42
    b = [(2*x, x=1,10)]

! { dg-final { scan-tree-dump-times "#pragma omp target map\\(tofrom:a\\) map\\(tofrom:b\\) map\\(tofrom:x\\)\[\r\n\]" 1 "original" } }
! { dg-final { scan-tree-dump-times "#pragma omp parallel\[\r\n\]" 2 "original" } }
!  ^- shows up twice; checked only here.
! { dg-final { scan-tree-dump-times "#pragma omp loop lastprivate\\(x\\)\[\r\n\]" 1 "original" } }

    !$omp target parallel map(tofrom: a, b, x)
    !$omp loop lastprivate(x)
    DO x = 1, n
      a(x) = a(x) + b(x)
    END DO
    !$omp end loop
    !$omp end target parallel
    if (x /= 11) error stop
    if (any (a /= [(2*x - 42, x=1,10)])) error stop
    call two()
    call three()
    call four()
end

subroutine two
  implicit none
  integer :: ii, mm, arr(10)
  mm = 10
  arr = 0

! { dg-final { scan-tree-dump-times "#pragma omp target map\\(tofrom:arr\\) map\\(tofrom:ii\\)\[\r\n\]" 1 "original" } }
! { dg-final { scan-tree-dump-times "#pragma omp parallel shared\\(ii\\)\[\r\n\]" 1 "original" } }
! { dg-final { scan-tree-dump-times "#pragma omp loop lastprivate\\(ii\\)\[\r\n\]" 1 "original" } }

  !$omp target parallel loop map(tofrom: arr) lastprivate(ii)
    DO ii = 1, mm
      arr(ii) = arr(ii) + ii
    END DO
end

subroutine three
  implicit none
  integer :: kk, zz, var(10)
  zz = 10
  var = 0

! { dg-final { scan-tree-dump-times "#pragma omp target map\\(tofrom:var\\)\[\r\n\]" 1 "original" } }
! "#pragma omp parallel\[\r\n\]" - shows up twice, dump checked above
! { dg-final { scan-tree-dump-times "#pragma omp loop\[\r\n\]" 1 "original" } }

  !$omp target parallel loop map(tofrom: var)
    DO kk = 1, zz
      var(kk) = var(kk) + kk
    END DO
end

subroutine four
  implicit none
  integer :: jj, qq, dist(10)
  qq = 10
  dist = 0

! { dg-final { scan-tree-dump-times "#pragma omp target map\\(tofrom:dist\\)\[\r\n\]" 1 "original" } }
! { dg-final { scan-tree-dump-times "#pragma omp parallel private\\(jj\\)\[\r\n\]" 1 "original" } }

  !$omp target parallel map(tofrom: dist)
    ! *no* '!$omp do/loop/simd'
    DO jj = 1, qq
      dist(qq) = dist(qq) + qq
    END DO
  !$omp end target parallel
end