gnu: hwloc: Update to 2.1.0.
[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 git-download)
33 #:use-module (guix utils)
34 #:use-module (guix deprecation)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system python)
37 #:use-module (gnu packages)
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
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 bsd-3)))
133
134 (define-public hwloc-2
135 ;; Note: 2.0 isn't the default yet, see above.
136 (package
137 (inherit hwloc)
138 (version "2.1.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 "0qh8s7pphz0m5cwb7liqmc17xzfs23xhz5wn24r6ikvjyx99fhhr"))))
147
148 ;; libnuma is no longer needed.
149 (inputs (alist-delete "numactl" (package-inputs hwloc)))
150 (arguments
151 (substitute-keyword-arguments (package-arguments hwloc)
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
163 (define-deprecated hwloc-2.0 'hwloc-2
164 hwloc-2)
165
166 (define-public openmpi
167 (package
168 (name "openmpi")
169 (version "4.0.2")
170 (source
171 (origin
172 (method url-fetch)
173 (uri (string-append "https://www.open-mpi.org/software/ompi/v"
174 (version-major+minor version)
175 "/downloads/openmpi-" version ".tar.bz2"))
176 (sha256
177 (base32 "0ms0zvyxyy3pnx9qwib6zaljyp2b3ixny64xvq3czv3jpr8zf2wh"))))
178 (build-system gnu-build-system)
179 (inputs
180 `(("hwloc" ,hwloc "lib")
181 ("gfortran" ,gfortran)
182 ("libfabric" ,libfabric)
183 ("libevent" ,libevent)
184 ("opensm" ,opensm)
185 ,@(if (and (not (%current-target-system))
186 (member (%current-system) (package-supported-systems psm)))
187 `(("psm" ,psm))
188 '())
189 ,@(if (and (not (%current-target-system))
190 (member (%current-system) (package-supported-systems psm2)))
191 `(("psm2" ,psm2))
192 '())
193 ,@(if (and (not (%current-target-system))
194 (member (%current-system) (package-supported-systems psm2)))
195 `(("ucx" ,ucx))
196 '())
197 ("rdma-core" ,rdma-core)
198 ("valgrind" ,valgrind)
199 ("slurm" ,slurm))) ;for PMI support (launching via "srun")
200 (native-inputs
201 `(("pkg-config" ,pkg-config)
202 ("perl" ,perl)))
203 (outputs '("out" "debug"))
204 (arguments
205 `(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
206 "--enable-memchecker"
207 "--with-sge"
208 "--with-valgrind"
209 "--with-hwloc=external"
210 "--with-libevent"
211
212 ;; Make sure ./configure fails if one of these is
213 ;; missing.
214 "--with-ucx"
215 "--with-psm"
216 "--with-psm2"
217
218 ;; InfiniBand support
219 "--enable-openib-control-hdr-padding"
220 "--enable-openib-dynamic-sl"
221 "--enable-openib-udcm"
222 "--enable-openib-rdmacm"
223 "--enable-openib-rdmacm-ibaddr"
224
225 ;; Enable support for SLURM's Process Manager
226 ;; Interface (PMI).
227 ,(string-append "--with-pmi="
228 (assoc-ref %build-inputs "slurm")))
229 #:phases (modify-phases %standard-phases
230 ;; opensm is needed for InfiniBand support.
231 (add-after 'unpack 'find-opensm-headers
232 (lambda* (#:key inputs #:allow-other-keys)
233 (setenv "C_INCLUDE_PATH"
234 (string-append (assoc-ref inputs "opensm")
235 "/include/infiniband"))
236 (setenv "CPLUS_INCLUDE_PATH"
237 (string-append (assoc-ref inputs "opensm")
238 "/include/infiniband"))
239 #t))
240 (add-before 'build 'remove-absolute
241 (lambda _
242 ;; Remove compiler absolute file names (OPAL_FC_ABSOLUTE
243 ;; etc.) to reduce the closure size. See
244 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-07/msg00388.html>
245 ;; and
246 ;; <https://www.mail-archive.com/users@lists.open-mpi.org//msg31397.html>.
247 (substitute* '("orte/tools/orte-info/param.c"
248 "oshmem/tools/oshmem_info/param.c"
249 "ompi/tools/ompi_info/param.c")
250 (("_ABSOLUTE") ""))
251 ;; Avoid valgrind (which pulls in gdb etc.).
252 (substitute*
253 '("./ompi/mca/io/romio321/src/io_romio321_component.c")
254 (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
255 "\"[elided to reduce closure]\""))
256 #t))
257 (add-before 'build 'scrub-timestamps ;reproducibility
258 (lambda _
259 (substitute* '("ompi/tools/ompi_info/param.c"
260 "orte/tools/orte-info/param.c"
261 "oshmem/tools/oshmem_info/param.c")
262 ((".*(Built|Configured) on.*") ""))
263 #t))
264 (add-after 'install 'remove-logs ;reproducibility
265 (lambda* (#:key outputs #:allow-other-keys)
266 (let ((out (assoc-ref outputs "out")))
267 (for-each delete-file (find-files out "config.log"))
268 #t))))))
269 (home-page "http://www.open-mpi.org")
270 (synopsis "MPI-3 implementation")
271 (description
272 "The Open MPI Project is an MPI-3 implementation that is developed and
273 maintained by a consortium of academic, research, and industry partners. Open
274 MPI is therefore able to combine the expertise, technologies, and resources
275 from all across the High Performance Computing community in order to build the
276 best MPI library available. Open MPI offers advantages for system and
277 software vendors, application developers and computer science researchers.")
278 ;; See file://LICENSE
279 (license bsd-2)))
280
281 ;; TODO: javadoc files contain timestamps.
282 (define-public java-openmpi
283 (package (inherit openmpi)
284 (name "java-openmpi")
285 (inputs
286 `(("openmpi" ,openmpi)
287 ,@(package-inputs openmpi)))
288 (native-inputs
289 `(("jdk" ,openjdk11 "jdk")
290 ("zip" ,(@ (gnu packages compression) zip))
291 ,@(package-native-inputs openmpi)))
292 (outputs '("out"))
293 (arguments
294 `(#:modules ((guix build gnu-build-system)
295 ((guix build ant-build-system) #:prefix ant:)
296 (guix build utils))
297 #:imported-modules ((guix build ant-build-system)
298 (guix build syscalls)
299 ,@%gnu-build-system-modules)
300 ,@(substitute-keyword-arguments (package-arguments openmpi)
301 ((#:configure-flags flags)
302 `(cons "--enable-mpi-java" ,flags))
303 ((#:make-flags flags ''())
304 `(append '("-C" "ompi/mpi/java")
305 ,flags))
306 ((#:phases phases)
307 `(modify-phases ,phases
308 ;; We could provide the location of the JDK in the configure
309 ;; flags, but since the configure flags are embedded in the
310 ;; info binaries that would leave a reference to the JDK in
311 ;; the "out" output. To avoid this we set JAVA_HOME.
312 (add-after 'unpack 'set-JAVA_HOME
313 (lambda* (#:key inputs #:allow-other-keys)
314 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
315 #t))
316 (add-after 'unpack 'link-with-existing-mpi-libraries
317 (lambda* (#:key inputs #:allow-other-keys)
318 (substitute* "ompi/mpi/java/c/Makefile.in"
319 (("\\$\\(top_builddir\\)/ompi/lib@OMPI_LIBMPI_NAME@.la")
320 (string-append (assoc-ref inputs "openmpi") "/lib/libmpi.la")))
321 #t))
322 (add-after 'install 'strip-jar-timestamps
323 (assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))))
324 (synopsis "Java bindings for MPI")))
325
326 (define-public openmpi-thread-multiple
327 (package
328 (inherit openmpi)
329 (name "openmpi-thread-multiple")
330 (arguments
331 (substitute-keyword-arguments (package-arguments openmpi)
332 ((#:configure-flags flags)
333 `(cons "--enable-mpi-thread-multiple" ,flags))))
334 (description " This version of Open@tie{}MPI has an implementation of
335 @code{MPI_Init_thread} that provides @code{MPI_THREAD_MULTIPLE}. This won't
336 work correctly with all transports (such as @code{openib}), and the
337 performance is generally worse than the vanilla @code{openmpi} package, which
338 only provides @code{MPI_THREAD_FUNNELED}.")))
339
340 ;;; Build phase to be used for packages that execute MPI code.
341 (define-public %openmpi-setup
342 '(lambda _
343 ;; By default, running the test suite would fail because 'ssh' could not
344 ;; be found in $PATH. Define this variable to placate Open MPI without
345 ;; adding a dependency on OpenSSH (the agent isn't used anyway.)
346 (setenv "OMPI_MCA_plm_rsh_agent" (which "false"))
347 ;; Allow oversubscription in case there are less physical cores available
348 ;; in the build environment than the package wants while testing.
349 (setenv "OMPI_MCA_rmaps_base_mapping_policy" "core:OVERSUBSCRIBE")
350 #t))
351
352 (define-public intel-mpi-benchmarks
353 (package
354 (name "intel-mpi-benchmarks")
355 (version "2019.3")
356 (source (origin
357 (method git-fetch)
358 (uri (git-reference
359 (url "https://github.com/intel/mpi-benchmarks.git")
360 (commit (string-append "IMB-v" version))))
361 (file-name (git-file-name name version))
362 (sha256
363 (base32
364 "0si5xi6ilhd3w0gbsg124589pvp094hvf366rvjjb9pi7pdk5p4i"))))
365 (build-system gnu-build-system)
366 (arguments
367 '(#:phases (modify-phases %standard-phases
368 (delete 'configure)
369 (delete 'check)
370 (replace 'install
371 (lambda* (#:key outputs #:allow-other-keys)
372 (define (benchmark? file stat)
373 (and (string-prefix? "IMB-" (basename file))
374 (executable-file? file)))
375
376 (let* ((out (assoc-ref outputs "out"))
377 (bin (string-append out "/bin")))
378 (for-each (lambda (file)
379 (install-file file bin))
380 (find-files "." benchmark?))
381 #t))))
382
383 ;; The makefile doesn't express all the dependencies, it seems.
384 #:parallel-build? #t
385
386 #:make-flags (list (string-append "CC="
387 (assoc-ref %build-inputs "openmpi")
388 "/bin/mpicc")
389 (string-append "CXX="
390 (assoc-ref %build-inputs "openmpi")
391 "/bin/mpicxx"))))
392 (inputs
393 `(("openmpi" ,openmpi)))
394 (home-page "https://github.com/intel/mpi-benchmarks")
395 (synopsis "Benchmarks for the Message Passing Interface (MPI)")
396 (description
397 "Intel MPI Benchmarks (IMB) provides a set of elementary benchmarks that
398 conform with versions 1, 2, and 3 of the Message Passing Interface (MPI).")
399 (license
400 (fsf-free "https://directory.fsf.org/wiki/License:CPL-1.0"
401 "https://www.gnu.org/licenses/license-list.html#CommonPublicLicense10"))))
402
403 (define-public python-mpi4py
404 (package
405 (name "python-mpi4py")
406 (version "3.0.3")
407 (source
408 (origin
409 (method url-fetch)
410 (uri (pypi-uri "mpi4py" version))
411 (sha256
412 (base32 "07ssbhssv27rrjx1c5vd3vsr31vay5d8xcf4zh9yblcyidn72b81"))))
413 (build-system python-build-system)
414 (arguments
415 `(#:phases
416 (modify-phases %standard-phases
417 (add-after 'build 'mpi-setup
418 ,%openmpi-setup)
419 (add-before 'check 'pre-check
420 (lambda _
421 ;; Skip BaseTestSpawn class (causes error 'ompi_dpm_dyn_init()
422 ;; failed --> Returned "Unreachable"' in chroot environment).
423 (substitute* "test/test_spawn.py"
424 (("unittest.skipMPI\\('openmpi\\(<3.0.0\\)'\\)")
425 "unittest.skipMPI('openmpi')"))
426 #t)))))
427 (inputs
428 `(("openmpi" ,openmpi)))
429 (home-page "https://bitbucket.org/mpi4py/mpi4py/")
430 (synopsis "Python bindings for the Message Passing Interface standard")
431 (description "MPI for Python (mpi4py) provides bindings of the Message
432 Passing Interface (MPI) standard for the Python programming language, allowing
433 any Python program to exploit multiple processors.
434
435 mpi4py is constructed on top of the MPI-1/MPI-2 specification and provides an
436 object oriented interface which closely follows MPI-2 C++ bindings. It
437 supports point-to-point and collective communications of any picklable Python
438 object as well as optimized communications of Python objects (such as NumPy
439 arrays) that expose a buffer interface.")
440 (license bsd-3)))