[flang-commits] [flang] [flang][cuda] Lower simple host to device data transfer (PR #85960)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Thu Mar 21 08:51:42 PDT 2024


================
@@ -3706,15 +3706,40 @@ class FirConverter : public Fortran::lower::AbstractConverter {
     return false;
   }
 
+  static void genCUDADataTransfer(fir::FirOpBuilder &builder,
+                                  mlir::Location loc, bool lhsIsDevice,
+                                  hlfir::Entity &lhs, bool rhsIsDevice,
+                                  hlfir::Entity &rhs) {
+    if (rhs.isBoxAddressOrValue() || lhs.isBoxAddressOrValue())
+      TODO(loc, "CUDA data transfler with descriptors");
+    if (lhsIsDevice && !rhsIsDevice) {
+      auto transferKindAttr = fir::CUDADataTransferKindAttr::get(
+          builder.getContext(), fir::CUDADataTransferKind::HostDevice);
+      // device = host
+      if (!rhs.isVariable()) {
+        auto [temp, cleanup] = hlfir::createTempFromMold(loc, builder, rhs);
+        builder.create<hlfir::AssignOp>(loc, rhs, temp, false, false);
----------------
clementval wrote:

Ok I see. I'll update that. 

https://github.com/llvm/llvm-project/pull/85960


More information about the flang-commits mailing list