From: Valentin Clement Date: Wed, 21 Jun 2023 21:18:08 +0000 (-0700) Subject: [mlir][openacc] Add acc.firstprivate operation as data entry operation X-Git-Tag: upstream/17.0.6~4291 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8fb247e2dea15bb446faf69eb615fbd485b77cb7;p=platform%2Fupstream%2Fllvm.git [mlir][openacc] Add acc.firstprivate operation as data entry operation acc.firstprivate operation will be used as data entry operation for the firstprivate operands. Depends on D152970 Reviewed By: razvanlupusoru Differential Revision: https://reviews.llvm.org/D152972 --- diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td index 86e6728..8a31d43 100644 --- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td +++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td @@ -231,6 +231,15 @@ def OpenACC_PrivateOp : OpenACC_DataEntryOp<"private", } //===----------------------------------------------------------------------===// +// 2.5.14 firstprivate clause +//===----------------------------------------------------------------------===// +def OpenACC_FirstprivateOp : OpenACC_DataEntryOp<"firstprivate", + "mlir::acc::DataClause::acc_firstprivate"> { + let summary = "Represents firstprivate semantic for the acc firstprivate " + "clause."; +} + +//===----------------------------------------------------------------------===// // 2.7.4 deviceptr clause //===----------------------------------------------------------------------===// def OpenACC_DevicePtrOp : OpenACC_DataEntryOp<"deviceptr", diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp index 3c632cf..be3384d 100644 --- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp +++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp @@ -72,6 +72,16 @@ LogicalResult acc::PrivateOp::verify() { } //===----------------------------------------------------------------------===// +// FirstprivateOp +//===----------------------------------------------------------------------===// +LogicalResult acc::FirstprivateOp::verify() { + if (getDataClause() != acc::DataClause::acc_firstprivate) + return emitError("data clause associated with firstprivate operation must " + "match its intent"); + return success(); +} + +//===----------------------------------------------------------------------===// // DevicePtrOp //===----------------------------------------------------------------------===// LogicalResult acc::DevicePtrOp::verify() { diff --git a/mlir/test/Dialect/OpenACC/ops.mlir b/mlir/test/Dialect/OpenACC/ops.mlir index 6b6d8f7..92d2a92 100644 --- a/mlir/test/Dialect/OpenACC/ops.mlir +++ b/mlir/test/Dialect/OpenACC/ops.mlir @@ -584,7 +584,8 @@ func.func @testserialop(%a: memref<10xf32>, %b: memref<10xf32>, %c: memref<10x10 } acc.serial wait(%i64value, %i32value, %idxValue : i64, i32, index) { } - acc.serial private(@privatization_memref_10_f32 -> %a : memref<10xf32>, @privatization_memref_10_10_f32 -> %c : memref<10x10xf32>) firstprivate(@firstprivatization_memref_10xf32 -> %b: memref<10xf32>) { + %firstprivate = acc.firstprivate varPtr(%b : memref<10xf32>) -> memref<10xf32> + acc.serial private(@privatization_memref_10_f32 -> %a : memref<10xf32>, @privatization_memref_10_10_f32 -> %c : memref<10x10xf32>) firstprivate(@firstprivatization_memref_10xf32 -> %firstprivate : memref<10xf32>) { } acc.serial { } attributes {defaultAttr = #acc} @@ -620,7 +621,8 @@ func.func @testserialop(%a: memref<10xf32>, %b: memref<10xf32>, %c: memref<10x10 // CHECK-NEXT: } // CHECK: acc.serial wait([[I64VALUE]], [[I32VALUE]], [[IDXVALUE]] : i64, i32, index) { // CHECK-NEXT: } -// CHECK: acc.serial firstprivate(@firstprivatization_memref_10xf32 -> [[ARGB]] : memref<10xf32>) private(@privatization_memref_10_f32 -> [[ARGA]] : memref<10xf32>, @privatization_memref_10_10_f32 -> [[ARGC]] : memref<10x10xf32>) { +// CHECK: %[[FIRSTP:.*]] = acc.firstprivate varPtr([[ARGB]] : memref<10xf32>) -> memref<10xf32> +// CHECK: acc.serial firstprivate(@firstprivatization_memref_10xf32 -> %[[FIRSTP]] : memref<10xf32>) private(@privatization_memref_10_f32 -> [[ARGA]] : memref<10xf32>, @privatization_memref_10_10_f32 -> [[ARGC]] : memref<10x10xf32>) { // CHECK-NEXT: } // CHECK: acc.serial { // CHECK-NEXT: } attributes {defaultAttr = #acc}