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.

481 lines
21 KiB

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2015, 2018, 2019 Eric Bavier <>
;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <>
;;; Copyright © 2014 Ian Denhardt <>
;;; Copyright © 2016 Andreas Enge <>
;;; Copyright © 2017 Dave Love <>
;;; Copyright © 2017 Efraim Flashner <>
;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <>
;;; Copyright © 2018 Paul Garlick <>
;;; Copyright © 2019 Ricardo Wurmus <>
;;; This file is part of GNU Guix.
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; GNU General Public License for more details.
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <>.
(define-module (gnu packages mpi)
#:use-module (guix packages)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix 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)
#:use-module (gnu packages libevent)
#:use-module (gnu packages linux)
#:use-module (gnu packages pciutils)
#:use-module (gnu packages xorg)
#:use-module (gnu packages gtk)
#: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)
#:use-module (ice-9 match))
(define-public hwloc-1
;; Note: For now we keep 1.x as the default because many packages have yet
;; to migrate to 2.0.
(name "hwloc")
(version "1.11.12")
(source (origin
(method url-fetch)
(uri (string-append ""
(version-major+minor version)
"/downloads/hwloc-" version ".tar.bz2"))
(build-system gnu-build-system)
(outputs '("out" ;'lstopo' & co., depends on Cairo, libx11, etc.
"lib" ;small closure
`(("libx11" ,libx11)
("cairo" ,cairo)
("ncurses" ,ncurses)
("expat" ,expat)
,@(if (not (string-prefix? "armhf"
(or (%current-target-system)
`(("numactl" ,numactl))
;; hwloc.pc lists it in 'Requires.private'.
`(("libpciaccess" ,libpciaccess)))
`(("pkg-config" ,pkg-config)))
`(#:configure-flags '("--localstatedir=/var")
(modify-phases %standard-phases
(add-before 'check 'skip-linux-libnuma-test
(lambda _
;; Arrange to skip 'tests/linux-libnuma', which fails on some
;; machines: <>.
(substitute* "tests/linux-libnuma.c"
(add-after 'install 'refine-libnuma
;; Give -L arguments for libraries to avoid propagation
(lambda* (#:key inputs outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "lib"))
(numa (assoc-ref inputs "numactl")))
(substitute* (map (lambda (f) (string-append out "/" f))
'("lib/pkgconfig/hwloc.pc" "lib/"))
(("-lnuma" lib)
(string-append "-L" numa "/lib " lib))))))
(add-after 'install 'avoid-circular-references
(lambda* (#:key outputs #:allow-other-keys)
(let ((lib (assoc-ref outputs "lib")))
;; Suppress the 'prefix=' and 'exec_prefix=' lines so that the
;; "lib" output doesn't refer to "out".
(substitute* (string-append lib "/lib/pkgconfig/hwloc.pc")
(home-page "")
(synopsis "Abstraction of hardware architectures")
"hwloc provides a portable abstraction (across OS,
versions, architectures, ...) of the hierarchical topology of modern
architectures, including NUMA memory nodes, sockets, shared caches, cores and
simultaneous multithreading. It also gathers various attributes such as cache
and memory information. It primarily aims at helping high-performance
computing applications with gathering information about the hardware so as to
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 license:bsd-3)))
(define-public hwloc-2
;; Note: 2.0 isn't the default yet, see above.
(inherit hwloc-1)
(version "2.2.0")
(source (origin
(method url-fetch)
(uri (string-append ""
(version-major+minor version)
"/downloads/hwloc-" version ".tar.bz2"))
;; libnuma is no longer needed.
(inputs (alist-delete "numactl" (package-inputs hwloc-1)))
(substitute-keyword-arguments (package-arguments hwloc-1)
((#:phases phases)
`(modify-phases ,phases
(replace 'skip-linux-libnuma-test
(lambda _
;; Arrange to skip 'tests/hwloc/linux-libnuma', which fails on
;; some machines: <>.
(substitute* "tests/hwloc/linux-libnuma.c"
(add-before 'check 'skip-test-that-fails-on-qemu
(lambda _
;; Skip test that fails on emulated hardware due to QEMU bug:
;; <>.
(substitute* "tests/hwloc/hwloc_get_last_cpu_location.c"
(("hwloc_topology_init" all)
(string-append "exit (77);\n" all)))
(define-deprecated hwloc-2.0 hwloc-2)
(define-public hwloc
;; The latest stable series of hwloc.
(define-public openmpi
(name "openmpi")
(version "4.0.3")
(method url-fetch)
(uri (string-append ""
(version-major+minor version)
"/downloads/openmpi-" version ".tar.bz2"))
(base32 "00zxcw99gr5n693cmcmn4f6a47vx1ywna895p0x7p163v37gw0hl"))
(patches (search-patches "openmpi-mtl-priorities.patch"))))
(build-system gnu-build-system)
`(("hwloc" ,hwloc-2 "lib")
("gfortran" ,gfortran)
("libfabric" ,libfabric)
("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))
,@(if (and (not (%current-target-system))
(member (%current-system) (package-supported-systems ucx)))
`(("ucx" ,ucx))
("rdma-core" ,rdma-core)
("valgrind" ,valgrind)
("slurm" ,slurm))) ;for PMI support (launching via "srun")
`(("pkg-config" ,pkg-config)
("perl" ,perl)))
(outputs '("out" "debug"))
`(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
;; InfiniBand support
;; 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")
(string-append (assoc-ref inputs "opensm")
(add-before 'build 'remove-absolute
(lambda _
;; Remove compiler absolute file names (OPAL_FC_ABSOLUTE
;; etc.) to reduce the closure size. See
;; <>
;; and
;; <>.
(substitute* '("orte/tools/orte-info/param.c"
(("_ABSOLUTE") ""))
;; Avoid valgrind (which pulls in gdb etc.).
"\"[elided to reduce closure]\""))
(add-before 'build 'scrub-timestamps ;reproducibility
(lambda _
(substitute* '("ompi/tools/ompi_info/param.c"
((".*(Built|Configured) on.*") ""))
(add-after 'install 'remove-logs ;reproducibility
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(for-each delete-file (find-files out "config.log"))
(home-page "")
(synopsis "MPI-3 implementation")
"The Open MPI Project is an 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.")
;; See file://LICENSE
(license license:bsd-2)))
;; TODO: javadoc files contain timestamps.
(define-public java-openmpi
(package (inherit openmpi)
(name "java-openmpi")
`(("openmpi" ,openmpi)
,@(package-inputs openmpi)))
`(("jdk" ,openjdk11 "jdk")
("zip" ,(@ (gnu packages compression) zip))
,@(package-native-inputs openmpi)))
(outputs '("out"))
`(#: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)
,@(substitute-keyword-arguments (package-arguments openmpi)
((#:configure-flags flags)
`(cons "--enable-mpi-java" ,flags))
((#:make-flags flags ''())
`(append '("-C" "ompi/mpi/java")
((#: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"))
(add-after 'unpack 'link-with-existing-mpi-libraries
(lambda* (#:key inputs #:allow-other-keys)
(substitute* "ompi/mpi/java/c/"
(string-append (assoc-ref inputs "openmpi") "/lib/")))
(add-after 'install 'strip-jar-timestamps
(assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))))
(synopsis "Java bindings for MPI")))
(define-public openmpi-thread-multiple
(inherit openmpi)
(name "openmpi-thread-multiple")
(substitute-keyword-arguments (package-arguments openmpi)
((#:configure-flags flags)
`(cons "--enable-mpi-thread-multiple" ,flags))))
(description " This version of Open@tie{}MPI has an implementation of
@code{MPI_Init_thread} that provides @code{MPI_THREAD_MULTIPLE}. This won't
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")
;; 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")
(define-public python-mpi4py
(name "python-mpi4py")
(version "3.0.3")
(method url-fetch)
(uri (pypi-uri "mpi4py" version))
(base32 "07ssbhssv27rrjx1c5vd3vsr31vay5d8xcf4zh9yblcyidn72b81"))))
(build-system python-build-system)
(modify-phases %standard-phases
(add-after 'build 'mpi-setup
(add-before 'check 'pre-check
(lambda _
;; Skip BaseTestSpawn class (causes error 'ompi_dpm_dyn_init()
;; failed --> Returned "Unreachable"' in chroot environment).
(substitute* "test/"
`(("openmpi" ,openmpi)))
(home-page "")
(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 license:bsd-3)))
(define-public mpich
(name "mpich")
(version "3.3.2")
(source (origin
(method url-fetch)
(uri (string-append ""
version "/mpich-" version ".tar.gz"))
(build-system gnu-build-system)
`(("zlib" ,zlib)
("hwloc" ,hwloc-2 "lib")
("slurm" ,slurm)
,@(if (and (not (%current-target-system))
(member (%current-system) (package-supported-systems ucx)))
`(("ucx" ,ucx))
`(("perl" ,perl)
("which" ,which)
("gfortran" ,gfortran)))
(outputs '("out" "debug"))
(list "--disable-silent-rules" ;let's see what's happening
;; "--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")))
(add-before 'configure 'fix-makefile
(lambda _
;; Remove "@hwloclib@" from 'pmpi_convenience_libs'.
;; This fixes "No rule to make target '-lhwloc', needed
;; by 'lib/'".
(substitute* ""
(("^pmpi_convenience_libs = (.*) @hwloclib@ (.*)$" _
before after)
(string-append "pmpi_convenience_libs = "
before " " after)))
(home-page "")
(synopsis "Implementation of the Message Passing Interface (MPI)")
"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)))