[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:
It seems to me that if we get to this point the user specified yet another OpenMPI implementation. Hard for me to judge whether it is okay to proceed as MPICH, though a warning that you are ignoring whatever was specified could considerably help debugging (e.g. someone typed "openmpi" as the key name or "OpenMP", etc).
https://github.com/llvm/llvm-project/pull/127053
More information about the Mlir-commits
mailing list