File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -565,13 +565,18 @@ void CUDAChecker::Enter(const parser::CUFKernelDoConstruct &x) {
565
565
std::get<std::list<parser::CUFReduction>>(directive.t )) {
566
566
CheckReduce (context_, reduce);
567
567
}
568
+ inCUFKernelDoConstruct_ = true ;
569
+ }
570
+
571
+ void CUDAChecker::Leave (const parser::CUFKernelDoConstruct &) {
572
+ inCUFKernelDoConstruct_ = false ;
568
573
}
569
574
570
575
void CUDAChecker::Enter (const parser::AssignmentStmt &x) {
571
576
auto lhsLoc{std::get<parser::Variable>(x.t ).GetSource ()};
572
577
const auto &scope{context_.FindScope (lhsLoc)};
573
578
const Scope &progUnit{GetProgramUnitContaining (scope)};
574
- if (IsCUDADeviceContext (&progUnit)) {
579
+ if (IsCUDADeviceContext (&progUnit) || inCUFKernelDoConstruct_ ) {
575
580
return ; // Data transfer with assignment is only perform on host.
576
581
}
577
582
Original file line number Diff line number Diff line change @@ -39,10 +39,12 @@ class CUDAChecker : public virtual BaseChecker {
39
39
void Enter (const parser::FunctionSubprogram &);
40
40
void Enter (const parser::SeparateModuleSubprogram &);
41
41
void Enter (const parser::CUFKernelDoConstruct &);
42
+ void Leave (const parser::CUFKernelDoConstruct &);
42
43
void Enter (const parser::AssignmentStmt &);
43
44
44
45
private:
45
46
SemanticsContext &context_;
47
+ bool inCUFKernelDoConstruct_ = false ;
46
48
};
47
49
48
50
bool CanonicalizeCUDA (parser::Program &);
Original file line number Diff line number Diff line change @@ -332,3 +332,24 @@ end subroutine
332
332
! CHECK: acc.serial
333
333
! CHECK-NOT: cuf.data_transfer
334
334
! CHECK: hlfir.assign
335
+
336
+ ! Check that cuf.data_transfer are not generated within cuf kernel and do not
337
+ ! trigger semantic error.
338
+ subroutine sub17()
339
+ integer, parameter :: n = 10
340
+ real, device :: adev(n)
341
+ real, device :: bdev(n)
342
+ real :: ahost
343
+ real, managed :: b
344
+ integer :: i
345
+
346
+ adev = ahost
347
+ !$cuf kernel do <<<*,*>>>
348
+ do i = 1, n
349
+ ahost = adev(i) * bdev(i) + b
350
+ enddo
351
+ end subroutine
352
+
353
+ ! CHECK-LABEL: func.func @_QPsub17()
354
+ ! CHECK: cuf.kernel<<<*, *>>>
355
+ ! CHECK-NOT: cuf.data_transfer
You can’t perform that action at this time.
0 commit comments