Skip to content

[OpenACC] add AutomaticAllocationScope to recipe ops #124337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1008,8 +1008,9 @@ def OpenACC_UpdateHostOp : OpenACC_DataExitOpWithVarPtr<"update_host",
// 2.5.13 private clause
//===----------------------------------------------------------------------===//

def OpenACC_PrivateRecipeOp : OpenACC_Op<"private.recipe",
[IsolatedFromAbove, Symbol, RecipeInterface]> {
def OpenACC_PrivateRecipeOp
: OpenACC_Op<"private.recipe", [IsolatedFromAbove, Symbol, RecipeInterface,
AutomaticAllocationScope]> {
let summary = "privatization recipe";

let description = [{
Expand Down Expand Up @@ -1065,8 +1066,10 @@ def OpenACC_PrivateRecipeOp : OpenACC_Op<"private.recipe",
// 2.5.14 firstprivate clause
//===----------------------------------------------------------------------===//

def OpenACC_FirstprivateRecipeOp : OpenACC_Op<"firstprivate.recipe",
[IsolatedFromAbove, Symbol, RecipeInterface]> {
def OpenACC_FirstprivateRecipeOp
: OpenACC_Op<"firstprivate.recipe", [IsolatedFromAbove, Symbol,
RecipeInterface,
AutomaticAllocationScope]> {
let summary = "privatization recipe";

let description = [{
Expand Down Expand Up @@ -1131,8 +1134,10 @@ def OpenACC_FirstprivateRecipeOp : OpenACC_Op<"firstprivate.recipe",
// 2.5.15 reduction clause
//===----------------------------------------------------------------------===//

def OpenACC_ReductionRecipeOp : OpenACC_Op<"reduction.recipe",
[IsolatedFromAbove, Symbol, RecipeInterface]> {
def OpenACC_ReductionRecipeOp
: OpenACC_Op<"reduction.recipe", [IsolatedFromAbove, Symbol,
RecipeInterface,
AutomaticAllocationScope]> {
let summary = "reduction recipe";

let description = [{
Expand Down
41 changes: 41 additions & 0 deletions mlir/test/Dialect/OpenACC/ops.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1892,3 +1892,44 @@ func.func @acc_combined() {
// CHECK: acc.loop combined(kernels)
// CHECK: acc.serial combined(loop)
// CHECK: acc.loop combined(serial)

acc.firstprivate.recipe @firstprivatization_memref_i32 : memref<i32> init {
^bb0(%arg0: memref<i32>):
%alloca = memref.alloca() : memref<i32>
acc.yield %alloca : memref<i32>
} copy {
^bb0(%arg0: memref<i32>, %arg1: memref<i32>):
%0 = memref.load %arg1[] : memref<i32>
memref.store %0, %arg0[] : memref<i32>
acc.terminator
}

// CHECK-LABEL: acc.firstprivate.recipe @firstprivatization_memref_i32
// CHECK: memref.alloca

acc.reduction.recipe @reduction_add_memref_i32 : memref<i32> reduction_operator <add> init {
^bb0(%arg0: memref<i32>):
%c0_i32 = arith.constant 0 : i32
%alloca = memref.alloca() : memref<i32>
memref.store %c0_i32, %alloca[] : memref<i32>
acc.yield %alloca : memref<i32>
} combiner {
^bb0(%arg0: memref<i32>, %arg1: memref<i32>):
%0 = memref.load %arg0[] : memref<i32>
%1 = memref.load %arg1[] : memref<i32>
%2 = arith.addi %0, %1 : i32
memref.store %2, %arg0[] : memref<i32>
acc.yield %arg0 : memref<i32>
}

// CHECK-LABEL: acc.reduction.recipe @reduction_add_memref_i32
// CHECK: memref.alloca

acc.private.recipe @privatization_memref_i32 : memref<i32> init {
^bb0(%arg0: memref<i32>):
%alloca = memref.alloca() : memref<i32>
acc.yield %alloca : memref<i32>
}

// CHECK-LABEL: acc.private.recipe @privatization_memref_i32
// CHECK: memref.alloca
Loading