Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion flang/lib/Semantics/check-cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
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)
Expand Down Expand Up @@ -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
Loading