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