gnu: quilt: Update to 0.66.
[jackhill/guix/guix.git] / gnu / packages / mpi.scm
index 9c2f44d..952edca 100644 (file)
@@ -1,10 +1,13 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015 Eric Bavier <bavier@member.fsf.org>
-;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; 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 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 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018 Paul Garlick <pgarlick@tourbillion-technology.com>
+;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
   #:use-module (guix download)
   #:use-module (guix utils)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system python)
   #:use-module (gnu packages)
+  #:use-module (gnu packages fabric-management)
   #:use-module (gnu packages gcc)
+  #:use-module (gnu packages java)
+  #:use-module (gnu packages libevent)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages pciutils)
   #:use-module (gnu packages xorg)
@@ -37,6 +44,7 @@
   #:use-module (gnu packages xml)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages ncurses)
+  #:use-module (gnu packages parallel)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages valgrind)
   #:use-module (srfi srfi-1)
@@ -47,7 +55,7 @@
   ;; to migrate to 2.0.
   (package
     (name "hwloc")
-    (version "1.11.9")
+    (version "1.11.12")
     (source (origin
               (method url-fetch)
               (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
@@ -55,7 +63,7 @@
                                   "/downloads/hwloc-" version ".tar.bz2"))
               (sha256
                (base32
-                "0r2im1s5lp7zjwqalcqcnlxx0dsky1bnx5waf2r3rmj888c36hrr"))))
+                "0za1b9lvrm3rhn0lrxja5f64r0aq1qs4m0pxn1ji2mbi8ndppyyx"))))
     (build-system gnu-build-system)
     (outputs '("out"           ;'lstopo' & co., depends on Cairo, libx11, etc.
                "lib"           ;small closure
      `(#:configure-flags '("--localstatedir=/var")
        #:phases
        (modify-phases %standard-phases
+         (add-before 'check 'skip-linux-libnuma-test
+           (lambda _
+             ;; Arrange to skip 'tests/linux-libnuma', which fails on some
+             ;; machines: <https://github.com/open-mpi/hwloc/issues/213>.
+             (substitute* "tests/linux-libnuma.c"
+               (("numa_available\\(\\)")
+                "-1"))
+             #t))
          (add-after 'install 'refine-libnuma
            ;; Give -L arguments for libraries to avoid propagation
            (lambda* (#:key inputs outputs #:allow-other-keys)
@@ -117,7 +133,7 @@ bind processes, and much more.")
   ;; Note: 2.0 isn't the default yet, see above.
   (package
     (inherit hwloc)
-    (version "2.0.0")
+    (version "2.0.3")
     (source (origin
               (method url-fetch)
               (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
@@ -125,16 +141,27 @@ bind processes, and much more.")
                                   "/downloads/hwloc-" version ".tar.bz2"))
               (sha256
                (base32
-                "021765f9y6pxcxrvfpzzwaig16ypfbph5xjpkd29qkhzs9r6zrcr"))
-              (patches (search-patches "hwloc-tests-without-sysfs.patch"))))
+                "09f7ajak8wv5issr0hw72vs3jkldc7crcc7z5fd34sspkvrsm4z3"))))
 
     ;; libnuma is no longer needed.
-    (inputs (alist-delete "numactl" (package-inputs hwloc)))))
+    (inputs (alist-delete "numactl" (package-inputs hwloc)))
+    (arguments
+     (substitute-keyword-arguments (package-arguments hwloc)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (replace 'skip-linux-libnuma-test
+             (lambda _
+               ;; Arrange to skip 'tests/hwloc/linux-libnuma', which fails on
+               ;; some machines: <https://github.com/open-mpi/hwloc/issues/213>.
+               (substitute* "tests/hwloc/linux-libnuma.c"
+                 (("numa_available\\(\\)")
+                  "-1"))
+               #t))))))))
 
 (define-public openmpi
   (package
     (name "openmpi")
-    (version "1.10.7")
+    (version "4.0.0")
     (source
      (origin
       (method url-fetch)
@@ -143,18 +170,25 @@ bind processes, and much more.")
                           "/downloads/openmpi-" version ".tar.bz2"))
       (sha256
        (base32
-        "142s1vny9gllkq336yafxayjgcirj2jv0ddabj879jgya7hyr2d0"))))
+        "0srnjwzsmyhka9hhnmqm86qck4w3xwjm8g6sbns58wzbrwv8l2rg"))))
     (build-system gnu-build-system)
     (inputs
      `(("hwloc" ,hwloc "lib")
        ("gfortran" ,gfortran)
        ("libfabric" ,libfabric)
-       ,@(match (%current-system)
-                ((member (package-supported-systems psm))
-                 `(("psm" ,psm)))
-                (_ `()))
+       ("libevent" ,libevent)
+       ("opensm" ,opensm)
+       ,@(if (and (not (%current-target-system))
+                  (member (%current-system) (package-supported-systems psm)))
+             `(("psm" ,psm))
+             '())
+       ,@(if (and (not (%current-target-system))
+                  (member (%current-system) (package-supported-systems psm2)))
+             `(("psm2" ,psm2))
+             '())
        ("rdma-core" ,rdma-core)
-       ("valgrind" ,valgrind)))
+       ("valgrind" ,valgrind)
+       ("slurm" ,slurm)))              ;for PMI support (launching via "srun")
     (native-inputs
      `(("pkg-config" ,pkg-config)
        ("perl" ,perl)))
@@ -163,16 +197,34 @@ bind processes, and much more.")
      `(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
                            "--enable-memchecker"
                            "--with-sge"
+                           "--with-valgrind"
+                           "--with-hwloc=external"
+                           "--with-libevent"
 
-                           ;; VampirTrace is obsoleted by scorep and disabling
-                           ;; it reduces the closure size considerably.
-                           "--disable-vt"
+                           ;; InfiniBand support
+                           "--enable-openib-control-hdr-padding"
+                           "--enable-openib-dynamic-sl"
+                           "--enable-openib-udcm"
+                           "--enable-openib-rdmacm"
+                           "--enable-openib-rdmacm-ibaddr"
 
-                           ,(string-append "--with-valgrind="
-                                           (assoc-ref %build-inputs "valgrind"))
-                           ,(string-append "--with-hwloc="
-                                           (assoc-ref %build-inputs "hwloc")))
+                           ;; Enable support for SLURM's Process Manager
+                           ;; Interface (PMI).
+                           ,(string-append "--with-pmi="
+                                           (assoc-ref %build-inputs "slurm")))
        #:phases (modify-phases %standard-phases
