[Mlir-commits] [mlir] [mlir][mesh, mpi] Lower allreduce (PR #144060)

Christian Ulmann llvmlistbot at llvm.org
Mon Jun 16 04:20:32 PDT 2025


================
@@ -41,6 +42,38 @@ struct FoldCast final : public mlir::OpRewritePattern<OpT> {
     return mlir::success();
   }
 };
+
+struct FoldRank final : public mlir::OpRewritePattern<mlir::mpi::CommRankOp> {
+  using mlir::OpRewritePattern<mlir::mpi::CommRankOp>::OpRewritePattern;
+
+  LogicalResult matchAndRewrite(mlir::mpi::CommRankOp op,
+                                mlir::PatternRewriter &b) const override {
+    auto comm = op.getComm();
+    if (!comm.getDefiningOp<mlir::mpi::CommWorldOp>()) {
+      return mlir::failure();
+    }
+
+    // Try to get DLTI attribute for MPI:comm_world_rank
+    // If found, set worldRank to the value of the attribute.
+    {
----------------
Dinistro wrote:

Nit: This lexical block looks like a remnant, consider removing it.

https://github.com/llvm/llvm-project/pull/144060


More information about the Mlir-commits mailing list