[flang-commits] [flang] [flang][cuda] Emit error when a device actual argument is used in host intrinsic (PR #172914)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Thu Dec 18 21:59:49 PST 2025
================
@@ -1145,6 +1155,31 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
dummyName, toStr(dummyDataAttr), toStr(actualDataAttr));
}
}
+ // Emit an error message if an actual argument passed to a host intrinsic is
+ // on the device.
+ if (intrinsic && !FindCUDADeviceContext(scope) &&
+ !FindOpenACCConstructContaining(scope)) {
+ if (!cudaSkippedIntrinsics.contains(intrinsic->name)) {
+ std::optional<common::CUDADataAttr> actualDataAttr;
+ if (const auto *actualObject{actualLastSymbol
+ ? actualLastSymbol->detailsIf<ObjectEntityDetails>()
+ : nullptr}) {
+ actualDataAttr = actualObject->cudaDataAttr();
+ }
+ if (actualDataAttr && *actualDataAttr == common::CUDADataAttr::Device) {
+ // Allocatable or pointer with device attribute have their descriptor in
+ // managed memory. It is allowed to pass them to some inquiry
+ // intrinsics.
+ if (!actualLastSymbol || !IsAllocatableOrPointer(*actualLastSymbol) ||
+ (IsAllocatableOrPointer(*actualLastSymbol) &&
+ !cudaAllowedIntrinsics.contains(intrinsic->name))) {
+ messages.Say(
+ "Actual argument %s associated with host intrinsic %s is on the device"_err_en_US,
+ actualLastSymbol->name(), intrinsic->name);
----------------
clementval wrote:
Yeah you might be right. I'll guard that.
https://github.com/llvm/llvm-project/pull/172914
More information about the flang-commits
mailing list