gnu: Use PACKAGE/INHERIT in more places.
[jackhill/guix/guix.git] / gnu / packages / mpi.scm
index 30169f7..9a4dc6d 100644 (file)
@@ -1,11 +1,11 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2015, 2018, 2019 Eric Bavier <bavier@member.fsf.org>
-;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
 ;;; Copyright © 2016 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2017 Dave Love <fx@gnu.org>
 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
-;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2018 Paul Garlick <pgarlick@tourbillion-technology.com>
 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
 ;;;
 
 (define-module (gnu packages mpi)
   #:use-module (guix packages)
-  #:use-module ((guix licenses)
-                #:hide (expat))
+  #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix download)
-  #:use-module (guix git-download)
   #:use-module (guix utils)
   #:use-module (guix deprecation)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
   #:use-module (gnu packages)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages compression)
   #:use-module (gnu packages fabric-management)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages java)
@@ -52,7 +52,7 @@
   #:use-module (srfi srfi-1)
   #:use-module (ice-9 match))
 
-(define-public hwloc
+(define-public hwloc-1
   ;; Note: For now we keep 1.x as the default because many packages have yet
   ;; to migrate to 2.0.
   (package
@@ -69,6 +69,7 @@
     (build-system gnu-build-system)
     (outputs '("out"           ;'lstopo' & co., depends on Cairo, libx11, etc.
                "lib"           ;small closure
+               "doc"           ;400+ section 3 man pages
                "debug"))
     (inputs
      `(("libx11" ,libx11)
                (substitute* (string-append lib "/lib/pkgconfig/hwloc.pc")
                  (("^.*prefix=.*$")
                   ""))
+               #t)))
+         (add-after 'install 'move-man3-pages
+           (lambda* (#:key outputs #:allow-other-keys)
+             ;; Move section 3 man pages to the "doc" output.
+             (let ((out (assoc-ref outputs "out"))
+                   (doc (assoc-ref outputs "doc")))
+               (copy-recursively (string-append out "/share/man/man3")
+                                 (string-append doc "/share/man/man3"))
+               (delete-file-recursively (string-append out "/share/man/man3"))
                #t))))))
     (home-page "https://www.open-mpi.org/projects/hwloc/")
     (synopsis "Abstraction of hardware architectures")
@@ -129,26 +139,26 @@ exploit it accordingly and efficiently.
 hwloc may display the topology in multiple convenient formats.  It also offers
 a powerful programming interface to gather information about the hardware,
 bind processes, and much more.")
-    (license bsd-3)))
+    (license license:bsd-3)))
 
 (define-public hwloc-2
-  ;; Note: 2.0 isn't the default yet, see above.
+  ;; Note: 2.x isn't the default yet, see above.
   (package
-    (inherit hwloc)
-    (version "2.1.0")
+    (inherit hwloc-1)
+    (version "2.4.1")
     (source (origin
               (method url-fetch)
-              (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
+              (uri (string-append "https://download.open-mpi.org/release/hwloc/v"
                                   (version-major+minor version)
-                                  "/downloads/hwloc-" version ".tar.bz2"))
+                                  "/hwloc-" version ".tar.bz2"))
               (sha256
                (base32
-                "0qh8s7pphz0m5cwb7liqmc17xzfs23xhz5wn24r6ikvjyx99fhhr"))))
+                "0qyywmyns2jf3is3axrwmffvdd7ji7liy5axp650q4i6kzk2291r"))))
 
     ;; libnuma is no longer needed.
-    (inputs (alist-delete "numactl" (package-inputs hwloc)))
+    (inputs (alist-delete "numactl" (package-inputs hwloc-1)))
     (arguments
-     (substitute-keyword-arguments (package-arguments hwloc)
+     (substitute-keyword-arguments (package-arguments hwloc-1)
        ((#:phases phases)
         `(modify-phases ,phases
            (replace 'skip-linux-libnuma-test
@@ -158,15 +168,26 @@ bind processes, and much more.")
                (substitute* "tests/hwloc/linux-libnuma.c"
                  (("numa_available\\(\\)")
                   "-1"))
+               #t))
+           (add-before 'check 'skip-test-that-fails-on-qemu
+             (lambda _
+               ;; Skip test that fails on emulated hardware due to QEMU bug:
+               ;; <https://bugs.gnu.org/40342>.
+               (substitute* "tests/hwloc/hwloc_get_last_cpu_location.c"
+                 (("hwloc_topology_init" all)
+                  (string-append "exit (77);\n" all)))
                #t))))))))
 
-(define-deprecated hwloc-2.0 'hwloc-2
+(define-deprecated hwloc-2.0 hwloc-2)
+
+(define-public hwloc
+  ;; The latest stable series of hwloc.
   hwloc-2)
 
 (define-public openmpi
   (package
     (name "openmpi")
-    (version "4.0.2")
+    (version "4.0.5")
     (source
      (origin
       (method url-fetch)
@@ -174,8 +195,8 @@ bind processes, and much more.")
                           (version-major+minor version)
                           "/downloads/openmpi-" version ".tar.bz2"))
       (sha256
-       (base32 "0ms0zvyxyy3pnx9qwib6zaljyp2b3ixny64xvq3czv3jpr8zf2wh"))
-      (patches (search-patches "openmpi-psm2-priority.patch"))))
+       (base32 "02f0r9d3xgs08svkmj8v7lzviyxqnkk4yd3z0wql550xnriki3y5"))
+      (patches (search-patches "openmpi-mtl-priorities.patch"))))
     (build-system gnu-build-system)
     (inputs
      `(("hwloc" ,hwloc-2 "lib")
@@ -210,11 +231,9 @@ bind processes, and much more.")
                            "--with-hwloc=external"
                            "--with-libevent"
 
-                           ;; Make sure ./configure fails if one of these is
-                           ;; missing.
-                           "--with-ucx"
-                           "--with-psm"
-                           "--with-psm2"
+                           ;; Help 'orterun' and 'mpirun' find their tools
+                           ;; under $prefix by default.
+                           "--enable-mpirun-prefix-by-default"
 
                            ;; InfiniBand support
                            "--enable-openib-control-hdr-padding"
@@ -267,7 +286,7 @@ bind processes, and much more.")
                       (let ((out (assoc-ref outputs "out")))
                         (for-each delete-file (find-files out "config.log"))
                         #t))))))
-    (home-page "http://www.open-mpi.org")
+    (home-page "https://www.open-mpi.org")
     (synopsis "MPI-3 implementation")
     (description
      "The Open MPI Project is an MPI-3 implementation that is developed and
@@ -277,11 +296,11 @@ 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.")
     ;; See file://LICENSE
-    (license bsd-2)))
+    (license license:bsd-2)))
 
 ;; TODO: javadoc files contain timestamps.
 (define-public java-openmpi
-  (package (inherit openmpi)
+  (package/inherit openmpi
     (name "java-openmpi")
     (inputs
      `(("openmpi" ,openmpi)
@@ -325,8 +344,7 @@ software vendors, application developers and computer science researchers.")
     (synopsis "Java bindings for MPI")))
 
 (define-public openmpi-thread-multiple
-  (package
-    (inherit openmpi)
+  (package/inherit openmpi
     (name "openmpi-thread-multiple")
     (arguments
      (substitute-keyword-arguments (package-arguments openmpi)
@@ -348,58 +366,16 @@ only provides @code{MPI_THREAD_FUNNELED}.")))
      ;; Allow oversubscription in case there are less physical cores available
      ;; in the build environment than the package wants while testing.
      (setenv "OMPI_MCA_rmaps_base_mapping_policy" "core:OVERSUBSCRIBE")
-     #t))
-
-(define-public intel-mpi-benchmarks
-  (package
-    (name "intel-mpi-benchmarks")
-    (version "2019.3")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                    (url "https://github.com/intel/mpi-benchmarks.git")
-                    (commit (string-append "IMB-v" version))))
-              (file-name (git-file-name name version))
-              (sha256
-               (base32
-                "0si5xi6ilhd3w0gbsg124589pvp094hvf366rvjjb9pi7pdk5p4i"))))
-    (build-system gnu-build-system)
-    (arguments
-     '(#:phases (modify-phases %standard-phases
-                  (delete 'configure)
-                  (delete 'check)
-                  (replace 'install
-                    (lambda* (#:key outputs #:allow-other-keys)
-                      (define (benchmark? file stat)
-                        (and (string-prefix? "IMB-" (basename file))
-                             (executable-file? file)))
-
-                      (let* ((out (assoc-ref outputs "out"))
-                             (bin (string-append out "/bin")))
-                        (for-each (lambda (file)
-                                    (install-file file bin))
-                                  (find-files "." benchmark?))
-                        #t))))
 
-       ;; The makefile doesn't express all the dependencies, it seems.
-       #:parallel-build? #t
-
-       #:make-flags (list (string-append "CC="
-                                         (assoc-ref %build-inputs "openmpi")
-                                         "/bin/mpicc")
-                          (string-append "CXX="
-                                         (assoc-ref %build-inputs "openmpi")
-                                         "/bin/mpicxx"))))
-    (inputs
-     `(("openmpi" ,openmpi)))
-    (home-page "https://github.com/intel/mpi-benchmarks")
-    (synopsis "Benchmarks for the Message Passing Interface (MPI)")
-    (description
-     "Intel MPI Benchmarks (IMB) provides a set of elementary benchmarks that
-conform with versions 1, 2, and 3 of the Message Passing Interface (MPI).")
-    (license
-     (fsf-free "https://directory.fsf.org/wiki/License:CPL-1.0"
-               "https://www.gnu.org/licenses/license-list.html#CommonPublicLicense10"))))
+     ;; UCX sometimes outputs uninteresting warnings such as:
+     ;;
+     ;;   mpool.c:38   UCX  WARN  object 0x7ffff44fffc0 was not returned to mpool ucp_am_bufs
+     ;;
+     ;; These in turn leads to failures of test suites that capture and
+     ;; compare stdout, such as that of 'hdf5-parallel-openmpi'.  Thus, tell
+     ;; UCX to not emit those warnings.
+     (setenv "UCX_LOG_LEVEL" "error")
+     #t))
 
 (define-public python-mpi4py
   (package
@@ -438,4 +414,86 @@ object oriented interface which closely follows MPI-2 C++ bindings.  It
 supports point-to-point and collective communications of any picklable Python
 object as well as optimized communications of Python objects (such as NumPy
 arrays) that expose a buffer interface.")
-    (license bsd-3)))
+    (license license:bsd-3)))
+
+(define-public mpich
+  (package
+    (name "mpich")
+    (version "3.3.2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "http://www.mpich.org/static/downloads/"
+                                  version "/mpich-" version ".tar.gz"))
+              (sha256
+               (base32
+                "1farz5zfx4cd0c3a0wb9pgfypzw0xxql1j1294z1sxslga1ziyjb"))))
+    (build-system gnu-build-system)
+    (inputs
+     `(("zlib" ,zlib)
+       ("hwloc" ,hwloc-2 "lib")
+       ("slurm" ,slurm)
+       ,@(if (and (not (%current-target-system))
+                  (member (%current-system) (package-supported-systems ucx)))
+             `(("ucx" ,ucx))
+             '())))
+    (native-inputs
+     `(("perl" ,perl)
+       ("which" ,which)
+       ("gfortran" ,gfortran)))
+    (outputs '("out" "debug"))
+    (arguments
+     `(#:configure-flags
+       (list "--disable-silent-rules"             ;let's see what's happening
+             "--enable-debuginfo"
+
+             ;; Default to "ch4", as will be the case in 3.4.  It also works
+             ;; around issues when running test suites of packages that use
+             ;; MPICH: <https://issues.guix.gnu.org/39588#15>.
+             "--with-device=ch4:ucx" ; --with-device=ch4:ofi segfaults in tests
+
+             (string-append "--with-hwloc-prefix="
+                            (assoc-ref %build-inputs "hwloc"))
+
+             ,@(if (assoc "ucx" (package-inputs this-package))
+                   `((string-append "--with-ucx="
+                                    (assoc-ref %build-inputs "ucx")))
+                   '()))
+
+       #:phases (modify-phases %standard-phases
+                  (add-after 'unpack 'patch-sources
+                    (lambda _
+                      (substitute* "./maint/gen_subcfg_m4"
+                        (("/usr/bin/env") (which "env")))
+                      (substitute* "src/glue/romio/all_romio_symbols"
+                        (("/usr/bin/env") (which "env")))
+                      (substitute* (find-files "." "buildiface")
+                        (("/usr/bin/env") (which "env")))
+                      (substitute* "maint/extracterrmsgs"
+                        (("/usr/bin/env") (which "env")))
+                      (substitute* (find-files "." "f77tof90")
+                        (("/usr/bin/env") (which "env")))
+                      (substitute* (find-files "." "\\.sh$")
+                        (("/bin/sh") (which "sh")))
+                      #t))
+                  (add-before 'configure 'fix-makefile
+                    (lambda _
+                      ;; Remove "@hwloclib@" from 'pmpi_convenience_libs'.
+                      ;; This fixes "No rule to make target '-lhwloc', needed
+                      ;; by 'lib/libmpi.la'".
+                      (substitute* "Makefile.in"
+                        (("^pmpi_convenience_libs = (.*) @hwloclib@ (.*)$" _
+                          before after)
+                         (string-append "pmpi_convenience_libs = "
+                                        before " " after)))
+                      #t)))))
+    (home-page "https://www.mpich.org/")
+    (synopsis "Implementation of the Message Passing Interface (MPI)")
+    (description
+     "MPICH is a high-performance and portable implementation of the Message
+Passing Interface (MPI) standard (MPI-1, MPI-2 and MPI-3).  MPICH provides an
+MPI implementation that efficiently supports different computation and
+communication platforms including commodity clusters, high-speed networks (10
+Gigabit Ethernet, InfiniBand, Myrinet, Quadrics), and proprietary high-end
+computing systems (Blue Gene, Cray).  It enables research in MPI through a
+modular framework for other derived implementations.")
+    (license license:bsd-2)))