Skip to content

Commit

Permalink
Bump openmpi based on NixOS#275796
Browse files Browse the repository at this point in the history
  • Loading branch information
danjujan committed Apr 16, 2024
1 parent cfd6b5f commit 8a86fdd
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 63 deletions.
52 changes: 52 additions & 0 deletions pkgs/by-name/pr/prrte/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{ lib
, stdenv
, fetchFromGitHub
, autoconf
, automake
, libtool
, gitMinimal
, perl
, python3
, flex
, hwloc
, libevent
, zlib
, pmix
,
}:

stdenv.mkDerivation rec {
pname = "prrte";
version = "3.0.3";

src = fetchFromGitHub {
owner = "openpmix";
repo = "prrte";
rev = "v${version}";
sha256 = "sha256-WjK26jbte1iYngEfjVfwGXIMhU5aDhmWwUl/fYPrmfw=";
fetchSubmodules = true;
};

postPatch = ''
patchShebangs ./autogen.pl
patchShebangs ./config
'';

preConfigure = ''
./autogen.pl
'';

nativeBuildInputs = [ perl python3 autoconf automake libtool flex gitMinimal ];

buildInputs = [ libevent hwloc zlib pmix ];

enableParallelBuilding = true;

meta = with lib; {
description = "PMIx Reference Runtime Environment";
homepage = "https://docs.prrte.org/";
license = licenses.bsd3;
maintainers = [ maintainers.markuskowa ];
platforms = platforms.linux;
};
}
114 changes: 54 additions & 60 deletions pkgs/development/libraries/openmpi/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{ lib, stdenv, fetchurl, removeReferencesTo, gfortran, perl, libnl
{ lib, stdenv, fetchurl, gfortran, perl
, rdma-core, zlib, numactl, libevent, hwloc, targetPackages, symlinkJoin
, libpsm2, libfabric, pmix, ucx, ucc, makeWrapper
, libpsm2, libfabric, pmix, ucx, ucc
, config

# Enable CUDA support
, cudaSupport ? config.cudaSupport, cudaPackages

Expand All @@ -16,106 +17,99 @@

# Enable Fortran support
, fortranSupport ? true

# AVX/SSE options
, enableSse3 ? stdenv.hostPlatform.sse3Support
, enableSse4_1 ? stdenv.hostPlatform.sse4_1Support
, enableAvx ? true #stdenv.hostPlatform.avxSupport
, enableAvx2 ? stdenv.hostPlatform.avx2Support
, enableAvx512 ? stdenv.hostPlatform.avx512Support
}:

stdenv.mkDerivation rec {
pname = "openmpi";
version = "4.1.6";
version = "5.0.2";

src = with lib.versions; fetchurl {
url = "https://www.open-mpi.org/software/ompi/v${major version}.${minor version}/downloads/${pname}-${version}.tar.bz2";
sha256 = "sha256-90CZRIVRbetjtTEa8SLCZRefUyig2FelZ7hdsAsR5BU=";
sha256 = "sha256-7katju7iw/9wdyFgv/h3y/OMMwoLw7PdyBFkizOWaY8=";
};

postPatch = ''
patchShebangs ./
# Ensure build is reproducible
ts=`date -d @$SOURCE_DATE_EPOCH`
sed -i 's/OPAL_CONFIGURE_USER=.*/OPAL_CONFIGURE_USER="nixbld"/' configure
sed -i 's/OPAL_CONFIGURE_HOST=.*/OPAL_CONFIGURE_HOST="localhost"/' configure
sed -i "s/OPAL_CONFIGURE_DATE=.*/OPAL_CONFIGURE_DATE=\"$ts\"/" configure
find -name "Makefile.in" -exec sed -i "s/\`date\`/$ts/" \{} \;
# This is dynamically detected. Configure does not provide fine grained options
# We just disable the check in the configure script for now
${lib.optionalString (!enableSse3)
"substituteInPlace configure --replace 'ompi_cv_op_avx_check_sse3=yes' 'ompi_cv_op_avx_check_sse3=no'"}
${lib.optionalString (!enableSse4_1)
"substituteInPlace configure --replace 'ompi_cv_op_avx_check_sse41=yes' 'ompi_cv_op_avx_check_sse41=no'"}
${lib.optionalString (!enableAvx)
"substituteInPlace configure --replace 'ompi_cv_op_avx_check_avx=yes' 'ompi_cv_op_avx_check_avx=no'"}
${lib.optionalString (!enableAvx2)
"substituteInPlace configure --replace 'ompi_cv_op_avx_check_avx2=yes' 'ompi_cv_op_avx_check_avx2=no'"}
${lib.optionalString (!enableAvx512)
"substituteInPlace configure --replace 'ompi_cv_op_avx_check_avx512=yes' 'ompi_cv_op_avx_check_av512=no'"}
'';

outputs = [ "out" "man" "dev" ];
preConfigure = ''
# Ensure build is reproducible according to manual
# https://docs.open-mpi.org/en/v5.0.x/release-notes/general.html#general-notes
export USER=nixbld
export HOSTNAME=localhost
export SOURCE_DATE_EPOCH=0
'';

buildInputs = [ zlib ]
++ lib.optionals stdenv.isLinux [ libnl numactl pmix ucx ucc ]
outputs = [ "out" "man" ];

buildInputs = [ zlib libevent hwloc ]
++ lib.optionals stdenv.isLinux [ numactl pmix ucx ucc ]
++ lib.optionals cudaSupport [ cudaPackages.cuda_cudart ]
++ [ libevent hwloc ]
++ lib.optional (stdenv.isLinux || stdenv.isFreeBSD) rdma-core
++ lib.optionals fabricSupport [ libpsm2 libfabric ];

nativeBuildInputs = [ perl removeReferencesTo makeWrapper ]
nativeBuildInputs = [ perl ]
++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc ]
++ lib.optionals fortranSupport [ gfortran ];

configureFlags = lib.optional (!cudaSupport) "--disable-mca-dso"
++ lib.optional (!fortranSupport) "--disable-mpi-fortran"
++ lib.optionals stdenv.isLinux [
"--with-libnl=${lib.getDev libnl}"
"--with-pmix=${lib.getDev pmix}"
"--with-pmix-libdir=${pmix}/lib"
"--enable-mpi-cxx"
] ++ lib.optional enableSGE "--with-sge"
++ lib.optional enableSGE "--with-sge"
++ lib.optional enablePrefix "--enable-mpirun-prefix-by-default"
# TODO: add UCX support, which is recommended to use with cuda for the most robust OpenMPI build
# https://github.com/openucx/ucx
# https://www.open-mpi.org/faq/?category=buildcuda
++ lib.optionals cudaSupport [ "--with-cuda=${cudaPackages.cuda_cudart}" "--enable-dlopen" ]
++ lib.optionals fabricSupport [ "--with-psm2=${lib.getDev libpsm2}" "--with-libfabric=${lib.getDev libfabric}" ]
;
++ lib.optionals fabricSupport [
"--with-psm2=${lib.getDev libpsm2}"
"--with-libfabric=${lib.getDev libfabric}"
"--with-libfabric-libdir=${lib.getLib libfabric}/lib"
];

enableParallelBuilding = true;

postInstall = ''
find $out/lib/ -name "*.la" -exec rm -f \{} \;
for f in mpi shmem osh; do
for i in f77 f90 CC c++ cxx cc fort; do
moveToOutput "bin/$f$i" "''${!outputDev}"
echo "move $fi$i"
moveToOutput "share/openmpi/$f$i-wrapper-data.txt" "''${!outputDev}"
done
done
for i in ortecc orte-info ompi_info oshmem_info opal_wrapper; do
moveToOutput "bin/$i" "''${!outputDev}"
done
moveToOutput "share/openmpi/ortecc-wrapper-data.txt" "''${!outputDev}"
'';

postFixup = ''
remove-references-to -t $dev $(readlink -f $out/lib/libopen-pal${stdenv.hostPlatform.extensions.sharedLibrary})
remove-references-to -t $man $(readlink -f $out/lib/libopen-pal${stdenv.hostPlatform.extensions.sharedLibrary})
# The path to the wrapper is hard coded in libopen-pal.so, which we just cleared.
wrapProgram $dev/bin/opal_wrapper \
--set OPAL_INCLUDEDIR $dev/include \
--set OPAL_PKGDATADIR $dev/share/openmpi
# default compilers should be indentical to the
# compilers at build time
echo "$dev/share/openmpi/mpicc-wrapper-data.txt"
sed -i 's:compiler=.*:compiler=${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc:' \
$dev/share/openmpi/mpicc-wrapper-data.txt
echo "$dev/share/openmpi/ortecc-wrapper-data.txt"
sed -i 's:compiler=.*:compiler=${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc:' \
$dev/share/openmpi/ortecc-wrapper-data.txt
for cfg in mpicc shmemcc; do
sed -i 's:compiler=.*:compiler=${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc:' \
"$out/share/openmpi/$cfg-wrapper-data.txt"
done
echo "$dev/share/openmpi/mpic++-wrapper-data.txt"
sed -i 's:compiler=.*:compiler=${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}c++:' \
$dev/share/openmpi/mpic++-wrapper-data.txt
for cfg in mpic++ shmemc++; do
sed -i 's:compiler=.*:compiler=${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}c++:' \
"$out/share/openmpi/$cfg-wrapper-data.txt"
done
'' + lib.optionalString fortranSupport ''
echo "$dev/share/openmpi/mpifort-wrapper-data.txt"
sed -i 's:compiler=.*:compiler=${gfortran}/bin/${gfortran.targetPrefix}gfortran:' \
$dev/share/openmpi/mpifort-wrapper-data.txt
for cfg in mpifort shmemfort; do
sed -i 's:compiler=.*:compiler=${gfortran}/bin/${gfortran.targetPrefix}gfortran:' \
"$out/share/openmpi/$cfg-wrapper-data.txt"
done
'';

doCheck = true;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/libraries/pmix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ stdenv.mkDerivation rec {
makeWrapper
];

buildInputs = [ libevent hwloc munge zlib ];
buildInputs = [ libevent hwloc munge zlib python3 ];

configureFlags = [
"--with-libevent=${lib.getDev libevent}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
, blas
}:

assert !blas.isILP64;

stdenv.mkDerivation rec {
pname = "plumed";
version = "2.9.0";
Expand All @@ -21,6 +19,8 @@ stdenv.mkDerivation rec {
patchShebangs .
'';

configureFlags = [] ++ lib.optional blas.isILP64 "--enable-ilp64";

buildInputs = [ blas ];

enableParallelBuilding = true;
Expand Down

0 comments on commit 8a86fdd

Please sign in to comment.