File: single.f90

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (121 lines) | stat: -rw-r--r-- 4,635 bytes parent folder | download | duplicates (3)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
!RUN: bbc -emit-fir -fopenmp %s -o - | FileCheck %s

!===============================================================================
! Single construct
!===============================================================================

!CHECK-LABEL: func @_QPomp_single
!CHECK-SAME: (%[[x:.*]]: !fir.ref<i32> {fir.bindc_name = "x"})
subroutine omp_single(x)
  integer, intent(inout) :: x
  !CHECK: omp.parallel
  !$omp parallel
  !CHECK: omp.single
  !$omp single
    !CHECK: %[[xval:.*]] = fir.load %[[x]] : !fir.ref<i32>
    !CHECK: %[[res:.*]] = arith.addi %[[xval]], %{{.*}} : i32
    !CHECK: fir.store %[[res]] to %[[x]] : !fir.ref<i32>
    x = x + 12
  !CHECK: omp.terminator
  !$omp end single
  !CHECK: omp.terminator
  !$omp end parallel
end subroutine omp_single

!===============================================================================
! Single construct with nowait
!===============================================================================

!CHECK-LABEL: func @_QPomp_single_nowait
!CHECK-SAME: (%[[x:.*]]: !fir.ref<i32> {fir.bindc_name = "x"})
subroutine omp_single_nowait(x)
  integer, intent(inout) :: x
  !CHECK: omp.parallel
  !$omp parallel
  !CHECK: omp.single nowait
  !$omp single
    !CHECK: %[[xval:.*]] = fir.load %[[x]] : !fir.ref<i32>
    !CHECK: %[[res:.*]] = arith.addi %[[xval]], %{{.*}} : i32
    !CHECK: fir.store %[[res]] to %[[x]] : !fir.ref<i32>
    x = x + 12
  !CHECK: omp.terminator
  !$omp end single nowait
  !CHECK: omp.terminator
  !$omp end parallel
end subroutine omp_single_nowait

!===============================================================================
! Single construct with allocate
!===============================================================================

!CHECK-LABEL: func @_QPsingle_allocate
subroutine single_allocate()
  use omp_lib
  integer :: x
  !CHECK: omp.parallel {
  !$omp parallel
  !CHECK: omp.single allocate(%{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>) {
  !$omp single allocate(omp_high_bw_mem_alloc: x) private(x)
  !CHECK: arith.addi
  x = x + 12
  !CHECK: omp.terminator
  !$omp end single
  !CHECK: omp.terminator
  !$omp end parallel
end subroutine single_allocate

!===============================================================================
! Single construct with private/firstprivate
!===============================================================================

! CHECK-LABEL: func.func @_QPsingle_privatization(
! CHECK-SAME:                                     %[[VAL_0:.*]]: !fir.ref<f32> {fir.bindc_name = "x"},
! CHECK-SAME:                                     %[[VAL_1:.*]]: !fir.ref<f64> {fir.bindc_name = "y"}) {
! CHECK:         omp.single   {
! CHECK:           %[[VAL_2:.*]] = fir.alloca f32 {bindc_name = "x", pinned, uniq_name = "_QFsingle_privatizationEx"}
! CHECK:           %[[VAL_3:.*]] = fir.alloca f64 {bindc_name = "y", pinned, uniq_name = "_QFsingle_privatizationEy"}
! CHECK:           %[[VAL_4:.*]] = fir.load %[[VAL_1]] : !fir.ref<f64>
! CHECK:           fir.store %[[VAL_4]] to %[[VAL_3]] : !fir.ref<f64>
! CHECK:           fir.call @_QPbar(%[[VAL_2]], %[[VAL_3]]) {{.*}}: (!fir.ref<f32>, !fir.ref<f64>) -> ()
! CHECK:           omp.terminator
! CHECK:         }
! CHECK:         return
! CHECK:       }

subroutine single_privatization(x, y)
  real :: x
  real(8) :: y

  !$omp single private(x) firstprivate(y)
  call bar(x, y)
  !$omp end single
end subroutine

! CHECK-LABEL: func.func @_QPsingle_privatization2(
! CHECK-SAME:                                      %[[VAL_0:.*]]: !fir.ref<f32> {fir.bindc_name = "x"},
! CHECK-SAME:                                      %[[VAL_1:.*]]: !fir.ref<f64> {fir.bindc_name = "y"}) {
! CHECK:         omp.parallel   {
! CHECK:           omp.single   {
! CHECK:             %[[VAL_2:.*]] = fir.alloca f32 {bindc_name = "x", pinned, uniq_name = "_QFsingle_privatization2Ex"}
! CHECK:             %[[VAL_3:.*]] = fir.alloca f64 {bindc_name = "y", pinned, uniq_name = "_QFsingle_privatization2Ey"}
! CHECK:             %[[VAL_4:.*]] = fir.load %[[VAL_1]] : !fir.ref<f64>
! CHECK:             fir.store %[[VAL_4]] to %[[VAL_3]] : !fir.ref<f64>
! CHECK:             fir.call @_QPbar(%[[VAL_2]], %[[VAL_3]]) {{.*}}: (!fir.ref<f32>, !fir.ref<f64>) -> ()
! CHECK:             omp.terminator
! CHECK:           }
! CHECK:           omp.terminator
! CHECK:         }
! CHECK:         return
! CHECK:       }

subroutine single_privatization2(x, y)
  real :: x
  real(8) :: y

  !$omp parallel
  !$omp single private(x) firstprivate(y)
  call bar(x, y)
  !$omp end single
  !$omp end parallel
end subroutine