Skip to content

Commit 48122a7

Browse files
authored
[flang][cuda] Fix CUDA generic resolution for VALUE arguments in device procedures (#140952)
For actual arguments that have VALUE attribute inside device routines, treat them as if they have device attribute.
1 parent 32d2b6b commit 48122a7

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

flang/lib/Semantics/check-call.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,13 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
10331033
*actualDataAttr == common::CUDADataAttr::Managed)) {
10341034
actualDataAttr = common::CUDADataAttr::Device;
10351035
}
1036+
// For device procedures, treat actual arguments with VALUE attribute as
1037+
// device data
1038+
if (!actualDataAttr && actualLastSymbol && IsValue(*actualLastSymbol) &&
1039+
(*procedure.cudaSubprogramAttrs ==
1040+
common::CUDASubprogramAttrs::Device)) {
1041+
actualDataAttr = common::CUDADataAttr::Device;
1042+
}
10361043
}
10371044
if (dummyDataAttr == common::CUDADataAttr::Device &&
10381045
(dummyIsAssumedShape || dummyIsAssumedRank) &&

flang/test/Semantics/cuf21.cuf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@ module mlocModule
99
end interface maxlocUpdate
1010
contains
1111

12-
attributes(global) subroutine maxlocPartialMaskR_32F1D()
12+
attributes(global) subroutine maxlocPartialMaskR_32F1D(back)
1313
implicit none
14+
logical, intent(in), value :: back
1415
real(4) :: mval
1516

16-
call maxlocUpdate(mval)
17+
call maxlocUpdate(mval, back)
1718

1819
end subroutine maxlocPartialMaskR_32F1D
1920

20-
attributes(device) subroutine maxlocUpdateR_32F(mval)
21+
attributes(device) subroutine maxlocUpdateR_32F(mval, back)
2122
real(4) :: mval
23+
logical :: back
2224
end subroutine maxlocUpdateR_32F
2325

24-
attributes(device) subroutine maxlocUpdateR_64F(mval)
26+
attributes(device) subroutine maxlocUpdateR_64F(mval, back)
2527
real(8) :: mval
28+
logical :: back
2629
end subroutine maxlocUpdateR_64F
2730
end module

0 commit comments

Comments
 (0)