[Mlir-commits] [mlir] [mlir][mpi] Lowering Mpi To LLVM (PR #127053)
Rolf Morel
llvmlistbot at llvm.org
Wed Feb 19 09:48:54 PST 2025
================
@@ -184,29 +185,53 @@ struct OMPIImplTraits {
//===----------------------------------------------------------------------===//
// When lowering the mpi dialect to functions calls certain details
// differ between various MPI implementations. This class will provide
-// these in a gnereic way, depending on the MPI implementation that got
-// included.
+// these in a generic way, depending on the MPI implementation that got
+// selected by the DLTI attribute on the module.
//===----------------------------------------------------------------------===//
struct MPIImplTraits {
+ enum MPIImpl { MPICH, OMPI };
+
+ // Get the MPI implementation from a DLTI attribute on the module.
+ // Default to MPICH (and ABI compatible).
+ static MPIImpl getMPIImpl(mlir::ModuleOp &moduleOp) {
+ auto attr = dlti::query(*&moduleOp, {"MPI:Implementation"}, true);
+ if (failed(attr)) {
+ return MPICH;
+ }
+ auto strAttr = dyn_cast<StringAttr>(attr.value());
+ if (strAttr && strAttr.getValue() == "OpenMPI") {
+ return OMPI;
+ }
+ return MPICH;
----------------
rolfmorel wrote:
On that note: you probably want to check if the value string is "MPICH" as in that case you _don't_ want to output a warning. To state the obvious. 😅
https://github.com/llvm/llvm-project/pull/127053
More information about the Mlir-commits
mailing list