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