<commit_before>{ lib, stdenv, fetchurl, pkg-config, bison, numactl, libxml2
, perl, gfortran, slurm, openssh, hwloc, zlib, makeWrapper
# InfiniBand dependencies
, opensm, rdma-core
# OmniPath dependencies
, libpsm2, libfabric
# Compile with slurm as a process manager
, useSlurm ? false
# Network type for MVAPICH2
, network ? "ethernet"
} :

assert builtins.elem network [ "ethernet" "infiniband" "omnipath" ];

stdenv.mkDerivation rec {
  pname = "mvapich";
  version = "2.3.6";

  src = fetchurl {
    url = "http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-${version}.tar.gz";
    sha256 = "0jd28vy9ivl3rcpkxmhw73b6krzm0pd9jps8asw92wa00lm2z9mk";
  };

  nativeBuildInputs = [ pkg-config bison makeWrapper gfortran ];
  propagatedBuildInputs = [ numactl rdma-core zlib opensm ];
  buildInputs = with lib; [
    numactl
    libxml2
    perl
    openssh
    hwloc
  ] ++ optionals (network == "infiniband") [ rdma-core opensm ]
    ++ optionals (network == "omnipath") [ libpsm2 libfabric ]
    ++ optional useSlurm slurm;

  configureFlags = with lib; [
    "--with-pm=hydra"
    "--enable-fortran=all"
    "--enable-cxx"
    "--enable-threads=multiple"
    "--enable-hybrid"
    "--enable-shared"
  ] ++ optional useSlurm "--with-pm=slurm"
    ++ optional (network == "ethernet") "--with-device=ch3:sock"
    ++ optionals (network == "infiniband") [ "--with-device=ch3:mrail" "--with-rdma=gen2" ]
    ++ optionals (network == "omnipath") ["--with-device=ch3:psm" "--with-psm2=${libpsm2}"];

  doCheck = true;

  preFixup = ''
    # /tmp/nix-build... ends up in the RPATH, fix it manually
    for entry in $out/bin/mpichversion $out/bin/mpivars; do
      echo "fix rpath: $entry"
      patchelf --set-rpath "$out/lib" $entry
    done

    # Ensure the default compilers are the ones mvapich was built with<commit_msg>mvapich: fix build with gfortran 10<commit_after>{ lib, stdenv, fetchurl, pkg-config, bison, numactl, libxml2
, perl, gfortran, slurm, openssh, hwloc, zlib, makeWrapper
# InfiniBand dependencies
, opensm, rdma-core
# OmniPath dependencies
, libpsm2, libfabric
# Compile with slurm as a process manager
, useSlurm ? false
# Network type for MVAPICH2
, network ? "ethernet"
} :

assert builtins.elem network [ "ethernet" "infiniband" "omnipath" ];

stdenv.mkDerivation rec {
  pname = "mvapich";
  version = "2.3.6";

  src = fetchurl {
    url = "http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-${version}.tar.gz";
    sha256 = "0jd28vy9ivl3rcpkxmhw73b6krzm0pd9jps8asw92wa00lm2z9mk";
  };

  nativeBuildInputs = [ pkg-config bison makeWrapper gfortran ];
  propagatedBuildInputs = [ numactl rdma-core zlib opensm ];
  buildInputs = with lib; [
    numactl
    libxml2
    perl
    openssh
    hwloc
  ] ++ optionals (network == "infiniband") [ rdma-core opensm ]
    ++ optionals (network == "omnipath") [ libpsm2 libfabric ]
    ++ optional useSlurm slurm;

  configureFlags = with lib; [
    "--with-pm=hydra"
    "--enable-fortran=all"
    "--enable-cxx"
    "--enable-threads=multiple"
    "--enable-hybrid"
    "--enable-shared"
    "FFLAGS=-fallow-argument-mismatch" # fix build with gfortran 10
  ] ++ optional useSlurm "--with-pm=slurm"
    ++ optional (network == "ethernet") "--with-device=ch3:sock"
    ++ optionals (network == "infiniband") [ "--with-device=ch3:mrail" "--with-rdma=gen2" ]
    ++ optionals (network == "omnipath") ["--with-device=ch3:psm" "--with-psm2=${libpsm2}"];

  doCheck = true;

  preFixup = ''
    # /tmp/nix-build... ends up in the RPATH, fix it manually
    for entry in $out/bin/mpichversion $out/bin/mpivars; do
      echo "fix rpath: $entry"
      patchelf --set-rpath "$out/lib" $entry
    done

    # Ensure the default compilers are the ones mvapich was built with
{'fraction_non_alphanumeric': 0.14422565194252263, 'fraction_numerical': 0.020223523150612027, 'mean_word_length': 3.453791469194313, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4255592', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1393, 'n_words': 312}