Skip to content

Commit 4065d98

Browse files
authored
[flang][cuda] Allow complex type in cuf kernel reduce (#124185)
1 parent c7053ac commit 4065d98

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

flang/lib/Semantics/check-cuda.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,8 @@ static void CheckReduce(
553553
case parser::ReductionOperator::Operator::Multiply:
554554
case parser::ReductionOperator::Operator::Max:
555555
case parser::ReductionOperator::Operator::Min:
556-
isOk = cat == TypeCategory::Integer || cat == TypeCategory::Real;
556+
isOk = cat == TypeCategory::Integer || cat == TypeCategory::Real ||
557+
cat == TypeCategory::Complex;
557558
break;
558559
case parser::ReductionOperator::Operator::Iand:
559560
case parser::ReductionOperator::Operator::Ior:

flang/test/Semantics/reduce.cuf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
! RUN: %python %S/test_errors.py %s %flang_fc1
2-
subroutine s(n,m,a,l)
2+
subroutine s(n,m,a,l,c)
33
integer, intent(in) :: n
44
integer, device, intent(in) :: m(n)
55
real, device, intent(in) :: a(n)
66
logical, device, intent(in) :: l(n)
77
integer j, mr
88
real ar
99
logical lr
10+
complex :: cr
11+
complex, device, intent(in) :: c(n)
1012
!$cuf kernel do <<<*,*>>> reduce (+:mr,ar)
1113
do j=1,n; mr = mr + m(j); ar = ar + a(j); end do
1214
!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)
6971
!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type REAL(4)
7072
!$cuf kernel do <<<*,*>>> reduce (.or.:mr,ar)
7173
do j=1,n; end do
74+
!$cuf kernel do <<<*,*>>> reduce (+:cr) ! ok complex type
75+
do j=1,n; cr = cr + c(j); end do
7276
end

0 commit comments

Comments
 (0)