[flang-commits] [flang] [flang][cuda] Avoid generating cuf.data_transfer in OpenACC region (PR #106435)

via flang-commits flang-commits at lists.llvm.org
Thu Aug 29 04:57:53 PDT 2024


================
@@ -4380,9 +4380,19 @@ class FirConverter : public Fortran::lower::AbstractConverter {
   // Check if the insertion point is currently in a device context. HostDevice
   // subprogram are not considered fully device context so it will return false
   // for it.
-  static bool isDeviceContext(fir::FirOpBuilder &builder) {
+  // If the insertion point is inside an OpenACC region op, it is considered
+  // device context.
+  static bool isCudaDeviceContext(fir::FirOpBuilder &builder) {
     if (builder.getRegion().getParentOfType<cuf::KernelOp>())
       return true;
+    if (builder.getRegion().getParentOfType<mlir::acc::LoopOp>())
+      return true;
+    if (builder.getRegion().getParentOfType<mlir::acc::KernelsOp>())
+      return true;
+    if (builder.getRegion().getParentOfType<mlir::acc::ParallelOp>())
+      return true;
+    if (builder.getRegion().getParentOfType<mlir::acc::SerialOp>())
+      return true;
----------------
jeanPerier wrote:

Would it make sense to use the ComputeRegionOpInterface to detect those here instead?

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


More information about the flang-commits mailing list