aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/gomp/atomic.f90
blob: ca1279655700c37724bdb1f8ad90d490817d04f6 (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
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
! { dg-do compile }
! { dg-additional-options "-fdump-tree-original" }

! { dg-final { scan-tree-dump-times "#pragma omp atomic relaxed" 4 "original" } }
! { dg-final { scan-tree-dump-times "#pragma omp atomic release" 4 "original" } }
! { dg-final { scan-tree-dump-times "v = #pragma omp atomic capture relaxed" 4 "original" } }
! { dg-final { scan-tree-dump-times "v = #pragma omp atomic capture release" 2 "original" } }
! { dg-final { scan-tree-dump-times "v = #pragma omp atomic read acquire" 1 "original" } }

! { dg-final { scan-tree-dump-times "#pragma omp atomic seq_cst" 7 "original" } }
! { dg-final { scan-tree-dump-times "v = #pragma omp atomic read seq_cst" 3 "original" } }
! { dg-final { scan-tree-dump-times "v = #pragma omp atomic capture seq_cst" 6 "original" } }

subroutine foo ()
  integer :: x, v
  !$omp atomic
  i = i + 2

  !$omp atomic relaxed
  i = i + 2

  !$omp atomic seq_cst read
  v = x
  !$omp atomic seq_cst, read
  v = x
  !$omp atomic seq_cst write
  x = v
  !$omp atomic seq_cst ,write
  x = v
  !$omp atomic seq_cst update
  x = x + v
  !$omp atomic seq_cst , update
  x = x + v
  !$omp atomic seq_cst capture
  x = x + 2
  v = x
  !$omp end atomic
  !$omp atomic seq_cst, capture
  x = x + 2
  v = x
  !$omp end atomic
  !$omp atomic read , seq_cst
  v = x
  !$omp atomic write ,seq_cst
  x = v
  !$omp atomic update, seq_cst
  x = x + v
  !$omp atomic capture, seq_cst
  x = x + 2
  v = x
  !$omp end atomic
end

subroutine bar
  integer :: i, v
  real :: f
  !$omp atomic release, hint (0), update
  i = i + 1
  !$omp end atomic
  !$omp atomic hint(0)seq_cst
  i = i + 1
  !$omp atomic relaxed,update,hint (0)
  i = i + 1
  !$omp atomic release
  i = i + 1
  !$omp atomic relaxed
  i = i + 1
  !$omp atomic relaxed capture
  i = i + 1
  v = i
  !$omp end atomic
  !$omp atomic capture,release , hint (1)
  i = i + 1
  v = i
  !$omp end atomic
  !$omp atomic hint(0),relaxed capture
  i = i + 1
  v = i
  !$omp end atomic
  !$omp atomic read acquire
  v = i
  !$omp atomic release,write
  i = v
  !$omp atomic hint(1),update,release
  f = f + 2.0
end

subroutine openmp51_foo
  integer :: x, v
  !$omp atomic update seq_cst capture
  x = x + 2
  v = x
  !$omp end atomic
  !$omp atomic seq_cst, capture, update
  x = x + 2
  v = x
  !$omp end atomic
  !$omp atomic capture, seq_cst ,update
  x = x + 2
  v = x
  !$omp end atomic
end

subroutine openmp51_bar
  integer :: i, v
  real :: f
  !$omp atomic relaxed capture update
  i = i + 1
  v = i
  !$omp end atomic
  !$omp atomic update capture,release , hint (1)
  i = i + 1
  v = i
  !$omp end atomic
  !$omp atomic hint(0),update relaxed capture
  i = i + 1
  v = i
  !$omp end atomic
end