gnu: docker: Replace tini by tini-static.
[jackhill/guix/guix.git] / gnu / packages / mpi.scm
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, 2020, 2021 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–2021 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2018 Paul Garlick <pgarlick@tourbillion-technology.com>
10 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
11 ;;;
12 ;;; This file is part of GNU Guix.
13 ;;;
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.
18 ;;;
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.
23 ;;;
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/>.
26
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))
54
55 (define-public hwloc-1
56 ;; Note: For now we keep 1.x as the default because many packages have yet
57 ;; to migrate to 2.0.
58 (package
59 (name "hwloc")
60 (version "1.11.12")
61 (source (origin
62 (method url-fetch)
63 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
64 (version-major+minor version)
65 "/downloads/hwloc-" version ".tar.bz2"))
66 (sha256
67 (base32
68 "0za1b9lvrm3rhn0lrxja5f64r0aq1qs4m0pxn1ji2mbi8ndppyyx"))))
69
70 (properties
71 ;; Tell the 'generic-html' updater to monitor this URL for updates.
72 `((release-monitoring-url
73 . "https://www-lb.open-mpi.org/software/hwloc/current")))
74
75 (build-system gnu-build-system)
76 (outputs '("out" ;'lstopo' & co., depends on Cairo, libx11, etc.
77 "lib" ;small closure
78 "doc" ;400+ section 3 man pages
79 "debug"))
80 (inputs
81 `(("libx11" ,libx11)
82 ("cairo" ,cairo)
83 ("ncurses" ,ncurses)
84 ("expat" ,expat)
85 ,@(if (not (string-prefix? "armhf"
86 (or (%current-target-system)
87 (%current-system))))
88 `(("numactl" ,numactl))
89 '())))
90 (propagated-inputs
91 ;; hwloc.pc lists it in 'Requires.private'.
92 `(("libpciaccess" ,libpciaccess)))
93 (native-inputs
94 `(("pkg-config" ,pkg-config)))
95 (arguments
96 `(#:configure-flags '("--localstatedir=/var")
97 #:phases
98 (modify-phases %standard-phases
99 (add-before 'check 'skip-linux-libnuma-test
100 (lambda _
101 ;; Arrange to skip 'tests/linux-libnuma', which fails on some
102 ;; machines: <https://github.com/open-mpi/hwloc/issues/213>.
103 (substitute* "tests/linux-libnuma.c"
104 (("numa_available\\(\\)")
105 "-1"))
106 #t))
107 (add-after 'install 'refine-libnuma
108 ;; Give -L arguments for libraries to avoid propagation
109 (lambda* (#:key inputs outputs #:allow-other-keys)
110 (let ((out (assoc-ref outputs "lib"))
111 (numa (assoc-ref inputs "numactl")))
112 (substitute* (map (lambda (f) (string-append out "/" f))
113 '("lib/pkgconfig/hwloc.pc" "lib/libhwloc.la"))
114 (("-lnuma" lib)
115 (string-append "-L" numa "/lib " lib))))))
116 (add-after 'install 'avoid-circular-references
117 (lambda* (#:key outputs #:allow-other-keys)
118 (let ((lib (assoc-ref outputs "lib")))
119 ;; Suppress the 'prefix=' and 'exec_prefix=' lines so that the
120 ;; "lib" output doesn't refer to "out".
121 (substitute* (string-append lib "/lib/pkgconfig/hwloc.pc")
122 (("^.*prefix=.*$")
123 ""))
124 #t)))
125 (add-after 'install 'move-man3-pages
126 (lambda* (#:key outputs #:allow-other-keys)
127 ;; Move section 3 man pages to the "doc" output.
128 (let ((out (assoc-ref outputs "out"))
129 (doc (assoc-ref outputs "doc")))
130 (copy-recursively (string-append out "/share/man/man3")
131 (string-append doc "/share/man/man3"))
132 (delete-file-recursively (string-append out "/share/man/man3"))
133 #t))))))
134 (home-page "https://www.open-mpi.org/projects/hwloc/")
135 (synopsis "Abstraction of hardware architectures")
136 (description
137 "hwloc provides a portable abstraction (across OS,
138 versions, architectures, ...) of the hierarchical topology of modern
139 architectures, including NUMA memory nodes, sockets, shared caches, cores and
140 simultaneous multithreading. It also gathers various attributes such as cache
141 and memory information. It primarily aims at helping high-performance
142 computing applications with gathering information about the hardware so as to
143 exploit it accordingly and efficiently.
144
145 hwloc may display the topology in multiple convenient formats. It also offers
146 a powerful programming interface to gather information about the hardware,
147 bind processes, and much more.")
148 (license license:bsd-3)))
149
150 (define-public hwloc-2
151 ;; Note: 2.x isn't the default yet, see above.
152 (package
153 (inherit hwloc-1)
154 (version "2.4.1")
155 (source (origin
156 (method url-fetch)
157 (uri (string-append "https://download.open-mpi.org/release/hwloc/v"
158 (version-major+minor version)
159 "/hwloc-" version ".tar.bz2"))
160 (sha256
161 (base32
162 "0qyywmyns2jf3is3axrwmffvdd7ji7liy5axp650q4i6kzk2291r"))))
163
164 ;; libnuma is no longer needed.
165 (inputs (alist-delete "numactl" (package-inputs hwloc-1)))
166 (arguments
167 (substitute-keyword-arguments (package-arguments hwloc-1)
168 ((#:phases phases)
169 `(modify-phases ,phases
170 (replace 'skip-linux-libnuma-test
171 (lambda _
172 ;; Arrange to skip 'tests/hwloc/linux-libnuma', which fails on
173 ;; some machines: <https://github.com/open-mpi/hwloc/issues/213>.
174 (substitute* "tests/hwloc/linux-libnuma.c"
175 (("numa_available\\(\\)")
176 "-1"))
177 #t))
178 (add-before 'check 'skip-test-that-fails-on-qemu
179 (lambda _
180 ;; Skip test that fails on emulated hardware due to QEMU bug:
181 ;; <https://bugs.gnu.org/40342>.
182 (substitute* "tests/hwloc/hwloc_get_last_cpu_location.c"
183 (("hwloc_topology_init" all)
184 (string-append "exit (77);\n" all)))
185 #t))))))))
186
187 (define-deprecated hwloc-2.0 hwloc-2)
188
189 (define-public hwloc
190 ;; The latest stable series of hwloc.
191 hwloc-2)
192
193 (define-public openmpi
194 (package
195 (name "openmpi")
196 (version "4.1.1")
197 (source
198 (origin
199 (method url-fetch)
200 (uri (string-append "https://www.open-mpi.org/software/ompi/v"
201 (version-major+minor version)
202 "/downloads/openmpi-" version ".tar.bz2"))
203 (sha256
204 (base32 "1nkwq123vvmggcay48snm9qqmrh0bdzpln0l1jnp26niidvplkz2"))
205 (patches (search-patches "openmpi-mtl-priorities.patch"))))
206
207 (properties
208 ;; Tell the 'generic-html' updater to monitor this URL for updates.
209 `((release-monitoring-url
210 . "https://www.open-mpi.org/software/ompi/current")))
211
212 (build-system gnu-build-system)
213 (inputs
214 `(("hwloc" ,hwloc-2 "lib")
215 ("gfortran" ,gfortran)
216 ("libfabric" ,libfabric)
217 ("libevent" ,libevent)
218 ("opensm" ,opensm)
219 ,@(if (and (not (%current-target-system))
220 (member (%current-system) (package-supported-systems psm)))
221 `(("psm" ,psm))
222 '())
223 ,@(if (and (not (%current-target-system))
224 (member (%current-system) (package-supported-systems psm2)))
225 `(("psm2" ,psm2))
226 '())
227 ,@(if (and (not (%current-target-system))
228 (member (%current-system) (package-supported-systems ucx)))
229 `(("ucx" ,ucx))
230 '())
231 ("rdma-core" ,rdma-core)
232 ("valgrind" ,valgrind)
233 ("slurm" ,slurm))) ;for PMI support (launching via "srun")
234 (native-inputs
235 `(("pkg-config" ,pkg-config)
236 ("perl" ,perl)))
237 (outputs '("out" "debug"))
238 (arguments
239 `(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
240 "--enable-memchecker"
241 "--with-sge"
242 "--with-valgrind"
243 "--with-hwloc=external"
244 "--with-libevent"
245
246 ;; Help 'orterun' and 'mpirun' find their tools
247 ;; under $prefix by default.
248 "--enable-mpirun-prefix-by-default"
249
250 ;; InfiniBand support
251 "--enable-openib-control-hdr-padding"
252 "--enable-openib-dynamic-sl"
253 "--enable-openib-udcm"
254 "--enable-openib-rdmacm"
255 "--enable-openib-rdmacm-ibaddr"
256
257 ;; Enable support for SLURM's Process Manager
258 ;; Interface (PMI).
259 ,(string-append "--with-pmi="
260 (assoc-ref %build-inputs "slurm")))
261 #:phases (modify-phases %standard-phases
262 ;; opensm is needed for InfiniBand support.
263 (add-after 'unpack 'find-opensm-headers
264 (lambda* (#:key inputs #:allow-other-keys)
265 (setenv "C_INCLUDE_PATH"
266 (string-append (assoc-ref inputs "opensm")
267 "/include/infiniband"))
268 (setenv "CPLUS_INCLUDE_PATH"
269 (string-append (assoc-ref inputs "opensm")
270 "/include/infiniband"))
271 #t))
272 (add-before 'build 'remove-absolute
273 (lambda _
274 ;; Remove compiler absolute file names (OPAL_FC_ABSOLUTE
275 ;; etc.) to reduce the closure size. See
276 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-07/msg00388.html>
277 ;; and
278 ;; <https://www.mail-archive.com/users@lists.open-mpi.org//msg31397.html>.
279 (substitute* '("orte/tools/orte-info/param.c"
280 "oshmem/tools/oshmem_info/param.c"
281 "ompi/tools/ompi_info/param.c")
282 (("_ABSOLUTE") ""))
283 ;; Avoid valgrind (which pulls in gdb etc.).
284 (substitute*
285 '("./ompi/mca/io/romio321/src/io_romio321_component.c")
286 (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
287 "\"[elided to reduce closure]\""))
288 #t))
289 (add-before 'build 'scrub-timestamps ;reproducibility
290 (lambda _
291 (substitute* '("ompi/tools/ompi_info/param.c"
292 "orte/tools/orte-info/param.c"
293 "oshmem/tools/oshmem_info/param.c")
294 ((".*(Built|Configured) on.*") ""))
295 #t))
296 (add-after 'install 'remove-logs ;reproducibility
297 (lambda* (#:key outputs #:allow-other-keys)
298 (let ((out (assoc-ref outputs "out")))
299 (for-each delete-file (find-files out "config.log"))
300 #t))))))
301 (home-page "https://www.open-mpi.org")
302 (synopsis "MPI-3 implementation")
303 (description
304 "The Open MPI Project is an MPI-3 implementation that is developed and
305 maintained by a consortium of academic, research, and industry partners. Open
306 MPI is therefore able to combine the expertise, technologies, and resources
307 from all across the High Performance Computing community in order to build the
308 best MPI library available. Open MPI offers advantages for system and
309 software vendors, application developers and computer science researchers.")
310 ;; See file://LICENSE
311 (license license:bsd-2)))
312
313 ;; TODO: javadoc files contain timestamps.
314 (define-public java-openmpi
315 (package/inherit openmpi
316 (name "java-openmpi")
317 (inputs
318 `(("openmpi" ,openmpi)
319 ,@(package-inputs openmpi)))
320 (native-inputs
321 `(("jdk" ,openjdk11 "jdk")
322 ("zip" ,(@ (gnu packages compression) zip))
323 ,@(package-native-inputs openmpi)))
324 (outputs '("out"))
325 (arguments
326 `(#:modules ((guix build gnu-build-system)
327 ((guix build ant-build-system) #:prefix ant:)
328 (guix build utils))
329 #:imported-modules ((guix build ant-build-system)
330 (guix build syscalls)
331 ,@%gnu-build-system-modules)
332 ,@(substitute-keyword-arguments (package-arguments openmpi)
333 ((#:configure-flags flags)
334 `(cons "--enable-mpi-java" ,flags))
335 ((#:make-flags flags ''())
336 `(append '("-C" "ompi/mpi/java")
337 ,flags))
338 ((#:phases phases)
339 `(modify-phases ,phases
340 ;; We could provide the location of the JDK in the configure
341 ;; flags, but since the configure flags are embedded in the
342 ;; info binaries that would leave a reference to the JDK in
343 ;; the "out" output. To avoid this we set JAVA_HOME.
344 (add-after 'unpack 'set-JAVA_HOME
345 (lambda* (#:key inputs #:allow-other-keys)
346 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
347 #t))
348 (add-after 'unpack 'link-with-existing-mpi-libraries
349 (lambda* (#:key inputs #:allow-other-keys)
350 (substitute* "ompi/mpi/java/c/Makefile.in"
351 (("\\$\\(top_builddir\\)/ompi/lib@OMPI_LIBMPI_NAME@.la")
352 (string-append (assoc-ref inputs "openmpi") "/lib/libmpi.la")))
353 #t))
354 (add-after 'install 'strip-jar-timestamps
355 (assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))))
356 (synopsis "Java bindings for MPI")))
357
358 (define-public openmpi-thread-multiple
359 (package/inherit openmpi
360 (name "openmpi-thread-multiple")
361 (arguments
362 (substitute-keyword-arguments (package-arguments openmpi)
363 ((#:configure-flags flags)
364 `(cons "--enable-mpi-thread-multiple" ,flags))))
365 (description " This version of Open@tie{}MPI has an implementation of
366 @code{MPI_Init_thread} that provides @code{MPI_THREAD_MULTIPLE}. This won't
367 work correctly with all transports (such as @code{openib}), and the
368 performance is generally worse than the vanilla @code{openmpi} package, which
369 only provides @code{MPI_THREAD_FUNNELED}.")))
370
371 ;;; Build phase to be used for packages that execute MPI code.
372 (define-public %openmpi-setup
373 '(lambda _
374 ;; By default, running the test suite would fail because 'ssh' could not
375 ;; be found in $PATH. Define this variable to placate Open MPI without
376 ;; adding a dependency on OpenSSH (the agent isn't used anyway.)
377 (setenv "OMPI_MCA_plm_rsh_agent" (which "false"))
378 ;; Allow oversubscription in case there are less physical cores available
379 ;; in the build environment than the package wants while testing.
380 (setenv "OMPI_MCA_rmaps_base_mapping_policy" "core:OVERSUBSCRIBE")
381
382 ;; UCX sometimes outputs uninteresting warnings such as:
383 ;;
384 ;; mpool.c:38 UCX WARN object 0x7ffff44fffc0 was not returned to mpool ucp_am_bufs
385 ;;
386 ;; These in turn leads to failures of test suites that capture and
387 ;; compare stdout, such as that of 'hdf5-parallel-openmpi'. Thus, tell
388 ;; UCX to not emit those warnings.
389 (setenv "UCX_LOG_LEVEL" "error")
390 #t))
391
392 (define-public python-mpi4py
393 (package
394 (name "python-mpi4py")
395 (version "3.0.3")
396 (source
397 (origin
398 (method url-fetch)
399 (uri (pypi-uri "mpi4py" version))
400 (sha256
401 (base32 "07ssbhssv27rrjx1c5vd3vsr31vay5d8xcf4zh9yblcyidn72b81"))))
402 (build-system python-build-system)
403 (arguments
404 `(#:phases
405 (modify-phases %standard-phases
406 (add-after 'build 'mpi-setup
407 ,%openmpi-setup)
408 (add-before 'check 'pre-check
409 (lambda _
410 ;; Skip BaseTestSpawn class (causes error 'ompi_dpm_dyn_init()
411 ;; failed --> Returned "Unreachable"' in chroot environment).
412 (substitute* "test/test_spawn.py"
413 (("unittest.skipMPI\\('openmpi\\(<3.0.0\\)'\\)")
414 "unittest.skipMPI('openmpi')"))
415 #t)))))
416 (inputs
417 `(("openmpi" ,openmpi)))
418 (home-page "https://bitbucket.org/mpi4py/mpi4py/")
419 (synopsis "Python bindings for the Message Passing Interface standard")
420 (description "MPI for Python (mpi4py) provides bindings of the Message
421 Passing Interface (MPI) standard for the Python programming language, allowing
422 any Python program to exploit multiple processors.
423
424 mpi4py is constructed on top of the MPI-1/MPI-2 specification and provides an
425 object oriented interface which closely follows MPI-2 C++ bindings. It
426 supports point-to-point and collective communications of any picklable Python
427 object as well as optimized communications of Python objects (such as NumPy
428 arrays) that expose a buffer interface.")
429 (license license:bsd-3)))
430
431 (define-public mpich
432 (package
433 (name "mpich")
434 (version "3.3.2")
435 (source (origin
436 (method url-fetch)
437 (uri (string-append "http://www.mpich.org/static/downloads/"
438 version "/mpich-" version ".tar.gz"))
439 (sha256
440 (base32
441 "1farz5zfx4cd0c3a0wb9pgfypzw0xxql1j1294z1sxslga1ziyjb"))))
442 (build-system gnu-build-system)
443 (inputs
444 `(("zlib" ,zlib)
445 ("hwloc" ,hwloc-2 "lib")
446 ("slurm" ,slurm)
447 ,@(if (and (not (%current-target-system))
448 (member (%current-system) (package-supported-systems ucx)))
449 `(("ucx" ,ucx))
450 '())))
451 (native-inputs
452 `(("perl" ,perl)
453 ("which" ,which)
454 ("gfortran" ,gfortran)))
455 (outputs '("out" "debug"))
456 (arguments
457 `(#:configure-flags
458 (list "--disable-silent-rules" ;let's see what's happening
459 "--enable-debuginfo"
460
461 ;; Default to "ch4", as will be the case in 3.4. It also works
462 ;; around issues when running test suites of packages that use
463 ;; MPICH: <https://issues.guix.gnu.org/39588#15>.
464 "--with-device=ch4:ucx" ; --with-device=ch4:ofi segfaults in tests
465
466 (string-append "--with-hwloc-prefix="
467 (assoc-ref %build-inputs "hwloc"))
468
469 ,@(if (assoc "ucx" (package-inputs this-package))
470 `((string-append "--with-ucx="
471 (assoc-ref %build-inputs "ucx")))
472 '()))
473
474 #:phases (modify-phases %standard-phases
475 (add-after 'unpack 'patch-sources
476 (lambda _
477 (substitute* "./maint/gen_subcfg_m4"
478 (("/usr/bin/env") (which "env")))
479 (substitute* "src/glue/romio/all_romio_symbols"
480 (("/usr/bin/env") (which "env")))
481 (substitute* (find-files "." "buildiface")
482 (("/usr/bin/env") (which "env")))
483 (substitute* "maint/extracterrmsgs"
484 (("/usr/bin/env") (which "env")))
485 (substitute* (find-files "." "f77tof90")
486 (("/usr/bin/env") (which "env")))
487 (substitute* (find-files "." "\\.sh$")
488 (("/bin/sh") (which "sh")))
489 #t))
490 (add-before 'configure 'fix-makefile
491 (lambda _
492 ;; Remove "@hwloclib@" from 'pmpi_convenience_libs'.
493 ;; This fixes "No rule to make target '-lhwloc', needed
494 ;; by 'lib/libmpi.la'".
495 (substitute* "Makefile.in"
496 (("^pmpi_convenience_libs = (.*) @hwloclib@ (.*)$" _
497 before after)
498 (string-append "pmpi_convenience_libs = "
499 before " " after)))
500 #t)))))
501 (home-page "https://www.mpich.org/")
502 (synopsis "Implementation of the Message Passing Interface (MPI)")
503 (description
504 "MPICH is a high-performance and portable implementation of the Message
505 Passing Interface (MPI) standard (MPI-1, MPI-2 and MPI-3). MPICH provides an
506 MPI implementation that efficiently supports different computation and
507 communication platforms including commodity clusters, high-speed networks (10
508 Gigabit Ethernet, InfiniBand, Myrinet, Quadrics), and proprietary high-end
509 computing systems (Blue Gene, Cray). It enables research in MPI through a
510 modular framework for other derived implementations.")
511 (license license:bsd-2)))