[flang][cuda] Allow complex type in cuf kernel reduce (#124185)

This commit is contained in:
Valentin Clement (バレンタイン クレメン) 2025-01-23 15:09:24 -08:00 committed by GitHub
parent c7053ac202
commit 4065d985ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -553,7 +553,8 @@ static void CheckReduce(
case parser::ReductionOperator::Operator::Multiply:
case parser::ReductionOperator::Operator::Max:
case parser::ReductionOperator::Operator::Min:
isOk = cat == TypeCategory::Integer || cat == TypeCategory::Real;
isOk = cat == TypeCategory::Integer || cat == TypeCategory::Real ||
cat == TypeCategory::Complex;
break;
case parser::ReductionOperator::Operator::Iand:
case parser::ReductionOperator::Operator::Ior:

View File

@ -1,5 +1,5 @@
! RUN: %python %S/test_errors.py %s %flang_fc1
subroutine s(n,m,a,l)
subroutine s(n,m,a,l,c)
integer, intent(in) :: n
integer, device, intent(in) :: m(n)
real, device, intent(in) :: a(n)
@ -7,6 +7,8 @@ subroutine s(n,m,a,l)
integer j, mr
real ar
logical lr
complex :: cr
complex, device, intent(in) :: c(n)
!$cuf kernel do <<<*,*>>> reduce (+:mr,ar)
do j=1,n; mr = mr + m(j); ar = ar + a(j); end do
!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type LOGICAL(4)
@ -69,4 +71,6 @@ subroutine s(n,m,a,l)
!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type REAL(4)
!$cuf kernel do <<<*,*>>> reduce (.or.:mr,ar)
do j=1,n; end do
!$cuf kernel do <<<*,*>>> reduce (+:cr) ! ok complex type
do j=1,n; cr = cr + c(j); end do
end