[flang-commits] [flang] [flang][openmp]Add UserReductionDetails and use in DECLARE REDUCTION (PR #131628)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Wed Apr 16 02:28:56 PDT 2025
kiranchandramohan wrote:
Can you check whether the declare reduction works with renamed operators. I am giving an example below for reference, but please think through in general about the possibility of renamed operators.
```
module my_module
implicit none
type :: my_type
real :: value
end type my_type
interface operator(.mul.)
module procedure my_mul
end interface
contains
function my_mul(a, b) result(c)
type(my_type), intent(in) :: a, b
type(my_type) :: c
c%value = a%value * b%value
end function my_mul
end module my_module
!------------------------------
program test_omp_reduction
use omp_lib
use my_module, only: my_type, operator(.submul.) => operator(.mul.)
implicit none
type(my_type) :: result
integer :: i
!$omp declare reduction (.submul. : my_type : omp_out = omp_out .submul. omp_in) initializer(omp_priv = my_type(1.0))
result = my_type(1.0)
!$omp parallel do reduction(.submul.:result)
do i = 1, 10
result = result .submul. my_type(real(i))
end do
!$omp end parallel do
print *, 'Final result: ', result%value
end program test_omp_reduction
```
https://github.com/llvm/llvm-project/pull/131628
More information about the flang-commits
mailing list