[flang-commits] [flang] [flang][OpenMP]Add parsing and semantics support for ATOMIC COMPARE (PR #117032)

Mats Petersson via flang-commits flang-commits at lists.llvm.org
Thu Nov 28 07:51:13 PST 2024


================
@@ -0,0 +1,78 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp-version=51 %openmp_flags
+  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
+
+  ! Check for error conidtions:
----------------
Leporacanthicus wrote:

Well, test didn't work, so needed a change anyway! :) Fingers crossed I figured out what is needed now... :crossed_fingers: 

https://github.com/llvm/llvm-project/pull/117032


More information about the flang-commits mailing list