projects/guix·blob python-team · refs

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