switch (op) {
case parser::DefinedOperator::IntrinsicOperator::Add:
- case parser::DefinedOperator::IntrinsicOperator::Subtract:
case parser::DefinedOperator::IntrinsicOperator::Multiply:
case parser::DefinedOperator::IntrinsicOperator::AND:
case parser::DefinedOperator::IntrinsicOperator::OR:
case parser::DefinedOperator::IntrinsicOperator::EQV:
case parser::DefinedOperator::IntrinsicOperator::NEQV:
return true;
+ case parser::DefinedOperator::IntrinsicOperator::Subtract:
+ context_.Say(GetContext().clauseSource,
+ "The minus reduction operator is deprecated since OpenMP 5.2 and is not supported in the REDUCTION clause."_err_en_US,
+ ContextDirectiveAsFortran());
+ break;
default:
context_.Say(GetContext().clauseSource,
"Invalid reduction operator in REDUCTION clause."_err_en_US,
+++ /dev/null
-! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
-! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
-
-! CHECK: not yet implemented: Reduction of some intrinsic operators is not supported
-subroutine reduction_subtract
- integer :: x
- !$omp parallel
- !$omp do reduction(-:x)
- do i=1, 100
- x = x - i
- end do
- !$omp end do
- !$omp end parallel
- print *, x
-end subroutine
!$omp end do
!$omp end parallel
- !$omp parallel reduction(-:a)
+ !$omp parallel reduction(*:a)
!ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
!$omp do firstprivate(a,b)
do i = 1, 10
- c(i) = c(i) - a(i) * b(i) * i
+ c(i) = c(i) * a(i) * b(i) * i
end do
!$omp end do
!$omp end parallel
!$omp end sections
!$omp end parallel
- !$omp parallel reduction(-:a)
+ !$omp parallel reduction(*:a)
!ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
!$omp task firstprivate(a,b)
- c = c - a * b
+ c = c * a * b
!$omp end task
!$omp end parallel
--- /dev/null
+! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
+! OpenMP Version 5.2
+! Minus operation is deprecated in reduction
+
+subroutine reduction_subtract
+ integer :: x
+ !ERROR: The minus reduction operator is deprecated since OpenMP 5.2 and is not supported in the REDUCTION clause.
+ !$omp do reduction(-:x)
+ do i=1, 100
+ x = x - i
+ end do
+ !$omp end do
+end subroutine
integer :: j = 10
!ERROR: 'k' appears in more than one data-sharing clause on the same OpenMP directive
- !$omp parallel do reduction(+:k), reduction(-:k)
+ !$omp parallel do reduction(+:k), reduction(*:k)
do i = 1, 10
k = k + 1
+ k = k * 3
end do
!$omp end parallel do
!ERROR: 'k' appears in more than one data-sharing clause on the same OpenMP directive
- !$omp parallel do reduction(+:k), reduction(-:j), reduction(+:k)
+ !$omp parallel do reduction(+:k), reduction(*:j), reduction(+:k)
do i = 1, 10
k = k + 1
+ j = j * 3
end do
!$omp end parallel do
!ERROR: 'k' appears in more than one data-sharing clause on the same OpenMP directive
- !$omp parallel do reduction(+:j), reduction(-:k), reduction(+:k)
+ !$omp parallel do reduction(+:j), reduction(*:k), reduction(+:k)
do i = 1, 10
+ j = j + 1
k = k + 1
+ k = k * 3
end do
!$omp end parallel do
!ERROR: 'k' appears in more than one data-sharing clause on the same OpenMP directive
- !$omp parallel do reduction(+:j), reduction(-:k), private(k)
+ !$omp parallel do reduction(+:j), reduction(*:k), private(k)
do i = 1, 10
+ j = j + 1
k = k + 1
+ k = k * 3
end do
!$omp end parallel do
end program omp_reduction
!$omp end parallel do
!ERROR: Variable 'c' on the REDUCTION clause is not definable
- !$omp parallel do reduction(-:/c/)
+ !$omp parallel do reduction(*:/c/)
do i = 1, 10
l = k + 1
end do
! 2.15.3.6 Reduction Clause
program omp_reduction
- integer :: i,j,l
+ integer :: a,i,j,l
integer :: k = 10
!$omp parallel private(k)
!ERROR: REDUCTION variable 'k' is PRIVATE in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
!$omp end parallel
- !$omp parallel private(j),reduction(-:k)
+ !$omp parallel private(j),reduction(+:k)
!ERROR: REDUCTION variable 'k' is REDUCTION in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
!$omp do reduction(+:k)
do i = 1, 10
!$omp parallel private(l,j),firstprivate(k)
!ERROR: REDUCTION variable 'k' is FIRSTPRIVATE in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
!ERROR: REDUCTION variable 'j' is PRIVATE in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
- !$omp sections reduction(ior:k) reduction(-:j)
+ !$omp sections reduction(ior:k) reduction(*:j)
do i = 1, 10
- k = k + 1
+ k = ior(k, 1)
+ j = j * 3
end do
!$omp end sections
!$omp end parallel
!$omp parallel reduction(+:a)
!ERROR: REDUCTION variable 'a' is REDUCTION in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
-!$omp sections reduction(-:a)
-a = 10
+!$omp sections reduction(*:a)
+a = a + 10
!$omp end sections
!$omp end parallel
-!$omp parallel reduction(-:a)
+!$omp parallel reduction(*:a)
!$omp end parallel
!$omp parallel reduction(+:a)
!ERROR: REDUCTION clause is not allowed on the WORKSHARE directive
!ERROR: REDUCTION variable 'a' is REDUCTION in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
-!$omp workshare reduction(-:a)
-a = 10
+!$omp workshare reduction(*:a)
+a = a + 10
!$omp end workshare
!$omp end parallel
-!$omp parallel reduction(-:a)
+!$omp parallel reduction(*:a)
!$omp end parallel
!$omp parallel reduction(+:a)
!ERROR: REDUCTION clause is not allowed on the SINGLE directive
!ERROR: REDUCTION variable 'a' is REDUCTION in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
-!$omp single reduction(-:a)
-a = 10
+!$omp single reduction(*:a)
+a = a + 10
!$omp end single
!$omp end parallel
-!$omp parallel reduction(-:a)
+!$omp parallel reduction(+:a)
!$omp end parallel
!ERROR: REDUCTION clause is not allowed on the SINGLE directive
!ERROR: REDUCTION variable 'a' is REDUCTION in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
!$omp single reduction(iand:a)
-a = 10
+a = a + 10
!$omp end single
!$omp end parallel
!$omp parallel reduction(ieor:a)
!ERROR: REDUCTION variable 'a' is REDUCTION in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
-!$omp sections reduction(-:a)
-a = 10
+!$omp sections reduction(+:a)
+a = ieor(a, 10)
!$omp end sections
!$omp end parallel
!$omp end do
!$omp end parallel
- !$omp do reduction(-:k) reduction(*:j) reduction(-:l)
+ !$omp do reduction(+:k) reduction(*:j) reduction(+:l)
!DEF: /omp_reduction/OtherConstruct7/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do i=1,10
!DEF: /omp_reduction/OtherConstruct7/k (OmpReduction) HostAssoc INTEGER(4)