1{ stdenv, lib, fetchurl, perl, gfortran
2, openssh, hwloc, python3
3# either libfabric or ucx work for ch4backend on linux. On darwin, neither of
4# these libraries currently build so this argument is ignored on Darwin.
5, ch4backend
6# Process manager to build
7, withPm ? "hydra:gforker"
8} :
9
10assert (ch4backend.pname == "ucx" || ch4backend.pname == "libfabric");
11
12stdenv.mkDerivation rec {
13 pname = "mpich";
14 version = "4.1.2";
15
16 src = fetchurl {
17 url = "https://www.mpich.org/static/downloads/${version}/mpich-${version}.tar.gz";
18 sha256 = "sha256-NJLpitq2K1l+8NKS+yRZthI7yABwqKoKML5pYgdaEvA=";
19 };
20
21 outputs = [ "out" "doc" "man" ];
22
23 configureFlags = [
24 "--enable-shared"
25 "--enable-sharedlib"
26 "--with-pm=${withPm}"
27 ] ++ lib.optionals (lib.versionAtLeast gfortran.version "10") [
28 "FFLAGS=-fallow-argument-mismatch" # https://github.com/pmodels/mpich/issues/4300
29 "FCFLAGS=-fallow-argument-mismatch"
30 ];
31
32 enableParallelBuilding = true;
33
34 nativeBuildInputs = [ gfortran python3 ];
35 buildInputs = [ perl openssh hwloc ]
36 ++ lib.optional (!stdenv.isDarwin) ch4backend;
37
38 doCheck = true;
39
40 preFixup = ''
41 # Ensure the default compilers are the ones mpich was built with
42 sed -i 's:CC="gcc":CC=${stdenv.cc}/bin/gcc:' $out/bin/mpicc
43 sed -i 's:CXX="g++":CXX=${stdenv.cc}/bin/g++:' $out/bin/mpicxx
44 sed -i 's:FC="gfortran":FC=${gfortran}/bin/gfortran:' $out/bin/mpifort
45 '';
46
47 meta = with lib; {
48 description = "Implementation of the Message Passing Interface (MPI) standard";
49
50 longDescription = ''
51 MPICH2 is a free high-performance and portable implementation of
52 the Message Passing Interface (MPI) standard, both version 1 and
53 version 2.
54 '';
55 homepage = "http://www.mcs.anl.gov/mpi/mpich2/";
56 license = {
57 url = "http://git.mpich.org/mpich.git/blob/a385d6d0d55e83c3709ae851967ce613e892cd21:/COPYRIGHT";
58 fullName = "MPICH license (permissive)";
59 };
60 maintainers = [ maintainers.markuskowa ];
61 platforms = platforms.linux ++ platforms.darwin;
62 };
63}