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>
12 ;;; This file is part of GNU Guix.
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.
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.
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/>.
27 (define-module (gnu packages mpi)
28 #:use-module (guix packages)
29 #:use-module ((guix licenses)
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))
56 ;; Note: For now we keep 1.x as the default because many packages have yet
63 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
64 (version-major+minor version)
65 "/downloads/hwloc-" version ".tar.bz2"))
68 "0za1b9lvrm3rhn0lrxja5f64r0aq1qs4m0pxn1ji2mbi8ndppyyx"))))
69 (build-system gnu-build-system)
70 (outputs '("out" ;'lstopo' & co., depends on Cairo, libx11, etc.
78 ,@(if (not (string-prefix? "armhf"
79 (or (%current-target-system)
81 `(("numactl" ,numactl))
84 ;; hwloc.pc lists it in 'Requires.private'.
85 `(("libpciaccess" ,libpciaccess)))
87 `(("pkg-config" ,pkg-config)))
89 `(#:configure-flags '("--localstatedir=/var")
91 (modify-phases %standard-phases
92 (add-before 'check 'skip-linux-libnuma-test
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\\(\\)")
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"))
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")
118 (home-page "https://www.open-mpi.org/projects/hwloc/")
119 (synopsis "Abstraction of hardware architectures")
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.
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.")
134 (define-public hwloc-2
135 ;; Note: 2.0 isn't the default yet, see above.
141 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
142 (version-major+minor version)
143 "/downloads/hwloc-" version ".tar.bz2"))
146 "0qh8s7pphz0m5cwb7liqmc17xzfs23xhz5wn24r6ikvjyx99fhhr"))))
148 ;; libnuma is no longer needed.
149 (inputs (alist-delete "numactl" (package-inputs hwloc)))
151 (substitute-keyword-arguments (package-arguments hwloc)
153 `(modify-phases ,phases
154 (replace 'skip-linux-libnuma-test
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\\(\\)")
163 (define-deprecated hwloc-2.0 'hwloc-2
166 (define-public openmpi
173 (uri (string-append "https://www.open-mpi.org/software/ompi/v"
174 (version-major+minor version)
175 "/downloads/openmpi-" version ".tar.bz2"))
177 (base32 "0ms0zvyxyy3pnx9qwib6zaljyp2b3ixny64xvq3czv3jpr8zf2wh"))))
178 (build-system gnu-build-system)
180 `(("hwloc" ,hwloc "lib")
181 ("gfortran" ,gfortran)
182 ("libfabric" ,libfabric)
183 ("libevent" ,libevent)
185 ,@(if (and (not (%current-target-system))
186 (member (%current-system) (package-supported-systems psm)))
189 ,@(if (and (not (%current-target-system))
190 (member (%current-system) (package-supported-systems psm2)))
193 ,@(if (and (not (%current-target-system))
194 (member (%current-system) (package-supported-systems psm2)))
197 ("rdma-core" ,rdma-core)
198 ("valgrind" ,valgrind)
199 ("slurm" ,slurm))) ;for PMI support (launching via "srun")
201 `(("pkg-config" ,pkg-config)
203 (outputs '("out" "debug"))
205 `(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
206 "--enable-memchecker"
209 "--with-hwloc=external"
212 ;; Make sure ./configure fails if one of these is
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"
225 ;; Enable support for SLURM's Process Manager
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"))
240 (add-before 'build 'remove-absolute
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>
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")
251 ;; Avoid valgrind (which pulls in gdb etc.).
253 '("./ompi/mca/io/romio321/src/io_romio321_component.c")
254 (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
255 "\"[elided to reduce closure]\""))
257 (add-before 'build 'scrub-timestamps ;reproducibility
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.*") ""))
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"))
269 (home-page "http://www.open-mpi.org")
270 (synopsis "MPI-3 implementation")
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
281 ;; TODO: javadoc files contain timestamps.
282 (define-public java-openmpi
283 (package (inherit openmpi)
284 (name "java-openmpi")
286 `(("openmpi" ,openmpi)
287 ,@(package-inputs openmpi)))
289 `(("jdk" ,openjdk11 "jdk")
290 ("zip" ,(@ (gnu packages compression) zip))
291 ,@(package-native-inputs openmpi)))
294 `(#:modules ((guix build gnu-build-system)
295 ((guix build ant-build-system) #:prefix ant:)
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")
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"))
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")))
322 (add-after 'install 'strip-jar-timestamps
323 (assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))))
324 (synopsis "Java bindings for MPI")))
326 (define-public openmpi-thread-multiple
329 (name "openmpi-thread-multiple")
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}.")))
340 ;;; Build phase to be used for packages that execute MPI code.
341 (define-public %openmpi-setup
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")
352 (define-public intel-mpi-benchmarks
354 (name "intel-mpi-benchmarks")
359 (url "https://github.com/intel/mpi-benchmarks.git")
360 (commit (string-append "IMB-v" version))))
361 (file-name (git-file-name name version))
364 "0si5xi6ilhd3w0gbsg124589pvp094hvf366rvjjb9pi7pdk5p4i"))))
365 (build-system gnu-build-system)
367 '(#:phases (modify-phases %standard-phases
371 (lambda* (#:key outputs #:allow-other-keys)
372 (define (benchmark? file stat)
373 (and (string-prefix? "IMB-" (basename file))
374 (executable-file? file)))
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?))
383 ;; The makefile doesn't express all the dependencies, it seems.
386 #:make-flags (list (string-append "CC="
387 (assoc-ref %build-inputs "openmpi")
389 (string-append "CXX="
390 (assoc-ref %build-inputs "openmpi")
393 `(("openmpi" ,openmpi)))
394 (home-page "https://github.com/intel/mpi-benchmarks")
395 (synopsis "Benchmarks for the Message Passing Interface (MPI)")
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).")
400 (fsf-free "https://directory.fsf.org/wiki/License:CPL-1.0"
401 "https://www.gnu.org/licenses/license-list.html#CommonPublicLicense10"))))
403 (define-public python-mpi4py
405 (name "python-mpi4py")
410 (uri (pypi-uri "mpi4py" version))
412 (base32 "07ssbhssv27rrjx1c5vd3vsr31vay5d8xcf4zh9yblcyidn72b81"))))
413 (build-system python-build-system)
416 (modify-phases %standard-phases
417 (add-after 'build 'mpi-setup
419 (add-before 'check 'pre-check
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')"))
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.
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.")