[flang-commits] [flang] [flang][cuda] Avoid to issue data transfer in device context (PR #90247)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Fri Apr 26 11:53:25 PDT 2024


================
@@ -3807,16 +3807,30 @@ class FirConverter : public Fortran::lower::AbstractConverter {
     return temps;
   }
 
+  static bool isDeviceContext(fir::FirOpBuilder &builder) {
+    if (builder.getRegion().getParentOfType<fir::CUDAKernelOp>())
+      return true;
+    if (auto funcOp =
+            builder.getRegion().getParentOfType<mlir::func::FuncOp>()) {
+      if (auto cudaProcAttr =
+              funcOp.getOperation()->getAttrOfType<fir::CUDAProcAttributeAttr>(
+                  fir::getCUDAAttrName())) {
+        return cudaProcAttr.getValue() != fir::CUDAProcAttribute::Host;
----------------
clementval wrote:

Yes, there would be a pass that create the device func part. I guess the easiest is to still generate the data transfer for those and as you mentioned, we will handle them during the host/device func creation. 

I'll update the code to represent that and add some comment. 

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


More information about the flang-commits mailing list