gnu: pies: Update to 1.4.
[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 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 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))
52
53 (define-public hwloc
54 ;; Note: For now we keep 1.x as the default because many packages have yet
55 ;; to migrate to 2.0.
56 (package
57 (name "hwloc")
58 (version "1.11.12")
59 (source (origin
60 (method url-fetch)
61 (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
62 (version-major+minor version)
63 "/downloads/hwloc-" version ".tar.bz2"))
64 (sha256
65 (base32
66 "0za1b9lvrm3rhn0lrxja5f64r0aq1qs4m0pxn1ji2mbi8ndppyyx"))))
67 (build-system gnu-build-system)
68 (outputs '("out" ;'lstopo' & co., depends on Cairo, libx11, etc.
69 "lib" ;small closure
70 "debug"))
71 (inputs
72 `(("libx11" ,libx11)
73 ("cairo" ,cairo)
74 ("ncurses" ,ncurses)
75 ("expat" ,expat)
76 ,@(if (not (string-prefix? "armhf"
77 (or (%current-target-system)
78 (%current-system))))
79 `(("numactl" ,numactl))
80 '())))
81 (propagated-inputs
82 ;; hwloc.pc lists it in 'Requires.private'.
83 `(("libpciaccess" ,libpciaccess)))
84 (native-inputs
85 `(("pkg-config" ,pkg-config)))
86 (arguments
87 `(#:configure-flags '("--localstatedir=/var")
88 #:phases
89 (modify-phases %standard-phases
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))
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))))))
116 (home-page "https://www.open-mpi.org/projects/hwloc/")
117 (synopsis "Abstraction of hardware architectures")
118 (description
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.
126
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.")
130 (license bsd-3)))
131
132 (define-public hwloc-2.0
133 ;; Note: 2.0 isn't the default yet, see above.
134 (package
135 (inherit hwloc)
136 (version "2.0.3")
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
144 "09f7ajak8wv5issr0hw72vs3jkldc7crcc7z5fd34sspkvrsm4z3"))))
145
146 ;; libnuma is no longer needed.
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))))))))
160
161 (define-public openmpi
162 (package
163 (name "openmpi")
164 (version "4.0.1")
165 (source
166 (origin
167 (method url-fetch)
168 (uri (string-append "https://www.open-mpi.org/software/ompi/v"
169 (version-major+minor version)
170 "/downloads/openmpi-" version ".tar.bz2"))
171 (sha256
172 (base32 "02cpzcp113gj5hb0j2xc0cqma2fn04i2i0bzf80r71120p9bdryc"))))
173 (build-system gnu-build-system)
174 (inputs
175 `(("hwloc" ,hwloc "lib")
176 ("gfortran" ,gfortran)
177 ("libfabric" ,libfabric)
178 ("libevent" ,libevent)
179 ("opensm" ,opensm)
180 ,@(if (and (not (%current-target-system))
181 (member (%current-system) (package-supported-systems psm)))
182 `(("psm" ,psm))
183 '())
184 ,@(if (and (not (%current-target-system))
185 (member (%current-system) (package-supported-systems psm2)))
186 `(("psm2" ,psm2))
187 '())
188 ("rdma-core" ,rdma-core)
189 ("valgrind" ,valgrind)
190 ("slurm" ,slurm))) ;for PMI support (launching via "srun")
191 (native-inputs
192 `(("pkg-config" ,pkg-config)
193 ("perl" ,perl)))
194 (outputs '("out" "debug"))
195 (arguments
196 `(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
197 "--enable-memchecker"
198 "--with-sge"
199 "--with-valgrind"
200 "--with-hwloc=external"
201 "--with-libevent"
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
210 ;; Enable support for SLURM's Process Manager
211 ;; Interface (PMI).
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")))
226 #t))
227 (add-before 'build 'remove-absolute
228 (lambda _
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>.
234 (substitute* '("orte/tools/orte-info/param.c"
235 "oshmem/tools/oshmem_info/param.c"
236 "ompi/tools/ompi_info/param.c")
237 (("_ABSOLUTE") ""))
238 ;; Avoid valgrind (which pulls in gdb etc.).
239 (substitute*
240 '("./ompi/mca/io/romio321/src/io_romio321_component.c")
241 (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
242 "\"[elided to reduce closure]\""))
243 #t))
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))))))
256 (home-page "http://www.open-mpi.org")
257 (synopsis "MPI-3 implementation")
258 (description
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
266 (license bsd-2)))
267
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
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
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}.")))
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.
336 (setenv "OMPI_MCA_rmaps_base_mapping_policy" "core:OVERSUBSCRIBE")
337 #t))
338
339 (define-public python-mpi4py
340 (package
341 (name "python-mpi4py")
342 (version "3.0.2")
343 (source
344 (origin
345 (method url-fetch)
346 (uri (pypi-uri "mpi4py" version))
347 (sha256
348 (base32
349 "1q28xl36difma1wq0acq111cqxjya32kn3lxp6fbidz3wg8jkmpq"))))
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
369 Passing Interface (MPI) standard for the Python programming language, allowing
370 any Python program to exploit multiple processors.
371
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.")
377 (license bsd-3)))