gnu: sbcl-cl-cffi-gtk: Update to 20200417.
[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 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.3")
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 "00zxcw99gr5n693cmcmn4f6a47vx1ywna895p0x7p163v37gw0hl"))
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 ;; 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
231 ;; Enable support for SLURM's Process Manager
232 ;; Interface (PMI).
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"))
245 #t))
246 (add-before 'build 'remove-absolute
247 (lambda _
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>.
253 (substitute* '("orte/tools/orte-info/param.c"
254 "oshmem/tools/oshmem_info/param.c"
255 "ompi/tools/ompi_info/param.c")
256 (("_ABSOLUTE") ""))
257 ;; Avoid valgrind (which pulls in gdb etc.).
258 (substitute*
259 '("./ompi/mca/io/romio321/src/io_romio321_component.c")
260 (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
261 "\"[elided to reduce closure]\""))
262 #t))
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))))))
275 (home-page "https://www.open-mpi.org")
276 (synopsis "MPI-3 implementation")
277 (description
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)))
286
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
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
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}.")))
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.
355 (setenv "OMPI_MCA_rmaps_base_mapping_policy" "core:OVERSUBSCRIBE")
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")
365 #t))
366
367 (define-public python-mpi4py
368 (package
369 (name "python-mpi4py")
370 (version "3.0.3")
371 (source
372 (origin
373 (method url-fetch)
374 (uri (pypi-uri "mpi4py" version))
375 (sha256
376 (base32 "07ssbhssv27rrjx1c5vd3vsr31vay5d8xcf4zh9yblcyidn72b81"))))
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
396 Passing Interface (MPI) standard for the Python programming language, allowing
397 any Python program to exploit multiple processors.
398
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)))
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
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)))