gnu: r-shape: Update to 1.4.5.
[jackhill/guix/guix.git] / gnu / packages / mpi.scm
CommitLineData
fb0e3709 1;;; GNU Guix --- Functional package management for GNU
41313ace 2;;; Copyright © 2014, 2015, 2018, 2019 Eric Bavier <bavier@member.fsf.org>
b07712bf 3;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
29a7c98a 4;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
37d6b097 5;;; Copyright © 2016 Andreas Enge <andreas@enge.fr>
1f9bff41 6;;; Copyright © 2017 Dave Love <fx@gnu.org>
91298042 7;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
9dd7082c 8;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
54fcd547 9;;; Copyright © 2018 Paul Garlick <pgarlick@tourbillion-technology.com>
e9823f9c 10;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
fb0e3709
EB
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)
15e62623 29 #:use-module ((guix licenses) #:prefix license:)
fb0e3709 30 #:use-module (guix download)
29a7c98a 31 #:use-module (guix utils)
8c8e1089 32 #:use-module (guix deprecation)
fb0e3709 33 #:use-module (guix build-system gnu)
54fcd547 34 #:use-module (guix build-system python)
fb0e3709 35 #:use-module (gnu packages)
c70261bf
MB
36 #:use-module (gnu packages base)
37 #:use-module (gnu packages compression)
e9823f9c 38 #:use-module (gnu packages fabric-management)
fb0e3709 39 #:use-module (gnu packages gcc)
fa5a2538 40 #:use-module (gnu packages java)
41313ace 41 #:use-module (gnu packages libevent)
2b0d560a
LC
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)
38f0a2ba 47 #:use-module (gnu packages perl)
2b0d560a 48 #:use-module (gnu packages ncurses)
b07712bf 49 #:use-module (gnu packages parallel)
2b0d560a 50 #:use-module (gnu packages pkg-config)
91298042 51 #:use-module (gnu packages valgrind)
71e78931 52 #:use-module (srfi srfi-1)
91298042 53 #:use-module (ice-9 match))
fb0e3709 54
8ec7ca22 55(define-public hwloc-1
71e78931
LC
56 ;; Note: For now we keep 1.x as the default because many packages have yet
57 ;; to migrate to 2.0.
2b0d560a
LC
58 (package
59 (name "hwloc")
9dd50845 60 (version "1.11.12")
2b0d560a
LC
61 (source (origin
62 (method url-fetch)
a2d0e200 63 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
ce7d9c98
EB
64 (version-major+minor version)
65 "/downloads/hwloc-" version ".tar.bz2"))
2b0d560a
LC
66 (sha256
67 (base32
9dd50845 68 "0za1b9lvrm3rhn0lrxja5f64r0aq1qs4m0pxn1ji2mbi8ndppyyx"))))
2b0d560a 69 (build-system gnu-build-system)
798b7678
LC
70 (outputs '("out" ;'lstopo' & co., depends on Cairo, libx11, etc.
71 "lib" ;small closure
72 "debug"))
2b0d560a 73 (inputs
5b527256 74 `(("libx11" ,libx11)
2b0d560a
LC
75 ("cairo" ,cairo)
76 ("ncurses" ,ncurses)
37d6b097
AE
77 ("expat" ,expat)
78 ,@(if (not (string-prefix? "armhf"
79 (or (%current-target-system)
80 (%current-system))))
81 `(("numactl" ,numactl))
82 '())))
c6e59259
LC
83 (propagated-inputs
84 ;; hwloc.pc lists it in 'Requires.private'.
85 `(("libpciaccess" ,libpciaccess)))
2b0d560a
LC
86 (native-inputs
87 `(("pkg-config" ,pkg-config)))
579f5c8a 88 (arguments
7eb9f31c
LC
89 `(#:configure-flags '("--localstatedir=/var")
90 #:phases
579f5c8a 91 (modify-phases %standard-phases
10de06bd
LC
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))
798b7678
LC
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))))))
a2d0e200 118 (home-page "https://www.open-mpi.org/projects/hwloc/")
2b0d560a
LC
119 (synopsis "Abstraction of hardware architectures")
120 (description
121 "hwloc provides a portable abstraction (across OS,
122versions, architectures, ...) of the hierarchical topology of modern
123architectures, including NUMA memory nodes, sockets, shared caches, cores and
124simultaneous multithreading. It also gathers various attributes such as cache
125and memory information. It primarily aims at helping high-performance
126computing applications with gathering information about the hardware so as to
127exploit it accordingly and efficiently.
128
129hwloc may display the topology in multiple convenient formats. It also offers
130a powerful programming interface to gather information about the hardware,
131bind processes, and much more.")
15e62623 132 (license license:bsd-3)))
2b0d560a 133
8c8e1089 134(define-public hwloc-2
71e78931
LC
135 ;; Note: 2.0 isn't the default yet, see above.
136 (package
8ec7ca22 137 (inherit hwloc-1)
06efbe2f 138 (version "2.2.0")
71e78931
LC
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
06efbe2f 146 "0li27a3lnmb77qxpijj0kpblz32wmqd3b386sypq8ar7vy9vhw5f"))))
71e78931
LC
147
148 ;; libnuma is no longer needed.
0d8a8234 149 (inputs (alist-delete "numactl" (package-inputs hwloc-1)))
10de06bd 150 (arguments
0d8a8234 151 (substitute-keyword-arguments (package-arguments hwloc-1)
10de06bd
LC
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"))
8db4e704
LC
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)))
10de06bd 169 #t))))))))
71e78931 170
9b65dea8 171(define-deprecated hwloc-2.0 hwloc-2)
8c8e1089 172
8ec7ca22
LC
173(define-public hwloc
174 ;; The latest stable series of hwloc.
175 hwloc-2)
176
fb0e3709
EB
177(define-public openmpi
178 (package
179 (name "openmpi")
9dd7082c 180 (version "4.0.3")
fb0e3709
EB
181 (source
182 (origin
183 (method url-fetch)
6876590f 184 (uri (string-append "https://www.open-mpi.org/software/ompi/v"
29a7c98a 185 (version-major+minor version)
fb0e3709
EB
186 "/downloads/openmpi-" version ".tar.bz2"))
187 (sha256
9dd7082c 188 (base32 "00zxcw99gr5n693cmcmn4f6a47vx1ywna895p0x7p163v37gw0hl"))
68ac34e1 189 (patches (search-patches "openmpi-mtl-priorities.patch"))))
fb0e3709 190 (build-system gnu-build-system)
5b527256 191 (inputs
58a536bb 192 `(("hwloc" ,hwloc-2 "lib")
19afbea1 193 ("gfortran" ,gfortran)
a0995702 194 ("libfabric" ,libfabric)
41313ace 195 ("libevent" ,libevent)
e9823f9c 196 ("opensm" ,opensm)
a560641a
LC
197 ,@(if (and (not (%current-target-system))
198 (member (%current-system) (package-supported-systems psm)))
199 `(("psm" ,psm))
200 '())
fbe1b85b
LC
201 ,@(if (and (not (%current-target-system))
202 (member (%current-system) (package-supported-systems psm2)))
203 `(("psm2" ,psm2))
204 '())
8ba94edd 205 ,@(if (and (not (%current-target-system))
96a469f1 206 (member (%current-system) (package-supported-systems ucx)))
8ba94edd
LC
207 `(("ucx" ,ucx))
208 '())
a0995702 209 ("rdma-core" ,rdma-core)
b07712bf
LC
210 ("valgrind" ,valgrind)
211 ("slurm" ,slurm))) ;for PMI support (launching via "srun")
5b527256 212 (native-inputs
38f0a2ba
EB
213 `(("pkg-config" ,pkg-config)
214 ("perl" ,perl)))
c971d9ef 215 (outputs '("out" "debug"))
fb0e3709 216 (arguments
b08952f1 217 `(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
1691b4cd 218 "--enable-memchecker"
efcacc17 219 "--with-sge"
41313ace
EB
220 "--with-valgrind"
221 "--with-hwloc=external"
222 "--with-libevent"
e9823f9c
RW
223
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"
230
b07712bf
LC
231 ;; Enable support for SLURM's Process Manager
232 ;; Interface (PMI).
233 ,(string-append "--with-pmi="
234 (assoc-ref %build-inputs "slurm")))
9474a4b3 235 #:phases (modify-phases %standard-phases
e9823f9c
RW
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")
97149c57 241 "/include/infiniband"))
e9823f9c
RW
242 (setenv "CPLUS_INCLUDE_PATH"
243 (string-append (assoc-ref inputs "opensm")
97149c57 244 "/include/infiniband"))
e9823f9c 245 #t))
0d97d3cb 246 (add-before 'build 'remove-absolute
0d97d3cb 247 (lambda _
a247fe7b
DL
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>
251 ;; and
252 ;; <https://www.mail-archive.com/users@lists.open-mpi.org//msg31397.html>.
0d97d3cb
DL
253 (substitute* '("orte/tools/orte-info/param.c"
254 "oshmem/tools/oshmem_info/param.c"
255 "ompi/tools/ompi_info/param.c")
256 (("_ABSOLUTE") ""))
a247fe7b
DL
257 ;; Avoid valgrind (which pulls in gdb etc.).
258 (substitute*
41313ace
EB
259 '("./ompi/mca/io/romio321/src/io_romio321_component.c")
260 (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
a247fe7b 261 "\"[elided to reduce closure]\""))
0d97d3cb 262 #t))
9474a4b3
EB
263 (add-before 'build 'scrub-timestamps ;reproducibility
264 (lambda _
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.*") ""))
269 #t))
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"))
274 #t))))))
f9a69e9b 275 (home-page "https://www.open-mpi.org")
bb0f6d75 276 (synopsis "MPI-3 implementation")
fb0e3709 277 (description
bb0f6d75 278 "The Open MPI Project is an MPI-3 implementation that is developed and
8ede638c
EB
279maintained by a consortium of academic, research, and industry partners. Open
280MPI is therefore able to combine the expertise, technologies, and resources
281from all across the High Performance Computing community in order to build the
282best MPI library available. Open MPI offers advantages for system and
283software vendors, application developers and computer science researchers.")
fb0e3709 284 ;; See file://LICENSE
15e62623 285 (license license:bsd-2)))
685bef2b 286
fa5a2538
RW
287;; TODO: javadoc files contain timestamps.
288(define-public java-openmpi
289 (package (inherit openmpi)
290 (name "java-openmpi")
291 (inputs
292 `(("openmpi" ,openmpi)
293 ,@(package-inputs openmpi)))
294 (native-inputs
295 `(("jdk" ,openjdk11 "jdk")
296 ("zip" ,(@ (gnu packages compression) zip))
297 ,@(package-native-inputs openmpi)))
298 (outputs '("out"))
299 (arguments
300 `(#:modules ((guix build gnu-build-system)
301 ((guix build ant-build-system) #:prefix ant:)
302 (guix build utils))
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")
311 ,flags))
312 ((#:phases phases)
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"))
321 #t))
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")))
327 #t))
328 (add-after 'install 'strip-jar-timestamps
329 (assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))))
330 (synopsis "Java bindings for MPI")))
331
685bef2b
DL
332(define-public openmpi-thread-multiple
333 (package
334 (inherit openmpi)
335 (name "openmpi-thread-multiple")
336 (arguments
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
342work correctly with all transports (such as @code{openib}), and the
343performance is generally worse than the vanilla @code{openmpi} package, which
344only provides @code{MPI_THREAD_FUNNELED}.")))
bbe46a4a
EB
345
346;;; Build phase to be used for packages that execute MPI code.
347(define-public %openmpi-setup
348 '(lambda _
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.
41313ace 355 (setenv "OMPI_MCA_rmaps_base_mapping_policy" "core:OVERSUBSCRIBE")
b1077c22
LC
356
357 ;; UCX sometimes outputs uninteresting warnings such as:
358 ;;
359 ;; mpool.c:38 UCX WARN object 0x7ffff44fffc0 was not returned to mpool ucp_am_bufs
360 ;;
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")
bbe46a4a 365 #t))
54fcd547
PG
366
367(define-public python-mpi4py
368 (package
369 (name "python-mpi4py")
fe390200 370 (version "3.0.3")
54fcd547 371 (source
fe390200
TGR
372 (origin
373 (method url-fetch)
374 (uri (pypi-uri "mpi4py" version))
375 (sha256
376 (base32 "07ssbhssv27rrjx1c5vd3vsr31vay5d8xcf4zh9yblcyidn72b81"))))
54fcd547
PG
377 (build-system python-build-system)
378 (arguments
379 `(#:phases
380 (modify-phases %standard-phases
381 (add-after 'build 'mpi-setup
382 ,%openmpi-setup)
383 (add-before 'check 'pre-check
384 (lambda _
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')"))
390 #t)))))
391 (inputs
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
396Passing Interface (MPI) standard for the Python programming language, allowing
397any Python program to exploit multiple processors.
398
399mpi4py is constructed on top of the MPI-1/MPI-2 specification and provides an
400object oriented interface which closely follows MPI-2 C++ bindings. It
401supports point-to-point and collective communications of any picklable Python
402object as well as optimized communications of Python objects (such as NumPy
403arrays) that expose a buffer interface.")
15e62623 404 (license license:bsd-3)))
c70261bf
MB
405
406(define-public mpich
407 (package
408 (name "mpich")
409 (version "3.3.2")
410 (source (origin
411 (method url-fetch)
412 (uri (string-append "http://www.mpich.org/static/downloads/"
413 version "/mpich-" version ".tar.gz"))
414 (sha256
415 (base32
416 "1farz5zfx4cd0c3a0wb9pgfypzw0xxql1j1294z1sxslga1ziyjb"))))
417 (build-system gnu-build-system)
418 (inputs
419 `(("zlib" ,zlib)
420 ("hwloc" ,hwloc-2 "lib")
421 ("slurm" ,slurm)
422 ,@(if (and (not (%current-target-system))
423 (member (%current-system) (package-supported-systems ucx)))
424 `(("ucx" ,ucx))
425 '())))
426 (native-inputs
427 `(("perl" ,perl)
428 ("which" ,which)
429 ("gfortran" ,gfortran)))
430 (outputs '("out" "debug"))
431 (arguments
432 `(#:configure-flags
433 (list "--disable-silent-rules" ;let's see what's happening
434 "--enable-debuginfo"
435 ;; "--with-device=ch4:ucx" ; --with-device=ch4:ofi segfaults in tests
436 (string-append "--with-hwloc-prefix="
437 (assoc-ref %build-inputs "hwloc"))
438
439 ,@(if (assoc "ucx" (package-inputs this-package))
440 `((string-append "--with-ucx="
441 (assoc-ref %build-inputs "ucx")))
442 '()))
443
444 #:phases (modify-phases %standard-phases
445 (add-after 'unpack 'patch-sources
446 (lambda _
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")))
459 #t))
460 (add-before 'configure 'fix-makefile
461 (lambda _
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@ (.*)$" _
467 before after)
468 (string-append "pmpi_convenience_libs = "
469 before " " after)))
470 #t)))))
471 (home-page "https://www.mpich.org/")
472 (synopsis "Implementation of the Message Passing Interface (MPI)")
473 (description
474 "MPICH is a high-performance and portable implementation of the Message
475Passing Interface (MPI) standard (MPI-1, MPI-2 and MPI-3). MPICH provides an
476MPI implementation that efficiently supports different computation and
477communication platforms including commodity clusters, high-speed networks (10
478Gigabit Ethernet, InfiniBand, Myrinet, Quadrics), and proprietary high-end
479computing systems (Blue Gene, Cray). It enables research in MPI through a
480modular framework for other derived implementations.")
15e62623 481 (license license:bsd-2)))