From 024932c25e7f7419bc18fc7ba3256154cc059971 Mon Sep 17 00:00:00 2001 From: erwei-xilinx Date: Mon, 20 Jan 2025 17:04:17 -0800 Subject: [PATCH 1/2] Avoid adding op with it's own returned token, creating circular dependency --- mlir/lib/Util/Dependency.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mlir/lib/Util/Dependency.cpp b/mlir/lib/Util/Dependency.cpp index 4a301ceaf..268db9844 100644 --- a/mlir/lib/Util/Dependency.cpp +++ b/mlir/lib/Util/Dependency.cpp @@ -595,6 +595,8 @@ void addAsyncDependencyIfNew(Operation *op, Value token) { return; if (!token) return; + if (token.getDefiningOp() && token.getDefiningOp() == op) + return; if (auto async_op = dyn_cast(op)) { addAsyncDependencyIfNewImpl(async_op, token); } else if (auto for_op = dyn_cast(op)) { From 01805f12e0303be78081456440da2eb3ab4b7b62 Mon Sep 17 00:00:00 2001 From: erwei-xilinx Date: Mon, 20 Jan 2025 17:05:08 -0800 Subject: [PATCH 2/2] Make the dependency tracing method isAsyncDependent more generic by allowing it to trace through any async op, rather than just wait_all --- mlir/lib/Util/Dependency.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mlir/lib/Util/Dependency.cpp b/mlir/lib/Util/Dependency.cpp index 268db9844..677b0d05d 100644 --- a/mlir/lib/Util/Dependency.cpp +++ b/mlir/lib/Util/Dependency.cpp @@ -676,8 +676,8 @@ bool isAsyncDependent(Operation *a, Operation *b) { for (auto dep : dep_b) { if (dep == token_a) return true; - else if (auto dep_wa_defop = dep.getDefiningOp()) { - if (isAsyncDependent(a, dep_wa_defop)) + else if (dep.getDefiningOp() && air::isAsyncOp(dep.getDefiningOp())) { + if (isAsyncDependent(a, dep.getDefiningOp())) return true; } }