Skip to content

Commit 1b355fe

Browse files
committed
[flang][cuda] Set alloca block in cuf kernel
1 parent ab9cd53 commit 1b355fe

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

flang/lib/Optimizer/Builder/FIRBuilder.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ mlir::Block *fir::FirOpBuilder::getAllocaBlock() {
264264
return recipeIface.getAllocaBlock(getRegion());
265265
}
266266

267+
if (auto cufKernelOp = getRegion().getParentOfType<cuf::KernelOp>())
268+
return &cufKernelOp.getRegion().front();
269+
267270
return getEntryBlock();
268271
}
269272

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
! RUN: bbc -emit-fir -hlfir -fcuda %s -o - | FileCheck %s
2+
3+
module char1
4+
5+
character*1, dimension(:), allocatable, device :: da, db
6+
7+
contains
8+
attributes(device) logical function check_char( c1, c2 )
9+
character*1, value :: c1, c2
10+
check_char = .false.
11+
if(c1 .eq. c2) check_char = .true.
12+
end function
13+
end module
14+
15+
program p
16+
use char1
17+
integer :: n, i
18+
!$cuf kernel do(1)<<<*,*>>>
19+
do i = 1, n
20+
if (check_char(da(i),db(i))) then
21+
print*,'same'
22+
endif
23+
enddo
24+
end program
25+
26+
! CHECK-LABEL: func.func @_QQmain()
27+
! CHECK: cuf.kernel
28+
! CHECK-COUNT-2: %{{.*}} = fir.alloca !fir.char<1> {bindc_name = ".tmp"}
29+

0 commit comments

Comments
 (0)