NixOS configuration for HPC cluster https://docs.hpc.informatik.hs-fulda.de/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
4.8 KiB

  1. { lib
  2. , stdenv
  3. , fetchurl
  4. , removeReferencesTo
  5. , gfortran
  6. , perl
  7. , libnl
  8. , rdma-core
  9. , zlib
  10. , numactl
  11. , libevent
  12. , hwloc
  13. , targetPackages
  14. , symlinkJoin
  15. , libpsm2
  16. , libfabric
  17. , pmix
  18. , ucx
  19. , ucc
  20. , makeWrapper
  21. , config
  22. # Enable CUDA support
  23. , cudaSupport ? config.cudaSupport
  24. , cudaPackages
  25. # Enable the Sun Grid Engine bindings
  26. , enableSGE ? false
  27. # Pass PATH/LD_LIBRARY_PATH to point to current mpirun by default
  28. , enablePrefix ? false
  29. # Enable libfabric support (necessary for Omnipath networks) on x86_64 linux
  30. , fabricSupport ? stdenv.isLinux && stdenv.isx86_64
  31. # Enable Fortran support
  32. , fortranSupport ? true
  33. , ripgrep
  34. }:
  35. stdenv.mkDerivation rec {
  36. pname = "openmpi";
  37. version = "5.0.3";
  38. src = with lib.versions; fetchurl {
  39. url = "https://www.open-mpi.org/software/ompi/v${major version}.${minor version}/downloads/${pname}-${version}.tar.bz2";
  40. hash = "sha256-mQWC8gazqzLpOKoxu/B8Y5No5EBdyhlvq+fw927tqQs=";
  41. };
  42. postPatch = ''
  43. patchShebangs ./
  44. '';
  45. preConfigure = ''
  46. # Ensure build is reproducible according to manual
  47. # https://docs.open-mpi.org/en/v5.0.x/release-notes/general.html#general-notes
  48. export USER=nixbld
  49. export HOSTNAME=localhost
  50. export SOURCE_DATE_EPOCH=0
  51. '';
  52. #outputs = [ "out" "man" "dev" ];
  53. buildInputs = [ zlib libevent hwloc ]
  54. ++ lib.optionals stdenv.isLinux [ libnl numactl pmix ucx ucc ]
  55. ++ lib.optionals cudaSupport [ cudaPackages.cuda_cudart ]
  56. ++ lib.optional (stdenv.isLinux || stdenv.isFreeBSD) rdma-core
  57. ++ lib.optionals fabricSupport [ libpsm2 libfabric ];
  58. nativeBuildInputs = [ perl removeReferencesTo makeWrapper ]
  59. ++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc ]
  60. ++ lib.optionals fortranSupport [ gfortran ];
  61. configureFlags = lib.optional (!cudaSupport) "--disable-mca-dso"
  62. ++ lib.optional (!fortranSupport) "--disable-mpi-fortran"
  63. ++ lib.optionals stdenv.isLinux [
  64. "--with-libnl=${lib.getDev libnl}"
  65. "--with-pmix=${lib.getDev pmix}"
  66. "--with-pmix-libdir=${pmix}/lib"
  67. ] ++ lib.optional enableSGE "--with-sge"
  68. ++ lib.optional enablePrefix "--enable-mpirun-prefix-by-default"
  69. # TODO: add UCX support, which is recommended to use with cuda for the most robust OpenMPI build
  70. # https://github.com/openucx/ucx
  71. # https://www.open-mpi.org/faq/?category=buildcuda
  72. ++ lib.optionals cudaSupport [ "--with-cuda=${cudaPackages.cuda_cudart}" "--enable-dlopen" ]
  73. ++ lib.optionals fabricSupport [
  74. "--with-psm2=${lib.getDev libpsm2}"
  75. "--with-libfabric=${lib.getDev libfabric}"
  76. "--with-libfabric-libdir=${lib.getLib libfabric}/lib"
  77. ];
  78. enableParallelBuilding = true;
  79. postFixup = ''
  80. remove-references-to -t $out $(readlink -f $out/lib/libopen-pal${stdenv.hostPlatform.extensions.sharedLibrary})
  81. remove-references-to -t $out $(readlink -f $out/lib/libopen-pal${stdenv.hostPlatform.extensions.sharedLibrary})
  82. # The path to the wrapper is hard coded in libopen-pal.so, which we just cleared.
  83. wrapProgram $out/bin/opal_wrapper \
  84. --set OPAL_INCLUDEDIR $out/include \
  85. --set OPAL_PKGDATADIR $out/share/openmpi
  86. # default compilers should be indentical to the
  87. # compilers at build time
  88. echo "$out/share/openmpi/mpicc-wrapper-data.txt"
  89. sed -i 's:compiler=.*:compiler=${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc:' \
  90. $out/share/openmpi/mpicc-wrapper-data.txt
  91. echo "$out/share/openmpi/shmemcc-wrapper-data.txt"
  92. sed -i 's:compiler=.*:compiler=${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc:' \
  93. $out/share/openmpi/shmemcc-wrapper-data.txt
  94. '' + lib.optionalString fortranSupport ''
  95. echo "$out/share/openmpi/mpifort-wrapper-data.txt"
  96. sed -i 's:compiler=.*:compiler=${gfortran}/bin/${gfortran.targetPrefix}gfortran:' \
  97. $out/share/openmpi/mpifort-wrapper-data.txt
  98. echo "$out/share/openmpi/shmemfort-wrapper-data.txt"
  99. sed -i 's:compiler=.*:compiler=${gfortran}/bin/${gfortran.targetPrefix}gfortran:' \
  100. $out/share/openmpi/shmemfort-wrapper-data.txt
  101. '';
  102. doCheck = true;
  103. passthru = {
  104. inherit cudaSupport;
  105. inherit (cudaPackages) cudatoolkit; # For backward compatibility only
  106. };
  107. meta = with lib; {
  108. homepage = "https://www.open-mpi.org/";
  109. description = "Open source MPI-3 implementation";
  110. 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.";
  111. maintainers = with maintainers; [ markuskowa ];
  112. license = licenses.bsd3;
  113. platforms = platforms.unix;
  114. };
  115. }