gnu: r-limma: Update to 3.40.0.
[jackhill/guix/guix.git] / gnu / packages / mpi.scm
CommitLineData
fb0e3709 1;;; GNU Guix --- Functional package management for GNU
41313ace 2;;; Copyright © 2014, 2015, 2018, 2019 Eric Bavier <bavier@member.fsf.org>
b07712bf 3;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
29a7c98a 4;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
37d6b097 5;;; Copyright © 2016 Andreas Enge <andreas@enge.fr>
1f9bff41 6;;; Copyright © 2017 Dave Love <fx@gnu.org>
91298042 7;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
b9b53fb4 8;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
54fcd547 9;;; Copyright © 2018 Paul Garlick <pgarlick@tourbillion-technology.com>
e9823f9c 10;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
fb0e3709
EB
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)
2b0d560a
LC
29 #:use-module ((guix licenses)
30 #:hide (expat))
fb0e3709 31 #:use-module (guix download)
29a7c98a 32 #:use-module (guix utils)
fb0e3709 33 #:use-module (guix build-system gnu)
54fcd547 34 #:use-module (guix build-system python)
fb0e3709 35 #:use-module (gnu packages)
e9823f9c 36 #:use-module (gnu packages fabric-management)
fb0e3709 37 #:use-module (gnu packages gcc)
fa5a2538 38 #:use-module (gnu packages java)
41313ace 39 #:use-module (gnu packages libevent)
2b0d560a
LC
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)
38f0a2ba 45 #:use-module (gnu packages perl)
2b0d560a 46 #:use-module (gnu packages ncurses)
b07712bf 47 #:use-module (gnu packages parallel)
2b0d560a 48 #:use-module (gnu packages pkg-config)
91298042 49 #:use-module (gnu packages valgrind)
71e78931 50 #:use-module (srfi srfi-1)
91298042 51 #:use-module (ice-9 match))
fb0e3709 52
2b0d560a 53(define-public hwloc
71e78931
LC
54 ;; Note: For now we keep 1.x as the default because many packages have yet
55 ;; to migrate to 2.0.
2b0d560a
LC
56 (package
57 (name "hwloc")
9dd50845 58 (version "1.11.12")
2b0d560a
LC
59 (source (origin
60 (method url-fetch)
a2d0e200 61 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
ce7d9c98
EB
62 (version-major+minor version)
63 "/downloads/hwloc-" version ".tar.bz2"))
2b0d560a
LC
64 (sha256
65 (base32
9dd50845 66 "0za1b9lvrm3rhn0lrxja5f64r0aq1qs4m0pxn1ji2mbi8ndppyyx"))))
2b0d560a 67 (build-system gnu-build-system)
798b7678
LC
68 (outputs '("out" ;'lstopo' & co., depends on Cairo, libx11, etc.
69 "lib" ;small closure
70 "debug"))
2b0d560a 71 (inputs
5b527256 72 `(("libx11" ,libx11)
2b0d560a
LC
73 ("cairo" ,cairo)
74 ("ncurses" ,ncurses)
37d6b097
AE
75 ("expat" ,expat)
76 ,@(if (not (string-prefix? "armhf"
77 (or (%current-target-system)
78 (%current-system))))
79 `(("numactl" ,numactl))
80 '())))
c6e59259
LC
81 (propagated-inputs
82 ;; hwloc.pc lists it in 'Requires.private'.
83 `(("libpciaccess" ,libpciaccess)))
2b0d560a
LC
84 (native-inputs
85 `(("pkg-config" ,pkg-config)))
579f5c8a 86 (arguments
7eb9f31c
LC
87 `(#:configure-flags '("--localstatedir=/var")
88 #:phases
579f5c8a 89 (modify-phases %standard-phases
10de06bd
LC
90 (add-before 'check 'skip-linux-libnuma-test
91 (lambda _
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\\(\\)")
96 "-1"))
97 #t))
798b7678
LC
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"))
105 (("-lnuma" lib)
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")
113 (("^.*prefix=.*$")
114 ""))
115 #t))))))
a2d0e200 116 (home-page "https://www.open-mpi.org/projects/hwloc/")
2b0d560a
LC
117 (synopsis "Abstraction of hardware architectures")
118 (description
119 "hwloc provides a portable abstraction (across OS,
120versions, architectures, ...) of the hierarchical topology of modern
121architectures, including NUMA memory nodes, sockets, shared caches, cores and
122simultaneous multithreading. It also gathers various attributes such as cache
123and memory information. It primarily aims at helping high-performance
124computing applications with gathering information about the hardware so as to
125exploit it accordingly and efficiently.
126
127hwloc may display the topology in multiple convenient formats. It also offers
128a powerful programming interface to gather information about the hardware,
129bind processes, and much more.")
2b0d560a
LC
130 (license bsd-3)))
131
71e78931
LC
132(define-public hwloc-2.0
133 ;; Note: 2.0 isn't the default yet, see above.
134 (package
135 (inherit hwloc)
cb85742f 136 (version "2.0.3")
71e78931
LC
137 (source (origin
138 (method url-fetch)
139 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
140 (version-major+minor version)
141 "/downloads/hwloc-" version ".tar.bz2"))
142 (sha256
143 (base32
cb85742f 144 "09f7ajak8wv5issr0hw72vs3jkldc7crcc7z5fd34sspkvrsm4z3"))))
71e78931
LC
145
146 ;; libnuma is no longer needed.
10de06bd
LC
147 (inputs (alist-delete "numactl" (package-inputs hwloc)))
148 (arguments
149 (substitute-keyword-arguments (package-arguments hwloc)
150 ((#:phases phases)
151 `(modify-phases ,phases
152 (replace 'skip-linux-libnuma-test
153 (lambda _
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\\(\\)")
158 "-1"))
159 #t))))))))
71e78931 160
fb0e3709
EB
161(define-public openmpi
162 (package
163 (name "openmpi")
6e36c6ed 164 (version "4.0.1")
fb0e3709
EB
165 (source
166 (origin
167 (method url-fetch)
6876590f 168 (uri (string-append "https://www.open-mpi.org/software/ompi/v"
29a7c98a 169 (version-major+minor version)
fb0e3709
EB
170 "/downloads/openmpi-" version ".tar.bz2"))
171 (sha256
6e36c6ed 172 (base32 "02cpzcp113gj5hb0j2xc0cqma2fn04i2i0bzf80r71120p9bdryc"))))
fb0e3709 173 (build-system gnu-build-system)
5b527256 174 (inputs
798b7678 175 `(("hwloc" ,hwloc "lib")
19afbea1 176 ("gfortran" ,gfortran)
a0995702 177 ("libfabric" ,libfabric)
41313ace 178 ("libevent" ,libevent)
e9823f9c 179 ("opensm" ,opensm)
a560641a
LC
180 ,@(if (and (not (%current-target-system))
181 (member (%current-system) (package-supported-systems psm)))
182 `(("psm" ,psm))
183 '())
fbe1b85b
LC
184 ,@(if (and (not (%current-target-system))
185 (member (%current-system) (package-supported-systems psm2)))
186 `(("psm2" ,psm2))
187 '())
a0995702 188 ("rdma-core" ,rdma-core)
b07712bf
LC
189 ("valgrind" ,valgrind)
190 ("slurm" ,slurm))) ;for PMI support (launching via "srun")
5b527256 191 (native-inputs
38f0a2ba
EB
192 `(("pkg-config" ,pkg-config)
193 ("perl" ,perl)))
c971d9ef 194 (outputs '("out" "debug"))
fb0e3709 195 (arguments
b08952f1 196 `(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
1691b4cd 197 "--enable-memchecker"
efcacc17 198 "--with-sge"
41313ace
EB
199 "--with-valgrind"
200 "--with-hwloc=external"
201 "--with-libevent"
e9823f9c
RW
202
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"
209
b07712bf
LC
210 ;; Enable support for SLURM's Process Manager
211 ;; Interface (PMI).
212 ,(string-append "--with-pmi="
213 (assoc-ref %build-inputs "slurm")))
9474a4b3 214 #:phases (modify-phases %standard-phases
e9823f9c
RW
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")))
226 #t))
0d97d3cb 227 (add-before 'build 'remove-absolute
0d97d3cb 228 (lambda _
a247fe7b
DL
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>
232 ;; and
233 ;; <https://www.mail-archive.com/users@lists.open-mpi.org//msg31397.html>.
0d97d3cb
DL
234 (substitute* '("orte/tools/orte-info/param.c"
235 "oshmem/tools/oshmem_info/param.c"
236 "ompi/tools/ompi_info/param.c")
237 (("_ABSOLUTE") ""))
a247fe7b
DL
238 ;; Avoid valgrind (which pulls in gdb etc.).
239 (substitute*
41313ace
EB
240 '("./ompi/mca/io/romio321/src/io_romio321_component.c")
241 (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
a247fe7b 242 "\"[elided to reduce closure]\""))
0d97d3cb 243 #t))
9474a4b3
EB
244 (add-before 'build 'scrub-timestamps ;reproducibility
245 (lambda _
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.*") ""))
250 #t))
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"))
255 #t))))))
fb0e3709 256 (home-page "http://www.open-mpi.org")
bb0f6d75 257 (synopsis "MPI-3 implementation")
fb0e3709 258 (description
bb0f6d75 259 "The Open MPI Project is an MPI-3 implementation that is developed and
8ede638c
EB
260maintained by a consortium of academic, research, and industry partners. Open
261MPI is therefore able to combine the expertise, technologies, and resources
262from all across the High Performance Computing community in order to build the
263best MPI library available. Open MPI offers advantages for system and
264software vendors, application developers and computer science researchers.")
fb0e3709
EB
265 ;; See file://LICENSE
266 (license bsd-2)))
685bef2b 267
fa5a2538
RW
268;; TODO: javadoc files contain timestamps.
269(define-public java-openmpi
270 (package (inherit openmpi)
271 (name "java-openmpi")
272 (inputs
273 `(("openmpi" ,openmpi)
274 ,@(package-inputs openmpi)))
275 (native-inputs
276 `(("jdk" ,openjdk11 "jdk")
277 ("zip" ,(@ (gnu packages compression) zip))
278 ,@(package-native-inputs openmpi)))
279 (outputs '("out"))
280 (arguments
281 `(#:modules ((guix build gnu-build-system)
282 ((guix build ant-build-system) #:prefix ant:)
283 (guix build utils))
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")
292 ,flags))
293 ((#:phases phases)
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"))
302 #t))
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")))
308 #t))
309 (add-after 'install 'strip-jar-timestamps
310 (assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))))
311 (synopsis "Java bindings for MPI")))
312
685bef2b
DL
313(define-public openmpi-thread-multiple
314 (package
315 (inherit openmpi)
316 (name "openmpi-thread-multiple")
317 (arguments
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
323work correctly with all transports (such as @code{openib}), and the
324performance is generally worse than the vanilla @code{openmpi} package, which
325only provides @code{MPI_THREAD_FUNNELED}.")))
bbe46a4a
EB
326
327;;; Build phase to be used for packages that execute MPI code.
328(define-public %openmpi-setup
329 '(lambda _
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.
41313ace 336 (setenv "OMPI_MCA_rmaps_base_mapping_policy" "core:OVERSUBSCRIBE")
bbe46a4a 337 #t))
54fcd547
PG
338
339(define-public python-mpi4py
340 (package
341 (name "python-mpi4py")
b49c8b9e 342 (version "3.0.1")
54fcd547
PG
343 (source
344 (origin
345 (method url-fetch)
346 (uri (pypi-uri "mpi4py" version))
347 (sha256
348 (base32
b49c8b9e 349 "0ld8rjmsjr0dklvj2g1gr3ax32sdq0xjxyh0cspknc1i36waajb5"))))
54fcd547
PG
350 (build-system python-build-system)
351 (arguments
352 `(#:phases
353 (modify-phases %standard-phases
354 (add-after 'build 'mpi-setup
355 ,%openmpi-setup)
356 (add-before 'check 'pre-check
357 (lambda _
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')"))
363 #t)))))
364 (inputs
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
369Passing Interface (MPI) standard for the Python programming language, allowing
370any Python program to exploit multiple processors.
371
372mpi4py is constructed on top of the MPI-1/MPI-2 specification and provides an
373object oriented interface which closely follows MPI-2 C++ bindings. It
374supports point-to-point and collective communications of any picklable Python
375object as well as optimized communications of Python objects (such as NumPy
376arrays) that expose a buffer interface.")
377 (license bsd-3)))