diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td index c60eb5cc620a7..7e9ed2c741cf7 100644 --- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td +++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td @@ -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 = [{ @@ -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 = [{ @@ -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 = [{ diff --git a/mlir/test/Dialect/OpenACC/ops.mlir b/mlir/test/Dialect/OpenACC/ops.mlir index 2706792a263a8..28ab6f9fcfb4c 100644 --- a/mlir/test/Dialect/OpenACC/ops.mlir +++ b/mlir/test/Dialect/OpenACC/ops.mlir @@ -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 init { +^bb0(%arg0: memref): + %alloca = memref.alloca() : memref + acc.yield %alloca : memref +} copy { +^bb0(%arg0: memref, %arg1: memref): + %0 = memref.load %arg1[] : memref + memref.store %0, %arg0[] : memref + acc.terminator +} + +// CHECK-LABEL: acc.firstprivate.recipe @firstprivatization_memref_i32 +// CHECK: memref.alloca + +acc.reduction.recipe @reduction_add_memref_i32 : memref reduction_operator init { +^bb0(%arg0: memref): + %c0_i32 = arith.constant 0 : i32 + %alloca = memref.alloca() : memref + memref.store %c0_i32, %alloca[] : memref + acc.yield %alloca : memref +} combiner { +^bb0(%arg0: memref, %arg1: memref): + %0 = memref.load %arg0[] : memref + %1 = memref.load %arg1[] : memref + %2 = arith.addi %0, %1 : i32 + memref.store %2, %arg0[] : memref + acc.yield %arg0 : memref +} + +// CHECK-LABEL: acc.reduction.recipe @reduction_add_memref_i32 +// CHECK: memref.alloca + +acc.private.recipe @privatization_memref_i32 : memref init { +^bb0(%arg0: memref): + %alloca = memref.alloca() : memref + acc.yield %alloca : memref +} + +// CHECK-LABEL: acc.private.recipe @privatization_memref_i32 +// CHECK: memref.alloca