8a1cf5b1f6856de1125759c1032501f9e0ecc444
[gcc.git] / gcc / testsuite / gfortran.dg / gomp / atomic.f90
1 ! { dg-do compile }
2 ! { dg-additional-options "-fdump-tree-original" }
3
4 ! { dg-final { scan-tree-dump-times "#pragma omp atomic relaxed" 4 "original" } }
5 ! { dg-final { scan-tree-dump-times "#pragma omp atomic release" 4 "original" } }
6 ! { dg-final { scan-tree-dump-times "v = #pragma omp atomic capture relaxed" 4 "original" } }
7 ! { dg-final { scan-tree-dump-times "v = #pragma omp atomic capture release" 2 "original" } }
8 ! { dg-final { scan-tree-dump-times "v = #pragma omp atomic read acquire" 1 "original" } }
9
10 ! { dg-final { scan-tree-dump-times "#pragma omp atomic seq_cst" 7 "original" } }
11 ! { dg-final { scan-tree-dump-times "v = #pragma omp atomic read seq_cst" 3 "original" } }
12 ! { dg-final { scan-tree-dump-times "v = #pragma omp atomic capture seq_cst" 6 "original" } }
13
14
15 subroutine foo ()
16 integer :: x, v
17 !$omp atomic
18 i = i + 2
19
20 !$omp atomic relaxed
21 i = i + 2
22
23 !$omp atomic seq_cst read
24 v = x
25 !$omp atomic seq_cst, read
26 v = x
27 !$omp atomic seq_cst write
28 x = v
29 !$omp atomic seq_cst ,write
30 x = v
31 !$omp atomic seq_cst update
32 x = x + v
33 !$omp atomic seq_cst , update
34 x = x + v
35 !$omp atomic seq_cst capture
36 x = x + 2
37 v = x
38 !$omp end atomic
39 !$omp atomic update seq_cst capture
40 x = x + 2
41 v = x
42 !$omp end atomic
43 !$omp atomic seq_cst, capture
44 x = x + 2
45 v = x
46 !$omp end atomic
47 !$omp atomic seq_cst, capture, update
48 x = x + 2
49 v = x
50 !$omp end atomic
51 !$omp atomic read , seq_cst
52 v = x
53 !$omp atomic write ,seq_cst
54 x = v
55 !$omp atomic update, seq_cst
56 x = x + v
57 !$omp atomic capture, seq_cst
58 x = x + 2
59 v = x
60 !$omp end atomic
61 !$omp atomic capture, seq_cst ,update
62 x = x + 2
63 v = x
64 !$omp end atomic
65 end
66
67 subroutine bar
68 integer :: i, v
69 real :: f
70 !$omp atomic release, hint (0), update
71 i = i + 1
72 !$omp end atomic
73 !$omp atomic hint(0)seq_cst
74 i = i + 1
75 !$omp atomic relaxed,update,hint (0)
76 i = i + 1
77 !$omp atomic release
78 i = i + 1
79 !$omp atomic relaxed
80 i = i + 1
81 !$omp atomic relaxed capture update
82 i = i + 1
83 v = i
84 !$omp end atomic
85 !$omp atomic relaxed capture
86 i = i + 1
87 v = i
88 !$omp end atomic
89 !$omp atomic capture,release , hint (1)
90 i = i + 1
91 v = i
92 !$omp end atomic
93 !$omp atomic update capture,release , hint (1)
94 i = i + 1
95 v = i
96 !$omp end atomic
97 !$omp atomic hint(0),relaxed capture
98 i = i + 1
99 v = i
100 !$omp end atomic
101 !$omp atomic hint(0),update relaxed capture
102 i = i + 1
103 v = i
104 !$omp end atomic
105 !$omp atomic read acquire
106 v = i
107 !$omp atomic release,write
108 i = v
109 !$omp atomic hint(1),update,release
110 f = f + 2.0
111 end