Skip to content
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: 22 additions & 2 deletions lib/Dialect/TritonGPU/Transforms/WSDataPartition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@ void fixTaskId(triton::FuncOp &funcOp) {
// Do not update loads.
if (isa<tt::LoadOp, tt::ExperimentalDescriptorLoadOp>(defOp))
continue;
// Skip control flow ops.
if (isa<scf::YieldOp>(op))
continue;
auto defTaskIds = getAsyncTaskIds(defOp);
// Make sure defTaskIds cover asyncTaskIds. Call addAsyncTaskIds if
// necessary.
if (!oneVecCoversTheOther(defTaskIds, asyncTaskIds)) {
// Const ops with same value but different task ids can be folded.
if (isa<arith::ConstantIntOp>(defOp)) {
if (defOp->getDialect()->getNamespace() == "arith") {
LLVM_DEBUG({
LDBG("backward fixing taskId for");
defOp->dump();
Expand All @@ -80,7 +83,7 @@ void fixTaskId(triton::FuncOp &funcOp) {
if (operand.hasOneUse() &&
!oneVecCoversTheOther(asyncTaskIds, defTaskIds)) {
// YieldOp may lose task attribute during MLIR canonicalization.
if (isa<scf::YieldOp>(op)) {
if (isa<scf::YieldOp, scf::IfOp>(op)) {
LLVM_DEBUG({
LDBG("forward fixing taskId for");
defOp->dump();
Expand Down Expand Up @@ -131,6 +134,23 @@ void getBackwardSliceToPartition(Value root, unsigned dim, int sliceSize,
} else if (auto dotOp = dyn_cast<nvidia_gpu::WarpGroupDotOp>(op)) {
queue.push_back(dim == 0 ? dotOp.getA() : dotOp.getB());
queue.push_back(dotOp.getC());
} else if (auto ifOp = dyn_cast<scf::IfOp>(op)) {
// track yield value
// find result index of v
unsigned resultIndex = 0;
for (int i = 0; i < op->getNumResults(); ++i) {
if (op->getResult(i) == v) {
resultIndex = i;
break;
}
}

auto thenYieldArg = ifOp.thenYield().getOperand(resultIndex);
backwardSlice.insert(ifOp.thenYield());
queue.push_back(thenYieldArg);
auto elseYieldArg = ifOp.elseYield().getOperand(resultIndex);
backwardSlice.insert(ifOp.elseYield());
queue.push_back(elseYieldArg);
} else {
llvm_unreachable("Unexpected op");
}
Expand Down