[Mlir-commits] [mlir] ee1557f - [flang][openacc] Lower self clause on acc update as host clause

Valentin Clement llvmlistbot at llvm.org
Tue May 9 10:34:16 PDT 2023


Author: Valentin Clement
Date: 2023-05-09T10:33:57-07:00
New Revision: ee1557f865b9de85465743279781d9573d5ca995

URL: https://github.com/llvm/llvm-project/commit/ee1557f865b9de85465743279781d9573d5ca995
DIFF: https://github.com/llvm/llvm-project/commit/ee1557f865b9de85465743279781d9573d5ca995.diff

LOG: [flang][openacc] Lower self clause on acc update as host clause

Self clause is the same same as the host clause. Lower it
in a simmilar way.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D150174

Added: 
    

Modified: 
    flang/lib/Lower/OpenACC.cpp
    flang/test/Lower/OpenACC/acc-update.f90
    mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 562317c5fb7a..ce287e1ac495 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -1482,6 +1482,16 @@ genACCUpdateOp(Fortran::lower::AbstractConverter &converter,
           dataClauseOperands, mlir::acc::DataClause::acc_update_device, false);
     } else if (std::get_if<Fortran::parser::AccClause::IfPresent>(&clause.u)) {
       addIfPresentAttr = true;
+    } else if (const auto *selfClause =
+                   std::get_if<Fortran::parser::AccClause::Self>(&clause.u)) {
+      const std::optional<Fortran::parser::AccSelfClause> &accSelfClause =
+          selfClause->v;
+      const auto *accObjectList =
+          std::get_if<Fortran::parser::AccObjectList>(&(*accSelfClause).u);
+      assert(accObjectList && "expect AccObjectList");
+      genDataOperandOperations<mlir::acc::GetDevicePtrOp>(
+          *accObjectList, converter, semanticsContext, stmtCtx,
+          updateHostOperands, mlir::acc::DataClause::acc_update_self, false);
     }
   }
 

diff  --git a/flang/test/Lower/OpenACC/acc-update.f90 b/flang/test/Lower/OpenACC/acc-update.f90
index ac25cb12a1ff..afe02bf9a0bc 100644
--- a/flang/test/Lower/OpenACC/acc-update.f90
+++ b/flang/test/Lower/OpenACC/acc-update.f90
@@ -21,6 +21,11 @@ subroutine acc_update
 ! CHECK: acc.update dataOperands(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>) attributes {ifPresent}{{$}}
 ! CHECK: acc.update_host accPtr(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref<!fir.array<10x10xf32>>) {name = "a", structured = false}
 
+  !$acc update self(a)
+! CHECK: %[[DEVPTR_A:.*]] = acc.getdeviceptr varPtr(%[[A]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref<!fir.array<10x10xf32>> {dataClause = 18 : i64, name = "a", structured = false}
+! CHECK: acc.update dataOperands(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>){{$}}
+! CHECK: acc.update_host accPtr(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref<!fir.array<10x10xf32>>) {dataClause = 18 : i64, name = "a", structured = false}
+
   !$acc update host(a) if(.true.)
 ! CHECK: %[[DEVPTR_A:.*]] = acc.getdeviceptr varPtr(%[[A]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref<!fir.array<10x10xf32>> {dataClause = 17 : i64, name = "a", structured = false}
 ! CHECK: %[[IF1:.*]] = arith.constant true

diff  --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
index 49b6b1d53bb7..08eb54b1af9f 100644
--- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
+++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
@@ -151,7 +151,8 @@ LogicalResult acc::GetDevicePtrOp::verify() {
       getDataClause() != acc::DataClause::acc_copyout &&
       getDataClause() != acc::DataClause::acc_delete &&
       getDataClause() != acc::DataClause::acc_detach &&
-      getDataClause() != acc::DataClause::acc_update_host)
+      getDataClause() != acc::DataClause::acc_update_host &&
+      getDataClause() != acc::DataClause::acc_update_self)
     return emitError("getDevicePtr mismatch");
   return success();
 }


        


More information about the Mlir-commits mailing list