[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 03:16:03 PDT 2025
kiranchandramohan wrote:
There is a crash in `Fortran::semantics::IsReductionAllowedForType` for the following test.
```
module custom_reduce_mod
type :: my_data
real :: val
end type my_data
!$omp declare reduction(+:my_data:omp_out = omp_out + omp_in) &
!$omp& initializer(omp_priv = my_data(0.0))
interface operator(+)
module procedure combine_values
end interface
contains
function combine_values(a, b) result(c)
type(my_data), intent(in) :: a, b
type(my_data) :: c
c%val = a%val + b%val
end function combine_values
end module custom_reduce_mod
subroutine compute_sum
use custom_reduce_mod
implicit none
type(my_data) :: total
integer :: idx
total = my_data(0.0)
!$omp parallel do reduction(+:total)
do idx = 1, 100
total = total + my_data(real(idx))
end do
!$omp end parallel do
print *, 'Total sum: ', total%val
end subroutine compute_sum
```
The following test also crashes in some checks for pure functions.
```
pure logical function is_reduction_valid()
!$omp declare reduction (bar : integer : red_out = red_out + red_in) initializer (red_priv = 0)
is_reduction_valid = .false.
end function is_reduction_valid
```
https://github.com/llvm/llvm-project/pull/131628
More information about the flang-commits
mailing list