+                  ;; opensm is needed for InfiniBand support.
+                  (add-after 'unpack 'find-opensm-headers
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      (setenv "C_INCLUDE_PATH"
+                              (string-append (assoc-ref inputs "opensm")
+                                             "/include/infiniband/:"
+                                             (getenv "C_INCLUDE_PATH")))
+                      (setenv "CPLUS_INCLUDE_PATH"
+                              (string-append (assoc-ref inputs "opensm")
+                                             "/include/infiniband/:"
+                                             (getenv "CPLUS_INCLUDE_PATH")))
+                      #t))
                   (add-before 'build 'remove-absolute
                     (lambda _
                       ;; Remove compiler absolute file names (OPAL_FC_ABSOLUTE
@@ -186,8 +238,8 @@ bind processes, and much more.")
                         (("_ABSOLUTE") ""))
                       ;; Avoid valgrind (which pulls in gdb etc.).
                       (substitute*
-                          '("./ompi/mca/io/romio/src/io_romio_component.c")
-                        (("MCA_io_romio_COMPLETE_CONFIGURE_FLAGS")
+                          '("./ompi/mca/io/romio321/src/io_romio321_component.c")
+                        (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
                          "\"[elided to reduce closure]\""))
                       #t))
                   (add-before 'build 'scrub-timestamps ;reproducibility
@@ -214,6 +266,51 @@ software vendors, application developers and computer science researchers.")
     ;; See file://LICENSE
     (license bsd-2)))
 
+;; TODO: javadoc files contain timestamps.
+(define-public java-openmpi
+  (package (inherit openmpi)
+    (name "java-openmpi")
+    (inputs
+     `(("openmpi" ,openmpi)
+       ,@(package-inputs openmpi)))
+    (native-inputs
+     `(("jdk" ,openjdk11 "jdk")
+       ("zip" ,(@ (gnu packages compression) zip))
+       ,@(package-native-inputs openmpi)))
+    (outputs '("out"))
+    (arguments
+     `(#:modules ((guix build gnu-build-system)
+                  ((guix build ant-build-system) #:prefix ant:)
+                  (guix build utils))
+       #:imported-modules ((guix build ant-build-system)
+                           (guix build syscalls)
+                           ,@%gnu-build-system-modules)
+       ,@(substitute-keyword-arguments (package-arguments openmpi)
+           ((#:configure-flags flags)
+            `(cons "--enable-mpi-java" ,flags))
+           ((#:make-flags flags ''())
+            `(append '("-C" "ompi/mpi/java")
+                     ,flags))
+           ((#:phases phases)
+            `(modify-phases ,phases
+               ;; We could provide the location of the JDK in the configure
+               ;; flags, but since the configure flags are embedded in the
+               ;; info binaries that would leave a reference to the JDK in
+               ;; the "out" output.  To avoid this we set JAVA_HOME.
+               (add-after 'unpack 'set-JAVA_HOME
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
+                   #t))
+               (add-after 'unpack 'link-with-existing-mpi-libraries
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (substitute* "ompi/mpi/java/c/Makefile.in"
+                     (("\\$\\(top_builddir\\)/ompi/lib@OMPI_LIBMPI_NAME@.la")
+                      (string-append (assoc-ref inputs "openmpi") "/lib/libmpi.la")))
+                   #t))
+               (add-after 'install 'strip-jar-timestamps
+                 (assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))))
+    (synopsis "Java bindings for MPI")))
+
 (define-public openmpi-thread-multiple
   (package
     (inherit openmpi)
@@ -227,3 +324,55 @@ software vendors, application developers and computer science researchers.")
 work correctly with all transports (such as @code{openib}), and the
 performance is generally worse than the vanilla @code{openmpi} package, which
 only provides @code{MPI_THREAD_FUNNELED}.")))
+
+;;; Build phase to be used for packages that execute MPI code.
+(define-public %openmpi-setup
+  '(lambda _
+     ;; By default, running the test suite would fail because 'ssh' could not
+     ;; be found in $PATH.  Define this variable to placate Open MPI without
+     ;; adding a dependency on OpenSSH (the agent isn't used anyway.)
+     (setenv "OMPI_MCA_plm_rsh_agent" (which "false"))
+     ;; 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 python-mpi4py
+  (package
+    (name "python-mpi4py")
+    (version "3.0.1")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (pypi-uri "mpi4py" version))
+        (sha256
+          (base32
+            "0ld8rjmsjr0dklvj2g1gr3ax32sdq0xjxyh0cspknc1i36waajb5"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'build 'mpi-setup
+           ,%openmpi-setup)
+         (add-before 'check 'pre-check
+           (lambda _
+             ;; Skip BaseTestSpawn class (causes error 'ompi_dpm_dyn_init()
+             ;; failed --> Returned "Unreachable"' in chroot environment).
+             (substitute* "test/test_spawn.py"
+               (("unittest.skipMPI\\('openmpi\\(<3.0.0\\)'\\)")
+                "unittest.skipMPI('openmpi')"))
+             #t)))))
+    (inputs
+     `(("openmpi" ,openmpi)))
+    (home-page "https://bitbucket.org/mpi4py/mpi4py/")
+    (synopsis "Python bindings for the Message Passing Interface standard")
+    (description "MPI for Python (mpi4py) provides bindings of the Message
+Passing Interface (MPI) standard for the Python programming language, allowing
+any Python program to exploit multiple processors.
+
+mpi4py is constructed on top of the MPI-1/MPI-2 specification and provides an
+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)))