Merge branch 'staging' into core-updates
[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 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)
30 #:hide (expat))
31 #:use-module (guix download)
32 #:use-module (guix utils)
33 #:use-module (guix deprecation)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system python)
36 #:use-module (gnu packages)
37 #:use-module (gnu packages fabric-management)
38 #:use-module (gnu packages gcc)
39 #:use-module (gnu packages java)
40 #:use-module (gnu packages libevent)
41 #:use-module (gnu packages linux)
42 #:use-module (gnu packages pciutils)
43 #:use-module (gnu packages xorg)
44 #:use-module (gnu packages gtk)
45 #:use-module (gnu packages xml)
46 #:use-module (gnu packages perl)
47 #:use-module (gnu packages ncurses)
48 #:use-module (gnu packages parallel)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages valgrind)
51 #:use-module (srfi srfi-1)
52 #:use-module (ice-9 match))
53
54 (define-public hwloc-1
55 ;; Note: For now we keep 1.x as the default because many packages have yet
56 ;; to migrate to 2.0.
57 (package
58 (name "hwloc")
59 (version "1.11.12")
60 (source (origin
61 (method url-fetch)
62 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
63 (version-major+minor version)
64 "/downloads/hwloc-" version ".tar.bz2"))
65 (sha256
66 (base32
67 "0za1b9lvrm3rhn0lrxja5f64r0aq1qs4m0pxn1ji2mbi8ndppyyx"))))
68 (build-system gnu-build-system)
69 (outputs '("out" ;'lstopo' & co., depends on Cairo, libx11, etc.
70 "lib" ;small closure
71 "debug"))
72 (inputs
73 `(("libx11" ,libx11)
74 ("cairo" ,cairo)
75 ("ncurses" ,ncurses)
76 ("expat" ,expat)
77 ,@(if (not (string-prefix? "armhf"
78 (or (%current-target-system)
79 (%current-system))))
80 `(("numactl" ,numactl))
81 '())))
82 (propagated-inputs
83 ;; hwloc.pc lists it in 'Requires.private'.
84 `(("libpciaccess" ,libpciaccess)))
85 (native-inputs
86 `(("pkg-config" ,pkg-config)))
87 (arguments
88 `(#:configure-flags '("--localstatedir=/var")
89 #:phases
90 (modify-phases %standard-phases
91 (add-before 'check 'skip-linux-libnuma-test
92 (lambda _
93 ;; Arrange to skip 'tests/linux-libnuma', which fails on some
94 ;; machines: <https://github.com/open-mpi/hwloc/issues/213>.
95 (substitute* "tests/linux-libnuma.c"
96 (("numa_available\\(\\)")
97 "-1"))
98 #t))
99 (add-after 'install 'refine-libnuma
100 ;; Give -L arguments for libraries to avoid propagation
101 (lambda* (#:key inputs outputs #:allow-other-keys)
102 (let ((out (assoc-ref outputs "lib"))
103 (numa (assoc-ref inputs "numactl")))
104 (substitute* (map (lambda (f) (string-append out "/" f))
105 '("lib/pkgconfig/hwloc.pc" "lib/libhwloc.la"))
106 (("-lnuma" lib)
107 (string-append "-L" numa "/lib " lib))))))
108 (add-after 'install 'avoid-circular-references
109 (lambda* (#:key outputs #:allow-other-keys)
110 (let ((lib (assoc-ref outputs "lib")))
111 ;; Suppress the 'prefix=' and 'exec_prefix=' lines so that the
112 ;; "lib" output doesn't refer to "out".
113 (substitute* (string-append lib "/lib/pkgconfig/hwloc.pc")
114 (("^.*prefix=.*$")
115 ""))
116 #t))))))
117 (home-page "https://www.open-mpi.org/projects/hwloc/")
118 (synopsis "Abstraction of hardware architectures")
119 (description
120 "hwloc provides a portable abstraction (across OS,
121 versions, architectures, ...) of the hierarchical topology of modern
122 architectures, including NUMA memory nodes, sockets, shared caches, cores and
123 simultaneous multithreading. It also gathers various attributes such as cache
124 and memory information. It primarily aims at helping high-performance
125 computing applications with gathering information about the hardware so as to
126 exploit it accordingly and efficiently.
127
128 hwloc may display the topology in multiple convenient formats. It also offers
129 a powerful programming interface to gather information about the hardware,
130 bind processes, and much more.")
131 (license bsd-3)))
132
133 (define-public hwloc-2
134 ;; Note: 2.0 isn't the default yet, see above.
135 (package
136 (inherit hwloc-1)
137 (version "2.1.0")
138 (source (origin
139 (method url-fetch)
140 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
141 (version-major+minor version)
142 "/downloads/hwloc-" version ".tar.bz2"))
143 (sha256
144 (base32
145 "0qh8s7pphz0m5cwb7liqmc17xzfs23xhz5wn24r6ikvjyx99fhhr"))))
146
147 ;; libnuma is no longer needed.
148 (inputs (alist-delete "numactl" (package-inputs hwloc-1)))
149 (arguments
150 (substitute-keyword-arguments (package-arguments hwloc-1)
151 ((#:phases phases)
152 `(modify-phases ,phases
153 (replace 'skip-linux-libnuma-test
154 (lambda _
155 ;; Arrange to skip 'tests/hwloc/linux-libnuma', which fails on
156 ;; some machines: <https://github.com/open-mpi/hwloc/issues/213>.
157 (substitute* "tests/hwloc/linux-libnuma.c"
158 (("numa_available\\(\\)")
159 "-1"))
160 #t))))))))
161
162 (define-deprecated hwloc-2.0 hwloc-2)
163
164 (define-public hwloc
165 ;; The latest stable series of hwloc.
166 hwloc-2)
167
168 (define-public openmpi
169 (package
170 (name "openmpi")
171 (version "4.0.2")
172 (source
173 (origin
174 (method url-fetch)
175 (uri (string-append "https://www.open-mpi.org/software/ompi/v"
176 (version-major+minor version)
177 "/downloads/openmpi-" version ".tar.bz2"))
178 (sha256
179 (base32 "0ms0zvyxyy3pnx9qwib6zaljyp2b3ixny64xvq3czv3jpr8zf2wh"))
180 (patches (search-patches "openmpi-mtl-priorities.patch"))))
181 (build-system gnu-build-system)
182 (inputs
183 `(("hwloc" ,hwloc-2 "lib")
184 ("gfortran" ,gfortran)
185 ("libfabric" ,libfabric)
186 ("libevent" ,libevent)
187 ("opensm" ,opensm)
188 ,@(if (and (not (%current-target-system))
189 (member (%current-system) (package-supported-systems psm)))
190 `(("psm" ,psm))
191 '())
192 ,@(if (and (not (%current-target-system))
193 (member (%current-system) (package-supported-systems psm2)))
194 `(("psm2" ,psm2))
195 '())
196 ,@(if (and (not (%current-target-system))
197 (member (%current-system) (package-supported-systems ucx)))
198 `(("ucx" ,ucx))
199 '())
200 ("rdma-core" ,rdma-core)
201 ("valgrind" ,valgrind)
202 ("slurm" ,slurm))) ;for PMI support (launching via "srun")
203 (native-inputs
204 `(("pkg-config" ,pkg-config)
205 ("perl" ,perl)))
206 (outputs '("out" "debug"))
207 (arguments
208 `(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
209 "--enable-memchecker"
210 "--with-sge"
211 "--with-valgrind"
212 "--with-hwloc=external"
213 "--with-libevent"
214
215 ;; InfiniBand support
216 "--enable-openib-control-hdr-padding"
217 "--enable-openib-dynamic-sl"
218 "--enable-openib-udcm"
219 "--enable-openib-rdmacm"
220 "--enable-openib-rdmacm-ibaddr"
221
222 ;; Enable support for SLURM's Process Manager
223 ;; Interface (PMI).
224 ,(string-append "--with-pmi="
225 (assoc-ref %build-inputs "slurm")))
226 #:phases (modify-phases %standard-phases
227 ;; opensm is needed for InfiniBand support.
228 (add-after 'unpack 'find-opensm-headers
229 (lambda* (#:key inputs #:allow-other-keys)
230 (setenv "C_INCLUDE_PATH"
231 (string-append (assoc-ref inputs "opensm")
232 "/include/infiniband"))
233 (setenv "CPLUS_INCLUDE_PATH"
234 (string-append (assoc-ref inputs "opensm")
235 "/include/infiniband"))
236 #t))
237 (add-before 'build 'remove-absolute
238 (lambda _
239 ;; Remove compiler absolute file names (OPAL_FC_ABSOLUTE
240 ;; etc.) to reduce the closure size. See
241 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-07/msg00388.html>
242 ;; and
243 ;; <https://www.mail-archive.com/users@lists.open-mpi.org//msg31397.html>.
244 (substitute* '("orte/tools/orte-info/param.c"
245 "oshmem/tools/oshmem_info/param.c"
246 "ompi/tools/ompi_info/param.c")
247 (("_ABSOLUTE") ""))
248 ;; Avoid valgrind (which pulls in gdb etc.).
249 (substitute*
250 '("./ompi/mca/io/romio321/src/io_romio321_component.c")
251 (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
252 "\"[elided to reduce closure]\""))
253 #t))
254 (add-before 'build 'scrub-timestamps ;reproducibility
255 (lambda _
256 (substitute* '("ompi/tools/ompi_info/param.c"
257 "orte/tools/orte-info/param.c"
258 "oshmem/tools/oshmem_info/param.c")
259 ((".*(Built|Configured) on.*") ""))
260 #t))
261 (add-after 'install 'remove-logs ;reproducibility
262 (lambda* (#:key outputs #:allow-other-keys)
263 (let ((out (assoc-ref outputs "out")))
264 (for-each delete-file (find-files out "config.log"))
265 #t))))))
266 (home-page "http://www.open-mpi.org")
267 (synopsis "MPI-3 implementation")
268 (description
269 "The Open MPI Project is an MPI-3 implementation that is developed and
270 maintained by a consortium of academic, research, and industry partners. Open
271 MPI is therefore able to combine the expertise, technologies, and resources
272 from all across the High Performance Computing community in order to build the
273 best MPI library available. Open MPI offers advantages for system and
274 software vendors, application developers and computer science researchers.")
275 ;; See file://LICENSE
276 (license bsd-2)))
277
278 ;; TODO: javadoc files contain timestamps.
279 (define-public java-openmpi
280 (package (inherit openmpi)
281 (name "java-openmpi")
282 (inputs
283 `(("openmpi" ,openmpi)
284 ,@(package-inputs openmpi)))
285 (native-inputs
286 `(("jdk" ,openjdk11 "jdk")
287 ("zip" ,(@ (gnu packages compression) zip))
288 ,@(package-native-inputs openmpi)))
289 (outputs '("out"))
290 (arguments
291 `(#:modules ((guix build gnu-build-system)
292 ((guix build ant-build-system) #:prefix ant:)
293 (guix build utils))
294 #:imported-modules ((guix build ant-build-system)
295 (guix build syscalls)
296 ,@%gnu-build-system-modules)
297 ,@(substitute-keyword-arguments (package-arguments openmpi)
298 ((#:configure-flags flags)
299 `(cons "--enable-mpi-java" ,flags))
300 ((#:make-flags flags ''())
301 `(append '("-C" "ompi/mpi/java")
302 ,flags))
303 ((#:phases phases)
304 `(modify-phases ,phases
305 ;; We could provide the location of the JDK in the configure
306 ;; flags, but since the configure flags are embedded in the
307 ;; info binaries that would leave a reference to the JDK in
308 ;; the "out" output. To avoid this we set JAVA_HOME.
309 (add-after 'unpack 'set-JAVA_HOME
310 (lambda* (#:key inputs #:allow-other-keys)
311 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
312 #t))
313 (add-after 'unpack 'link-with-existing-mpi-libraries
314 (lambda* (#:key inputs #:allow-other-keys)
315 (substitute* "ompi/mpi/java/c/Makefile.in"
316 (("\\$\\(top_builddir\\)/ompi/lib@OMPI_LIBMPI_NAME@.la")
317 (string-append (assoc-ref inputs "openmpi") "/lib/libmpi.la")))
318 #t))
319 (add-after 'install 'strip-jar-timestamps
320 (assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))))
321 (synopsis "Java bindings for MPI")))
322
323 (define-public openmpi-thread-multiple
324 (package
325 (inherit openmpi)
326 (name "openmpi-thread-multiple")
327 (arguments
328 (substitute-keyword-arguments (package-arguments openmpi)
329 ((#:configure-flags flags)
330 `(cons "--enable-mpi-thread-multiple" ,flags))))
331 (description " This version of Open@tie{}MPI has an implementation of
332 @code{MPI_Init_thread} that provides @code{MPI_THREAD_MULTIPLE}. This won't
333 work correctly with all transports (such as @code{openib}), and the
334 performance is generally worse than the vanilla @code{openmpi} package, which
335 only provides @code{MPI_THREAD_FUNNELED}.")))
336
337 ;;; Build phase to be used for packages that execute MPI code.
338 (define-public %openmpi-setup
339 '(lambda _
340 ;; By default, running the test suite would fail because 'ssh' could not
341 ;; be found in $PATH. Define this variable to placate Open MPI without
342 ;; adding a dependency on OpenSSH (the agent isn't used anyway.)
343 (setenv "OMPI_MCA_plm_rsh_agent" (which "false"))
344 ;; Allow oversubscription in case there are less physical cores available
345 ;; in the build environment than the package wants while testing.
346 (setenv "OMPI_MCA_rmaps_base_mapping_policy" "core:OVERSUBSCRIBE")
347
348 ;; UCX sometimes outputs uninteresting warnings such as:
349 ;;
350 ;; mpool.c:38 UCX WARN object 0x7ffff44fffc0 was not returned to mpool ucp_am_bufs
351 ;;
352 ;; These in turn leads to failures of test suites that capture and
353 ;; compare stdout, such as that of 'hdf5-parallel-openmpi'. Thus, tell
354 ;; UCX to not emit those warnings.
355 (setenv "UCX_LOG_LEVEL" "error")
356 #t))
357
358 (define-public python-mpi4py
359 (package
360 (name "python-mpi4py")
361 (version "3.0.3")
362 (source
363 (origin
364 (method url-fetch)
365 (uri (pypi-uri "mpi4py" version))
366 (sha256
367 (base32 "07ssbhssv27rrjx1c5vd3vsr31vay5d8xcf4zh9yblcyidn72b81"))))
368 (build-system python-build-system)
369 (arguments
370 `(#:phases
371 (modify-phases %standard-phases
372 (add-after 'build 'mpi-setup
373 ,%openmpi-setup)
374 (add-before 'check 'pre-check
375 (lambda _
376 ;; Skip BaseTestSpawn class (causes error 'ompi_dpm_dyn_init()
377 ;; failed --> Returned "Unreachable"' in chroot environment).
378 (substitute* "test/test_spawn.py"
379 (("unittest.skipMPI\\('openmpi\\(<3.0.0\\)'\\)")
380 "unittest.skipMPI('openmpi')"))
381 #t)))))
382 (inputs
383 `(("openmpi" ,openmpi)))
384 (home-page "https://bitbucket.org/mpi4py/mpi4py/")
385 (synopsis "Python bindings for the Message Passing Interface standard")
386 (description "MPI for Python (mpi4py) provides bindings of the Message
387 Passing Interface (MPI) standard for the Python programming language, allowing
388 any Python program to exploit multiple processors.
389
390 mpi4py is constructed on top of the MPI-1/MPI-2 specification and provides an
391 object oriented interface which closely follows MPI-2 C++ bindings. It
392 supports point-to-point and collective communications of any picklable Python
393 object as well as optimized communications of Python objects (such as NumPy
394 arrays) that expose a buffer interface.")
395 (license bsd-3)))