Skip to content

Commit e492083

Browse files
authored
[OpenACC] Add AutomaticAllocationScope to recipe ops (#124337)
The recipe operations should have AutomaticAllocationScope so recipes can be converted using operators that require parent ops to have AutomaticAllocationScope
1 parent 1e2d5f7 commit e492083

File tree

2 files changed

+52
-6
lines changed

2 files changed

+52
-6
lines changed

mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,8 +1008,9 @@ def OpenACC_UpdateHostOp : OpenACC_DataExitOpWithVarPtr<"update_host",
10081008
// 2.5.13 private clause
10091009
//===----------------------------------------------------------------------===//
10101010

1011-
def OpenACC_PrivateRecipeOp : OpenACC_Op<"private.recipe",
1012-
[IsolatedFromAbove, Symbol, RecipeInterface]> {
1011+
def OpenACC_PrivateRecipeOp
1012+
: OpenACC_Op<"private.recipe", [IsolatedFromAbove, Symbol, RecipeInterface,
1013+
AutomaticAllocationScope]> {
10131014
let summary = "privatization recipe";
10141015

10151016
let description = [{
@@ -1065,8 +1066,10 @@ def OpenACC_PrivateRecipeOp : OpenACC_Op<"private.recipe",
10651066
// 2.5.14 firstprivate clause
10661067
//===----------------------------------------------------------------------===//
10671068

1068-
def OpenACC_FirstprivateRecipeOp : OpenACC_Op<"firstprivate.recipe",
1069-
[IsolatedFromAbove, Symbol, RecipeInterface]> {
1069+
def OpenACC_FirstprivateRecipeOp
1070+
: OpenACC_Op<"firstprivate.recipe", [IsolatedFromAbove, Symbol,
1071+
RecipeInterface,
1072+
AutomaticAllocationScope]> {
10701073
let summary = "privatization recipe";
10711074

10721075
let description = [{
@@ -1131,8 +1134,10 @@ def OpenACC_FirstprivateRecipeOp : OpenACC_Op<"firstprivate.recipe",
11311134
// 2.5.15 reduction clause
11321135
//===----------------------------------------------------------------------===//
11331136

1134-
def OpenACC_ReductionRecipeOp : OpenACC_Op<"reduction.recipe",
1135-
[IsolatedFromAbove, Symbol, RecipeInterface]> {
1137+
def OpenACC_ReductionRecipeOp
1138+
: OpenACC_Op<"reduction.recipe", [IsolatedFromAbove, Symbol,
1139+
RecipeInterface,
1140+
AutomaticAllocationScope]> {
11361141
let summary = "reduction recipe";
11371142

11381143
let description = [{

mlir/test/Dialect/OpenACC/ops.mlir

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,3 +1892,44 @@ func.func @acc_combined() {
18921892
// CHECK: acc.loop combined(kernels)
18931893
// CHECK: acc.serial combined(loop)
18941894
// CHECK: acc.loop combined(serial)
1895+
1896+
acc.firstprivate.recipe @firstprivatization_memref_i32 : memref<i32> init {
1897+
^bb0(%arg0: memref<i32>):
1898+
%alloca = memref.alloca() : memref<i32>
1899+
acc.yield %alloca : memref<i32>
1900+
} copy {
1901+
^bb0(%arg0: memref<i32>, %arg1: memref<i32>):
1902+
%0 = memref.load %arg1[] : memref<i32>
1903+
memref.store %0, %arg0[] : memref<i32>
1904+
acc.terminator
1905+
}
1906+
1907+
// CHECK-LABEL: acc.firstprivate.recipe @firstprivatization_memref_i32
1908+
// CHECK: memref.alloca
1909+
1910+
acc.reduction.recipe @reduction_add_memref_i32 : memref<i32> reduction_operator <add> init {
1911+
^bb0(%arg0: memref<i32>):
1912+
%c0_i32 = arith.constant 0 : i32
1913+
%alloca = memref.alloca() : memref<i32>
1914+
memref.store %c0_i32, %alloca[] : memref<i32>
1915+
acc.yield %alloca : memref<i32>
1916+
} combiner {
1917+
^bb0(%arg0: memref<i32>, %arg1: memref<i32>):
1918+
%0 = memref.load %arg0[] : memref<i32>
1919+
%1 = memref.load %arg1[] : memref<i32>
1920+
%2 = arith.addi %0, %1 : i32
1921+
memref.store %2, %arg0[] : memref<i32>
1922+
acc.yield %arg0 : memref<i32>
1923+
}
1924+
1925+
// CHECK-LABEL: acc.reduction.recipe @reduction_add_memref_i32
1926+
// CHECK: memref.alloca
1927+
1928+
acc.private.recipe @privatization_memref_i32 : memref<i32> init {
1929+
^bb0(%arg0: memref<i32>):
1930+
%alloca = memref.alloca() : memref<i32>
1931+
acc.yield %alloca : memref<i32>
1932+
}
1933+
1934+
// CHECK-LABEL: acc.private.recipe @privatization_memref_i32
1935+
// CHECK: memref.alloca

0 commit comments

Comments
 (0)