1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2015, 2018, 2019 Eric Bavier <bavier@member.fsf.org>
3 ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
5 ;;; Copyright © 2016 Andreas Enge <andreas@enge.fr>
6 ;;; Copyright © 2017 Dave Love <fx@gnu.org>
7 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
8 ;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2018 Paul Garlick <pgarlick@tourbillion-technology.com>
10 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
12 ;;; This file is part of GNU Guix.
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27 (define-module (gnu packages mpi)
28 #:use-module (guix packages)
29 #:use-module ((guix licenses) #:prefix license:)
30 #:use-module (guix download)
31 #:use-module (guix utils)
32 #:use-module (guix deprecation)
33 #:use-module (guix build-system gnu)
34 #:use-module (guix build-system python)
35 #:use-module (gnu packages)
36 #:use-module (gnu packages base)
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages fabric-management)
39 #:use-module (gnu packages gcc)
40 #:use-module (gnu packages java)
41 #:use-module (gnu packages libevent)
42 #:use-module (gnu packages linux)
43 #:use-module (gnu packages pciutils)
44 #:use-module (gnu packages xorg)
45 #:use-module (gnu packages gtk)
46 #:use-module (gnu packages xml)
47 #:use-module (gnu packages perl)
48 #:use-module (gnu packages ncurses)
49 #:use-module (gnu packages parallel)
50 #:use-module (gnu packages pkg-config)
51 #:use-module (gnu packages valgrind)
52 #:use-module (srfi srfi-1)
53 #:use-module (ice-9 match))
55 (define-public hwloc-1
56 ;; Note: For now we keep 1.x as the default because many packages have yet
63 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
64 (version-major+minor version)
65 "/downloads/hwloc-" version ".tar.bz2"))
68 "0za1b9lvrm3rhn0lrxja5f64r0aq1qs4m0pxn1ji2mbi8ndppyyx"))))
69 (build-system gnu-build-system)
70 (outputs '("out" ;'lstopo' & co., depends on Cairo, libx11, etc.
78 ,@(if (not (string-prefix? "armhf"
79 (or (%current-target-system)
81 `(("numactl" ,numactl))
84 ;; hwloc.pc lists it in 'Requires.private'.
85 `(("libpciaccess" ,libpciaccess)))
87 `(("pkg-config" ,pkg-config)))
89 `(#:configure-flags '("--localstatedir=/var")
91 (modify-phases %standard-phases
92 (add-before 'check 'skip-linux-libnuma-test
94 ;; Arrange to skip 'tests/linux-libnuma', which fails on some
95 ;; machines: <https://github.com/open-mpi/hwloc/issues/213>.
96 (substitute* "tests/linux-libnuma.c"
97 (("numa_available\\(\\)")
100 (add-after 'install 'refine-libnuma
101 ;; Give -L arguments for libraries to avoid propagation
102 (lambda* (#:key inputs outputs #:allow-other-keys)
103 (let ((out (assoc-ref outputs "lib"))
104 (numa (assoc-ref inputs "numactl")))
105 (substitute* (map (lambda (f) (string-append out "/" f))
106 '("lib/pkgconfig/hwloc.pc" "lib/libhwloc.la"))
108 (string-append "-L" numa "/lib " lib))))))
109 (add-after 'install 'avoid-circular-references
110 (lambda* (#:key outputs #:allow-other-keys)
111 (let ((lib (assoc-ref outputs "lib")))
112 ;; Suppress the 'prefix=' and 'exec_prefix=' lines so that the
113 ;; "lib" output doesn't refer to "out".
114 (substitute* (string-append lib "/lib/pkgconfig/hwloc.pc")
118 (home-page "https://www.open-mpi.org/projects/hwloc/")
119 (synopsis "Abstraction of hardware architectures")
121 "hwloc provides a portable abstraction (across OS,
122 versions, architectures, ...) of the hierarchical topology of modern
123 architectures, including NUMA memory nodes, sockets, shared caches, cores and
124 simultaneous multithreading. It also gathers various attributes such as cache
125 and memory information. It primarily aims at helping high-performance
126 computing applications with gathering information about the hardware so as to
127 exploit it accordingly and efficiently.
129 hwloc may display the topology in multiple convenient formats. It also offers
130 a powerful programming interface to gather information about the hardware,
131 bind processes, and much more.")
132 (license license:bsd-3)))
134 (define-public hwloc-2
135 ;; Note: 2.0 isn't the default yet, see above.
141 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
142 (version-major+minor version)
143 "/downloads/hwloc-" version ".tar.bz2"))
146 "0li27a3lnmb77qxpijj0kpblz32wmqd3b386sypq8ar7vy9vhw5f"))))
148 ;; libnuma is no longer needed.
149 (inputs (alist-delete "numactl" (package-inputs hwloc-1)))
151 (substitute-keyword-arguments (package-arguments hwloc-1)
153 `(modify-phases ,phases
154 (replace 'skip-linux-libnuma-test
156 ;; Arrange to skip 'tests/hwloc/linux-libnuma', which fails on
157 ;; some machines: <https://github.com/open-mpi/hwloc/issues/213>.
158 (substitute* "tests/hwloc/linux-libnuma.c"
159 (("numa_available\\(\\)")
162 (add-before 'check 'skip-test-that-fails-on-qemu
164 ;; Skip test that fails on emulated hardware due to QEMU bug:
165 ;; <https://bugs.gnu.org/40342>.
166 (substitute* "tests/hwloc/hwloc_get_last_cpu_location.c"
167 (("hwloc_topology_init" all)
168 (string-append "exit (77);\n" all)))
171 (define-deprecated hwloc-2.0 hwloc-2)
174 ;; The latest stable series of hwloc.
177 (define-public openmpi
184 (uri (string-append "https://www.open-mpi.org/software/ompi/v"
185 (version-major+minor version)
186 "/downloads/openmpi-" version ".tar.bz2"))
188 (base32 "00zxcw99gr5n693cmcmn4f6a47vx1ywna895p0x7p163v37gw0hl"))
189 (patches (search-patches "openmpi-mtl-priorities.patch"))))
190 (build-system gnu-build-system)
192 `(("hwloc" ,hwloc-2 "lib")
193 ("gfortran" ,gfortran)
194 ("libfabric" ,libfabric)
195 ("libevent" ,libevent)
197 ,@(if (and (not (%current-target-system))
198 (member (%current-system) (package-supported-systems psm)))
201 ,@(if (and (not (%current-target-system))
202 (member (%current-system) (package-supported-systems psm2)))
205 ,@(if (and (not (%current-target-system))
206 (member (%current-system) (package-supported-systems ucx)))
209 ("rdma-core" ,rdma-core)
210 ("valgrind" ,valgrind)
211 ("slurm" ,slurm))) ;for PMI support (launching via "srun")
213 `(("pkg-config" ,pkg-config)
215 (outputs '("out" "debug"))
217 `(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
218 "--enable-memchecker"
221 "--with-hwloc=external"
224 ;; InfiniBand support
225 "--enable-openib-control-hdr-padding"
226 "--enable-openib-dynamic-sl"
227 "--enable-openib-udcm"
228 "--enable-openib-rdmacm"
229 "--enable-openib-rdmacm-ibaddr"
231 ;; Enable support for SLURM's Process Manager
233 ,(string-append "--with-pmi="
234 (assoc-ref %build-inputs "slurm")))
235 #:phases (modify-phases %standard-phases
236 ;; opensm is needed for InfiniBand support.
237 (add-after 'unpack 'find-opensm-headers
238 (lambda* (#:key inputs #:allow-other-keys)
239 (setenv "C_INCLUDE_PATH"
240 (string-append (assoc-ref inputs "opensm")
241 "/include/infiniband"))
242 (setenv "CPLUS_INCLUDE_PATH"
243 (string-append (assoc-ref inputs "opensm")
244 "/include/infiniband"))
246 (add-before 'build 'remove-absolute
248 ;; Remove compiler absolute file names (OPAL_FC_ABSOLUTE
249 ;; etc.) to reduce the closure size. See
250 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-07/msg00388.html>
252 ;; <https://www.mail-archive.com/users@lists.open-mpi.org//msg31397.html>.
253 (substitute* '("orte/tools/orte-info/param.c"
254 "oshmem/tools/oshmem_info/param.c"
255 "ompi/tools/ompi_info/param.c")
257 ;; Avoid valgrind (which pulls in gdb etc.).
259 '("./ompi/mca/io/romio321/src/io_romio321_component.c")
260 (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
261 "\"[elided to reduce closure]\""))
263 (add-before 'build 'scrub-timestamps ;reproducibility
265 (substitute* '("ompi/tools/ompi_info/param.c"
266 "orte/tools/orte-info/param.c"
267 "oshmem/tools/oshmem_info/param.c")
268 ((".*(Built|Configured) on.*") ""))
270 (add-after 'install 'remove-logs ;reproducibility
271 (lambda* (#:key outputs #:allow-other-keys)
272 (let ((out (assoc-ref outputs "out")))
273 (for-each delete-file (find-files out "config.log"))
275 (home-page "https://www.open-mpi.org")
276 (synopsis "MPI-3 implementation")
278 "The Open MPI Project is an MPI-3 implementation that is developed and
279 maintained by a consortium of academic, research, and industry partners. Open
280 MPI is therefore able to combine the expertise, technologies, and resources
281 from all across the High Performance Computing community in order to build the
282 best MPI library available. Open MPI offers advantages for system and
283 software vendors, application developers and computer science researchers.")
284 ;; See file://LICENSE
285 (license license:bsd-2)))
287 ;; TODO: javadoc files contain timestamps.
288 (define-public java-openmpi
289 (package (inherit openmpi)
290 (name "java-openmpi")
292 `(("openmpi" ,openmpi)
293 ,@(package-inputs openmpi)))
295 `(("jdk" ,openjdk11 "jdk")
296 ("zip" ,(@ (gnu packages compression) zip))
297 ,@(package-native-inputs openmpi)))
300 `(#:modules ((guix build gnu-build-system)
301 ((guix build ant-build-system) #:prefix ant:)
303 #:imported-modules ((guix build ant-build-system)
304 (guix build syscalls)
305 ,@%gnu-build-system-modules)
306 ,@(substitute-keyword-arguments (package-arguments openmpi)
307 ((#:configure-flags flags)
308 `(cons "--enable-mpi-java" ,flags))
309 ((#:make-flags flags ''())
310 `(append '("-C" "ompi/mpi/java")
313 `(modify-phases ,phases
314 ;; We could provide the location of the JDK in the configure
315 ;; flags, but since the configure flags are embedded in the
316 ;; info binaries that would leave a reference to the JDK in
317 ;; the "out" output. To avoid this we set JAVA_HOME.
318 (add-after 'unpack 'set-JAVA_HOME
319 (lambda* (#:key inputs #:allow-other-keys)
320 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
322 (add-after 'unpack 'link-with-existing-mpi-libraries
323 (lambda* (#:key inputs #:allow-other-keys)
324 (substitute* "ompi/mpi/java/c/Makefile.in"
325 (("\\$\\(top_builddir\\)/ompi/lib@OMPI_LIBMPI_NAME@.la")
326 (string-append (assoc-ref inputs "openmpi") "/lib/libmpi.la")))
328 (add-after 'install 'strip-jar-timestamps
329 (assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))))
330 (synopsis "Java bindings for MPI")))
332 (define-public openmpi-thread-multiple
335 (name "openmpi-thread-multiple")
337 (substitute-keyword-arguments (package-arguments openmpi)
338 ((#:configure-flags flags)
339 `(cons "--enable-mpi-thread-multiple" ,flags))))
340 (description " This version of Open@tie{}MPI has an implementation of
341 @code{MPI_Init_thread} that provides @code{MPI_THREAD_MULTIPLE}. This won't
342 work correctly with all transports (such as @code{openib}), and the
343 performance is generally worse than the vanilla @code{openmpi} package, which
344 only provides @code{MPI_THREAD_FUNNELED}.")))
346 ;;; Build phase to be used for packages that execute MPI code.
347 (define-public %openmpi-setup
349 ;; By default, running the test suite would fail because 'ssh' could not
350 ;; be found in $PATH. Define this variable to placate Open MPI without
351 ;; adding a dependency on OpenSSH (the agent isn't used anyway.)
352 (setenv "OMPI_MCA_plm_rsh_agent" (which "false"))
353 ;; Allow oversubscription in case there are less physical cores available
354 ;; in the build environment than the package wants while testing.
355 (setenv "OMPI_MCA_rmaps_base_mapping_policy" "core:OVERSUBSCRIBE")
357 ;; UCX sometimes outputs uninteresting warnings such as:
359 ;; mpool.c:38 UCX WARN object 0x7ffff44fffc0 was not returned to mpool ucp_am_bufs
361 ;; These in turn leads to failures of test suites that capture and
362 ;; compare stdout, such as that of 'hdf5-parallel-openmpi'. Thus, tell
363 ;; UCX to not emit those warnings.
364 (setenv "UCX_LOG_LEVEL" "error")
367 (define-public python-mpi4py
369 (name "python-mpi4py")
374 (uri (pypi-uri "mpi4py" version))
376 (base32 "07ssbhssv27rrjx1c5vd3vsr31vay5d8xcf4zh9yblcyidn72b81"))))
377 (build-system python-build-system)
380 (modify-phases %standard-phases
381 (add-after 'build 'mpi-setup
383 (add-before 'check 'pre-check
385 ;; Skip BaseTestSpawn class (causes error 'ompi_dpm_dyn_init()
386 ;; failed --> Returned "Unreachable"' in chroot environment).
387 (substitute* "test/test_spawn.py"
388 (("unittest.skipMPI\\('openmpi\\(<3.0.0\\)'\\)")
389 "unittest.skipMPI('openmpi')"))
392 `(("openmpi" ,openmpi)))
393 (home-page "https://bitbucket.org/mpi4py/mpi4py/")
394 (synopsis "Python bindings for the Message Passing Interface standard")
395 (description "MPI for Python (mpi4py) provides bindings of the Message
396 Passing Interface (MPI) standard for the Python programming language, allowing
397 any Python program to exploit multiple processors.
399 mpi4py is constructed on top of the MPI-1/MPI-2 specification and provides an
400 object oriented interface which closely follows MPI-2 C++ bindings. It
401 supports point-to-point and collective communications of any picklable Python
402 object as well as optimized communications of Python objects (such as NumPy
403 arrays) that expose a buffer interface.")
404 (license license:bsd-3)))
412 (uri (string-append "http://www.mpich.org/static/downloads/"
413 version "/mpich-" version ".tar.gz"))
416 "1farz5zfx4cd0c3a0wb9pgfypzw0xxql1j1294z1sxslga1ziyjb"))))
417 (build-system gnu-build-system)
420 ("hwloc" ,hwloc-2 "lib")
422 ,@(if (and (not (%current-target-system))
423 (member (%current-system) (package-supported-systems ucx)))
429 ("gfortran" ,gfortran)))
430 (outputs '("out" "debug"))
433 (list "--disable-silent-rules" ;let's see what's happening
435 ;; "--with-device=ch4:ucx" ; --with-device=ch4:ofi segfaults in tests
436 (string-append "--with-hwloc-prefix="
437 (assoc-ref %build-inputs "hwloc"))
439 ,@(if (assoc "ucx" (package-inputs this-package))
440 `((string-append "--with-ucx="
441 (assoc-ref %build-inputs "ucx")))
444 #:phases (modify-phases %standard-phases
445 (add-after 'unpack 'patch-sources
447 (substitute* "./maint/gen_subcfg_m4"
448 (("/usr/bin/env") (which "env")))
449 (substitute* "src/glue/romio/all_romio_symbols"
450 (("/usr/bin/env") (which "env")))
451 (substitute* (find-files "." "buildiface")
452 (("/usr/bin/env") (which "env")))
453 (substitute* "maint/extracterrmsgs"
454 (("/usr/bin/env") (which "env")))
455 (substitute* (find-files "." "f77tof90")
456 (("/usr/bin/env") (which "env")))
457 (substitute* (find-files "." "\\.sh$")
458 (("/bin/sh") (which "sh")))
460 (add-before 'configure 'fix-makefile
462 ;; Remove "@hwloclib@" from 'pmpi_convenience_libs'.
463 ;; This fixes "No rule to make target '-lhwloc', needed
464 ;; by 'lib/libmpi.la'".
465 (substitute* "Makefile.in"
466 (("^pmpi_convenience_libs = (.*) @hwloclib@ (.*)$" _
468 (string-append "pmpi_convenience_libs = "
471 (home-page "https://www.mpich.org/")
472 (synopsis "Implementation of the Message Passing Interface (MPI)")
474 "MPICH is a high-performance and portable implementation of the Message
475 Passing Interface (MPI) standard (MPI-1, MPI-2 and MPI-3). MPICH provides an
476 MPI implementation that efficiently supports different computation and
477 communication platforms including commodity clusters, high-speed networks (10
478 Gigabit Ethernet, InfiniBand, Myrinet, Quadrics), and proprietary high-end
479 computing systems (Blue Gene, Cray). It enables research in MPI through a
480 modular framework for other derived implementations.")
481 (license license:bsd-2)))