Skip to content

Commit

Permalink
Make schedule-dataflow pass more efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
hanchenye committed Mar 24, 2024
1 parent 6696640 commit b688cf2
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/Dialect/HLS/Transforms/ScheduleDataflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ hls::TaskOp wrapOpIntoTask(Operation *op, StringRef taskName,

builder.setInsertionPoint(op);
auto task = builder.create<TaskOp>(op->getLoc(), destTypes, destOperands);
op->replaceAllUsesWith(task.getResults());
task->setAttr(taskName, builder.getUnitAttr());
auto taskBlock = builder.createBlock(
&task.getBody(), task.getBody().end(), destTypes,
llvm::map_to_vector(destOperands, [&](Value v) { return v.getLoc(); }));
IRMapping mapper;

builder.setInsertionPointToEnd(taskBlock);
auto yieldOp = builder.create<YieldOp>(op->getLoc(), op->getResults());

op->moveBefore(yieldOp);
for (auto [destOperand, taskBlockArg] :
llvm::zip(destOperands, taskBlock->getArguments()))
mapper.map(destOperand, taskBlockArg);

builder.setInsertionPointToStart(taskBlock);
auto newOp = builder.clone(*op, mapper);
builder.create<YieldOp>(op->getLoc(), newOp->getResults());
op->replaceAllUsesWith(task.getResults());
op->erase();
destOperand.replaceUsesWithIf(
taskBlockArg, [&](OpOperand &use) { return use.getOwner() == op; });
return task;
}

Expand All @@ -54,6 +54,8 @@ static LogicalResult scheduleBlock(StringRef prefix, Block *block,
destOperands = loop.getInitArgs();
} else if (isa<tensor::InsertOp, tensor::InsertSliceOp,
tensor::ParallelInsertSliceOp>(op)) {
// TODO: For now, tensor insert ops are not scheduled into separate tasks
// as they will be handled in the bufferization passes.
continue;
} else if (auto destStyleOp = dyn_cast<DestinationStyleOpInterface>(op)) {
destOperands = destStyleOp.getDpsInits();
Expand Down

0 comments on commit b688cf2

Please sign in to comment.