[flang-commits] [flang] [flang][cuda] Enforce PINNED attribute when ALLOCATE with PINNED option (PR #89455)
via flang-commits
flang-commits at lists.llvm.org
Fri Apr 19 14:08:10 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Valentin Clement (バレンタイン クレメン) (clementval)
<details>
<summary>Changes</summary>
When the PINNED option is specified on an ALLOCATE statement, the object must have the PINNED attribute.
---
Full diff: https://github.com/llvm/llvm-project/pull/89455.diff
2 Files Affected:
- (modified) flang/lib/Semantics/check-allocate.cpp (+7)
- (modified) flang/test/Semantics/cuf07.cuf (+8)
``````````diff
diff --git a/flang/lib/Semantics/check-allocate.cpp b/flang/lib/Semantics/check-allocate.cpp
index a7244e1c58330a..7bfd86262b3d62 100644
--- a/flang/lib/Semantics/check-allocate.cpp
+++ b/flang/lib/Semantics/check-allocate.cpp
@@ -611,6 +611,13 @@ bool AllocationCheckerHelper::RunChecks(SemanticsContext &context) {
return false;
}
}
+ if (allocateInfo_.gotPinned) {
+ std::optional<common::CUDADataAttr> cudaAttr{GetCUDADataAttr(ultimate_)};
+ if (!cudaAttr || *cudaAttr != common::CUDADataAttr::Pinned) {
+ context.Say(name_.source,
+ "Object in ALLOCATE must have PINNED attribute when PINNED option is specified"_err_en_US);
+ }
+ }
return RunCoarrayRelatedChecks(context);
}
diff --git a/flang/test/Semantics/cuf07.cuf b/flang/test/Semantics/cuf07.cuf
index b520b5da51264b..91a78e124c593b 100644
--- a/flang/test/Semantics/cuf07.cuf
+++ b/flang/test/Semantics/cuf07.cuf
@@ -23,4 +23,12 @@ module m
!BECAUSE: 'ma' is a host-associated allocatable and is not definable in a device subprogram
deallocate(ma)
end subroutine
+
+ subroutine hostsub()
+ integer, allocatable, device :: ia(:)
+ logical :: plog
+
+ !ERROR: Object in ALLOCATE must have PINNED attribute when PINNED option is specified
+ allocate(ia(100), pinned = plog)
+ end subroutine
end module
``````````
</details>
https://github.com/llvm/llvm-project/pull/89455
More information about the flang-commits
mailing list