projects/guix·blob java-team · refs

832 lines · 36.6 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014, 2015, 2018, 2019 Eric Bavier <[email protected]>
3;;; Copyright © 2014-2026 Ludovic Courtès <[email protected]>
4;;; Copyright © 2014 Ian Denhardt <[email protected]>
5;;; Copyright © 2016 Andreas Enge <[email protected]>
6;;; Copyright © 2017 Dave Love <[email protected]>
7;;; Copyright © 2017, 2022, 2025 Efraim Flashner <[email protected]>
8;;; Copyright © 2018–2022 Tobias Geerinckx-Rice <[email protected]>
9;;; Copyright © 2018 Paul Garlick <[email protected]>
10;;; Copyright © 2019, 2021 Ricardo Wurmus <[email protected]>
11;;; Copyright © 2024 Romain Garbage <[email protected]>
12;;; Copyright © 2025 Janneke Nieuwenhuizen <[email protected]>
13;;;
14;;; This file is part of GNU Guix.
15;;;
16;;; GNU Guix is free software; you can redistribute it and/or modify it
17;;; under the terms of the GNU General Public License as published by
18;;; the Free Software Foundation; either version 3 of the License, or (at
19;;; your option) any later version.
20;;;
21;;; GNU Guix is distributed in the hope that it will be useful, but
22;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24;;; GNU General Public License for more details.
25;;;
26;;; You should have received a copy of the GNU General Public License
27;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29(define-module (gnu packages mpi)
30 #:use-module (guix gexp)
31 #:use-module (guix packages)
32 #:use-module ((guix licenses) #:prefix license:)
33 #:use-module (guix download)
34 #:use-module (guix git-download)
35 #:use-module (guix utils)
36 #:use-module (guix deprecation)
37 #:use-module (guix build-system cmake)
38 #:use-module (guix build-system gnu)
39 #:use-module (guix build-system pyproject)
40 #:use-module (gnu packages)
41 #:use-module (gnu packages autotools)
42 #:use-module (gnu packages base)
43 #:use-module (gnu packages bash)
44 #:use-module (gnu packages bison)
45 #:use-module (gnu packages check)
46 #:use-module (gnu packages compression)
47 #:use-module (gnu packages documentation)
48 #:use-module (gnu packages fabric-management)
49 #:use-module (gnu packages compiler-tools)
50 #:use-module (gnu packages gcc)
51 #:use-module (gnu packages java)
52 #:use-module (gnu packages libevent)
53 #:use-module (gnu packages libunwind)
54 #:use-module (gnu packages linux)
55 #:use-module (gnu packages oneapi)
56 #:use-module (gnu packages opencl)
57 #:use-module (gnu packages pciutils)
58 #:use-module (gnu packages profiling)
59 #:use-module (gnu packages python)
60 #:use-module (gnu packages xorg)
61 #:use-module (gnu packages gtk)
62 #:use-module (gnu packages xml)
63 #:use-module (gnu packages perl)
64 #:use-module (gnu packages ncurses)
65 #:use-module (gnu packages parallel)
66 #:use-module (gnu packages pkg-config)
67 #:use-module (gnu packages python)
68 #:use-module (gnu packages python-build)
69 #:use-module (gnu packages python-xyz)
70 #:use-module (gnu packages rocm)
71 #:use-module (gnu packages rocm-tools)
72 #:use-module (gnu packages ssh)
73 #:use-module (gnu packages valgrind)
74 #:use-module (gnu packages version-control)
75 #:use-module (gnu packages xdisorg)
76 #:use-module (srfi srfi-1)
77 #:use-module (ice-9 match))
78
79(define-public hwloc
80 (package
81 (name "hwloc")
82 (version "2.13.0")
83 (source
84 (origin
85 (method git-fetch)
86 (uri (git-reference
87 (url "https://github.com/open-mpi/hwloc")
88 (commit (string-append "hwloc-" version))))
89 (file-name (git-file-name name version))
90 (sha256
91 (base32 "1l9skkcizlv0qvw2lzmysndbm528xvszhiqq3569da157qpa5xav"))
92 ;; XXX: Remove after updating package from 2.13.0.
93 (patches (search-patches "hwloc-add-with-opencl.patch"))))
94 (build-system gnu-build-system)
95 (outputs '("out" ;'lstopo' & co., depends on Cairo, libx11, etc.
96 "lib" ;small closure
97 "doc" ;400+ section 3 man pages
98 "debug"))
99 (native-inputs
100 (list autoconf automake libtool opencl-headers bash pkg-config))
101 (inputs
102 (append (if (%current-target-system)
103 '() ;fewer dependencies when cross-compiling
104 (list libx11 cairo ncurses expat))
105 (list
106 ;; XXX: rocm-smi requires libdrm/drm.h but doesn't
107 ;; propagate a package providing these. For now, libdrm is
108 ;; used to provide this header.
109 libdrm
110 opencl-icd-loader
111 rocm-smi-lib)))
112 (propagated-inputs
113 ;; hwloc.pc lists libze_loader and libxml2 in
114 ;; 'Requires.private' in 'hwloc.pc'.
115 (list libpciaccess libxml2))
116 (arguments
117 (list
118 #:configure-flags
119 #~(list
120 (string-append
121 "--with-opencl=" #$(this-package-input "opencl-icd-loader"))
122 "--enable-rsmi"
123 (string-append "--with-rocm=" #$(this-package-input "rocm-smi-lib"))
124 "--localstatedir=/var")
125 #:phases
126 #~(modify-phases %standard-phases
127 (add-before 'check 'skip-linux-libnuma-test
128 (lambda _
129 ;; Arrange to skip 'tests/hwloc/linux-libnuma', which fails on
130 ;; some machines: <https://github.com/open-mpi/hwloc/issues/213>.
131 (substitute* "tests/hwloc/linux-libnuma.c"
132 (("numa_available\\(\\)")
133 "-1"))))
134 (add-after 'install 'refine-libnuma
135 ;; Give -L arguments for libraries to avoid propagation
136 (lambda* (#:key inputs outputs #:allow-other-keys)
137 (let ((out (assoc-ref outputs "lib"))
138 (numa (assoc-ref inputs "numactl")))
139 (substitute* (map (lambda (f) (string-append out "/" f))
140 '("lib/pkgconfig/hwloc.pc" "lib/libhwloc.la"))
141 (("-lnuma" lib)
142 (string-append "-L" numa "/lib " lib))))))
143 (add-after 'install 'avoid-circular-references
144 (lambda* (#:key outputs #:allow-other-keys)
145 (let ((lib (assoc-ref outputs "lib")))
146 ;; Suppress the 'prefix=' and 'exec_prefix=' lines so that the
147 ;; "lib" output doesn't refer to "out".
148 (substitute* (string-append lib "/lib/pkgconfig/hwloc.pc")
149 (("^.*prefix=.*$")
150 "")))))
151 (add-after 'install 'move-man-pages
152 (lambda _
153 ;; Move section 1 and 3 man pages to the "doc" output.
154 (copy-recursively (string-append #$output "/share/man/man1")
155 (string-append #$output:doc "/share/man/man1"))
156 (copy-recursively (string-append #$output "/share/man/man7")
157 (string-append #$output:doc "/share/man/man7"))
158 (delete-file-recursively
159 (string-append #$output "/share/man/man1"))
160 (delete-file-recursively
161 (string-append #$output "/share/man/man7"))))
162 (add-before 'check 'skip-tests-that-require-/sys
163 (lambda _
164 ;; 'test-gather-topology.sh' requires /sys as of 2.9.0; skip it.
165 (setenv "HWLOC_TEST_GATHER_TOPOLOGY" "0")))
166 (add-before 'check 'skip-test-that-fails-on-qemu
167 (lambda _
168 ;; Skip test that fails on emulated hardware due to QEMU bug:
169 ;; <https://bugs.gnu.org/40342>.
170 (substitute* "tests/hwloc/hwloc_get_last_cpu_location.c"
171 (("hwloc_topology_init" all)
172 (string-append "exit (77);\n" all))))))))
173 (home-page "https://www.open-mpi.org/projects/hwloc/")
174 (synopsis "Abstraction of hardware architectures")
175 (description
176 "hwloc provides a portable abstraction (across OS,
177versions, architectures, ...) of the hierarchical topology of modern
178architectures, including NUMA memory nodes, sockets, shared caches, cores and
179simultaneous multithreading. It also gathers various attributes such as cache
180and memory information. It primarily aims at helping high-performance
181computing applications with gathering information about the hardware so as to
182exploit it accordingly and efficiently.
183
184hwloc may display the topology in multiple convenient formats. It also offers
185a powerful programming interface to gather information about the hardware,
186bind processes, and much more.")
187 (license license:bsd-3)))
188
189(define-public openmpi-4
190 (package
191 (name "openmpi")
192 (version "4.1.6")
193 (source
194 (origin
195 (method url-fetch)
196 (uri (string-append "https://www.open-mpi.org/software/ompi/v"
197 (version-major+minor version)
198 "/downloads/openmpi-" version ".tar.bz2"))
199 (sha256
200 (base32 "05g4245v0pdqcyjmgn50519ry5v5q8ig26iinmiynvaihm29jh7p"))
201 (patches (search-patches "openmpi-mtl-priorities.patch"))))
202
203 (properties
204 ;; Tell the 'generic-html' updater to monitor this URL for updates.
205 `((release-monitoring-url
206 . "https://www.open-mpi.org/software/ompi/current")))
207
208 (build-system gnu-build-system)
209 (inputs
210 (let ((if-supported
211 (lambda (package)
212 (if (and (not (%current-target-system))
213 (member (%current-system)
214 (package-supported-systems package)))
215 (list package)
216 '()))))
217 (append (list `(,hwloc "lib")
218 gfortran
219 libfabric-1 ;fails to build with 2.3
220 libevent
221 opensm
222 openssh-sans-x)
223 (if-supported psm)
224 (if-supported psm2)
225 (if-supported ucx)
226 (if-supported valgrind/pinned)
227 (list rdma-core
228 slurm)))) ;for PMI support (launching via "srun")
229 (native-inputs
230 (list pkg-config perl))
231 (outputs '("out" "debug"))
232 (arguments
233 (list
234 #:configure-flags #~(list (string-append
235 "CFLAGS=-g -O2"
236 " -Wno-error=implicit-function-declaration"
237 " -Wno-error=incompatible-pointer-types")
238 "--enable-mpi-ext=affinity" ;cr doesn't work
239 "--with-sge"
240 "--disable-static"
241
242 #$@(if (package? (this-package-input "valgrind"))
243 #~("--enable-memchecker"
244 "--with-valgrind")
245 #~("--without-valgrind"))
246
247 "--with-hwloc=external"
248 "--with-libevent"
249
250 ;; Help 'orterun' and 'mpirun' find their tools
251 ;; under $prefix by default.
252 "--enable-mpirun-prefix-by-default"
253
254 ;; InfiniBand support
255 "--enable-openib-control-hdr-padding"
256 "--enable-openib-dynamic-sl"
257 "--enable-openib-udcm"
258 "--enable-openib-rdmacm"
259 "--enable-openib-rdmacm-ibaddr"
260
261 ;; Enable support for the 'Process Management
262 ;; Interface for Exascale' (PMIx) used e.g. by
263 ;; Slurm for the management communication and
264 ;; coordination of MPI processes.
265 "--with-pmix=internal"
266
267 ;; Enable support for SLURM's Process Manager
268 ;; Interface (PMI).
269 (string-append "--with-pmi="
270 #$(this-package-input "slurm")))
271 #:phases #~(modify-phases %standard-phases
272 ;; opensm is needed for InfiniBand support.
273 (add-after 'unpack 'find-opensm-headers
274 (lambda* (#:key inputs #:allow-other-keys)
275 (setenv "C_INCLUDE_PATH"
276 (search-input-directory inputs
277 "/include/infiniband"))
278 (setenv "CPLUS_INCLUDE_PATH"
279 (search-input-directory inputs
280 "/include/infiniband"))))
281 (add-before 'build 'remove-absolute
282 (lambda _
283 ;; Remove compiler absolute file names (OPAL_FC_ABSOLUTE
284 ;; etc.) to reduce the closure size. See
285 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-07/msg00388.html>
286 ;; and
287 ;; <https://www.mail-archive.com/[email protected]//msg31397.html>.
288 (substitute* '("orte/tools/orte-info/param.c"
289 "oshmem/tools/oshmem_info/param.c"
290 "ompi/tools/ompi_info/param.c")
291 (("_ABSOLUTE") ""))
292 ;; Avoid valgrind (which pulls in gdb etc.).
293 (substitute*
294 '("./ompi/mca/io/romio321/src/io_romio321_component.c")
295 (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
296 "\"[elided to reduce closure]\""))))
297 (add-before 'build 'ssh-absolute-path
298 (lambda* (#:key inputs #:allow-other-keys)
299 ;; Avoid error at run time about 'ssh' not being found.
300 (substitute* "orte/mca/plm/rsh/plm_rsh_component.c"
301 (("mca_plm_rsh_component.agent = \"ssh : rsh\";")
302 (format #f "mca_plm_rsh_component.agent = \"~a : rsh\";"
303 (search-input-file inputs
304 "bin/ssh"))))))
305 (add-before 'build 'scrub-timestamps ;reproducibility
306 (lambda _
307 (substitute* '("ompi/tools/ompi_info/param.c"
308 "orte/tools/orte-info/param.c"
309 "oshmem/tools/oshmem_info/param.c")
310 ((".*(Built|Configured) on.*") ""))))
311 (add-after 'install 'remove-logs ;reproducibility
312 (lambda* (#:key outputs #:allow-other-keys)
313 (let ((out (assoc-ref outputs "out")))
314 (for-each delete-file (find-files out "config.log"))))))))
315 (home-page "https://www.open-mpi.org")
316 (synopsis "MPI-3 implementation")
317 (description
318 "The Open MPI Project is an MPI-3 implementation that is developed and
319maintained by a consortium of academic, research, and industry partners. Open
320MPI is therefore able to combine the expertise, technologies, and resources
321from all across the High Performance Computing community in order to build the
322best MPI library available. Open MPI offers advantages for system and
323software vendors, application developers and computer science researchers.")
324 ;; See file://LICENSE
325 (license license:bsd-2)))
326
327(define-public openmpi openmpi-4)
328
329(define-public openmpi-5
330 (package
331 (inherit openmpi)
332 (version "5.0.10")
333 (source
334 (origin
335 (method url-fetch)
336 (uri (string-append "https://www.open-mpi.org/software/ompi/v"
337 (version-major+minor version)
338 "/downloads/openmpi-" version ".tar.bz2"))
339 (modules '((guix build utils)
340 (ice-9 ftw)
341 (srfi srfi-26)))
342 (snippet
343 '(begin
344 ;; XXX: 'delete-all-but' is copied from the turbovnc package.
345 (define (delete-all-but directory . preserve)
346 (with-directory-excursion directory
347 (let* ((pred (negate (cut member <>
348 (cons* "." ".." preserve))))
349 (items (scandir "." pred)))
350 (for-each (cut delete-file-recursively <>) items))))
351 ;; Delete as many bundled libraries as permitted by the build
352 ;; system.
353 (delete-all-but "3rd-party" "treematch" "Makefile.in" "Makefile.am")
354 ;; Do not install 64 MiB worth fo pre-generated HTML
355 ;; documentation.
356 (delete-file-recursively "docs/html")))
357 (sha256
358 (base32 "1ijc6zbxb49a7dvfs59h74lis3vb5hc1v95qpjyxxr8qq97wrkha"))))
359
360 (inputs (modify-inputs inputs
361 ;; As of Open MPI 5.0.X, PMIx is used to communicate
362 ;; with SLURM, so SLURM'S PMI is no longer needed.
363 (delete "slurm")
364 ;; Replace libfabric 1.x with a newer version.
365 (replace "libfabric" libfabric)
366 (append openpmix) ;for PMI support (launching via "srun")
367 (append prrte))) ;for PMI support (launching via "srun")
368 (native-inputs (modify-inputs native-inputs
369 (append python)))
370
371 (outputs '("out" "debug"))
372 (arguments
373 (list #:configure-flags
374 #~(list #$(string-append
375 "CFLAGS=-g -O2"
376 " -Wno-error=incompatible-pointer-types")
377 "--enable-mpi-ext=affinity" ;cr doesn't work
378 "--with-sge"
379 "--disable-static"
380
381 #$@(if (this-package-input "valgrind")
382 #~("--enable-memchecker"
383 "--with-valgrind")
384 #~("--without-valgrind"))
385
386 "--with-hwloc=external"
387 "--with-libevent"
388
389 ;; This replaces --enable-mpirun-prefix-by-default wich is deprecated
390 ;; since 5.x.
391 "--enable-prte-prefix-by-default"
392
393 ;; Enable support for the 'Process Management Interface for Exascale'
394 ;; (PMIx) used e.g. by Slurm for the management communication and
395 ;; coordination of MPI processes.
396 (string-append "--with-pmix=" #$(this-package-input "openpmix"))
397 (string-append "--with-prrte=" #$(this-package-input "prrte"))
398
399 ;; Explicitly activate PSM2 when present. This is required
400 ;; for autotools to add the -L flag to .la files, that
401 ;; fixes link-time errors when missing.
402 #$@(if (this-package-input "psm2")
403 #~((string-append "--with-psm2=" #$(this-package-input "psm2")))
404 #~())
405
406 ;; Since 5.x, Infiniband support is provided by ucx.
407 ;; See https://docs.open-mpi.org/en/main/release-notes/networks.html#miscellaneous-network-notes
408 #$@(if (this-package-input "ucx")
409 #~((string-append "--with-ucx=" #$(this-package-input "ucx")))
410 #~()))
411
412 #:phases
413 #~(modify-phases %standard-phases
414 (add-before 'build 'remove-absolute
415 (lambda _
416 ;; Remove compiler absolute file names (OPAL_FC_ABSOLUTE
417 ;; etc.) to reduce the closure size. See
418 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-07/msg00388.html>
419 ;; and
420 ;; <https://www.mail-archive.com/[email protected]//msg31397.html>.
421 (substitute* '("oshmem/tools/oshmem_info/param.c"
422 "ompi/tools/ompi_info/param.c")
423 (("_ABSOLUTE") "")))))
424
425 #:disallowed-references (list (canonical-package gcc))))))
426
427;; XXX: ROCm support in Open MPI is enabled in a variant and not in the base
428;; package due to its dependency rocm-hip-runtime retaining references to
429;; clang-rocm, which causes the closure to go from ~400MB to ~2.4GB. See
430;; https://codeberg.org/guix/guix/issues/5585
431(define-public openmpi-rocm
432 (package/inherit openmpi-5
433 (name "openmpi-rocm")
434 (arguments
435 (substitute-keyword-arguments arguments
436 ((#:configure-flags flags '())
437 #~(cons* (string-append "--with-rocm="
438 #$(this-package-input "rocm-hip-runtime"))
439 #$flags))))
440 (inputs (modify-inputs (package-inputs openmpi-5)
441 ;; XXX: This might break openmpi-5 for architectures where ROCm
442 ;; is not supported.
443 (append rocm-hip-runtime)
444 (replace "ucx" ucx-rocm)
445 (replace "libfabric" libfabric-rocm)))
446 (synopsis "MPI-3 implementation (with ROCm support)")))
447
448(define-public openmpi-c++
449 (package/inherit openmpi
450 (name "openmpi-c++")
451 (outputs '("out"))
452 (arguments
453 (substitute-keyword-arguments arguments
454 ((#:configure-flags flags)
455 #~(cons "--enable-mpi-cxx" #$flags))))
456 (synopsis "C++ bindings for MPI")))
457
458;; TODO: javadoc files contain timestamps.
459(define-public java-openmpi
460 (package/inherit openmpi
461 (name "java-openmpi")
462 (inputs
463 `(("openmpi" ,openmpi)
464 ,@(package-inputs openmpi)))
465 (native-inputs
466 `(("jdk" ,openjdk11 "jdk")
467 ("zip" ,(@ (gnu packages compression) zip))
468 ,@(package-native-inputs openmpi)))
469 (outputs '("out"))
470 (arguments
471 (cons*
472 #:modules '((guix build gnu-build-system)
473 ((guix build ant-build-system) #:prefix ant:)
474 (guix build utils))
475 #:imported-modules `((guix build ant-build-system)
476 ,@%default-gnu-imported-modules)
477 (substitute-keyword-arguments arguments
478 ((#:configure-flags flags)
479 #~(cons "--enable-mpi-java" #$flags))
480 ((#:make-flags flags ''())
481 #~(append '("-C" "ompi/mpi/java")
482 #$flags))
483 ((#:phases phases)
484 #~(modify-phases #$phases
485 ;; We could provide the location of the JDK in the configure
486 ;; flags, but since the configure flags are embedded in the
487 ;; info binaries that would leave a reference to the JDK in
488 ;; the "out" output. To avoid this we set JAVA_HOME.
489 (add-after 'unpack 'set-JAVA_HOME
490 (lambda* (#:key inputs #:allow-other-keys)
491 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
492 #t))
493 (add-after 'unpack 'link-with-existing-mpi-libraries
494 (lambda* (#:key inputs #:allow-other-keys)
495 (substitute* "ompi/mpi/java/c/Makefile.in"
496 (("\\$\\(top_builddir\\)/ompi/lib@[email protected]")
497 (search-input-file inputs "/lib/libmpi.la")))))
498 (add-after 'install 'strip-jar-timestamps
499 (assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))))
500 (synopsis "Java bindings for MPI")))
501
502(define-public openmpi-thread-multiple
503 (package/inherit openmpi
504 (name "openmpi-thread-multiple")
505 (arguments
506 (substitute-keyword-arguments arguments
507 ((#:configure-flags flags)
508 #~(cons "--enable-mpi-thread-multiple" #$flags))))
509 (description "This version of Open@tie{}MPI has an implementation of
510@code{MPI_Init_thread} that provides @code{MPI_THREAD_MULTIPLE}. This won't
511work correctly with all transports (such as @code{openib}), and the
512performance is generally worse than the vanilla @code{openmpi} package, which
513only provides @code{MPI_THREAD_FUNNELED}.")))
514
515;;; Build phase to be used for packages that execute MPI code.
516(define-public %openmpi-setup
517 '(lambda _
518 ;; By default, running the test suite would fail because 'ssh' could not
519 ;; be found in $PATH. Define this variable to placate Open MPI without
520 ;; adding a dependency on OpenSSH (the agent isn't used anyway.)
521 (setenv "OMPI_MCA_plm_rsh_agent" (which "false"))
522 ;; Allow oversubscription in case there are less physical cores available
523 ;; in the build environment than the package wants while testing.
524 (setenv "OMPI_MCA_rmaps_base_mapping_policy" "core:OVERSUBSCRIBE")
525
526 ;; UCX sometimes outputs uninteresting warnings such as:
527 ;;
528 ;; mpool.c:38 UCX WARN object 0x7ffff44fffc0 was not returned to mpool ucp_am_bufs
529 ;;
530 ;; These in turn leads to failures of test suites that capture and
531 ;; compare stdout, such as that of 'hdf5-parallel-openmpi'. Thus, tell
532 ;; UCX to not emit those warnings.
533 (setenv "UCX_LOG_LEVEL" "error")
534
535 ;; Starting from 2.9.0, hwloc fails when /sys is unavailable:
536 ;;
537 ;; [hwloc/linux] failed to find sysfs cpu topology directory, aborting linux discovery.
538 ;;
539 ;; This in turn breaks Open MPI users. To work around it, define a fake
540 ;; topology with 4 cores. That silently disables CPU binding, though
541 ;; 'get_cpubind' will report there's no binding.
542 (setenv "HWLOC_SYNTHETIC" "4")
543 #t))
544
545(define-public python-mpi4py
546 (package
547 (name "python-mpi4py")
548 (version "4.1.0")
549 (source
550 (origin
551 (method git-fetch)
552 (uri (git-reference
553 (url "https://github.com/mpi4py/mpi4py")
554 (commit version)))
555 (file-name (git-file-name name version))
556 (sha256
557 (base32 "1r4n2d3nacpa6sq18jp0xk4a81ha0iipgvlsdv0bhfmdvgpv2vqy"))))
558 (build-system pyproject-build-system)
559 (arguments
560 (list
561 #:test-flags
562 #~(list ;; MPI errors are unrecoverable.
563 "--ignore=test/test_spawn.py"
564 "--ignore=test/test_util_pool.py"
565 "--ignore=demo/futures/test_futures.py")
566 #:phases
567 #~(modify-phases %standard-phases
568 (add-after 'build 'mpi-setup #$%openmpi-setup)
569 (add-before 'check 'pre-check
570 (lambda _
571 ;; Skip BaseTestSpawn class (causes error 'ompi_dpm_dyn_init()
572 ;; failed --> Returned "Unreachable"' in chroot environment).
573 (substitute* "test/test_spawn.py"
574 (("unittest.skipMPI\\('openmpi\\(<3.0.0\\)'\\)")
575 "unittest.skipMPI('openmpi')"))))
576 (replace 'check
577 (lambda* (#:key tests? test-flags #:allow-other-keys)
578 (if tests?
579 (apply invoke "mpiexec" "pytest" "-vv" test-flags)
580 (format #t "test suite not run~%")))))))
581 (native-inputs (list python-cython python-pytest python-setuptools))
582 (inputs (list openmpi))
583 (properties '((updater-extra-inputs "openmpi")))
584 (home-page "https://github.com/mpi4py/mpi4py")
585 (synopsis "Python bindings for the Message Passing Interface standard")
586 (description
587 "MPI for Python (mpi4py) provides bindings of the Message Passing
588Interface (MPI) standard for the Python programming language, allowing any
589Python program to exploit multiple processors.
590
591mpi4py is constructed on top of the MPI-1/MPI-2 specification and provides an
592object oriented interface which closely follows MPI-2 C++ bindings. It
593supports point-to-point and collective communications of any picklable Python
594object as well as optimized communications of Python objects (such as NumPy
595arrays) that expose a buffer interface.")
596 (license license:bsd-3)))
597
598(define-public mpich
599 (package
600 (name "mpich")
601 (version "4.3.0")
602 (source (origin
603 (method url-fetch)
604 (uri (string-append "http://www.mpich.org/static/downloads/"
605 version "/mpich-" version ".tar.gz"))
606 (sha256
607 (base32
608 "0qyc3c99dzx88y8gzadh4inmmvxms9r61xskrjwwm0xdhhli612y"))))
609 (build-system gnu-build-system)
610 (inputs
611 `(,zlib
612 (,hwloc "lib")
613 ,slurm
614 ,@(if (and (not (%current-target-system))
615 (member (%current-system) (package-supported-systems ucx)))
616 (list ucx)
617 '())))
618 (native-inputs
619 (list perl which gfortran python-minimal))
620 (outputs '("out" "debug"))
621 (arguments
622 `(#:configure-flags
623 (list "--disable-silent-rules" ;let's see what's happening
624 "--enable-debuginfo"
625
626 (string-append "--with-hwloc-prefix="
627 (assoc-ref %build-inputs "hwloc"))
628
629 ,@(if (assoc "ucx" (package-inputs this-package))
630 `((string-append "--with-ucx="
631 (assoc-ref %build-inputs "ucx"))
632
633 ;; Default to using ucx when built with ucx as an input.
634 "--with-device=ch4:ucx")
635 '(;; Fallback to ch4 with autodetect at configure time.
636 "--with-device=ch4")))
637
638 #:phases (modify-phases %standard-phases
639 (add-after 'unpack 'patch-sources
640 (lambda _
641 (substitute* "./maint/gen_subcfg_m4"
642 (("/usr/bin/env") (which "env")))
643 (substitute* "src/glue/romio/all_romio_symbols"
644 (("/usr/bin/env") (which "env")))
645 (substitute* (find-files "." "buildiface")
646 (("/usr/bin/env") (which "env")))
647 (substitute* "maint/extracterrmsgs"
648 (("/usr/bin/env") (which "env")))
649 (substitute* (find-files "." "f77tof90")
650 (("/usr/bin/env") (which "env")))
651 (substitute* (find-files "." "\\.sh$")
652 (("/bin/sh") (which "sh")))))
653 ;; Move 'check after 'install. Some tests try to call
654 ;; #$output/bin/mpicc.
655 (delete 'check)
656 (add-after 'install 'post-install-check
657 (assoc-ref %standard-phases 'check))
658 (add-before 'configure 'fix-makefile
659 (lambda _
660 ;; Remove "@hwloclib@" from 'pmpi_convenience_libs'.
661 ;; This fixes "No rule to make target '-lhwloc', needed
662 ;; by 'lib/libmpi.la'".
663 (substitute* "Makefile.in"
664 (("^pmpi_convenience_libs = (.*) @hwloclib@ (.*)$" _
665 before after)
666 (string-append "pmpi_convenience_libs = "
667 before " " after)))))
668 (add-before 'configure 'define-gfortran-wrapper
669 (lambda* (#:key inputs #:allow-other-keys)
670 ;; 'configure' checks whether the Fortran compiler
671 ;; allows argument type mismatch. Since gfortran >= 10
672 ;; does not, provide a wrapper that passes
673 ;; '-fallow-argument-mismatch' to get the desired
674 ;; behavior.
675 (mkdir-p ".gfortran-wrapper/bin")
676 (call-with-output-file ".gfortran-wrapper/bin/gfortran"
677 (lambda (port)
678 (display (string-append "#!" (which "sh") "\n")
679 port)
680 (display
681 (string-append "exec \"" (which "gfortran")
682 "\" -fallow-argument-mismatch"
683 " \"$@\"\n")
684 port)
685 (chmod port #o755)))
686
687 (setenv "PATH"
688 (string-append (getcwd) "/"
689 ".gfortran-wrapper/bin:"
690 (getenv "PATH"))))))))
691 (home-page "https://www.mpich.org/")
692 (synopsis "Implementation of the Message Passing Interface (MPI)")
693 (description
694 "MPICH is a high-performance and portable implementation of the Message
695Passing Interface (MPI) standard (MPI-1, MPI-2 and MPI-3). MPICH provides an
696MPI implementation that efficiently supports different computation and
697communication platforms including commodity clusters, high-speed networks (10
698Gigabit Ethernet, InfiniBand, Myrinet, Quadrics), and proprietary high-end
699computing systems (Blue Gene, Cray). It enables research in MPI through a
700modular framework for other derived implementations.")
701 (license license:bsd-2)))
702
703(define-public mpich-ofi
704 (package/inherit mpich
705 (name "mpich-ofi")
706 (inputs (modify-inputs inputs
707 (delete ucx)
708 (append libfabric)
709 (append rdma-core)
710 (append psm2)))
711 (arguments
712 (substitute-keyword-arguments arguments
713 ((#:configure-flags flags)
714 #~(list "--disable-silent-rules" ;let's see what's happening
715 "--enable-debuginfo"
716 "--with-device=ch4:ofi"
717
718 (string-append "--with-hwloc-prefix="
719 #$(this-package-input "hwloc"))
720
721 (string-append "--with-libfabric="
722 #$(this-package-input "libfabric"))))
723 ((#:phases phases
724 '%standard-phases)
725 phases)))
726 (synopsis "Implementation of the Message Passing Interface (MPI) for OmniPath")))
727
728(define-public gotcha
729 (package
730 (name "gotcha")
731 (version "1.0.8")
732 (source
733 (origin
734 (method git-fetch)
735 (uri (git-reference
736 (url "https://github.com/LLNL/GOTCHA")
737 (commit version)))
738 (file-name (git-file-name name version))
739 (sha256
740 (base32 "172h70x7mpyik2rbqc4zynfi7kpjfcxpazcwnjnm3d9wsmlwb1z5"))))
741 (build-system cmake-build-system)
742 (native-inputs
743 ;; "git" is needed by test/unit/CMakeLists.txt but is not actually used
744 ;; if "check" is provided and DEPENDENCIES_PREINSTALLED is true.
745 (list git
746 check))
747 (arguments
748 (list #:configure-flags #~'("-DGOTCHA_ENABLE_TESTS=on"
749 "-DDEPENDENCIES_PREINSTALLED=true")))
750 (home-page "https://github.com/LLNL/GOTCHA")
751 (synopsis "Wrapping function calls in shared libraries")
752 (description
753 "Gotcha is a library that wraps functions. Tools can use gotcha to
754install hooks into other libraries, for example putting a wrapper function
755around libc's malloc. It is similar to @code{LD_PRELOAD}, but operates via a
756programmable API.")
757 ;; See <LGPL> file for preamble notice.
758 (license license:lgpl2.1)))
759
760(define (make-scorep mpi)
761 (package
762 (name (string-append "scorep-" (package-name mpi)))
763 (version "9.0")
764 (source (origin
765 (method url-fetch)
766 (uri (string-append
767 "https://perftools.pages.jsc.fz-juelich.de/cicd/scorep/tags/"
768 "scorep-" version "/scorep-" version ".tar.gz"))
769 (sha256
770 (base32
771 "15q93rc8wblbzqgh99rqzyq6fdp88mi6yziww05c6cbgrjs5s2jx"))
772 (modules '((guix build utils)))
773 (snippet
774 ;; Remove bundled software.
775 '(begin
776 (for-each delete-file-recursively
777 '("vendor/otf2" "vendor/opari2"
778 "vendor/cubelib" "vendor/cubew"))))))
779 (build-system gnu-build-system)
780 (inputs
781 (list mpi
782 papi
783 opari2
784 libunwind
785 otf2
786 cubelib
787 cubew
788 gotcha
789 libbfd
790 libiberty
791 openmpi
792 zlib))
793 (native-inputs
794 (list gfortran
795 flex
796 bison
797 python
798 doxygen
799 which))
800 (arguments
801 (list
802 #:configure-flags
803 #~(list "--enable-shared" "--disable-static"
804 "MPI_LIBS=-lmpi" "SHMEM_LIBS=-loshmem"
805 (string-append "--with-cubelib="
806 #$(this-package-input "cubelib"))
807 (string-append "--with-cubew="
808 #$(this-package-input "cubew"))
809 (string-append "--with-libbfd="
810 #$(this-package-input "libbfd"))
811 (string-append "--with-otf2="
812 #$(this-package-input "otf2"))
813 (string-append "--with-opari2="
814 #$(this-package-input "opari2")))
815 #:parallel-tests? #f
816 #:phases
817 #~(modify-phases %standard-phases
818 (add-after 'install 'licence
819 (lambda* (#:key outputs #:allow-other-keys)
820 (let ((doc (string-append (assoc-ref outputs "out")
821 "/share/doc/scorep")))
822 (install-file "COPYING" doc)))))))
823 (home-page "https://www.vi-hps.org/projects/score-p/")
824 (synopsis "Performance measurement infrastructure for parallel code")
825 (description
826 "The Score-P (Scalable Performance Measurement Infrastructure for
827Parallel Codes) measurement infrastructure is a scalable and easy-to-use tool
828suite for profiling, event trace recording, and online analysis of
829high-performance computing (HPC) applications.")
830 (license license:cpl1.0)))
831
832(define-public scorep-openmpi (make-scorep openmpi))