[OpenACC][CIR] Implement copyin/copyout/create lowering for compute/c… (#145976)
…ombined
This patch does the lowering of copyin (represented as a
acc.copyin/acc.delete), copyout (acc.create/acc.copyin), and create
(acc.create/acc.delete).
Additionally, it found a few problems with #144806, so it fixes those as
well.
This commit is contained in:
@@ -575,8 +575,10 @@ LogicalResult acc::CreateOp::verify() {
|
||||
return failure();
|
||||
if (failed(checkVarAndAccVar(*this)))
|
||||
return failure();
|
||||
// this op is the entry part of copyout, so it also needs to allow all
|
||||
// modifiers allowed on copyout.
|
||||
if (failed(checkValidModifier(*this, acc::DataClauseModifier::zero |
|
||||
acc::DataClauseModifier::alwaysout |
|
||||
acc::DataClauseModifier::always |
|
||||
acc::DataClauseModifier::capture)))
|
||||
return failure();
|
||||
return success();
|
||||
@@ -708,7 +710,7 @@ LogicalResult acc::DeleteOp::verify() {
|
||||
// allowed on either case.
|
||||
if (failed(checkValidModifier(*this, acc::DataClauseModifier::zero |
|
||||
acc::DataClauseModifier::readonly |
|
||||
acc::DataClauseModifier::alwaysin |
|
||||
acc::DataClauseModifier::always |
|
||||
acc::DataClauseModifier::capture)))
|
||||
return failure();
|
||||
return success();
|
||||
|
||||
@@ -829,5 +829,5 @@ func.func @acc_loop_container() {
|
||||
// -----
|
||||
|
||||
%value = memref.alloc() : memref<f32>
|
||||
// expected-error @below {{invalid data clause modifiers: alwaysin}}
|
||||
%0 = acc.create varPtr(%value : memref<f32>) -> memref<f32> {modifiers = #acc<data_clause_modifier zero,capture,always>}
|
||||
// expected-error @below {{invalid data clause modifiers: readonly}}
|
||||
%0 = acc.create varPtr(%value : memref<f32>) -> memref<f32> {modifiers = #acc<data_clause_modifier readonly,zero,capture,always>}
|
||||
|
||||
@@ -924,15 +924,25 @@ func.func @testdataop(%a: memref<f32>, %b: memref<f32>, %c: memref<f32>) -> () {
|
||||
func.func @testdataopmodifiers(%a: memref<f32>, %b: memref<f32>, %c: memref<f32>) -> () {
|
||||
%0 = acc.create varPtr(%a : memref<f32>) -> memref<f32> {modifiers = #acc<data_clause_modifier capture,zero>}
|
||||
%1 = acc.copyin varPtr(%b : memref<f32>) -> memref<f32> {modifiers = #acc<data_clause_modifier readonly,capture,always>}
|
||||
acc.data dataOperands(%0, %1 : memref<f32>, memref<f32>) {
|
||||
%2 = acc.copyin varPtr(%c : memref<f32>) -> memref<f32> {modifiers = #acc<data_clause_modifier always>}
|
||||
%3 = acc.create varPtr(%c : memref<f32>) -> memref<f32> {modifiers = #acc<data_clause_modifier always>}
|
||||
acc.data dataOperands(%0, %1, %2, %3 : memref<f32>, memref<f32>, memref<f32>, memref<f32>) {
|
||||
}
|
||||
acc.copyout accPtr(%0 : memref<f32>) to varPtr(%a : memref<f32>) {modifiers = #acc<data_clause_modifier zero,capture,always>}
|
||||
acc.delete accPtr(%2 : memref<f32>) {modifiers = #acc<data_clause_modifier always>}
|
||||
acc.copyout accPtr(%3 : memref<f32>) to varPtr(%c : memref<f32>) {modifiers = #acc<data_clause_modifier always>}
|
||||
|
||||
func.return
|
||||
}
|
||||
|
||||
// CHECK: func @testdataopmodifiers(%[[ARGA:.*]]: memref<f32>, %[[ARGB:.*]]: memref<f32>, %[[ARGC:.*]]: memref<f32>) {
|
||||
// CHECK: %[[CREATEA:.*]] = acc.create varPtr(%[[ARGA]] : memref<f32>) -> memref<f32> {modifiers = #acc<data_clause_modifier zero,capture>}
|
||||
// CHECK: %[[COPYINB:.*]] = acc.copyin varPtr(%[[ARGB]] : memref<f32>) -> memref<f32> {modifiers = #acc<data_clause_modifier always,readonly,capture>}
|
||||
// CHECK: %[[COPYINC:.*]] = acc.copyin varPtr(%[[ARGC]] : memref<f32>) -> memref<f32> {modifiers = #acc<data_clause_modifier always>}
|
||||
// CHECK: %[[CREATEC:.*]] = acc.create varPtr(%[[ARGC]] : memref<f32>) -> memref<f32> {modifiers = #acc<data_clause_modifier always>}
|
||||
// CHECK: acc.copyout accPtr(%[[CREATEA]] : memref<f32>) to varPtr(%[[ARGA]] : memref<f32>) {modifiers = #acc<data_clause_modifier always,zero,capture>}
|
||||
// CHECK: acc.delete accPtr(%[[COPYINC]] : memref<f32>) {modifiers = #acc<data_clause_modifier always>}
|
||||
// CHECK: acc.copyout accPtr(%[[CREATEC]] : memref<f32>) to varPtr(%[[ARGC]] : memref<f32>) {modifiers = #acc<data_clause_modifier always>}
|
||||
|
||||
// -----
|
||||
|
||||
|
||||
Reference in New Issue
Block a user