gnu: Add cl-ana.statistical-learning.
[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 utils)
33 #:use-module (guix deprecation)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system python)
36 #:use-module (gnu packages)
37 #:use-module (gnu packages fabric-management)
38 #:use-module (gnu packages gcc)
39 #:use-module (gnu packages java)
40 #:use-module (gnu packages libevent)
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)
46 #:use-module (gnu packages perl)
47 #:use-module (gnu packages ncurses)
48 #:use-module (gnu packages parallel)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages valgrind)
51 #:use-module (srfi srfi-1)
52 #:use-module (ice-9 match))
53
54 (define-public hwloc-1
55 ;; Note: For now we keep 1.x as the default because many packages have yet
56 ;; to migrate to 2.0.
57 (package
58 (name "hwloc")
59 (version "1.11.12")
60 (source (origin
61 (method url-fetch)
62 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
63 (version-major+minor version)
64 "/downloads/hwloc-" version ".tar.bz2"))
65 (sha256
66 (base32
67 "0za1b9lvrm3rhn0lrxja5f64r0aq1qs4m0pxn1ji2mbi8ndppyyx"))))
68 (build-system gnu-build-system)
69 (outputs '("out" ;'lstopo' & co., depends on Cairo, libx11, etc.
70 "lib" ;small closure
71 "debug"))
72 (inputs
73 `(("libx11" ,libx11)
74 ("cairo" ,cairo)
75 ("ncurses" ,ncurses)
76 ("expat" ,expat)
77 ,@(if (not (string-prefix? "armhf"
78 (or (%current-target-system)
79 (%current-system))))
80 `(("numactl" ,numactl))
81 '())))
82 (propagated-inputs
83 ;; hwloc.pc lists it in 'Requires.private'.
84 `(("libpciaccess" ,libpciaccess)))
85 (native-inputs
86 `(("pkg-config" ,pkg-config)))
87 (arguments
88 `(#:configure-flags '("--localstatedir=/var")
89 #:phases
90 (modify-phases %standard-phases
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))
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))))))
117 (home-page "https://www.open-mpi.org/projects/hwloc/")
118 (synopsis "Abstraction of hardware architectures")
119 (description
120 "hwloc provides a portable abstraction (across OS,
121 versions, architectures, ...) of the hierarchical topology of modern
122 architectures, including NUMA memory nodes, sockets, shared caches, cores and
123 simultaneous multithreading. It also gathers various attributes such as cache
124 and memory information. It primarily aims at helping high-performance
125 computing applications with gathering information about the hardware so as to
126 exploit it accordingly and efficiently.
127
128 hwloc may display the topology in multiple convenient formats. It also offers
129 a powerful programming interface to gather information about the hardware,
130 bind processes, and much more.")
131 (license bsd-3)))
132
133 (define-public hwloc-2
134 ;; Note: 2.0 isn't the default yet, see above.
135 (package
136 (inherit hwloc-1)
137 (version "2.1.0")
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
145 "0qh8s7pphz0m5cwb7liqmc17xzfs23xhz5wn24r6ikvjyx99fhhr"))))
146
147 ;; libnuma is no longer needed.
148 (inputs (alist-delete "numactl" (package-inputs hwloc-1)))
149 (arguments
150 (substitute-keyword-arguments (package-arguments hwloc-1)
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))))))))
161
162 (define-deprecated hwloc-2.0 'hwloc-2
163 hwloc-2)
164
165 (define-public hwloc
166 ;; The latest stable series of hwloc.
167 hwloc-2)
168
169 (define-public openmpi
170 (package
171 (name "openmpi")
172 (version "4.0.2")
173 (source
174 (origin
175 (method url-fetch)
176 (uri (string-append "https://www.open-mpi.org/software/ompi/v"
177 (version-major+minor version)
178 "/downloads/openmpi-" version ".tar.bz2"))
179 (sha256
180 (base32 "0ms0zvyxyy3pnx9qwib6zaljyp2b3ixny64xvq3czv3jpr8zf2wh"))
181 (patches (search-patches "openmpi-mtl-priorities.patch"))))
182 (build-system gnu-build-system)
183 (inputs
184 `(("hwloc" ,hwloc-2 "lib")
185 ("gfortran" ,gfortran)
186 ("libfabric" ,libfabric)
187 ("libevent" ,libevent)
188 ("opensm" ,opensm)
189 ,@(if (and (not (%current-target-system))
190 (member (%current-system) (package-supported-systems psm)))
191 `(("psm" ,psm))
192 '())
193 ,@(if (and (not (%current-target-system))
194 (member (%current-system) (package-supported-systems psm2)))
195 `(("psm2" ,psm2))
196 '())
197 ,@(if (and (not (%current-target-system))
198 (member (%current-system) (package-supported-systems ucx)))
199 `(("ucx" ,ucx))
200 '())
201 ("rdma-core" ,rdma-core)
202 ("valgrind" ,valgrind)
203 ("slurm" ,slurm))) ;for PMI support (launching via "srun")
204 (native-inputs
205 `(("pkg-config" ,pkg-config)
206 ("perl" ,perl)))
207 (outputs '("out" "debug"))
208 (arguments
209 `(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
210 "--enable-memchecker"
211 "--with-sge"
212 "--with-valgrind"
213 "--with-hwloc=external"
214 "--with-libevent"
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
223 ;; Enable support for SLURM's Process Manager
224 ;; Interface (PMI).
225 ,(string-append "--with-pmi="
226 (assoc-ref %build-inputs "slurm")))
227 #:phases (modify-phases %standard-phases
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")
233 "/include/infiniband"))
234 (setenv "CPLUS_INCLUDE_PATH"
235 (string-append (assoc-ref inputs "opensm")
236 "/include/infiniband"))
237 #t))
238 (add-before 'build 'remove-absolute
239 (lambda _
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>.
245 (substitute* '("orte/tools/orte-info/param.c"
246 "oshmem/tools/oshmem_info/param.c"
247 "ompi/tools/ompi_info/param.c")
248 (("_ABSOLUTE") ""))
249 ;; Avoid valgrind (which pulls in gdb etc.).
250 (substitute*
251 '("./ompi/mca/io/romio321/src/io_romio321_component.c")
252 (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
253 "\"[elided to reduce closure]\""))
254 #t))
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))))))
267 (home-page "http://www.open-mpi.org")
268 (synopsis "MPI-3 implementation")
269 (description
270 "The Open MPI Project is an MPI-3 implementation that is developed and
271 maintained by a consortium of academic, research, and industry partners. Open
272 MPI is therefore able to combine the expertise, technologies, and resources
273 from all across the High Performance Computing community in order to build the
274 best MPI library available. Open MPI offers advantages for system and
275 software vendors, application developers and computer science researchers.")
276 ;; See file://LICENSE
277 (license bsd-2)))
278
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
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
334 work correctly with all transports (such as @code{openib}), and the
335 performance is generally worse than the vanilla @code{openmpi} package, which
336 only provides @code{MPI_THREAD_FUNNELED}.")))
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.
347 (setenv "OMPI_MCA_rmaps_base_mapping_policy" "core:OVERSUBSCRIBE")
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")
357 #t))
358
359 (define-public python-mpi4py
360 (package
361 (name "python-mpi4py")
362 (version "3.0.3")
363 (source
364 (origin
365 (method url-fetch)
366 (uri (pypi-uri "mpi4py" version))
367 (sha256
368 (base32 "07ssbhssv27rrjx1c5vd3vsr31vay5d8xcf4zh9yblcyidn72b81"))))
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
388 Passing Interface (MPI) standard for the Python programming language, allowing
389 any Python program to exploit multiple processors.
390
391 mpi4py is constructed on top of the MPI-1/MPI-2 specification and provides an
392 object oriented interface which closely follows MPI-2 C++ bindings. It
393 supports point-to-point and collective communications of any picklable Python
394 object as well as optimized communications of Python objects (such as NumPy
395 arrays) that expose a buffer interface.")
396 (license bsd-3)))