#1345 WIP: Simplifying the MPI build process
Opened a year ago by lecris. Modified a year ago

This is a proposal/discussion on how to improve the MPI packaging guidelines to simplify the spec files.

What we have so far

So far we have found a few tricks to simplify the script:

  • set %global _vpath_builddir %{_vendor}-%{_target_os}-build${MPI_SUFFIX:-_serial} and use a for loop to go through the mpi variants. For example:
for mpi in '' mpich %{?with_openmpi:openmpi}; do
  if [ -n "$mpi" ]; then
    module load mpi/${mpi}-%{_arch}
    cmake_mpi_args=(
      "-DCMAKE_INSTALL_PREFIX:PATH=${MPI_HOME}"
      "-DCMAKE_INSTALL_LIBDIR:PATH=lib"
      "-DUSE_MPI:BOOL=ON"
    )
  else
    cmake_mpi_args=(
      "-DUSE_MPI:BOOL=OFF"
    )
  fi
  %cmake ${cmake_mpi_args[@]}
  %cmake_build
done

Some issues

  • The issue with manually running module load instead of %_openmpi_load is that it misses on some specific environment's improvements, e.g. export PRTE_MCA_rmaps_default_mapping_policy=:oversubscribe. But these macros are static so we cannot easily incorporate them in the for loop above

What can be improved

  • Maintain a common macro interface like %mpi_load which uses a shell if checks for loading specific %_openmpi_load, etc. This could be combined with the %global _vpath_builddir simplification
  • Make a lua/python etc. script helpers like the %pyproject macros to make the module preparation more dynamic
  • Templating the mpi package metadata as well. If the spec file is not mpi-backend dependent, i.e. the (Build)Requires for openmpi are the same for mpich
  • Making the script more reusable for upstream. Let's say upstream wants to package with an additional intel mpi variant and use some automation with copr/packit etc. and have a synchronized upstream/downstream spec file. It would be helpful if this process is easily expandable to variable mpi backends. (Disregard the licensing issues and everything, maybe they are advanced enough to host their own copr cluster)

Tagging some people who participated in the previous issue @davidsch @ngompa @gotmax23 @james @rathann


Another approach that would be interesting to explore are defining BuildSystem. This depends on how inheritable and expandable that is.

It will be some time before we are able to use that in guidelines. RPM 4.20 won't be in until Fedora 41, so we need to wait until, at the earliest, we are starting to think about F40 going EOL.

Indeed, but it would be nice to experiment and see if the implementation in RPM 4.20 is sufficient for this so that we can suggest some improvements without waiting for F40 EOL

You're completely welcome to experiment, but until there's a concrete proposal then there's not much for the committee to look at. I'm sure there are plenty of interesting things in newer RPM versions that could be used to make some of this stuff easier, so go for it. The sad fact, though, is that FPC doesn't have much experience with MPI; I probably have the most as I support computational mathematicians. In any case, please make sure to state explicitly when it's time for us to have a look at something.

In the meantime while BuildSystem is being developed, I think we can still consider how to simplify the shell approach in the top-most comment.

I think one approach is to standardize a shell variable name to be used in generic %mpi_load

%mpi_load %{expand:\\\
  if [ "${MPI_VARIANT,,}"  ==  "openmpi" ]; then
    %_openmpi_load
  elif [ "${MPI_VARIANT,,}"  ==  "mpich" ]; then
    %_mpichi_load
    ...
  fi
}

I think this one is worth for FPC to consider right now?

Also there is #1335, that FPC could discuss upon.

Another item to add to the list. The module load and equivalent macro should account for the change of folders due to %{buildroot}. Right now I am doing this workaround:

  if [ -n "$mpi" ]; then
    bindir=${MPI_BIN}
    libdir=${MPI_LIB}
  else
    bindir=%{_bindir}
    libdir=%{_libdir}
  fi
  # Run packaged do_regtest.sh with appropriate buildroot runpaths
  env CP2K_BUILDROOTPATH=%{buildroot} \
    PATH=%{buildroot}${bindir}:${PATH} \
    LD_LIBRARY_PATH=%{buildroot}${libdir} \
    CP2K_VARIANT=${mpi:-serial} run_tests.sh

Log in to comment on this ticket.

Metadata