Skip to content

Commit 6d0f1e0

Browse files
authored
[flang][cuda] Do not add contiguity check with ignore_tkr(c) is present (#160363)
1 parent 5ecc6d1 commit 6d0f1e0

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

flang/lib/Lower/ConvertCall.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ Fortran::lower::genCallOpAndResult(
571571
!cuf::isCUDADeviceContext(builder.getRegion())) {
572572
for (auto [oper, arg] :
573573
llvm::zip(operands, caller.getPassedArguments())) {
574+
if (arg.testTKR(Fortran::common::IgnoreTKR::Contiguous))
575+
continue;
574576
if (auto boxTy = mlir::dyn_cast<fir::BaseBoxType>(oper.getType())) {
575577
const Fortran::semantics::Symbol *sym = caller.getDummySymbol(arg);
576578
if (sym && Fortran::evaluate::IsCUDADeviceSymbol(*sym))

flang/test/Lower/CUDA/cuda-runtime-check.cuf

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ contains
1616
call foo(a(1:10,1:10:2))
1717
end subroutine
1818

19+
! CHECK-LABEL: func.func @_QMsection_testPtest_host()
20+
! CHECK: fir.call @_FortranACUFDescriptorCheckSection
21+
! CHECK: fir.call @_QMsection_testPfoo
22+
1923
attributes(device) subroutine zoo(a)
2024
real, device, dimension(:,:) :: a
2125
end subroutine
@@ -25,12 +29,23 @@ contains
2529
allocate(a(10,10))
2630
call zoo(a(1:10,1:10:2))
2731
end subroutine
28-
end module
29-
30-
! CHECK-LABEL: func.func @_QMsection_testPtest_host()
31-
! CHECK: fir.call @_FortranACUFDescriptorCheckSection
32-
! CHECK: fir.call @_QMsection_testPfoo
3332

3433
! CHECK-LABEL: func.func @_QMsection_testPtest_device()
3534
! CHECK-NOT: fir.call @_FortranACUFDescriptorCheckSection
3635
! CHECK: fir.call @_QMsection_testPzoo
36+
37+
subroutine ignore(a)
38+
real, device, dimension(:,:) :: a
39+
!dir$ ignore_tkr(c) a
40+
end subroutine
41+
42+
subroutine test_host2()
43+
real, device, allocatable, dimension(:,:) :: a
44+
allocate(a(10,10))
45+
call ignore(a(1:10,1:10:2))
46+
end subroutine
47+
48+
! CHECK-LABEL: func.func @_QMsection_testPtest_host2()
49+
! CHECK-NOT: fir.call @_FortranACUFDescriptorCheckSection
50+
! CHECK: fir.call @_QMsection_testPignore
51+
end module

0 commit comments

Comments
 (0)