84 lines · plain
1! REQUIRES: openmp_runtime2! RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags -fopenmp-version=513 use omp_lib4 implicit none5 ! Check atomic compare. This combines elements from multiple other "atomic*.f90", as6 ! to avoid having several files with just a few lines in them. atomic compare needs7 ! higher openmp version than the others, so need a separate file.8 9 10 real a, b, c11 a = 1.012 b = 2.013 c = 3.014 !$omp parallel num_threads(4)15 ! First a few things that should compile without error.16 !$omp atomic seq_cst, compare17 if (b .eq. a) then18 b = c19 end if20 21 !$omp atomic seq_cst compare22 if (a .eq. b) a = c23 !$omp end atomic24 25 !$omp atomic compare acquire hint(OMP_LOCK_HINT_CONTENDED)26 if (b .eq. a) b = c27 28 !$omp atomic release hint(OMP_LOCK_HINT_UNCONTENDED) compare29 if (b .eq. a) b = c30 31 !$omp atomic compare seq_cst32 if (b .eq. c) b = a33 34 !$omp atomic hint(1) acq_rel compare35 if (b .eq. a) b = c36 !$omp end atomic37 38 !$omp atomic hint(1) acq_rel compare fail(release)39 if (c .eq. a) a = b40 !$omp end atomic41 42 !$omp atomic compare fail(release)43 if (c .eq. a) a = b44 !$omp end atomic45 46 ! Check for error conditions:47 !ERROR: At most one SEQ_CST clause can appear on the ATOMIC directive48 !$omp atomic seq_cst seq_cst compare49 if (b .eq. c) b = a50 !ERROR: At most one SEQ_CST clause can appear on the ATOMIC directive51 !$omp atomic compare seq_cst seq_cst52 if (b .eq. c) b = a53 !ERROR: At most one SEQ_CST clause can appear on the ATOMIC directive54 !$omp atomic seq_cst compare seq_cst55 if (b .eq. c) b = a56 57 !ERROR: At most one ACQUIRE clause can appear on the ATOMIC directive58 !$omp atomic acquire acquire compare59 if (b .eq. c) b = a60 !ERROR: At most one ACQUIRE clause can appear on the ATOMIC directive61 !$omp atomic compare acquire acquire62 if (b .eq. c) b = a63 !ERROR: At most one ACQUIRE clause can appear on the ATOMIC directive64 !$omp atomic acquire compare acquire65 if (b .eq. c) b = a66 67 !ERROR: At most one RELAXED clause can appear on the ATOMIC directive68 !$omp atomic relaxed relaxed compare69 if (b .eq. c) b = a70 !ERROR: At most one RELAXED clause can appear on the ATOMIC directive71 !$omp atomic compare relaxed relaxed72 if (b .eq. c) b = a73 !ERROR: At most one RELAXED clause can appear on the ATOMIC directive74 !$omp atomic relaxed compare relaxed75 if (b .eq. c) b = a76 77 !ERROR: At most one FAIL clause can appear on the ATOMIC directive78 !$omp atomic fail(release) compare fail(release)79 if (c .eq. a) a = b80 !$omp end atomic81 82 !$omp end parallel83end84