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.0.3";
15
16 src = fetchurl {
17 url = "https://www.mpich.org/static/downloads/${version}/mpich-${version}.tar.gz";
18 sha256 = "sha256-F0BuqQpu1OzVvjnJ3cv6yTQ+arT3esToxevko+O2xQE=";
19 };
20
21 configureFlags = [
22 "--enable-shared"
23 "--enable-sharedlib"
24 "--with-pm=${withPm}"
25 ] ++ lib.optionals (lib.versionAtLeast gfortran.version "10") [
26 "FFLAGS=-fallow-argument-mismatch" # https://github.com/pmodels/mpich/issues/4300
27 "FCFLAGS=-fallow-argument-mismatch"
28 ];
29
30 enableParallelBuilding = true;
31
32 nativeBuildInputs = [ gfortran python3 ];
33 buildInputs = [ perl openssh hwloc ]
34 ++ lib.optional (!stdenv.isDarwin) ch4backend;
35
36 doCheck = true;
37
38 preFixup = ''
39 # Ensure the default compilers are the ones mpich was built with
40 sed -i 's:CC="gcc":CC=${stdenv.cc}/bin/gcc:' $out/bin/mpicc
41 sed -i 's:CXX="g++":CXX=${stdenv.cc}/bin/g++:' $out/bin/mpicxx
42 sed -i 's:FC="gfortran":FC=${gfortran}/bin/gfortran:' $out/bin/mpifort
43 '';
44
45 meta = with lib; {
46 description = "Implementation of the Message Passing Interface (MPI) standard";
47
48 longDescription = ''
49 MPICH2 is a free high-performance and portable implementation of
50 the Message Passing Interface (MPI) standard, both version 1 and
51 version 2.
52 '';
53 homepage = "http://www.mcs.anl.gov/mpi/mpich2/";
54 license = {
55 url = "http://git.mpich.org/mpich.git/blob/a385d6d0d55e83c3709ae851967ce613e892cd21:/COPYRIGHT";
56 fullName = "MPICH license (permissive)";
57 };
58 maintainers = [ maintainers.markuskowa ];
59 platforms = platforms.linux ++ platforms.darwin;
60 };
61}