Convert barriers into copies during allocation (#19735)
Content aliasing of barriers appears to be causing numerical issues.
This operation should just be removed safely however that appears to be
causing downstream issues. Swapping to a copy makes them go away however
this should be aliasable in the future.
diff --git a/compiler/src/iree/compiler/Dialect/Stream/Transforms/ScheduleAllocation.cpp b/compiler/src/iree/compiler/Dialect/Stream/Transforms/ScheduleAllocation.cpp
index 20ee572..92ce6d9 100644
--- a/compiler/src/iree/compiler/Dialect/Stream/Transforms/ScheduleAllocation.cpp
+++ b/compiler/src/iree/compiler/Dialect/Stream/Transforms/ScheduleAllocation.cpp
@@ -668,6 +668,17 @@
static LogicalResult applyAsyncBarrierOp(IREE::Stream::AsyncBarrierOp barrierOp,
AllocationScope &scope,
OpBuilder builder) {
+ // TODO: barriers are being treated as copies, they should just be metadata
+ // operations but currently it's causing failures to be removed.
+ auto sourceRange = scope.lookupResourceRange(barrierOp.getSource());
+ auto targetRange = scope.lookupResourceRange(barrierOp.getResult());
+
+ // Perform the copy.
+ builder.create<IREE::Stream::CmdCopyOp>(
+ barrierOp.getLoc(), sourceRange.resource, sourceRange.resourceSize,
+ sourceRange.offset, targetRange.resource, targetRange.resourceSize,
+ targetRange.offset, sourceRange.length);
+
barrierOp.erase();
return success();
}