[Mlir-commits] [mlir] [mlir][mpi] adding MPI_Allgather and lowering to LLVM (PR #176937)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Jan 20 07:02:14 PST 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- mlir/lib/Conversion/MPIToLLVM/MPIToLLVM.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/lib/Conversion/MPIToLLVM/MPIToLLVM.cpp b/mlir/lib/Conversion/MPIToLLVM/MPIToLLVM.cpp
index f37622c0b..9caf1e396 100644
--- a/mlir/lib/Conversion/MPIToLLVM/MPIToLLVM.cpp
+++ b/mlir/lib/Conversion/MPIToLLVM/MPIToLLVM.cpp
@@ -800,22 +800,24 @@ struct AllGatherOpLowering : public ConvertOpToLLVMPattern<mpi::AllGatherOp> {
// void* buffer_recv, int count_recv, MPI_Datatype datatype_recv,
// MPI_Comm communicator);
auto funcType = LLVM::LLVMFunctionType::get(
- i32, {ptrType, i32, sDataType.getType(),
- ptrType, i32, rDataType.getType(),
- comm.getType()});
+ i32, {ptrType, i32, sDataType.getType(), ptrType, i32,
+ rDataType.getType(), comm.getType()});
// get or create function declaration:
LLVM::LLVMFuncOp funcDecl =
getOrDefineFunction(moduleOp, loc, rewriter, "MPI_Allgather", funcType);
// count_recv is the number of elements received from each rank, not total
- Value nRanks = mlir::mpi::CommSizeOp::create(rewriter, loc, i32, adaptor.getComm()).getSize();
- Value recvCountPerRank = LLVM::UDivOp::create(
- rewriter, loc, i32, recvSize, nRanks);
+ Value nRanks =
+ mlir::mpi::CommSizeOp::create(rewriter, loc, i32, adaptor.getComm())
+ .getSize();
+ Value recvCountPerRank =
+ LLVM::UDivOp::create(rewriter, loc, i32, recvSize, nRanks);
// replace op with function call
- auto funcCall = LLVM::CallOp::create(
- rewriter, loc, funcDecl,
- ValueRange{sendPtr, sendSize, sDataType, recvPtr, recvCountPerRank, rDataType, comm});
+ auto funcCall =
+ LLVM::CallOp::create(rewriter, loc, funcDecl,
+ ValueRange{sendPtr, sendSize, sDataType, recvPtr,
+ recvCountPerRank, rDataType, comm});
if (op.getRetval())
rewriter.replaceOp(op, funcCall.getResult());
@@ -915,9 +917,10 @@ void mpi::populateMPIToLLVMConversionPatterns(LLVMTypeConverter &converter,
converter.addConversion([](mpi::CommType type) {
return IntegerType::get(type.getContext(), 64);
});
- patterns.add<CommRankOpLowering, CommSizeOpLowering, CommSplitOpLowering, CommWorldOpLowering,
- FinalizeOpLowering, InitOpLowering, SendOpLowering,
- RecvOpLowering, AllGatherOpLowering, AllReduceOpLowering>(converter);
+ patterns.add<CommRankOpLowering, CommSizeOpLowering, CommSplitOpLowering,
+ CommWorldOpLowering, FinalizeOpLowering, InitOpLowering,
+ SendOpLowering, RecvOpLowering, AllGatherOpLowering,
+ AllReduceOpLowering>(converter);
}
void mpi::registerConvertMPIToLLVMInterface(DialectRegistry ®istry) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/176937
More information about the Mlir-commits
mailing list