| 1 |
! REQUIRES: openmp_runtime |
| 2 |
|
| 3 |
! RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags |
| 4 |
|
| 5 |
! Check OpenMP 5.0 - 2.17.8 flush Construct |
| 6 |
! Restriction - |
| 7 |
! If memory-order-clause is release, acquire, or acq_rel, list items must not be specified on the flush directive. |
| 8 |
|
| 9 |
use omp_lib |
| 10 |
implicit none |
| 11 |
|
| 12 |
TYPE someStruct |
| 13 |
REAL :: rr |
| 14 |
end TYPE |
| 15 |
integer :: i, a, b |
| 16 |
real, DIMENSION(10) :: array |
| 17 |
TYPE(someStruct) :: structObj |
| 18 |
|
| 19 |
a = 1.0 |
| 20 |
!$omp parallel num_threads(4) |
| 21 |
!No list flushes all. |
| 22 |
if (omp_get_thread_num() == 1) THEN |
| 23 |
!$omp flush |
| 24 |
END IF |
| 25 |
|
| 26 |
array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/) |
| 27 |
!Only memory-order-clauses. |
| 28 |
if (omp_get_thread_num() == 1) THEN |
| 29 |
! Not allowed clauses. |
| 30 |
!ERROR: SEQ_CST clause is not allowed on the FLUSH directive |
| 31 |
!$omp flush seq_cst |
| 32 |
!ERROR: RELAXED clause is not allowed on the FLUSH directive |
| 33 |
!$omp flush relaxed |
| 34 |
|
| 35 |
! Not allowed more than once. |
| 36 |
!ERROR: At most one ACQ_REL clause can appear on the FLUSH directive |
| 37 |
!$omp flush acq_rel acq_rel |
| 38 |
!ERROR: At most one RELEASE clause can appear on the FLUSH directive |
| 39 |
!$omp flush release release |
| 40 |
!ERROR: At most one ACQUIRE clause can appear on the FLUSH directive |
| 41 |
!$omp flush acquire acquire |
| 42 |
|
| 43 |
! Mix of allowed and not allowed. |
| 44 |
!ERROR: SEQ_CST clause is not allowed on the FLUSH directive |
| 45 |
!$omp flush seq_cst acquire |
| 46 |
END IF |
| 47 |
|
| 48 |
array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/) |
| 49 |
! No memory-order-clause only list-items. |
| 50 |
if (omp_get_thread_num() == 2) THEN |
| 51 |
!$omp flush (a) |
| 52 |
!$omp flush (i, a, b) |
| 53 |
!$omp flush (array, structObj%rr) |
| 54 |
! Too many flush with repeating list items. |
| 55 |
!$omp flush (i, a, b, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, b, b, b, b) |
| 56 |
!ERROR: No explicit type declared for 'notpresentitem' |
| 57 |
!$omp flush (notPresentItem) |
| 58 |
END IF |
| 59 |
|
| 60 |
array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/) |
| 61 |
if (omp_get_thread_num() == 3) THEN |
| 62 |
!ERROR: If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive |
| 63 |
!$omp flush acq_rel (array) |
| 64 |
!ERROR: If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive |
| 65 |
!$omp flush acq_rel (array, a, i) |
| 66 |
|
| 67 |
array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/) |
| 68 |
!ERROR: If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive |
| 69 |
!$omp flush release (array) |
| 70 |
!ERROR: If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive |
| 71 |
!$omp flush release (array, a) |
| 72 |
|
| 73 |
array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/) |
| 74 |
!ERROR: If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive |
| 75 |
!$omp flush acquire (array) |
| 76 |
!ERROR: If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive |
| 77 |
!$omp flush acquire (array, a, structObj%rr) |
| 78 |
END IF |
| 79 |
!$omp end parallel |
| 80 |
|
| 81 |
!$omp parallel num_threads(4) |
| 82 |
array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/) |
| 83 |
!$omp master |
| 84 |
!$omp flush (array) |
| 85 |
!$omp end master |
| 86 |
!$omp end parallel |
| 87 |
end |
| 88 |
|