Skip to content

Commit 564ff8f

Browse files
committed
implicitly set DEVICE attribute to scalars in device routines
1 parent 57a90ed commit 564ff8f

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9376,7 +9376,7 @@ static void SetImplicitCUDADevice(bool inDeviceSubprogram, Symbol &symbol) {
93769376
if (inDeviceSubprogram && symbol.has<ObjectEntityDetails>()) {
93779377
auto *object{symbol.detailsIf<ObjectEntityDetails>()};
93789378
if (!object->cudaDataAttr() && !IsValue(symbol) &&
9379-
(IsDummy(symbol) || object->IsArray())) {
9379+
!IsFunctionResult(symbol)) {
93809380
// Implicitly set device attribute if none is set in device context.
93819381
object->set_cudaDataAttr(common::CUDADataAttr::Device);
93829382
}

flang/test/Lower/CUDA/cuda-shared.cuf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ end subroutine
99

1010
! CHECK-LABEL: func.func @_QPsharedmem() attributes {cuf.proc_attr = #cuf.cuda_proc<global>}
1111
! CHECK: %{{.*}} = cuf.shared_memory !fir.array<32xf32> {bindc_name = "s", uniq_name = "_QFsharedmemEs"} -> !fir.ref<!fir.array<32xf32>>
12+
! CHECK: cuf.free %{{.*}}#0 : !fir.ref<i32> {data_attr = #cuf.cuda<device>}
1213
! CHECK-NOT: cuf.free

flang/test/Semantics/cuf21.cuf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s
2+
3+
module mlocModule
4+
interface maxlocUpdate
5+
module procedure :: &
6+
maxlocUpdateR_32F, &
7+
maxlocUpdateR_64F, &
8+
maxlocUpdateR_32I, &
9+
maxlocUpdateR_64I
10+
end interface maxlocUpdate
11+
contains
12+
13+
attributes(global) subroutine maxlocPartialMaskR_32F1D()
14+
implicit none
15+
real(4) :: mval
16+
17+
call maxlocUpdate(mval)
18+
19+
end subroutine maxlocPartialMaskR_32F1D
20+
21+
attributes(device) subroutine maxlocUpdateR_32F(mval)
22+
real(4) :: mval
23+
end subroutine maxlocUpdateR_32F
24+
25+
attributes(device) subroutine maxlocUpdateR_64F(mval)
26+
real(8) :: mval
27+
end subroutine maxlocUpdateR_64F
28+
29+
attributes(device) subroutine maxlocUpdateR_32I(mval)
30+
integer(4) :: mval
31+
end subroutine maxlocUpdateR_32I
32+
33+
attributes(device) subroutine maxlocUpdateR_64I(mval)
34+
integer(8) :: mval
35+
end subroutine maxlocUpdateR_64I
36+
end module
37+
38+
! CHECK-LABEL: func.func @_QMmlocmodulePmaxlocpartialmaskr_32f1d()

0 commit comments

Comments
 (0)