|
| 1 | +! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=51 |
| 2 | + use omp_lib |
| 3 | + implicit none |
| 4 | + ! Check atomic compare. This combines elements from multiple other "atomic*.f90", as |
| 5 | + ! to avoid having several files with just a few lines in them. atomic compare needs |
| 6 | + ! higher openmp version than the others, so need a separate file. |
| 7 | + |
| 8 | + |
| 9 | + real a, b |
| 10 | + logical r |
| 11 | + a = 1.0 |
| 12 | + b = 2.0 |
| 13 | + !$omp parallel num_threads(4) |
| 14 | + ! First a few things that should compile without error. |
| 15 | + !$omp atomic seq_cst, compare |
| 16 | + r = b .ne. a |
| 17 | + |
| 18 | + !$omp atomic seq_cst compare |
| 19 | + r = a .ge. b |
| 20 | + !$omp end atomic |
| 21 | + |
| 22 | + !$omp atomic compare acquire hint(OMP_LOCK_HINT_CONTENDED) |
| 23 | + r = a .lt. b |
| 24 | + |
| 25 | + !$omp atomic release hint(OMP_LOCK_HINT_UNCONTENDED) compare |
| 26 | + r = a .gt. b |
| 27 | + |
| 28 | + !$omp atomic compare seq_cst |
| 29 | + r = b .ne. a |
| 30 | + |
| 31 | + !$omp atomic hint(1) acq_rel compare |
| 32 | + r = b .eq. a |
| 33 | + !$omp end atomic |
| 34 | + |
| 35 | + ! Check for error conidtions: |
| 36 | + !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct |
| 37 | + !ERROR: At most one SEQ_CST clause can appear on the COMPARE directive |
| 38 | + !$omp atomic seq_cst seq_cst compare |
| 39 | + r = a .le. b |
| 40 | + !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct |
| 41 | + !ERROR: At most one SEQ_CST clause can appear on the COMPARE directive |
| 42 | + !$omp atomic compare seq_cst seq_cst |
| 43 | + r = b .gt. a |
| 44 | + !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct |
| 45 | + !ERROR: At most one SEQ_CST clause can appear on the COMPARE directive |
| 46 | + !$omp atomic seq_cst compare seq_cst |
| 47 | + r = b .ge. b |
| 48 | + |
| 49 | + !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct |
| 50 | + !ERROR: At most one ACQUIRE clause can appear on the COMPARE directive |
| 51 | + !$omp atomic acquire acquire compare |
| 52 | + r = a .le. b |
| 53 | + !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct |
| 54 | + !ERROR: At most one ACQUIRE clause can appear on the COMPARE directive |
| 55 | + !$omp atomic compare acquire acquire |
| 56 | + r = b .gt. a |
| 57 | + !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct |
| 58 | + !ERROR: At most one ACQUIRE clause can appear on the COMPARE directive |
| 59 | + !$omp atomic acquire compare acquire |
| 60 | + r = b .ge. b |
| 61 | + |
| 62 | + !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct |
| 63 | + !ERROR: At most one RELAXED clause can appear on the COMPARE directive |
| 64 | + !$omp atomic relaxed relaxed compare |
| 65 | + r = a .le. b |
| 66 | + !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct |
| 67 | + !ERROR: At most one RELAXED clause can appear on the COMPARE directive |
| 68 | + !$omp atomic compare relaxed relaxed |
| 69 | + r = b .gt. a |
| 70 | + !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct |
| 71 | + !ERROR: At most one RELAXED clause can appear on the COMPARE directive |
| 72 | + !$omp atomic relaxed compare relaxed |
| 73 | + r = b .ge. b |
| 74 | + |
| 75 | + !$omp end parallel |
| 76 | +end |
0 commit comments