Skip to content

Commit

Permalink
[flang][cuda] Allow complex type in cuf kernel reduce (#124185)
Browse files Browse the repository at this point in the history
clementval authored Jan 23, 2025
1 parent c7053ac commit 4065d98
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion flang/lib/Semantics/check-cuda.cpp
Original file line number Diff line number Diff line change
@@ -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:
6 changes: 5 additions & 1 deletion flang/test/Semantics/reduce.cuf
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
! 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)
logical, device, intent(in) :: l(n)
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

0 comments on commit 4065d98

Please sign in to comment.