File: atomic-compare.f90

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,388 kB
  • sloc: cpp: 7,438,767; ansic: 1,393,871; asm: 1,012,926; python: 241,728; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (92 lines) | stat: -rw-r--r-- 3,328 bytes parent folder | download | duplicates (2)
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
! REQUIRES: openmp_runtime
! RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags -fopenmp-version=51
  use omp_lib
  implicit none
  ! Check atomic compare. This combines elements from multiple other "atomic*.f90", as
  ! to avoid having several files with just a few lines in them. atomic compare needs
  ! higher openmp version than the others, so need a separate file.
  

  real a, b, c
  a = 1.0
  b = 2.0
  c = 3.0
  !$omp parallel num_threads(4)
  ! First a few things that should compile without error.
  !$omp atomic seq_cst, compare
  if (b .eq. a) then
     b = c
  end if

  !$omp atomic seq_cst compare
  if (a .eq. b) a = c
  !$omp end atomic

  !$omp atomic compare acquire hint(OMP_LOCK_HINT_CONTENDED)
  if (b .eq. a) b = c

  !$omp atomic release hint(OMP_LOCK_HINT_UNCONTENDED) compare
  if (b .eq. a) b = c

  !$omp atomic compare seq_cst
  if (b .eq. c) b = a

  !$omp atomic hint(1) acq_rel compare
  if (b .eq. a) b = c
  !$omp end atomic

  !$omp atomic hint(1) acq_rel compare fail(release)
  if (c .eq. a) a = b
  !$omp end atomic

  !$omp atomic compare fail(release)
  if (c .eq. a) a = b
  !$omp end atomic

  ! Check for error conditions:
  !ERROR: More than one memory order clause not allowed on OpenMP ATOMIC construct
  !ERROR: At most one SEQ_CST clause can appear on the COMPARE directive
  !$omp atomic seq_cst seq_cst compare
  if (b .eq. c) b = a
  !ERROR: More than one memory order clause not allowed on OpenMP ATOMIC construct
  !ERROR: At most one SEQ_CST clause can appear on the COMPARE directive
  !$omp atomic compare seq_cst seq_cst
  if (b .eq. c) b = a
  !ERROR: More than one memory order clause not allowed on OpenMP ATOMIC construct
  !ERROR: At most one SEQ_CST clause can appear on the COMPARE directive
  !$omp atomic seq_cst compare seq_cst
  if (b .eq. c) b = a

  !ERROR: More than one memory order clause not allowed on OpenMP ATOMIC construct
  !ERROR: At most one ACQUIRE clause can appear on the COMPARE directive
  !$omp atomic acquire acquire compare
  if (b .eq. c) b = a
  !ERROR: More than one memory order clause not allowed on OpenMP ATOMIC construct
  !ERROR: At most one ACQUIRE clause can appear on the COMPARE directive
  !$omp atomic compare acquire acquire
  if (b .eq. c) b = a
  !ERROR: More than one memory order clause not allowed on OpenMP ATOMIC construct
  !ERROR: At most one ACQUIRE clause can appear on the COMPARE directive
  !$omp atomic acquire compare acquire
  if (b .eq. c) b = a

  !ERROR: More than one memory order clause not allowed on OpenMP ATOMIC construct
  !ERROR: At most one RELAXED clause can appear on the COMPARE directive
  !$omp atomic relaxed relaxed compare
  if (b .eq. c) b = a
  !ERROR: More than one memory order clause not allowed on OpenMP ATOMIC construct
  !ERROR: At most one RELAXED clause can appear on the COMPARE directive
  !$omp atomic compare relaxed relaxed
  if (b .eq. c) b = a
  !ERROR: More than one memory order clause not allowed on OpenMP ATOMIC construct
  !ERROR: At most one RELAXED clause can appear on the COMPARE directive
  !$omp atomic relaxed compare relaxed
  if (b .eq. c) b = a

  !ERROR: More than one FAIL clause not allowed on OpenMP ATOMIC construct
  !$omp atomic fail(release) compare fail(release)
  if (c .eq. a) a = b
  !$omp end atomic

  !$omp end parallel
end