2019-06-28 04:24:10 +01:00
|
|
|
{ stdenv, fetchurl, fetchpatch, gfortran, perl, libnl
|
2019-10-20 22:05:35 +01:00
|
|
|
, rdma-core, zlib, numactl, libevent, hwloc, pkgsTargetTarget, symlinkJoin
|
|
|
|
|
|
|
|
# Enable CUDA support
|
|
|
|
, cudaSupport ? false, cudatoolkit ? null
|
2014-07-06 22:13:04 +01:00
|
|
|
|
|
|
|
# Enable the Sun Grid Engine bindings
|
|
|
|
, enableSGE ? false
|
|
|
|
|
|
|
|
# Pass PATH/LD_LIBRARY_PATH to point to current mpirun by default
|
|
|
|
, enablePrefix ? false
|
|
|
|
}:
|
|
|
|
|
2019-10-20 22:05:35 +01:00
|
|
|
assert !cudaSupport || cudatoolkit != null;
|
|
|
|
|
2015-12-28 23:24:51 +00:00
|
|
|
let
|
2019-10-09 11:32:51 +01:00
|
|
|
version = "4.0.2";
|
2015-12-28 23:24:51 +00:00
|
|
|
|
2019-10-20 22:05:35 +01:00
|
|
|
cudatoolkit_joined = symlinkJoin {
|
|
|
|
name = "${cudatoolkit.name}-unsplit";
|
|
|
|
paths = [ cudatoolkit.out cudatoolkit.lib ];
|
|
|
|
};
|
2015-12-28 23:24:51 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
2019-08-13 22:52:01 +01:00
|
|
|
pname = "openmpi";
|
|
|
|
inherit version;
|
2015-12-28 23:24:51 +00:00
|
|
|
|
2018-11-10 15:27:47 +00:00
|
|
|
src = with stdenv.lib.versions; fetchurl {
|
2019-08-13 22:52:01 +01:00
|
|
|
url = "https://www.open-mpi.org/software/ompi/v${major version}.${minor version}/downloads/${pname}-${version}.tar.bz2";
|
2019-10-09 11:32:51 +01:00
|
|
|
sha256 = "0ms0zvyxyy3pnx9qwib6zaljyp2b3ixny64xvq3czv3jpr8zf2wh";
|
2009-06-05 14:31:57 +01:00
|
|
|
};
|
2015-12-28 23:24:51 +00:00
|
|
|
|
2018-01-20 00:16:35 +00:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs ./
|
2019-04-04 13:51:33 +01:00
|
|
|
|
|
|
|
# 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/" \{} \;
|
2018-01-20 00:16:35 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
buildInputs = with stdenv; [ gfortran zlib ]
|
2019-07-13 14:41:14 +01:00
|
|
|
++ lib.optionals isLinux [ libnl numactl ]
|
2019-10-20 22:05:35 +01:00
|
|
|
++ lib.optionals cudaSupport [ cudatoolkit ]
|
2019-07-13 14:41:14 +01:00
|
|
|
++ [ libevent hwloc ]
|
2018-01-25 21:31:45 +00:00
|
|
|
++ lib.optional (isLinux || isFreeBSD) rdma-core;
|
2015-12-28 23:24:51 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [ perl ];
|
|
|
|
|
2019-10-20 22:05:35 +01:00
|
|
|
configureFlags = with stdenv; lib.optional (!cudaSupport) "--disable-mca-dso"
|
2018-01-25 21:31:45 +00:00
|
|
|
++ lib.optional isLinux "--with-libnl=${libnl.dev}"
|
|
|
|
++ lib.optional enableSGE "--with-sge"
|
|
|
|
++ lib.optional enablePrefix "--enable-mpirun-prefix-by-default"
|
2019-10-20 22:05:35 +01:00
|
|
|
# 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=${cudatoolkit_joined}" "--enable-dlopen" ]
|
2014-07-06 22:13:04 +01:00
|
|
|
;
|
2015-12-28 23:24:51 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2016-08-31 11:03:07 +01:00
|
|
|
postInstall = ''
|
2018-01-20 00:16:35 +00:00
|
|
|
rm -f $out/lib/*.la
|
2016-08-31 11:03:07 +01:00
|
|
|
'';
|
|
|
|
|
2019-04-04 14:13:34 +01:00
|
|
|
postFixup = ''
|
|
|
|
# default compilers should be indentical to the
|
|
|
|
# compilers at build time
|
|
|
|
|
|
|
|
sed -i 's:compiler=.*:compiler=${pkgsTargetTarget.stdenv.cc}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}cc:' \
|
|
|
|
$out/share/openmpi/mpicc-wrapper-data.txt
|
|
|
|
|
|
|
|
sed -i 's:compiler=.*:compiler=${pkgsTargetTarget.stdenv.cc}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}cc:' \
|
|
|
|
$out/share/openmpi/ortecc-wrapper-data.txt
|
|
|
|
|
|
|
|
sed -i 's:compiler=.*:compiler=${pkgsTargetTarget.stdenv.cc}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}c++:' \
|
|
|
|
$out/share/openmpi/mpic++-wrapper-data.txt
|
|
|
|
|
|
|
|
sed -i 's:compiler=.*:compiler=${pkgsTargetTarget.gfortran}/bin/${pkgsTargetTarget.gfortran.targetPrefix}gfortran:' \
|
|
|
|
$out/share/openmpi/mpifort-wrapper-data.txt
|
|
|
|
'';
|
|
|
|
|
2018-01-20 00:16:35 +00:00
|
|
|
doCheck = true;
|
|
|
|
|
2019-10-20 22:05:35 +01:00
|
|
|
passthru = {
|
|
|
|
inherit cudaSupport cudatoolkit;
|
|
|
|
};
|
|
|
|
|
2018-01-25 21:31:45 +00:00
|
|
|
meta = with stdenv.lib; {
|
2019-07-10 20:52:51 +01:00
|
|
|
homepage = https://www.open-mpi.org/;
|
2018-01-20 00:16:35 +00:00
|
|
|
description = "Open source MPI-3 implementation";
|
|
|
|
longDescription = "The Open MPI Project is an open source MPI-3 implementation that is developed and maintained by a consortium of academic, research, and industry partners. Open MPI is therefore able to combine the expertise, technologies, and resources from all across the High Performance Computing community in order to build the best MPI library available. Open MPI offers advantages for system and software vendors, application developers and computer science researchers.";
|
|
|
|
maintainers = with maintainers; [ markuskowa ];
|
|
|
|
license = licenses.bsd3;
|
2016-07-21 23:55:44 +01:00
|
|
|
platforms = platforms.unix;
|
2013-02-03 16:45:35 +00:00
|
|
|
};
|
2009-06-05 14:31:57 +01:00
|
|
|
}
|