[flang-commits] [flang] 5e98394 - [mlir][openacc] Cleanup acc.parallel from old data clause operands
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Tue May 9 14:57:56 PDT 2023
Author: Valentin Clement
Date: 2023-05-09T14:57:50-07:00
New Revision: 5e983942d59c4957c48b4a492e4b5e7cff38be44
URL: https://github.com/llvm/llvm-project/commit/5e983942d59c4957c48b4a492e4b5e7cff38be44
DIFF: https://github.com/llvm/llvm-project/commit/5e983942d59c4957c48b4a492e4b5e7cff38be44.diff
LOG: [mlir][openacc] Cleanup acc.parallel from old data clause operands
Remove old clause operands from acc.parallel operation since
the new dataOperands is now in place.
private, firstprivate and reductions will receive some redesign but are
not part of the new dataOperands.
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D150207
Added:
Modified:
flang/lib/Lower/OpenACC.cpp
flang/lib/Optimizer/Transforms/OpenACC/OpenACCDataOperandConversion.cpp
mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
mlir/lib/Conversion/OpenACCToLLVM/OpenACCToLLVM.cpp
mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
mlir/test/Dialect/OpenACC/ops.mlir
Removed:
flang/test/Transforms/OpenACC/convert-data-operands-to-llvmir.fir
mlir/test/Conversion/OpenACCToLLVM/convert-data-operands-to-llvmir.mlir
################################################################################
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 7c057036666b..00cca5d4e6f3 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -992,7 +992,8 @@ createComputeOp(Fortran::lower::AbstractConverter &converter,
addOperand(operands, operandSegments, selfCond);
if constexpr (!std::is_same_v<Op, mlir::acc::KernelsOp>)
addOperands(operands, operandSegments, reductionOperands);
- operandSegments.append({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
+ if constexpr (!std::is_same_v<Op, mlir::acc::ParallelOp>)
+ operandSegments.append({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
if constexpr (!std::is_same_v<Op, mlir::acc::KernelsOp>) {
addOperands(operands, operandSegments, privateOperands);
addOperands(operands, operandSegments, firstprivateOperands);
diff --git a/flang/lib/Optimizer/Transforms/OpenACC/OpenACCDataOperandConversion.cpp b/flang/lib/Optimizer/Transforms/OpenACC/OpenACCDataOperandConversion.cpp
index 8459ac2aa48d..de28a8f3872c 100644
--- a/flang/lib/Optimizer/Transforms/OpenACC/OpenACCDataOperandConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/OpenACC/OpenACCDataOperandConversion.cpp
@@ -133,17 +133,6 @@ void OpenACCDataOperandConversion::runOnOperation() {
target.addDynamicallyLegalOp<acc::ParallelOp>(
[allDataOperandsAreConverted](acc::ParallelOp op) {
return allDataOperandsAreConverted(op.getReductionOperands()) &&
- allDataOperandsAreConverted(op.getCopyOperands()) &&
- allDataOperandsAreConverted(op.getCopyinOperands()) &&
- allDataOperandsAreConverted(op.getCopyinReadonlyOperands()) &&
- allDataOperandsAreConverted(op.getCopyoutOperands()) &&
- allDataOperandsAreConverted(op.getCopyoutZeroOperands()) &&
- allDataOperandsAreConverted(op.getCreateOperands()) &&
- allDataOperandsAreConverted(op.getCreateZeroOperands()) &&
- allDataOperandsAreConverted(op.getNoCreateOperands()) &&
- allDataOperandsAreConverted(op.getPresentOperands()) &&
- allDataOperandsAreConverted(op.getDevicePtrOperands()) &&
- allDataOperandsAreConverted(op.getAttachOperands()) &&
allDataOperandsAreConverted(op.getGangPrivateOperands()) &&
allDataOperandsAreConverted(op.getGangFirstPrivateOperands());
});
diff --git a/flang/test/Transforms/OpenACC/convert-data-operands-to-llvmir.fir b/flang/test/Transforms/OpenACC/convert-data-operands-to-llvmir.fir
deleted file mode 100644
index f691ea6667d9..000000000000
--- a/flang/test/Transforms/OpenACC/convert-data-operands-to-llvmir.fir
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: fir-opt -fir-openacc-data-operand-conversion='use-opaque-pointers=1' -split-input-file %s | FileCheck %s
-// RUN: fir-opt -fir-openacc-data-operand-conversion='use-opaque-pointers=1' -split-input-file %s | fir-opt -split-input-file --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR
-
-fir.global internal @_QFEa : !fir.array<10xf32> {
- %0 = fir.undefined !fir.array<10xf32>
- fir.has_value %0 : !fir.array<10xf32>
-}
-
-func.func @_QQsub_parallel() attributes {fir.bindc_name = "test"} {
- %0 = fir.address_of(@_QFEa) : !fir.ref<!fir.array<10xf32>>
- %1 = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFEi"}
- acc.parallel copyin(%0: !fir.ref<!fir.array<10xf32>>) {
- acc.loop {
- acc.yield
- }
- acc.yield
- }
- return
-}
-
-// CHECK-LABEL: func.func @_QQsub_parallel() attributes {fir.bindc_name = "test"} {
-// CHECK: %[[ADDR:.*]] = fir.address_of(@_QFEa) : !fir.ref<!fir.array<10xf32>>
-// CHECK: %[[CAST:.*]] = builtin.unrealized_conversion_cast %[[ADDR]] : !fir.ref<!fir.array<10xf32>> to !llvm.ptr<array<10 x f32>>
-// CHECK: acc.parallel copyin(%[[CAST]] : !llvm.ptr<array<10 x f32>>) {
-// CHECK: acc.loop
-
-// LLVMIR-LABEL: llvm.func @_QQsub_parallel() attributes {fir.bindc_name = "test"} {
-// LLVMIR: %[[ADDR:.*]] = llvm.mlir.addressof @_QFEa : !llvm.ptr<array<10 x f32>>
-// LLVMIR: acc.parallel copyin(%[[ADDR]] : !llvm.ptr<array<10 x f32>>) {
diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
index 39a5bba6cefc..c73948550f03 100644
--- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
@@ -420,17 +420,6 @@ def OpenACC_ParallelOp : OpenACC_Op<"parallel",
UnitAttr:$selfAttr,
OptionalAttr<OpenACC_ReductionOpAttr>:$reductionOp,
Variadic<AnyType>:$reductionOperands,
- Variadic<AnyType>:$copyOperands,
- Variadic<AnyType>:$copyinOperands,
- Variadic<AnyType>:$copyinReadonlyOperands,
- Variadic<AnyType>:$copyoutOperands,
- Variadic<AnyType>:$copyoutZeroOperands,
- Variadic<AnyType>:$createOperands,
- Variadic<AnyType>:$createZeroOperands,
- Variadic<AnyType>:$noCreateOperands,
- Variadic<AnyType>:$presentOperands,
- Variadic<AnyType>:$devicePtrOperands,
- Variadic<AnyType>:$attachOperands,
Variadic<AnyType>:$gangPrivateOperands,
Variadic<AnyType>:$gangFirstPrivateOperands,
Variadic<OpenACC_PointerLikeTypeInterface>:$dataClauseOperands,
@@ -449,26 +438,12 @@ def OpenACC_ParallelOp : OpenACC_Op<"parallel",
let assemblyFormat = [{
oilist(
`dataOperands` `(` $dataClauseOperands `:` type($dataClauseOperands) `)`
- | `attach` `(` $attachOperands `:` type($attachOperands) `)`
| `async` `(` $async `:` type($async) `)`
- | `copy` `(` $copyOperands `:` type($copyOperands) `)`
- | `copyin` `(` $copyinOperands `:` type($copyinOperands) `)`
- | `copyin_readonly` `(` $copyinReadonlyOperands `:`
- type($copyinReadonlyOperands) `)`
- | `copyout` `(` $copyoutOperands `:` type($copyoutOperands) `)`
- | `copyout_zero` `(` $copyoutZeroOperands `:`
- type($copyoutZeroOperands) `)`
- | `create` `(` $createOperands `:` type($createOperands) `)`
- | `create_zero` `(` $createZeroOperands `:`
- type($createZeroOperands) `)`
- | `deviceptr` `(` $devicePtrOperands `:` type($devicePtrOperands) `)`
| `firstprivate` `(` $gangFirstPrivateOperands `:`
type($gangFirstPrivateOperands) `)`
- | `no_create` `(` $noCreateOperands `:` type($noCreateOperands) `)`
| `num_gangs` `(` $numGangs `:` type($numGangs) `)`
| `num_workers` `(` $numWorkers `:` type($numWorkers) `)`
| `private` `(` $gangPrivateOperands `:` type($gangPrivateOperands) `)`
- | `present` `(` $presentOperands `:` type($presentOperands) `)`
| `vector_length` `(` $vectorLength `:` type($vectorLength) `)`
| `wait` `(` $waitOperands `:` type($waitOperands) `)`
| `self` `(` $selfCond `)`
diff --git a/mlir/lib/Conversion/OpenACCToLLVM/OpenACCToLLVM.cpp b/mlir/lib/Conversion/OpenACCToLLVM/OpenACCToLLVM.cpp
index e1283d237d90..6bc52c99e9e5 100644
--- a/mlir/lib/Conversion/OpenACCToLLVM/OpenACCToLLVM.cpp
+++ b/mlir/lib/Conversion/OpenACCToLLVM/OpenACCToLLVM.cpp
@@ -194,17 +194,6 @@ void ConvertOpenACCToLLVMPass::runOnOperation() {
target.addDynamicallyLegalOp<acc::ParallelOp>(
[allDataOperandsAreConverted](acc::ParallelOp op) {
return allDataOperandsAreConverted(op.getReductionOperands()) &&
- allDataOperandsAreConverted(op.getCopyOperands()) &&
- allDataOperandsAreConverted(op.getCopyinOperands()) &&
- allDataOperandsAreConverted(op.getCopyinReadonlyOperands()) &&
- allDataOperandsAreConverted(op.getCopyoutOperands()) &&
- allDataOperandsAreConverted(op.getCopyoutZeroOperands()) &&
- allDataOperandsAreConverted(op.getCreateOperands()) &&
- allDataOperandsAreConverted(op.getCreateZeroOperands()) &&
- allDataOperandsAreConverted(op.getNoCreateOperands()) &&
- allDataOperandsAreConverted(op.getPresentOperands()) &&
- allDataOperandsAreConverted(op.getDevicePtrOperands()) &&
- allDataOperandsAreConverted(op.getAttachOperands()) &&
allDataOperandsAreConverted(op.getGangPrivateOperands()) &&
allDataOperandsAreConverted(op.getGangFirstPrivateOperands());
});
diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
index df32d8890ddb..a69a40d87f93 100644
--- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
+++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
@@ -302,13 +302,7 @@ static LogicalResult checkDataOperands(Op op,
}
unsigned ParallelOp::getNumDataOperands() {
- return getReductionOperands().size() + getCopyOperands().size() +
- getCopyinOperands().size() + getCopyinReadonlyOperands().size() +
- getCopyoutOperands().size() + getCopyoutZeroOperands().size() +
- getCreateOperands().size() + getCreateZeroOperands().size() +
- getNoCreateOperands().size() + getPresentOperands().size() +
- getDevicePtrOperands().size() + getAttachOperands().size() +
- getGangPrivateOperands().size() +
+ return getReductionOperands().size() + getGangPrivateOperands().size() +
getGangFirstPrivateOperands().size() + getDataClauseOperands().size();
}
diff --git a/mlir/test/Conversion/OpenACCToLLVM/convert-data-operands-to-llvmir.mlir b/mlir/test/Conversion/OpenACCToLLVM/convert-data-operands-to-llvmir.mlir
deleted file mode 100644
index 093149ae06b4..000000000000
--- a/mlir/test/Conversion/OpenACCToLLVM/convert-data-operands-to-llvmir.mlir
+++ /dev/null
@@ -1,65 +0,0 @@
-// RUN: mlir-opt -convert-openacc-to-llvm='use-opaque-pointers=1' -split-input-file %s | FileCheck %s
-
-func.func @testparallelop(%a: memref<10xf32>, %b: memref<10xf32>) -> () {
- acc.parallel copy(%b : memref<10xf32>) copyout(%a : memref<10xf32>) {
- }
- return
-}
-
-// CHECK: acc.parallel copy(%{{.*}}: !llvm.struct<"openacc_data", (struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>, ptr, i64)>) copyout(%{{.*}}: !llvm.struct<"openacc_data.1", (struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>, ptr, i64)>)
-
-// -----
-
-func.func @testparallelop(%a: !llvm.ptr, %b: memref<10xf32>, %c: !llvm.ptr) -> () {
- acc.parallel copyin(%b : memref<10xf32>) deviceptr(%c: !llvm.ptr) attach(%a : !llvm.ptr) {
- }
- return
-}
-
-// CHECK: acc.parallel attach(%{{.*}}: !llvm.ptr) copyin(%{{.*}}: !llvm.struct<"openacc_data", (struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>, ptr, i64)>) deviceptr(%{{.*}} : !llvm.ptr)
-
-// -----
-
-func.func @testparallelop(%a: memref<10xf32>, %b: memref<10xf32>) -> () {
- %ifCond = arith.constant true
- acc.parallel if(%ifCond) copyin_readonly(%b : memref<10xf32>) copyout_zero(%a : memref<10xf32>) {
- }
- return
-}
-
-// CHECK: acc.parallel copyin_readonly(%{{.*}}: !llvm.struct<"openacc_data", (struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>, ptr, i64)>) copyout_zero(%{{.*}}: !llvm.struct<"openacc_data.1", (struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>, ptr, i64)>) if(%{{.*}})
-
-// -----
-
-func.func @testparallelop(%a: !llvm.ptr, %b: memref<10xf32>, %c: !llvm.ptr) -> () {
- acc.parallel create(%b : memref<10xf32>) create_zero(%c: !llvm.ptr) no_create(%a : !llvm.ptr) {
- }
- return
-}
-
-// CHECK: acc.parallel create(%{{.*}}: !llvm.struct<"openacc_data", (struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>, ptr, i64)>) create_zero(%{{.*}}: !llvm.ptr) no_create(%{{.*}}: !llvm.ptr)
-
-// -----
-
-func.func @testparallelop(%a: memref<10xf32>, %b: memref<10xf32>) -> () {
- acc.parallel present(%a, %b : memref<10xf32>, memref<10xf32>) {
- }
- return
-}
-
-// CHECK: acc.parallel present(%{{.*}}, %{{.*}} : !llvm.struct<"openacc_data", (struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>, ptr, i64)>, !llvm.struct<"openacc_data.1", (struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>, ptr, i64)>)
-
-// -----
-
-func.func @testparallelop(%i: i64, %a: memref<10xf32>, %b: memref<10xf32>) -> () {
- acc.parallel num_gangs(%i: i64) present(%a, %b : memref<10xf32>, memref<10xf32>) {
- %0 = arith.constant 0 : i32
- acc.yield
- } attributes {async}
- return
-}
-
-// CHECK: acc.parallel num_gangs(%{{.*}}: i64) present(%{{.*}}, %{{.*}} : !llvm.struct<"openacc_data", (struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>, ptr, i64)>, !llvm.struct<"openacc_data.1", (struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>, ptr, i64)>)
-// CHECK: %c0_i32 = arith.constant 0 : i32
-// CHECK: acc.yield
-// CHECK: } attributes {async}
diff --git a/mlir/test/Dialect/OpenACC/ops.mlir b/mlir/test/Dialect/OpenACC/ops.mlir
index 5913e09ec4ff..42e0bda734c6 100644
--- a/mlir/test/Dialect/OpenACC/ops.mlir
+++ b/mlir/test/Dialect/OpenACC/ops.mlir
@@ -394,20 +394,6 @@ func.func @testparallelop(%a: memref<10xf32>, %b: memref<10xf32>, %c: memref<10x
}
acc.parallel vector_length(%idxValue: index) {
}
- acc.parallel copyin(%a, %b : memref<10xf32>, memref<10xf32>) {
- }
- acc.parallel copyin_readonly(%a, %b : memref<10xf32>, memref<10xf32>) {
- }
- acc.parallel copyin(%a: memref<10xf32>) copyout_zero(%b, %c : memref<10xf32>, memref<10x10xf32>) {
- }
- acc.parallel copyout(%b, %c : memref<10xf32>, memref<10x10xf32>) create(%a: memref<10xf32>) {
- }
- acc.parallel copyout_zero(%b, %c : memref<10xf32>, memref<10x10xf32>) create_zero(%a: memref<10xf32>) {
- }
- acc.parallel no_create(%a: memref<10xf32>) present(%b, %c : memref<10xf32>, memref<10x10xf32>) {
- }
- acc.parallel deviceptr(%a: memref<10xf32>) attach(%b, %c : memref<10xf32>, memref<10x10xf32>) {
- }
acc.parallel private(%a, %c : memref<10xf32>, memref<10x10xf32>) firstprivate(%b: memref<10xf32>) {
}
acc.parallel {
@@ -459,20 +445,6 @@ func.func @testparallelop(%a: memref<10xf32>, %b: memref<10xf32>, %c: memref<10x
// CHECK-NEXT: }
// CHECK: acc.parallel vector_length([[IDXVALUE]] : index) {
// CHECK-NEXT: }
-// CHECK: acc.parallel copyin([[ARGA]], [[ARGB]] : memref<10xf32>, memref<10xf32>) {
-// CHECK-NEXT: }
-// CHECK: acc.parallel copyin_readonly([[ARGA]], [[ARGB]] : memref<10xf32>, memref<10xf32>) {
-// CHECK-NEXT: }
-// CHECK: acc.parallel copyin([[ARGA]] : memref<10xf32>) copyout_zero([[ARGB]], [[ARGC]] : memref<10xf32>, memref<10x10xf32>) {
-// CHECK-NEXT: }
-// CHECK: acc.parallel copyout([[ARGB]], [[ARGC]] : memref<10xf32>, memref<10x10xf32>) create([[ARGA]] : memref<10xf32>) {
-// CHECK-NEXT: }
-// CHECK: acc.parallel copyout_zero([[ARGB]], [[ARGC]] : memref<10xf32>, memref<10x10xf32>) create_zero([[ARGA]] : memref<10xf32>) {
-// CHECK-NEXT: }
-// CHECK: acc.parallel no_create([[ARGA]] : memref<10xf32>) present([[ARGB]], [[ARGC]] : memref<10xf32>, memref<10x10xf32>) {
-// CHECK-NEXT: }
-// CHECK: acc.parallel attach([[ARGB]], [[ARGC]] : memref<10xf32>, memref<10x10xf32>) deviceptr([[ARGA]] : memref<10xf32>) {
-// CHECK-NEXT: }
// CHECK: acc.parallel firstprivate([[ARGB]] : memref<10xf32>) private([[ARGA]], [[ARGC]] : memref<10xf32>, memref<10x10xf32>) {
// CHECK-NEXT: }
// CHECK: acc.parallel {
More information about the flang-commits
mailing list