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 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 utils)
33 #:use-module (guix build-system gnu)
34 #:use-module (guix build-system python)
35 #:use-module (gnu packages)
36 #:use-module (gnu packages fabric-management)
37 #:use-module (gnu packages gcc)
38 #:use-module (gnu packages java)
39 #:use-module (gnu packages libevent)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages pciutils)
42 #:use-module (gnu packages xorg)
43 #:use-module (gnu packages gtk)
44 #:use-module (gnu packages xml)
45 #:use-module (gnu packages perl)
46 #:use-module (gnu packages ncurses)
47 #:use-module (gnu packages parallel)
48 #:use-module (gnu packages pkg-config)
49 #:use-module (gnu packages valgrind)
50 #:use-module (srfi srfi-1)
51 #:use-module (ice-9 match))
54 ;; Note: For now we keep 1.x as the default because many packages have yet
61 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
62 (version-major+minor version)
63 "/downloads/hwloc-" version ".tar.bz2"))
66 "0za1b9lvrm3rhn0lrxja5f64r0aq1qs4m0pxn1ji2mbi8ndppyyx"))))
67 (build-system gnu-build-system)
68 (outputs '("out" ;'lstopo' & co., depends on Cairo, libx11, etc.
76 ,@(if (not (string-prefix? "armhf"
77 (or (%current-target-system)
79 `(("numactl" ,numactl))
82 ;; hwloc.pc lists it in 'Requires.private'.
83 `(("libpciaccess" ,libpciaccess)))
85 `(("pkg-config" ,pkg-config)))
87 `(#:configure-flags '("--localstatedir=/var")
89 (modify-phases %standard-phases
90 (add-before 'check 'skip-linux-libnuma-test
92 ;; Arrange to skip 'tests/linux-libnuma', which fails on some
93 ;; machines: <https://github.com/open-mpi/hwloc/issues/213>.
94 (substitute* "tests/linux-libnuma.c"
95 (("numa_available\\(\\)")
98 (add-after 'install 'refine-libnuma
99 ;; Give -L arguments for libraries to avoid propagation
100 (lambda* (#:key inputs outputs #:allow-other-keys)
101 (let ((out (assoc-ref outputs "lib"))
102 (numa (assoc-ref inputs "numactl")))
103 (substitute* (map (lambda (f) (string-append out "/" f))
104 '("lib/pkgconfig/hwloc.pc" "lib/libhwloc.la"))
106 (string-append "-L" numa "/lib " lib))))))
107 (add-after 'install 'avoid-circular-references
108 (lambda* (#:key outputs #:allow-other-keys)
109 (let ((lib (assoc-ref outputs "lib")))
110 ;; Suppress the 'prefix=' and 'exec_prefix=' lines so that the
111 ;; "lib" output doesn't refer to "out".
112 (substitute* (string-append lib "/lib/pkgconfig/hwloc.pc")
116 (home-page "https://www.open-mpi.org/projects/hwloc/")
117 (synopsis "Abstraction of hardware architectures")
119 "hwloc provides a portable abstraction (across OS,
120 versions, architectures, ...) of the hierarchical topology of modern
121 architectures, including NUMA memory nodes, sockets, shared caches, cores and
122 simultaneous multithreading. It also gathers various attributes such as cache
123 and memory information. It primarily aims at helping high-performance
124 computing applications with gathering information about the hardware so as to
125 exploit it accordingly and efficiently.
127 hwloc may display the topology in multiple convenient formats. It also offers
128 a powerful programming interface to gather information about the hardware,
129 bind processes, and much more.")
132 (define-public hwloc-2.0
133 ;; Note: 2.0 isn't the default yet, see above.
139 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
140 (version-major+minor version)
141 "/downloads/hwloc-" version ".tar.bz2"))
144 "09f7ajak8wv5issr0hw72vs3jkldc7crcc7z5fd34sspkvrsm4z3"))))
146 ;; libnuma is no longer needed.
147 (inputs (alist-delete "numactl" (package-inputs hwloc)))
149 (substitute-keyword-arguments (package-arguments hwloc)
151 `(modify-phases ,phases
152 (replace 'skip-linux-libnuma-test
154 ;; Arrange to skip 'tests/hwloc/linux-libnuma', which fails on
155 ;; some machines: <https://github.com/open-mpi/hwloc/issues/213>.
156 (substitute* "tests/hwloc/linux-libnuma.c"
157 (("numa_available\\(\\)")
161 (define-public openmpi
168 (uri (string-append "https://www.open-mpi.org/software/ompi/v"
169 (version-major+minor version)
170 "/downloads/openmpi-" version ".tar.bz2"))
172 (base32 "02cpzcp113gj5hb0j2xc0cqma2fn04i2i0bzf80r71120p9bdryc"))))
173 (build-system gnu-build-system)
175 `(("hwloc" ,hwloc "lib")
176 ("gfortran" ,gfortran)
177 ("libfabric" ,libfabric)
178 ("libevent" ,libevent)
180 ,@(if (and (not (%current-target-system))
181 (member (%current-system) (package-supported-systems psm)))
184 ,@(if (and (not (%current-target-system))
185 (member (%current-system) (package-supported-systems psm2)))
188 ("rdma-core" ,rdma-core)
189 ("valgrind" ,valgrind)
190 ("slurm" ,slurm))) ;for PMI support (launching via "srun")
192 `(("pkg-config" ,pkg-config)
194 (outputs '("out" "debug"))
196 `(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
197 "--enable-memchecker"
200 "--with-hwloc=external"
203 ;; InfiniBand support
204 "--enable-openib-control-hdr-padding"
205 "--enable-openib-dynamic-sl"
206 "--enable-openib-udcm"
207 "--enable-openib-rdmacm"
208 "--enable-openib-rdmacm-ibaddr"
210 ;; Enable support for SLURM's Process Manager
212 ,(string-append "--with-pmi="
213 (assoc-ref %build-inputs "slurm")))
214 #:phases (modify-phases %standard-phases
215 ;; opensm is needed for InfiniBand support.
216 (add-after 'unpack 'find-opensm-headers
217 (lambda* (#:key inputs #:allow-other-keys)
218 (setenv "C_INCLUDE_PATH"
219 (string-append (assoc-ref inputs "opensm")
220 "/include/infiniband/:"
221 (getenv "C_INCLUDE_PATH")))
222 (setenv "CPLUS_INCLUDE_PATH"
223 (string-append (assoc-ref inputs "opensm")
224 "/include/infiniband/:"
225 (getenv "CPLUS_INCLUDE_PATH")))
227 (add-before 'build 'remove-absolute
229 ;; Remove compiler absolute file names (OPAL_FC_ABSOLUTE
230 ;; etc.) to reduce the closure size. See
231 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-07/msg00388.html>
233 ;; <https://www.mail-archive.com/users@lists.open-mpi.org//msg31397.html>.
234 (substitute* '("orte/tools/orte-info/param.c"
235 "oshmem/tools/oshmem_info/param.c"
236 "ompi/tools/ompi_info/param.c")
238 ;; Avoid valgrind (which pulls in gdb etc.).
240 '("./ompi/mca/io/romio321/src/io_romio321_component.c")
241 (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
242 "\"[elided to reduce closure]\""))
244 (add-before 'build 'scrub-timestamps ;reproducibility
246 (substitute* '("ompi/tools/ompi_info/param.c"
247 "orte/tools/orte-info/param.c"
248 "oshmem/tools/oshmem_info/param.c")
249 ((".*(Built|Configured) on.*") ""))
251 (add-after 'install 'remove-logs ;reproducibility
252 (lambda* (#:key outputs #:allow-other-keys)
253 (let ((out (assoc-ref outputs "out")))
254 (for-each delete-file (find-files out "config.log"))
256 (home-page "http://www.open-mpi.org")
257 (synopsis "MPI-3 implementation")
259 "The Open MPI Project is an MPI-3 implementation that is developed and
260 maintained by a consortium of academic, research, and industry partners. Open
261 MPI is therefore able to combine the expertise, technologies, and resources
262 from all across the High Performance Computing community in order to build the
263 best MPI library available. Open MPI offers advantages for system and
264 software vendors, application developers and computer science researchers.")
265 ;; See file://LICENSE
268 ;; TODO: javadoc files contain timestamps.
269 (define-public java-openmpi
270 (package (inherit openmpi)
271 (name "java-openmpi")
273 `(("openmpi" ,openmpi)
274 ,@(package-inputs openmpi)))
276 `(("jdk" ,openjdk11 "jdk")
277 ("zip" ,(@ (gnu packages compression) zip))
278 ,@(package-native-inputs openmpi)))
281 `(#:modules ((guix build gnu-build-system)
282 ((guix build ant-build-system) #:prefix ant:)
284 #:imported-modules ((guix build ant-build-system)
285 (guix build syscalls)
286 ,@%gnu-build-system-modules)
287 ,@(substitute-keyword-arguments (package-arguments openmpi)
288 ((#:configure-flags flags)
289 `(cons "--enable-mpi-java" ,flags))
290 ((#:make-flags flags ''())
291 `(append '("-C" "ompi/mpi/java")
294 `(modify-phases ,phases
295 ;; We could provide the location of the JDK in the configure
296 ;; flags, but since the configure flags are embedded in the
297 ;; info binaries that would leave a reference to the JDK in
298 ;; the "out" output. To avoid this we set JAVA_HOME.
299 (add-after 'unpack 'set-JAVA_HOME
300 (lambda* (#:key inputs #:allow-other-keys)
301 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
303 (add-after 'unpack 'link-with-existing-mpi-libraries
304 (lambda* (#:key inputs #:allow-other-keys)
305 (substitute* "ompi/mpi/java/c/Makefile.in"
306 (("\\$\\(top_builddir\\)/ompi/lib@OMPI_LIBMPI_NAME@.la")
307 (string-append (assoc-ref inputs "openmpi") "/lib/libmpi.la")))
309 (add-after 'install 'strip-jar-timestamps
310 (assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))))
311 (synopsis "Java bindings for MPI")))
313 (define-public openmpi-thread-multiple
316 (name "openmpi-thread-multiple")
318 (substitute-keyword-arguments (package-arguments openmpi)
319 ((#:configure-flags flags)
320 `(cons "--enable-mpi-thread-multiple" ,flags))))
321 (description " This version of Open@tie{}MPI has an implementation of
322 @code{MPI_Init_thread} that provides @code{MPI_THREAD_MULTIPLE}. This won't
323 work correctly with all transports (such as @code{openib}), and the
324 performance is generally worse than the vanilla @code{openmpi} package, which
325 only provides @code{MPI_THREAD_FUNNELED}.")))
327 ;;; Build phase to be used for packages that execute MPI code.
328 (define-public %openmpi-setup
330 ;; By default, running the test suite would fail because 'ssh' could not
331 ;; be found in $PATH. Define this variable to placate Open MPI without
332 ;; adding a dependency on OpenSSH (the agent isn't used anyway.)
333 (setenv "OMPI_MCA_plm_rsh_agent" (which "false"))
334 ;; Allow oversubscription in case there are less physical cores available
335 ;; in the build environment than the package wants while testing.
336 (setenv "OMPI_MCA_rmaps_base_mapping_policy" "core:OVERSUBSCRIBE")
339 (define-public python-mpi4py
341 (name "python-mpi4py")
346 (uri (pypi-uri "mpi4py" version))
349 "0ld8rjmsjr0dklvj2g1gr3ax32sdq0xjxyh0cspknc1i36waajb5"))))
350 (build-system python-build-system)
353 (modify-phases %standard-phases
354 (add-after 'build 'mpi-setup
356 (add-before 'check 'pre-check
358 ;; Skip BaseTestSpawn class (causes error 'ompi_dpm_dyn_init()
359 ;; failed --> Returned "Unreachable"' in chroot environment).
360 (substitute* "test/test_spawn.py"
361 (("unittest.skipMPI\\('openmpi\\(<3.0.0\\)'\\)")
362 "unittest.skipMPI('openmpi')"))
365 `(("openmpi" ,openmpi)))
366 (home-page "https://bitbucket.org/mpi4py/mpi4py/")
367 (synopsis "Python bindings for the Message Passing Interface standard")
368 (description "MPI for Python (mpi4py) provides bindings of the Message
369 Passing Interface (MPI) standard for the Python programming language, allowing
370 any Python program to exploit multiple processors.
372 mpi4py is constructed on top of the MPI-1/MPI-2 specification and provides an
373 object oriented interface which closely follows MPI-2 C++ bindings. It
374 supports point-to-point and collective communications of any picklable Python
375 object as well as optimized communications of Python objects (such as NumPy
376 arrays) that expose a buffer interface.")