Skip to content
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

[mlir][acc] Update LegalizeDataValues pass to allow MappableType #125134

Merged
merged 1 commit into from
Jan 31, 2025
Merged
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
24 changes: 12 additions & 12 deletions mlir/lib/Dialect/OpenACC/Transforms/LegalizeDataValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ static bool insideAccComputeRegion(mlir::Operation *op) {
return false;
}

static void collectPtrs(mlir::ValueRange operands,
static void collectVars(mlir::ValueRange operands,
llvm::SmallVector<std::pair<Value, Value>> &values,
bool hostToDevice) {
for (auto operand : operands) {
Value varPtr = acc::getVarPtr(operand.getDefiningOp());
Value accPtr = acc::getAccPtr(operand.getDefiningOp());
if (varPtr && accPtr) {
Value var = acc::getVar(operand.getDefiningOp());
Value accVar = acc::getAccVar(operand.getDefiningOp());
if (var && accVar) {
if (hostToDevice)
values.push_back({varPtr, accPtr});
values.push_back({var, accVar});
else
values.push_back({accPtr, varPtr});
values.push_back({accVar, var});
}
}
}
Expand Down Expand Up @@ -75,16 +75,16 @@ static void collectAndReplaceInRegion(Op &op, bool hostToDevice) {
llvm::SmallVector<std::pair<Value, Value>> values;

if constexpr (std::is_same_v<Op, acc::LoopOp>) {
collectPtrs(op.getReductionOperands(), values, hostToDevice);
collectPtrs(op.getPrivateOperands(), values, hostToDevice);
collectVars(op.getReductionOperands(), values, hostToDevice);
collectVars(op.getPrivateOperands(), values, hostToDevice);
} else {
collectPtrs(op.getDataClauseOperands(), values, hostToDevice);
collectVars(op.getDataClauseOperands(), values, hostToDevice);
if constexpr (!std::is_same_v<Op, acc::KernelsOp> &&
!std::is_same_v<Op, acc::DataOp> &&
!std::is_same_v<Op, acc::DeclareOp>) {
collectPtrs(op.getReductionOperands(), values, hostToDevice);
collectPtrs(op.getPrivateOperands(), values, hostToDevice);
collectPtrs(op.getFirstprivateOperands(), values, hostToDevice);
collectVars(op.getReductionOperands(), values, hostToDevice);
collectVars(op.getPrivateOperands(), values, hostToDevice);
collectVars(op.getFirstprivateOperands(), values, hostToDevice);
}
}

Expand Down