2019-06-28 03:24:10 +00:00
|
|
|
{ stdenv, fetchurl, fetchpatch, gfortran, perl, libnl
|
2019-10-20 21:05:35 +00:00
|
|
|
, rdma-core, zlib, numactl, libevent, hwloc, pkgsTargetTarget, symlinkJoin
|
|
|
|
|
|
|
|
# Enable CUDA support
|
|
|
|
, cudaSupport ? false, cudatoolkit ? null
|
2014-07-06 21:13:04 +00: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 21:05:35 +00:00
|
|
|
assert !cudaSupport || cudatoolkit != null;
|
|
|
|
|
2015-12-28 23:24:51 +00:00
|
|
|
let
|
2020-03-07 02:26:10 +00:00
|
|
|
version = "4.0.3";
|
2015-12-28 23:24:51 +00:00
|
|
|
|
2019-10-20 21:05:35 +00: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 21:52:01 +00: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 21:52:01 +00:00
|
|
|
url = "https://www.open-mpi.org/software/ompi/v${major version}.${minor version}/downloads/${pname}-${version}.tar.bz2";
|
2020-03-07 02:26:10 +00:00
|
|
|
sha256 = "00zxcw99gr5n693cmcmn4f6a47vx1ywna895p0x7p163v37gw0hl";
|
2009-06-05 13:31:57 +00:00
|
|
|
};
|
2015-12-28 23:24:51 +00:00
|
|
|
|
2018-01-20 00:16:35 +00:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs ./
|
2019-04-04 12:51:33 +00: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 13:41:14 +00:00
|
|
|
++ lib.optionals isLinux [ libnl numactl ]
|
2019-10-20 21:05:35 +00:00
|
|
|
++ lib.optionals cudaSupport [ cudatoolkit ]
|
2019-07-13 13:41:14 +00: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 21:05:35 +00: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 21:05:35 +00: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 21:13:04 +00:00
|
|
|
;
|
2015-12-28 23:24:51 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2016-08-31 10:03:07 +00:00
|
|
|
postInstall = ''
|
2018-01-20 00:16:35 +00:00
|
|
|
rm -f $out/lib/*.la
|
2016-08-31 10:03:07 +00:00
|
|
|
'';
|
|
|
|
|
2019-04-04 13:13:34 +00: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 21:05:35 +00:00
|
|
|
passthru = {
|
|
|
|
inherit cudaSupport cudatoolkit;
|
|
|
|
};
|
|
|
|
|
2018-01-25 21:31:45 +00:00
|
|
|
meta = with stdenv.lib; {
|
2020-03-07 02:26:10 +00: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 22:55:44 +00:00
|
|
|
platforms = platforms.unix;
|
2013-02-03 16:45:35 +00:00
|
|
|
};
|
2009-06-05 13:31:57 +00:00
|
|
|
}
|